WIP: domain listing with Gandi
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Rethinking the interface already.
This commit is contained in:
28
pkg/dns/common.go
Normal file
28
pkg/dns/common.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user