Skip to content

Commit

Permalink
Changing flag to the cluster-topology
Browse files Browse the repository at this point in the history
  • Loading branch information
ljakimczuk committed Jan 20, 2022
1 parent f42f8c3 commit 80884bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
20 changes: 10 additions & 10 deletions cmd/template/cluster/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import (
)

const (
flagProvider = "provider"
flagTemplateType = "template-type"
flagProvider = "provider"

// AWS only.
flagAWSExternalSNAT = "external-snat"
Expand All @@ -25,6 +24,7 @@ const (
// Cluster App only.
flagClusterAppVersion = "cluster-app-version"
flagClusterUserConfigMap = "cluster-user-configmap"
flagClusterTopology = "cluster-topology"
flagDefaultAppsAppVersion = "default-apps-app-version"
flagDefaultAppsUserConfigMap = "default-apps-user-configmap"

Expand Down Expand Up @@ -77,14 +77,14 @@ type openStackFlag struct {

type clusterAppFlag struct {
ClusterUserConfigMap string
DefaultAppsUserConfigMap string
ClusterAppVersion string
ClusterTopology bool
DefaultAppsUserConfigMap string
DefaultAppsAppVersion string
}

type flag struct {
Provider string
TemplateType string
Provider string

AWS awsFlag
OpenStack openStackFlag
Expand All @@ -109,7 +109,6 @@ type flag struct {

func (f *flag) Init(cmd *cobra.Command) {
cmd.Flags().StringVar(&f.Provider, flagProvider, "", "Installation infrastructure provider.")
cmd.Flags().StringVar(&f.TemplateType, flagTemplateType, "raw", "Type of the template. Could be one of: raw, app. If app, cluster will be templated as an App CR. (default raw)")

// AWS only.
cmd.Flags().StringVar(&f.AWS.ControlPlaneSubnet, flagAWSControlPlaneSubnet, "", "Subnet used for the Control Plane.")
Expand All @@ -130,10 +129,11 @@ func (f *flag) Init(cmd *cobra.Command) {
cmd.Flags().StringVar(&f.OpenStack.NodeCIDR, flagOpenStackNodeCIDR, "", "CIDR used for the nodes.")

// OpenStack App only.
cmd.Flags().StringVar(&f.ClusterApp.ClusterAppVersion, flagClusterAppVersion, "0.1.0", "Cluster App version to be installed. (OpenStack App CR only).")
cmd.Flags().StringVar(&f.ClusterApp.DefaultAppsAppVersion, flagDefaultAppsAppVersion, "0.1.0", "Default Apps App version to be installed. (OpenStack App CR only).")
cmd.Flags().StringVar(&f.ClusterApp.ClusterUserConfigMap, flagClusterUserConfigMap, "", "Path to the user values configmap YAML file for Cluster App (OpenStack App CR only).")
cmd.Flags().StringVar(&f.ClusterApp.ClusterAppVersion, flagClusterAppVersion, "0.1.0", "Cluster App version to be installed. (OpenStack App CR only).")
cmd.Flags().StringVar(&f.ClusterApp.DefaultAppsUserConfigMap, flagDefaultAppsUserConfigMap, "", "Path to the user values configmap YAML file for Default Apps App (OpenStack App CR only).")
cmd.Flags().StringVar(&f.ClusterApp.DefaultAppsAppVersion, flagDefaultAppsAppVersion, "0.1.0", "Default Apps App version to be installed. (OpenStack App CR only).")
cmd.Flags().BoolVar(&f.ClusterApp.ClusterTopology, flagClusterTopology, false, "Templated cluster as an App CR. (OpenStack App CR only).")

// TODO: Make these flags visible once we have a better method for displaying provider-specific flags.
_ = cmd.Flags().MarkHidden(flagOpenStackCloud)
Expand All @@ -148,7 +148,7 @@ func (f *flag) Init(cmd *cobra.Command) {
_ = cmd.Flags().MarkHidden(flagOpenStackRootVolumeSourceUUID)
_ = cmd.Flags().MarkHidden(flagOpenStackNodeCIDR)

_ = cmd.Flags().MarkHidden(flagTemplateType)
_ = cmd.Flags().MarkHidden(flagClusterTopology)
_ = cmd.Flags().MarkHidden(flagClusterAppVersion)
_ = cmd.Flags().MarkHidden(flagDefaultAppsAppVersion)
_ = cmd.Flags().MarkHidden(flagClusterUserConfigMap)
Expand Down Expand Up @@ -294,7 +294,7 @@ func (f *flag) Validate() error {
}
}

if f.TemplateType != "app" && f.Release == "" {
if !f.ClusterApp.ClusterTopology && f.Release == "" {
return microerror.Maskf(invalidFlagError, "--%s must not be empty", flagRelease)
}

Expand Down
6 changes: 2 additions & 4 deletions cmd/template/cluster/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ func (r *runner) run(ctx context.Context, cmd *cobra.Command, args []string) err
return microerror.Mask(err)
}
case key.ProviderOpenStack:
if r.flag.TemplateType == "raw" {
err = provider.WriteOpenStackTemplateRaw(ctx, c.K8sClient, output, config)
} else if r.flag.TemplateType == "app" {
if r.flag.ClusterApp.ClusterTopology {
err = provider.WriteOpenStackTemplateAppCR(ctx, config)
} else {
return microerror.Maskf(invalidFlagError, "Type '%s' is not supported.\n", r.flag.TemplateType)
err = provider.WriteOpenStackTemplateRaw(ctx, c.K8sClient, output, config)
}

if err != nil {
Expand Down

0 comments on commit 80884bb

Please sign in to comment.