WIP: domain listing with Gandi
All checks were successful
continuous-integration/drone/push Build is passing

Rethinking the interface already.
This commit is contained in:
2021-10-18 22:16:29 +02:00
parent 7ea3df45d4
commit 597b4b586e
10 changed files with 161 additions and 145 deletions

28
pkg/dns/common.go Normal file
View File

@ -0,0 +1,28 @@
package dns
import (
"fmt"
"os"
"github.com/AlecAivazis/survey/v2"
"github.com/sirupsen/logrus"
)
// NewToken constructs a new DNS provider token.
func NewToken(provider, providerTokenEnvVar string) (string, error) {
if token, present := os.LookupEnv(providerTokenEnvVar); present {
return token, nil
}
logrus.Debugf("no %s in environment, asking via stdin", providerTokenEnvVar)
var token string
prompt := &survey.Input{
Message: fmt.Sprintf("%s API token?", provider),
}
if err := survey.AskOne(prompt, &token); err != nil {
return "", err
}
return token, nil
}