-
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.
Update deployment parameters to handle database and web connections.
- Loading branch information
Showing
7 changed files
with
489 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
type deploymentParameterTypeFlag string | ||
|
||
const ( | ||
deploymentParameterTypeFlagText deploymentParameterTypeFlag = "text" | ||
deploymentParameterTypeFlagDatabase deploymentParameterTypeFlag = "database" | ||
deploymentParameterTypeFlagWeb deploymentParameterTypeFlag = "web" | ||
) | ||
|
||
// String is used both by fmt.Print and by Cobra in help text | ||
func (e *deploymentParameterTypeFlag) String() string { | ||
return string(*e) | ||
} | ||
|
||
// Set must have pointer receiver so it doesn't change the value of a copy | ||
func (e *deploymentParameterTypeFlag) Set(v string) error { | ||
switch v { | ||
case "text", "database", "web": | ||
*e = deploymentParameterTypeFlag(v) | ||
return nil | ||
default: | ||
return errors.New(`must be one of "text" or "database" or "web"`) | ||
} | ||
} | ||
|
||
// Type is only used in help text | ||
func (e *deploymentParameterTypeFlag) Type() string { | ||
return "string" | ||
} | ||
|
||
// https://github.com/uber-go/guide/blob/master/style.md#verify-interface-compliance | ||
var _ pflag.Value = (*apiVersionFlag)(nil) | ||
|
||
// enable tab completion | ||
func deploymentParameterTypeFlagCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
return []string{ | ||
"text\ttext deployment parameter type", | ||
"database\tdatabase connection deployment parameter type", | ||
"web\tweb connection deployment parameter type", | ||
}, cobra.ShellCompDirectiveDefault | ||
} |
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
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
Oops, something went wrong.