This repository has been archived by the owner on Nov 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from jstrachan/changes
fix: improve CLI handling
- Loading branch information
Showing
9 changed files
with
260 additions
and
89 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
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
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,85 @@ | ||
package reqhelpers | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/jenkins-x/jx/pkg/cloud" | ||
"github.com/jenkins-x/jx/pkg/config" | ||
"github.com/jenkins-x/jx/pkg/gits" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// AddRequirementsFlagsOptions add CLI options to the flags | ||
func AddRequirementsFlagsOptions(cmd *cobra.Command, flags *RequirementBools) { | ||
cmd.Flags().BoolVarP(&flags.AutoUpgrade, "autoupgrade", "", false, "enables or disables auto upgrades") | ||
cmd.Flags().BoolVarP(&flags.EnvironmentRemote, "env-remote", "", false, "if enables then all other environments than dev (staging & production by default) will be configured to be in remote clusters") | ||
cmd.Flags().BoolVarP(&flags.EnvironmentGitPublic, "env-git-public", "", false, "enables or disables whether the environment repositories should be public") | ||
cmd.Flags().BoolVarP(&flags.GitPublic, "git-public", "", false, "enables or disables whether the project repositories should be public") | ||
cmd.Flags().BoolVarP(&flags.GitOps, "gitops", "g", false, "enables or disables the use of gitops") | ||
cmd.Flags().BoolVarP(&flags.Kaniko, "kaniko", "", false, "enables or disables the use of kaniko") | ||
cmd.Flags().BoolVarP(&flags.Terraform, "terraform", "", false, "enables or disables the use of terraform") | ||
cmd.Flags().BoolVarP(&flags.VaultRecreateBucket, "vault-recreate-bucket", "", false, "enables or disables whether to rereate the secret bucket on boot") | ||
cmd.Flags().BoolVarP(&flags.VaultDisableURLDiscover, "vault-disable-url-discover", "", false, "override the default lookup of the Vault URL, could be incluster service or external ingress") | ||
cmd.Flags().BoolVarP(&flags.ExternalDNS, "externaldns", "", false, "should we enable the ExternalDNS app to register DNS entries for Ingress resources") | ||
cmd.Flags().BoolVarP(&flags.TLS, "tls", "", false, "enable TLS for Ingress") | ||
cmd.Flags().StringVarP(&flags.Repository, "repository", "", "", "the artifact repository. Possible values are: "+strings.Join(config.RepositoryTypeValues, ", ")) | ||
} | ||
|
||
// AddRequirementsOptions add CLI flags to the requirements | ||
func AddRequirementsOptions(cmd *cobra.Command, r *config.RequirementsConfig) { | ||
cmd.Flags().StringVarP(&r.BootConfigURL, "boot-config-url", "", "", "specify the boot configuration git URL") | ||
|
||
// auto upgrade | ||
cmd.Flags().StringVarP(&r.AutoUpdate.Schedule, "autoupdate-schedule", "", "", "the cron schedule for auto upgrading your cluster") | ||
|
||
// cluster | ||
cmd.Flags().StringVarP(&r.Cluster.ClusterName, "cluster", "c", "", "configures the cluster name") | ||
cmd.Flags().StringVarP(&r.Cluster.Namespace, "namespace", "n", "", "configures the namespace to use") | ||
cmd.Flags().StringVarP(&r.Cluster.Provider, "provider", "p", "", "configures the kubernetes provider. Supported providers: "+cloud.KubernetesProviderOptions()) | ||
cmd.Flags().StringVarP(&r.Cluster.ProjectID, "project", "", "", "configures the Google Project ID") | ||
cmd.Flags().StringVarP(&r.Cluster.Registry, "registry", "", "", "configures the host name of the container registry") | ||
cmd.Flags().StringVarP(&r.Cluster.Region, "region", "r", "", "configures the cloud region") | ||
cmd.Flags().StringVarP(&r.Cluster.Zone, "zone", "z", "", "configures the cloud zone") | ||
|
||
cmd.Flags().StringVarP(&r.Cluster.ExternalDNSSAName, "extdns-sa", "", "", "configures the External DNS service account name") | ||
cmd.Flags().StringVarP(&r.Cluster.KanikoSAName, "kaniko-sa", "", "", "configures the Kaniko service account name") | ||
|
||
AddGitRequirementsOptions(cmd, r) | ||
|
||
// ingress | ||
cmd.Flags().StringVarP(&r.Ingress.Domain, "domain", "d", "", "configures the domain name") | ||
cmd.Flags().StringVarP(&r.Ingress.ServiceType, "service-type", "", "", "the Ingress controller Service Type such as NodePort if using on premise and you do not have a LoadBalancer service type support") | ||
cmd.Flags().StringVarP(&r.Ingress.TLS.Email, "tls-email", "", "", "the TLS email address to enable TLS on the domain") | ||
cmd.Flags().StringVarP(&r.Ingress.TLS.SecretName, "tls-secret", "", "", "the custom Kubernetes Secret name for the TLS certificate") | ||
|
||
// storage | ||
cmd.Flags().StringVarP(&r.Storage.Logs.URL, "bucket-logs", "", "", "the bucket URL to store logs") | ||
cmd.Flags().StringVarP(&r.Storage.Backup.URL, "bucket-backups", "", "", "the bucket URL to store backups") | ||
cmd.Flags().StringVarP(&r.Storage.Repository.URL, "bucket-repo", "", "", "the bucket URL to store repository artifacts") | ||
cmd.Flags().StringVarP(&r.Storage.Reports.URL, "bucket-reports", "", "", "the bucket URL to store reports. If not specified default to te logs bucket") | ||
|
||
// vault | ||
cmd.Flags().StringVarP(&r.Vault.Name, "vault-name", "", "", "specify the vault name") | ||
cmd.Flags().StringVarP(&r.Vault.Bucket, "vault-bucket", "", "", "specify the vault bucket") | ||
cmd.Flags().StringVarP(&r.Vault.Keyring, "vault-keyring", "", "", "specify the vault key ring") | ||
cmd.Flags().StringVarP(&r.Vault.Key, "vault-key", "", "", "specify the vault key") | ||
cmd.Flags().StringVarP(&r.Vault.ServiceAccount, "vault-sa", "", "", "specify the vault Service Account name") | ||
|
||
// velero | ||
cmd.Flags().StringVarP(&r.Velero.ServiceAccount, "velero-sa", "", "", "specify the Velero Service Account name") | ||
cmd.Flags().StringVarP(&r.Velero.Namespace, "velero-ns", "", "", "specify the Velero Namespace") | ||
|
||
// version stream | ||
cmd.Flags().StringVarP(&r.VersionStream.URL, "version-stream-url", "", "", "specify the Version Stream git URL") | ||
cmd.Flags().StringVarP(&r.VersionStream.Ref, "version-stream-ref", "", "", "specify the Version Stream git reference (branch, tag, sha)") | ||
} | ||
|
||
// AddGitRequirementsOptions adds git specific overrides to the given requirements | ||
func AddGitRequirementsOptions(cmd *cobra.Command, r *config.RequirementsConfig) { | ||
cmd.Flags().StringVarP(&r.Cluster.GitKind, "git-kind", "", "", fmt.Sprintf("the kind of git repository to use. Possible values: %s", strings.Join(gits.KindGits, ", "))) | ||
cmd.Flags().StringVarP(&r.Cluster.GitName, "git-name", "", "", "the name of the git repository") | ||
cmd.Flags().StringVarP(&r.Cluster.GitServer, "git-server", "", "", "the git server host such as https://github.com or https://gitlab.com") | ||
cmd.Flags().StringVarP(&r.Cluster.EnvironmentGitOwner, "env-git-owner", "", "", "the git owner (organisation or user) used to own the git repositories for the environments") | ||
cmd.Flags().StringArrayVarP(&r.Cluster.DevEnvApprovers, "approver", "", nil, "the git user names of the approvers for the environments") | ||
} |
Oops, something went wrong.