mirror of
https://github.com/davidallendj/configurator.git
synced 2025-12-19 19:17:01 -07:00
Added more API documentation and minor changes
This commit is contained in:
parent
cd840b2bf0
commit
1d862ebd8c
15 changed files with 117 additions and 48 deletions
|
|
@ -21,6 +21,7 @@ var (
|
|||
var fetchCmd = &cobra.Command{
|
||||
Use: "fetch",
|
||||
Short: "Fetch a config file from a remote instance of configurator",
|
||||
Long: "This command is simplified to make a HTTP request to the a configurator service.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// make sure a host is set
|
||||
if remoteHost == "" {
|
||||
|
|
@ -28,6 +29,7 @@ var fetchCmd = &cobra.Command{
|
|||
return
|
||||
}
|
||||
|
||||
// add the "Authorization" header if an access token is supplied
|
||||
headers := map[string]string{}
|
||||
if accessToken != "" {
|
||||
headers["Authorization"] = "Bearer " + accessToken
|
||||
|
|
@ -41,6 +43,7 @@ var fetchCmd = &cobra.Command{
|
|||
logrus.Errorf("failed to make request: %v", err)
|
||||
return
|
||||
}
|
||||
// handle getting other error codes other than a 200
|
||||
if res != nil {
|
||||
if res.StatusCode == http.StatusOK {
|
||||
fmt.Printf("%s\n", string(body))
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ var generateCmd = &cobra.Command{
|
|||
},
|
||||
}
|
||||
|
||||
// Generate files by supplying a list of targets as string values. Currently,
|
||||
// targets are defined statically in a config file. Targets are ran recursively
|
||||
// if more targets are nested in a defined target, but will not run additional
|
||||
// child targets if it is the same as the parent.
|
||||
//
|
||||
// NOTE: This may be changed in the future how this is done.
|
||||
func RunTargets(config *configurator.Config, args []string, targets ...string) {
|
||||
// generate config with each supplied target
|
||||
for _, target := range targets {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue