Use Cobra instead of bespoke startup code
We depend on Cobra anyway (transitive from Kubernetes) so might as well improve command line experience of our binaries.
Current:
go run ./cmd/cli --help
Program aborted: unknown subcommand: --help
Usage:
cli [command]
Available Commands:
generate Prints the YAML manifests based on specified configuration
exit status 1
###########################
go run ./cmd/cli
Program aborted: subcommand not specified
Usage:
cli [command]
Available Commands:
generate Prints the YAML manifests based on specified configuration
exit status 1
###########################
go run ./cmd/cli generate --help
Usage of cli:
--agent-token string Access token registered for agent
--agent-version string Version of the agentk image to use (default "v0.0.0")
--kas-address string GitLab Kubernetes Agent Server address
--namespace string Kubernetes namespace to create resources in (default "gitlab-agent")
--no-rbac Do not include corresponding Roles and RoleBindings for the agent service account
--version Print version and exit
###########################
go run ./cmd/agentk --help
Usage of agentk:
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--ca-cert-file string Optional file with X.509 certificate authority certificate in PEM format
--cache-dir string Default cache directory (default "/Users/mikhail/.kube/cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kas-address string GitLab Kubernetes Agent Server address
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-n, --namespace string If present, the namespace scope for this CLI request
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-s, --server string The address and port of the Kubernetes API server
--tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
--token string Bearer token for authentication to the API server
--token-file string File with access token
--user string The name of the kubeconfig user to use
--version Print version and exit
###########################
go run ./cmd/kas --help
Usage of kas:
--configuration-file string Optional configuration file to use (YAML)
--version Print version and exit
###########################
go run ./cmd/kas --version
kas version: v0.0.0, commit: 00000000, built: 00000000.000000
New:
go run ./cmd/cli --help
GitLab Kubernetes Agent CLI
Usage:
cli [command]
Available Commands:
generate Prints the YAML manifests based on specified configuration
help Help about any command
Flags:
-h, --help help for cli
-v, --version version for cli
Use "cli [command] --help" for more information about a command.
###########################
go run ./cmd/cli generate --help
Prints the YAML manifests based on specified configuration
Usage:
cli generate [flags]
Flags:
--agent-token string Access token registered for agent
--agent-version string Version of the agentk image to use (default "v0.0.0")
-h, --help help for generate
--kas-address string GitLab Kubernetes Agent Server address
--namespace string Kubernetes namespace to create resources in (default "gitlab-agent")
--no-rbac Do not include corresponding Roles and RoleBindings for the agent service account
###########################
go run ./cmd/agentk --help
GitLab Kubernetes Agent
Usage:
agentk [flags]
Flags:
--as string Username to impersonate for the operation
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
--ca-cert-file string Optional file with X.509 certificate authority certificate in PEM format
--cache-dir string Default cache directory (default "/Users/mikhail/.kube/cache")
--certificate-authority string Path to a cert file for the certificate authority
--client-certificate string Path to a client certificate file for TLS
--client-key string Path to a client key file for TLS
--cluster string The name of the kubeconfig cluster to use
--context string The name of the kubeconfig context to use
-h, --help help for agentk
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
--kas-address string GitLab Kubernetes Agent Server address
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
-n, --namespace string If present, the namespace scope for this CLI request
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
-s, --server string The address and port of the Kubernetes API server
--tls-server-name string Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used
--token string Bearer token for authentication to the API server
--token-file string File with access token
--user string The name of the kubeconfig user to use
-v, --version version for agentk
###########################
go run ./cmd/kas --help
GitLab Kubernetes Agent Server
Usage:
kas [flags]
Flags:
--configuration-file string Configuration file to use (YAML)
-h, --help help for kas
-v, --version version for kas
###########################
go run ./cmd/kas --version
kas version v0.0.0, commit: 00000000, built: 00000000.000000