Skip to content

Commit

Permalink
Merge pull request #104 from UKHomeOffice/release-1.9-cherrypick-103
Browse files Browse the repository at this point in the history
Support username and password flags
  • Loading branch information
KashifSaadat authored Jul 25, 2018
2 parents 87e0924 + 96f7d7f commit 11d0ab4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Supported types are:
- mysql
- yaml

**NOTE** a secret generated will automatically be set to `create-only` and will
**NOTE** a secret generated will automatically be set to `create-only` and will
not be updated for every deploy.

```yaml
Expand Down Expand Up @@ -240,7 +240,7 @@ USAGE:
kd [global options] command [command options] [arguments...]
VERSION:
v1.0.0
v1.10.1
AUTHOR:
Vaidas Jablonskis <jablonskis@gmail.com>
Expand All @@ -250,26 +250,28 @@ COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--debug debug output [$DEBUG, $PLUGIN_DEBUG]
--debug-templates debug template output [$DEBUG_TEMPLATES, $PLUGIN_DEBUG_TEMPLATES]
--dryrun if true, kd will exit prior to deployment [$DRY_RUN]
--insecure-skip-tls-verify if true, the server's certificate will not be checked for validity [$INSECURE_SKIP_TLS_VERIFY, $PLUGIN_INSECURE_SKIP_TLS_VERIFY]
--kube-server URL, -s URL kubernetes api server URL [$KUBE_SERVER, $PLUGIN_KUBE_SERVER]
--kube-token TOKEN, -t TOKEN kubernetes auth TOKEN [$KUBE_TOKEN, $PLUGIN_KUBE_TOKEN]
--config value Env file location [$CONFIG_FILE, $PLUGIN_CONFIG_FILE]
--create-only only create resources (do not update, skip if exists). [$CREATE_ONLY, $PLUGIN_CREATE_ONLY]
--create-only-resource value only create specified resources e.g. 'kind/name' (do not update, skip if exists). [$CREATE_ONLY_RESOURCES, $PLUGIN_CREATE_ONLY_RESOURCES]
--context CONTEXT, -c CONTEXT kube config CONTEXT [$KUBE_CONTEXT, $PLUGIN_CONTEXT]
--namespace NAMESPACE, -n NAMESPACE kubernetes NAMESPACE [$KUBE_NAMESPACE, $PLUGIN_KUBE_NAMESPACE]
--fail-superseded fail deployment if it has been superseded by another deployment. WARNING: there are some bugs in kubernetes. [$FAIL_SUPERSEDED, $PLUGIN_FAIL_SUPERSEDED]
--certificate-authority PATH the path to a file containing the CA for kubernetes API PATH [$KUBE_CERTIFICATE_AUTHORITY, $PLUGIN_KUBE_CERTIFICATE_AUHORITY]
--certificate-authority-data PATH the certificate authority data for the kubernetes API PATH [$KUBE_CERTIFICATE_AUTHORITY_DATA, $PLUGIN_KUBE_CERTIFICATE_AUHORITY_DATA]
--certificate-authority-file value the path to file the certificate authority file from certifacte-authority-data option (default: "/tmp/kube-ca.pem")
--file PATH, -f PATH the path to a file or directory containing kubernetes resource/s PATH [$FILES, $PLUGIN_FILES]
--timeout TIMEOUT, -T TIMEOUT the amount of time to wait for a successful deployment TIMEOUT (default: 3m0s) [$TIMEOUT, $PLUGIN_TIMEOUT]
--check-interval INTERVAL deployment status check interval INTERVAL (default: 1s) [$CHECK_INTERVAL, $PLUGIN_CHECK_INTERVAL]
--help, -h show help
--version, -v print the version
--debug debug output [$DEBUG, $PLUGIN_DEBUG]
--debug-templates debug template output [$DEBUG_TEMPLATES, $PLUGIN_DEBUG_TEMPLATES]
--dryrun if true, kd will exit prior to deployment [$DRY_RUN]
--insecure-skip-tls-verify if true, the server's certificate will not be checked for validity [$INSECURE_SKIP_TLS_VERIFY, $PLUGIN_INSECURE_SKIP_TLS_VERIFY]
--kube-server URL, -s URL kubernetes api server URL [$KUBE_SERVER, $PLUGIN_KUBE_SERVER]
--kube-token TOKEN, -t TOKEN kubernetes auth TOKEN [$KUBE_TOKEN, $PLUGIN_KUBE_TOKEN]
--kube-username USERNAME, -u USERNAME kubernetes auth USERNAME [$KUBE_USERNAME, $PLUGIN_KUBE_USERNAME]
--kube-password PASSWORD, -p PASSWORD kubernetes auth PASSWORD [$KUBE_PASSWORD, $PLUGIN_KUBE_PASSWORD]
--config value Env file location [$CONFIG_FILE, $PLUGIN_CONFIG_FILE]
--create-only only create resources (do not update, skip if exists). [$CREATE_ONLY, $PLUGIN_CREATE_ONLY]
--create-only-resource value only create specified resources e.g. 'kind/name' (do not update, skip if exists). [$CREATE_ONLY_RESOURCES, $PLUGIN_CREATE_ONLY_RESOURCES]
--context CONTEXT, -c CONTEXT kube config CONTEXT [$KUBE_CONTEXT, $PLUGIN_CONTEXT]
--namespace NAMESPACE, -n NAMESPACE kubernetes NAMESPACE [$KUBE_NAMESPACE, $PLUGIN_KUBE_NAMESPACE]
--fail-superseded fail deployment if it has been superseded by another deployment. WARNING: there are some bugs in kubernetes. [$FAIL_SUPERSEDED, $PLUGIN_FAIL_SUPERSEDED]
--certificate-authority PATH the path (or URL) to a file containing the CA for kubernetes API PATH [$KUBE_CERTIFICATE_AUTHORITY, $PLUGIN_KUBE_CERTIFICATE_AUHORITY]
--certificate-authority-data PATH the certificate authority data for the kubernetes API PATH [$KUBE_CERTIFICATE_AUTHORITY_DATA, $PLUGIN_KUBE_CERTIFICATE_AUHORITY_DATA]
--certificate-authority-file value the path to save certificate authority data when data or a URL is specified (default: "/tmp/kube-ca.pem")
--file PATH, -f PATH the path to a file or directory containing kubernetes resource/s PATH [$FILES, $PLUGIN_FILES]
--timeout TIMEOUT, -T TIMEOUT the amount of time to wait for a successful deployment TIMEOUT (default: 3m0s) [$TIMEOUT, $PLUGIN_TIMEOUT]
--check-interval INTERVAL deployment status check interval INTERVAL (default: 1s) [$CHECK_INTERVAL, $PLUGIN_CHECK_INTERVAL]
--help, -h show help
--version, -v print the version
```

## Build
Expand Down
17 changes: 17 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ func main() {
Usage: "kubernetes auth `TOKEN`",
EnvVar: "KUBE_TOKEN,PLUGIN_KUBE_TOKEN",
},
cli.StringFlag{
Name: "kube-username, u",
Usage: "kubernetes auth `USERNAME`",
EnvVar: "KUBE_USERNAME,PLUGIN_KUBE_USERNAME",
},
cli.StringFlag{
Name: "kube-password, p",
Usage: "kubernetes auth `PASSWORD`",
EnvVar: "KUBE_PASSWORD,PLUGIN_KUBE_PASSWORD",
},
cli.StringFlag{
Name: "config",
Usage: "Env file location",
Expand Down Expand Up @@ -633,6 +643,13 @@ func newKubeCmdSub(c *cli.Context, args []string, subCommand bool) (*exec.Cmd, e
}
if c.IsSet("kube-token") {
args = append([]string{"--token=" + c.String("kube-token")}, args...)
} else {
if c.IsSet("kube-username") {
args = append([]string{"--username=" + c.String("kube-username")}, args...)
}
if c.IsSet("kube-password") {
args = append([]string{"--password=" + c.String("kube-password")}, args...)
}
}
if c.IsSet(FlagCaData) {
if err := createCertificateAuthority(c.String(FlagCaFile), c.String(FlagCaData)); err != nil {
Expand Down

0 comments on commit 11d0ab4

Please sign in to comment.