Skip to content

Commit

Permalink
Merge pull request #1 from kubesimplify/new-version
Browse files Browse the repository at this point in the history
updated to v1.1.1 of ksctl core
  • Loading branch information
dipankardas011 authored Oct 24, 2023
2 parents 6167f61 + 1792daf commit 91219d5
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 58 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test-mock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Test Functionality of the Mock cli"
on:
pull_request:
paths:
- 'cli/**'
- 'scripts/**'
- 'go.mod'
- 'go.sum'
types: [ labeled ]
branches: [ main ]
push:
paths:
- 'scripts/**'
- 'cli/**'
- 'go.mod'
- 'go.sum'
branches: [ main ]
jobs:
civo:
# if: ${{ github.event.label.name == 'pr/lgtm' }}
runs-on: ubuntu-latest
env:
KSCTL_FAKE_FLAG_ENABLED: "1"
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.0

- name: build ksctl
run: |
make install_linux
ksctl -h
- name: civo tests
run: |
ksctl create civo -n demo -r LON1 -v --approve
ksctl switch -p civo -n demo -r LON1
ksctl create ha-civo -n demo -r FRA1 -v --approve
ksctl switch -p ha-civo -n demo -r FRA1
ksctl get -p civo
56 changes: 56 additions & 0 deletions .idea/workspace.xml

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

4 changes: 2 additions & 2 deletions cli/cmd/addNodesHAAzure.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ksctl create-cluster ha-azure add-nodes <arguments to civo cloud provider>
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudAzure
SetDefaults(consts.CloudAzure, consts.ClusterTypeHa)
cli.Client.Metadata.NoWP = noWP
cli.Client.Metadata.WorkerPlaneNodeType = nodeSizeWP
cli.Client.Metadata.ClusterName = clusterName
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/addNodesHACivo.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ ksctl create-cluster ha-civo add-nodes <arguments to civo cloud provider>
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudCivo
SetDefaults(consts.CloudCivo, consts.ClusterTypeHa)
cli.Client.Metadata.NoWP = noWP
cli.Client.Metadata.WorkerPlaneNodeType = nodeSizeWP
cli.Client.Metadata.ClusterName = clusterName
Expand Down
20 changes: 10 additions & 10 deletions cli/cmd/createCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ var createClusterAzure = &cobra.Command{
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudAzure
SetDefaults(consts.CloudAzure, consts.ClusterTypeMang)
createManaged(cmd.Flags().Lookup("approve").Changed)
},
}
Expand All @@ -63,8 +63,8 @@ ksctl create-cluster civo <arguments to civo cloud provider>
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudCivo
SetDefaults(consts.CloudCivo, consts.ClusterTypeMang)
createManaged(cmd.Flags().Lookup("approve").Changed)
},
}
Expand All @@ -83,8 +83,8 @@ ksctl create-cluster local <arguments to civo cloud provider>
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_LOCAL
SetDefaults(consts.CLOUD_LOCAL, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudLocal
SetDefaults(consts.CloudLocal, consts.ClusterTypeMang)
createManaged(cmd.Flags().Lookup("approve").Changed)
},
}
Expand All @@ -103,8 +103,8 @@ ksctl create-cluster ha-civo <arguments to civo cloud provider>
}
SetRequiredFeatureFlags(cmd)

cli.Client.Metadata.Provider = consts.CLOUD_CIVO
SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudCivo
SetDefaults(consts.CloudCivo, consts.ClusterTypeHa)
createHA(cmd.Flags().Lookup("approve").Changed)
},
}
Expand All @@ -122,8 +122,8 @@ var createClusterHAAzure = &cobra.Command{
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudAzure
SetDefaults(consts.CloudAzure, consts.ClusterTypeHa)
createHA(cmd.Flags().Lookup("approve").Changed)
},
}
Expand Down
20 changes: 10 additions & 10 deletions cli/cmd/deleteCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ ksctl create-cluster azure <arguments to civo cloud provider>
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudAzure
SetDefaults(consts.CloudAzure, consts.ClusterTypeMang)

deleteManaged(cmd.Flags().Lookup("approve").Changed)
},
Expand All @@ -54,8 +54,8 @@ ksctl delete-cluster civo
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudCivo
SetDefaults(consts.CloudCivo, consts.ClusterTypeMang)

deleteManaged(cmd.Flags().Lookup("approve").Changed)

Expand All @@ -76,8 +76,8 @@ var deleteClusterHAAzure = &cobra.Command{
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudAzure
SetDefaults(consts.CloudAzure, consts.ClusterTypeHa)

deleteHA(cmd.Flags().Lookup("approve").Changed)
},
Expand All @@ -97,8 +97,8 @@ ksctl delete-cluster ha-civo <arguments to civo cloud provider>
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_HA)
cli.Client.Metadata.Provider = consts.CloudCivo
SetDefaults(consts.CloudCivo, consts.ClusterTypeHa)

deleteHA(cmd.Flags().Lookup("approve").Changed)
},
Expand All @@ -118,8 +118,8 @@ ksctl delete-cluster local <arguments to local/Docker provider>
}

SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_LOCAL
SetDefaults(consts.CLOUD_LOCAL, consts.CLUSTER_TYPE_MANG)
cli.Client.Metadata.Provider = consts.CloudLocal
SetDefaults(consts.CloudLocal, consts.ClusterTypeMang)

deleteManaged(cmd.Flags().Lookup("approve").Changed)
},
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/deleteNodesHAAzure.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ ksctl delete-cluster ha-azure delete-nodes <arguments to civo cloud provider>
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
cli.Client.Metadata.Provider = consts.CloudAzure
cli.Client.Metadata.IsHA = true

SetDefaults(consts.CLOUD_AZURE, consts.CLUSTER_TYPE_HA)
SetDefaults(consts.CloudAzure, consts.ClusterTypeHa)
cli.Client.Metadata.NoWP = noWP
cli.Client.Metadata.ClusterName = clusterName
cli.Client.Metadata.Region = region
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/deleteNodesHACivo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ ksctl delete-cluster ha-civo delete-nodes <arguments to civo cloud provider>
panic(err)
}
SetRequiredFeatureFlags(cmd)
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
cli.Client.Metadata.Provider = consts.CloudCivo
cli.Client.Metadata.IsHA = true

SetDefaults(consts.CLOUD_CIVO, consts.CLUSTER_TYPE_HA)
SetDefaults(consts.CloudCivo, consts.ClusterTypeHa)
cli.Client.Metadata.NoWP = noWP
cli.Client.Metadata.ClusterName = clusterName
cli.Client.Metadata.Region = region
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/featureFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func SetRequiredFeatureFlags(cmd *cobra.Command) {

switch consts.KsctlSpecialFlags(feature) {
case ksctl_feature_auto_scale:
if err := os.Setenv(string(consts.KSCTL_FEATURE_FLAG_HA_AUTOSCALE), "true"); err != nil {
if err := os.Setenv(string(consts.KsctlFeatureFlagHaAutoscale), "true"); err != nil {
if cli.Client.Storage != nil {
cli.Client.Storage.Logger().Err("Unable to set the ha autoscale feature")
} else {
Expand All @@ -40,7 +40,7 @@ func SetRequiredFeatureFlags(cmd *cobra.Command) {
}

case ksctl_feature_applications:
if err := os.Setenv(string(consts.KSCTL_FEATURE_FLAG_APPLICATIONS), "true"); err != nil {
if err := os.Setenv(string(consts.KsctlFeatureFlagApplications), "true"); err != nil {
if cli.Client.Storage != nil {
cli.Client.Storage.Logger().Err("Unable to set applications feature")
} else {
Expand Down
10 changes: 5 additions & 5 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ func Execute() {
controller = controlPkg.GenKsctlController()

cloud = map[int]string{
1: string(consts.CLOUD_AWS),
2: string(consts.CLOUD_AZURE),
3: string(consts.CLOUD_CIVO),
4: string(consts.CLOUD_LOCAL),
1: string(consts.CloudAws),
2: string(consts.CloudAzure),
3: string(consts.CloudCivo),
4: string(consts.CloudLocal),
}
cli.Client.Metadata.StateLocation = consts.STORE_LOCAL
cli.Client.Metadata.StateLocation = consts.StoreLocal

timer := time.Now()
err := rootCmd.Execute()
Expand Down
20 changes: 10 additions & 10 deletions cli/cmd/switchCluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ ksctl switch-context -p <civo,local,civo-ha,azure-ha,azure> -n <clustername> -r
cli.Client.Metadata.Region = region

switch provider {
case string(consts.CLOUD_LOCAL):
cli.Client.Metadata.Provider = consts.CLOUD_LOCAL
case string(consts.CloudLocal):
cli.Client.Metadata.Provider = consts.CloudLocal

case string(consts.CLUSTER_TYPE_HA) + "-" + string(consts.CLOUD_CIVO):
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
case string(consts.ClusterTypeHa) + "-" + string(consts.CloudCivo):
cli.Client.Metadata.Provider = consts.CloudCivo
cli.Client.Metadata.IsHA = true

case string(consts.CLOUD_CIVO):
cli.Client.Metadata.Provider = consts.CLOUD_CIVO
case string(consts.CloudCivo):
cli.Client.Metadata.Provider = consts.CloudCivo

case string(consts.CLUSTER_TYPE_HA) + "-" + string(consts.CLOUD_AZURE):
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
case string(consts.ClusterTypeHa) + "-" + string(consts.CloudAzure):
cli.Client.Metadata.Provider = consts.CloudAzure
cli.Client.Metadata.IsHA = true

case string(consts.CLOUD_AZURE):
cli.Client.Metadata.Provider = consts.CLOUD_AZURE
case string(consts.CloudAzure):
cli.Client.Metadata.Provider = consts.CloudAzure
}

stat, err := controller.SwitchCluster(&cli.Client)
Expand Down
15 changes: 7 additions & 8 deletions cli/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ func createApproval(showMsg bool) error {

func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType) {
switch string(provider) + string(clusterType) {
case string(consts.CLOUD_LOCAL) + string(consts.CLUSTER_TYPE_MANG):
case string(consts.CloudLocal) + string(consts.ClusterTypeMang):
if noMP == -1 {
noMP = 2
}
if len(k8sVer) == 0 {
k8sVer = "1.27.1"
}

case string(consts.CLOUD_AZURE) + string(consts.CLUSTER_TYPE_MANG):
case string(consts.CloudAzure) + string(consts.ClusterTypeMang):
if len(nodeSizeMP) == 0 {
nodeSizeMP = "Standard_DS2_v2"
}
Expand All @@ -191,8 +191,7 @@ func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType
k8sVer = "1.27"
}


case string(consts.CLOUD_CIVO) + string(consts.CLUSTER_TYPE_MANG):
case string(consts.CloudCivo) + string(consts.ClusterTypeMang):
if len(nodeSizeMP) == 0 {
nodeSizeMP = "g4s.kube.small"
}
Expand All @@ -206,7 +205,7 @@ func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType
k8sVer = "1.27.1"
}

case string(consts.CLOUD_AZURE) + string(consts.CLUSTER_TYPE_HA):
case string(consts.CloudAzure) + string(consts.ClusterTypeHa):
if len(nodeSizeCP) == 0 {
nodeSizeCP = "Standard_F2s"
}
Expand Down Expand Up @@ -235,10 +234,10 @@ func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType
k8sVer = "1.27.1"
}
if len(distro) == 0 {
distro = string(consts.K8S_K3S)
distro = string(consts.K8sK3s)
}

case string(consts.CLOUD_CIVO) + string(consts.CLUSTER_TYPE_HA):
case string(consts.CloudCivo) + string(consts.ClusterTypeHa):
if len(nodeSizeCP) == 0 {
nodeSizeCP = "g3.small"
}
Expand Down Expand Up @@ -267,7 +266,7 @@ func SetDefaults(provider consts.KsctlCloud, clusterType consts.KsctlClusterType
k8sVer = "1.27.1"
}
if len(distro) == 0 {
distro = string(consts.K8S_K3S)
distro = string(consts.K8sK3s)
}
}
}
Expand Down
Loading

0 comments on commit 91219d5

Please sign in to comment.