WIP: dns support via libdns
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5941ed9728
commit
7ea3df45d4
91
cli/server/dns.go
Normal file
91
cli/server/dns.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/urfave/cli/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var provider string
|
||||||
|
var providerFlag = &cli.StringFlag{
|
||||||
|
Name: "provider",
|
||||||
|
Value: "",
|
||||||
|
Aliases: []string{"p"},
|
||||||
|
Usage: "Choose a DNS provider (options: Gandi)",
|
||||||
|
Destination: &provider,
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverDnsListCommand = &cli.Command{
|
||||||
|
Name: "list",
|
||||||
|
Usage: "List domains for a server",
|
||||||
|
Aliases: []string{"ls"},
|
||||||
|
ArgsUsage: "<domain>",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
providerFlag,
|
||||||
|
},
|
||||||
|
Description: `
|
||||||
|
`,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
// domainName := internal.ValidateDomain(c)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverDnsRemoveCommand = &cli.Command{
|
||||||
|
Name: "remove",
|
||||||
|
Usage: "Remove domains for a server",
|
||||||
|
Aliases: []string{"rm"},
|
||||||
|
ArgsUsage: "<domain>",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
providerFlag,
|
||||||
|
},
|
||||||
|
Description: `
|
||||||
|
`,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
// domainName := internal.ValidateDomain(c)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverDnsAddCommand = &cli.Command{
|
||||||
|
Name: "add",
|
||||||
|
Usage: "Add domains for a server",
|
||||||
|
Aliases: []string{"a"},
|
||||||
|
ArgsUsage: "<domain>",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
providerFlag,
|
||||||
|
},
|
||||||
|
Description: `
|
||||||
|
`,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
// domainName := internal.ValidateDomain(c)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverDnsUpdateCommand = &cli.Command{
|
||||||
|
Name: "update",
|
||||||
|
Usage: "Update domains for a server",
|
||||||
|
Aliases: []string{"u"},
|
||||||
|
ArgsUsage: "<domain>",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
providerFlag,
|
||||||
|
},
|
||||||
|
Description: `
|
||||||
|
`,
|
||||||
|
Action: func(c *cli.Context) error {
|
||||||
|
// domainName := internal.ValidateDomain(c)
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var serverDnsCommand = &cli.Command{
|
||||||
|
Name: "dns",
|
||||||
|
Aliases: []string{"d"},
|
||||||
|
Usage: "Manage server domains",
|
||||||
|
ArgsUsage: "<command>",
|
||||||
|
Subcommands: []*cli.Command{
|
||||||
|
serverDnsListCommand,
|
||||||
|
serverDnsRemoveCommand,
|
||||||
|
serverDnsAddCommand,
|
||||||
|
serverDnsUpdateCommand,
|
||||||
|
},
|
||||||
|
}
|
@ -22,5 +22,6 @@ the connections to those servers.
|
|||||||
serverAddCommand,
|
serverAddCommand,
|
||||||
serverListCommand,
|
serverListCommand,
|
||||||
serverRemoveCommand,
|
serverRemoveCommand,
|
||||||
|
serverDnsCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
2
go.mod
2
go.mod
@ -32,6 +32,8 @@ require (
|
|||||||
github.com/fvbommel/sortorder v1.0.2 // indirect
|
github.com/fvbommel/sortorder v1.0.2 // indirect
|
||||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||||
github.com/gorilla/mux v1.8.0 // indirect
|
github.com/gorilla/mux v1.8.0 // indirect
|
||||||
|
github.com/libdns/gandi v1.0.2
|
||||||
|
github.com/libdns/libdns v0.2.1
|
||||||
github.com/moby/sys/mount v0.2.0 // indirect
|
github.com/moby/sys/mount v0.2.0 // indirect
|
||||||
github.com/morikuni/aec v1.0.0 // indirect
|
github.com/morikuni/aec v1.0.0 // indirect
|
||||||
github.com/opencontainers/runc v1.0.2 // indirect
|
github.com/opencontainers/runc v1.0.2 // indirect
|
||||||
|
5
go.sum
5
go.sum
@ -510,6 +510,11 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
|||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/libdns/gandi v1.0.2 h1:1Ts8UpI1x5PVKpOjKC7Dn4+EObndz9gm6vdZnloHSKQ=
|
||||||
|
github.com/libdns/gandi v1.0.2/go.mod h1:hxpbQKcQFgQrTS5lV4tAgn6QoL6HcCnoBJaW5nOW4Sk=
|
||||||
|
github.com/libdns/libdns v0.1.0/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40=
|
||||||
|
github.com/libdns/libdns v0.2.1 h1:Wu59T7wSHRgtA0cfxC+n1c/e+O3upJGWytknkmFEDis=
|
||||||
|
github.com/libdns/libdns v0.2.1/go.mod h1:yQCXzk1lEZmmCPa857bnk4TsOiqYasqpyOEeSObbb40=
|
||||||
github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
|
52
pkg/dns/gandi.go
Normal file
52
pkg/dns/gandi.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package gandi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/AlecAivazis/survey/v2"
|
||||||
|
"github.com/libdns/gandi"
|
||||||
|
"github.com/libdns/libdns"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getToken() (string, error) {
|
||||||
|
if token, present := os.LookupEnv("GANDI_TOKEN"); present {
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Debugf("no GANDI_TOKEN in environment, asking via stdin")
|
||||||
|
|
||||||
|
var token string
|
||||||
|
prompt := &survey.Input{
|
||||||
|
Message: "Gandi API token?",
|
||||||
|
}
|
||||||
|
if err := survey.AskOne(prompt, &token); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return token, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getProvider() (gandi.Provider, error) {
|
||||||
|
token, err := getToken()
|
||||||
|
if err != nil {
|
||||||
|
return gandi.Provider{}, err
|
||||||
|
}
|
||||||
|
return gandi.Provider{APIToken: token}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ListDomains() ([]libdns.Record, error) {
|
||||||
|
return []libdns.Record{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func RemoveDomain() (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func AddDomain() (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func UpdateDomain() (bool, error) {
|
||||||
|
return false, nil
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user