forked from go-acme/lego
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds a new generator to create
dns_provider.go
(go-acme#2305)
- Loading branch information
Showing
13 changed files
with
306 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package descriptors | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/BurntSushi/toml" | ||
) | ||
|
||
type Providers struct { | ||
Providers []Provider | ||
} | ||
|
||
type Provider struct { | ||
Name string // Real name of the DNS provider | ||
Code string // DNS code | ||
Aliases []string // DNS code aliases (for compatibility/deprecation) | ||
Since string // First lego version | ||
URL string // DNS provider URL | ||
Description string // Provider summary | ||
Example string // CLI example | ||
Configuration *Configuration // Environment variables | ||
Links *Links // Links | ||
Additional string // Extra documentation | ||
GeneratedFrom string // Source file | ||
} | ||
|
||
type Configuration struct { | ||
Credentials map[string]string | ||
Additional map[string]string | ||
} | ||
|
||
type Links struct { | ||
API string | ||
GoClient string | ||
} | ||
|
||
// GetProviderInformation extract provider information from TOML description files. | ||
func GetProviderInformation(root string) (*Providers, error) { | ||
models := &Providers{} | ||
|
||
err := filepath.Walk(filepath.Join(root, "providers", "dns"), walker(root, models)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return models, nil | ||
} | ||
|
||
func walker(root string, prs *Providers) func(string, os.FileInfo, error) error { | ||
return func(path string, _ os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if filepath.Ext(path) != ".toml" { | ||
return nil | ||
} | ||
|
||
m := Provider{} | ||
|
||
m.GeneratedFrom, err = filepath.Rel(root, path) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = toml.DecodeFile(path, &m) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
prs.Providers = append(prs.Providers, m) | ||
|
||
return nil | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.