Skip to content

Commit

Permalink
fixed the nil pointer issue for --approve -> --yes
Browse files Browse the repository at this point in the history
Signed-off-by: Dipankar Das <[email protected]>
  • Loading branch information
dipankardas011 committed May 31, 2024
1 parent 838af7f commit e8c6704
Show file tree
Hide file tree
Showing 10 changed files with 421 additions and 620 deletions.
758 changes: 379 additions & 379 deletions .github/workflows/test-mock.bkp.yml

Large diffs are not rendered by default.

247 changes: 24 additions & 223 deletions .github/workflows/test-mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ on:
- 'go.mod'
- 'go.sum'
branches: [ main ]

jobs:
ksctl-cli-windows:
ksctl-cli:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
Expand All @@ -36,63 +37,61 @@ jobs:
KSCTL_FAKE_FLAG_ENABLED: "1"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4.1.4

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

- name: build ksctl windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
cd .\scripts
.\builder.ps1
cd C:\Users\runneradmin\AppData\Local\ksctl
.\ksctl.exe version
echo "KSCTL_BIN=.\C:\Users\runneradmin\AppData\Local\ksctl\ksctl.exe" >> ${GITHUB_ENV}
echo "KSCTL_BIN=.\$env:LOCALAPPDATA\ksctl\ksctl.exe" >> "${GITHUB_ENV}"
- name: build ksctl linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
set -x
make install_linux
ksctl version
echo "KSCTL_BIN=ksctl" >> ${GITHUB_ENV}
echo "KSCTL_BIN=ksctl" >> "${GITHUB_ENV}"
- name: build ksctl macos
if: ${{ matrix.os == 'macos-latest' }}
run: |
set -x
make install_macos_intel
ksctl version
echo "KSCTL_BIN=ksctl" >> ${GITHUB_ENV}
echo "KSCTL_BIN=ksctl" >> "${GITHUB_ENV}"
- name: version
run: |
${{ env.KSCTL_BIN }} version
- name: civo create
run: |
${{ env.KSCTL_BIN }} create civo -n demo -r LON1 --nodeSizeMP "g4s.kube.small" --version 1.27.1 --verbose -1 -s store-local --yes
${{env.KSCTL_BIN}} create ha-civo -n ha-demo-k3s --nodeSizeDS "fake.small" --version 1.27.1 --nodeSizeLB "fake.small" --nodeSizeCP "fake.small" --nodeSizeWP "fake.small" -s store-local -r LON1 --verbose -1 --yes --bootstrap k3s
${{env.KSCTL_BIN}} create ha-civo -n ha-demo-kubeadm --nodeSizeDS "fake.small" --version 1.27.1 --nodeSizeLB "fake.small" --nodeSizeCP "fake.small" --nodeSizeWP "fake.small" -s store-local -r LON1 --verbose -1 --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-civo -n ha-demo-kubeadm --nodeSizeDS "fake.small" --version 1.28 --nodeSizeLB "fake.small" --nodeSizeCP "fake.small" --nodeSizeWP "fake.small" -s store-local -r LON1 --verbose -1 --yes --bootstrap kubeadm
- name: azure create
run: |
${{env.KSCTL_BIN}} create azure -n demo -r fake --nodeSizeMP "fake" -s store-local --version 1.27.1 --verbose -1 --yes
${{env.KSCTL_BIN}} create ha-azure -n ha-demo-k3s --nodeSizeDS "fake" --version 1.27.1 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap k3s
${{env.KSCTL_BIN}} create ha-azure -n ha-demo-kubeadm --nodeSizeDS "fake" --version 1.27.1 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-azure -n ha-demo-kubeadm --nodeSizeDS "fake" --version 1.28 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap kubeadm
- name: aws create
run: |
# ${{env.KSCTL_BIN}} create aws -n demo -r fake --nodeSizeMP "fake" --version 1.27.1 -s store-local --verbose -1 --yes
${{env.KSCTL_BIN}} create ha-aws -n ha-demo-k3s --nodeSizeDS "fake" --version 1.27.1 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap k3s
${{env.KSCTL_BIN}} create ha-aws -n ha-demo-kubeadm --nodeSizeDS "fake" --version 1.27.1 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-aws -n ha-demo-kubeadm --nodeSizeDS "fake" --version 1.28 --nodeSizeLB "fake" --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 -s store-local --yes --bootstrap kubeadm
- name: local create
run: |
Expand Down Expand Up @@ -175,26 +174,32 @@ jobs:
- name: civo scale up and down
run: |
${{env.KSCTL_BIN}} delete ha-civo del-nodes -n ha-demo-k3s --noWP 0 -r LON1 -s store-local --yes -v -1 --bootstrap k3s
${{env.KSCTL_BIN}} create ha-civo add-nodes -n ha-demo-k3s --noWP 1 --version 1.27.1 --nodeSizeWP "fake.small" -s store-local -r LON1 -v -1 --yes --bootstrap k3s
${{env.KSCTL_BIN}} delete ha-civo del-nodes -n ha-demo-kubeadm --noWP 0 -r LON1 -s store-local --yes -v -1 --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-civo add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.27.1 --nodeSizeWP "fake.small" -s store-local -r LON1 -v -1 --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-civo add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.28 --nodeSizeWP "fake.small" -s store-local -r LON1 -v -1 --yes --bootstrap kubeadm
- name: azure scale up and down
run: |
${{env.KSCTL_BIN}} delete ha-azure del-nodes -n ha-demo-k3s --noWP 0 -r fake -s store-local --yes -v -1 --bootstrap k3s
${{env.KSCTL_BIN}} create ha-azure add-nodes -n ha-demo-k3s --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap k3s
${{env.KSCTL_BIN}} delete ha-azure del-nodes -n ha-demo-kubeadm --noWP 0 -r fake -s store-local --yes -v -1 --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-azure add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-azure add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.28 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap kubeadm
- name: aws scale up and down
run: |
${{env.KSCTL_BIN}} delete ha-aws del-nodes -n ha-demo-k3s --noWP 0 -r fake -s store-local --yes -v -1 --bootstrap k3s
${{env.KSCTL_BIN}} create ha-aws add-nodes -n ha-demo-k3s --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap k3s
${{env.KSCTL_BIN}} delete ha-aws del-nodes -n ha-demo-kubeadm --noWP 0 -r fake -s store-local --yes -v -1 --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-aws add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap kubeadm
${{env.KSCTL_BIN}} create ha-aws add-nodes -n ha-demo-kubeadm --noWP 1 --version 1.28 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes --bootstrap kubeadm
- name: civo delete
run: |
Expand Down Expand Up @@ -225,207 +230,3 @@ jobs:
export MONGODB_URI="mongodb://root:[email protected]:27017"
${{env.KSCTL_BIN}} delete local -n demolocal-extmongo -v -1 -s external-store-mongodb --yes
# ksctl-cli-unix:
# strategy:
# matrix:
# os: [macos-latest, ubuntu-latest]
#
# if: |
# (
# github.event.label.name == 'pr/lgtm' ||
# contains(github.event.pull_request.labels.*.name, 'pr/lgtm')
# ) || (
# github.event_name == 'push' &&
# github.ref == 'refs/heads/main'
# )
# runs-on: ${{ matrix.os }}
# env:
# KSCTL_FAKE_FLAG_ENABLED: "1"
# PS4: '+\[\033[0;33m\](\[\033[0;36m\]${BASH_SOURCE##*/}:${LINENO}\[\033[0;33m\])\[\033[0m\] '
# 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 linux
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# make install_linux
# ksctl version
#
# - name: build ksctl macos
# if: ${{ matrix.os == 'macos-latest' }}
# run: |
# set -xe
# make install_macos_intel
# ksctl version
#
# - name: civo create
# run: |
# set -xe
# ksctl create civo -n demo -r LON1 --nodeSizeMP "g4s.kube.small" --version 1.27.1 -s store-local --verbose -1 --yes
# ksctl create ha-civo -n ha-demo --nodeSizeDS "fake.small" -s store-local --version 1.27.1 --nodeSizeLB "fake.small" --nodeSizeCP "fake.small" --nodeSizeWP "fake.small" -r LON1 --verbose -1 --yes
#
# - name: azure create
# run: |
# set -xe
# ksctl create azure -n demo -r fake --nodeSizeMP "fake" -s store-local --version 1.27.1 --verbose -1 --yes
# ksctl create ha-azure -n ha-demo --nodeSizeDS "fake" -s store-local --nodeSizeLB "fake" --version 1.27.1 --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 --yes
#
# - name: aws create
# run: |
# set -xe
# # ksctl create aws -n demo -r fake --nodeSizeMP "fake" -s store-local --version 1.27.1 --verbose -1 --yes
# ksctl create ha-aws -n ha-demo --nodeSizeDS "fake" -s store-local --nodeSizeLB "fake" --version 1.27.1 --nodeSizeCP "fake" --nodeSizeWP "fake" -r fake --verbose -1 --yes
#
# - name: local create
# run: |
# set -xe
# ksctl create local -n demolocal -s store-local --verbose -1 --yes
#
# - name: local create mongodb
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# unset KSCTL_FAKE_FLAG_ENABLED
# docker run -d \
# --name mongodb \
# -p 27017:27017 \
# -e MONGO_INITDB_ROOT_USERNAME=root \
# -e MONGO_INITDB_ROOT_PASSWORD=1234 \
# mongo
# export MONGODB_URI="mongodb://root:[email protected]:27017"
# ksctl create local -n demolocal-extmongo -s external-store-mongodb --verbose -1 --yes
#
# - name: civo get
# run: |
# set -xe
# ksctl get -p civo -s store-local
#
# - name: azure get
# run: |
# set -xe
# ksctl get -p azure -s store-local
#
# - name: aws get
# run: |
# set -xe
# ksctl get -p aws -s store-local
#
# - name: local get
# run: |
# set -xe
# ksctl get -p local -s store-local
#
# - name: local get mongo
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# unset KSCTL_FAKE_FLAG_ENABLED
# export MONGODB_URI="mongodb://root:[email protected]:27017"
# ksctl get -p local -s external-store-mongodb
#
# - name: all
# run: |
# set -xe
# ksctl get -s store-local
#
# - name: all mongodb
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# unset KSCTL_FAKE_FLAG_ENABLED
# export MONGODB_URI="mongodb://root:[email protected]:27017"
# ksctl get -s external-store-mongodb
#
# - name: local switch
# run: |
# set -xe
# ksctl switch -p local -n demolocal -s store-local
#
# - name: local switch mongodb
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# unset KSCTL_FAKE_FLAG_ENABLED
# export MONGODB_URI="mongodb://root:[email protected]:27017"
# ksctl switch -p local -n demolocal-extmongo -s external-store-mongodb
#
# - name: civo switch
# run: |
# set -xe
# ksctl switch -p civo -n demo -s store-local -r LON1
# ksctl switch -p ha-civo -n ha-demo -s store-local -r LON1
#
# - name: azure switch
# run: |
# set -xe
# ksctl switch -p azure -n demo -s store-local -r fake
# ksctl switch -p ha-azure -n ha-demo -s store-local -r fake
#
# - name: aws switch
# run: |
# set -xe
# # ksctl switch -p aws -n demo -s store-local -r fake
# ksctl switch -p ha-aws -n ha-demo -s store-local -r fake
#
# - name: civo scale up and down
# run: |
# set -xe
# ksctl delete ha-civo del-nodes -n ha-demo --noWP 0 -r LON1 -s store-local --yes -v -1
# ksctl create ha-civo add-nodes -n ha-demo --noWP 1 --version 1.27.1 --nodeSizeWP "fake.small" -s store-local -r LON1 -v -1 --yes
#
# - name: azure scale up and down
# run: |
# set -xe
# ksctl delete ha-azure del-nodes -n ha-demo --noWP 0 -s store-local -r fake --yes -v -1
# ksctl create ha-azure add-nodes -n ha-demo --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes
#
# - name: aws scale up and down
# run: |
# set -xe
# ksctl delete ha-aws del-nodes -n ha-demo --noWP 0 -s store-local -r fake --yes -v -1
# ksctl create ha-aws add-nodes -n ha-demo --noWP 1 --version 1.27.1 --nodeSizeWP "fake" -s store-local -r fake -v -1 --yes
#
# - name: civo delete
# run: |
# set -xe
# ksctl delete civo -n demo -r LON1 -s store-local -v -1 --yes
# ksctl delete ha-civo -n ha-demo -r LON1 -s store-local -v -1 --yes
#
# - name: azure delete
# run: |
# set -xe
# ksctl delete azure -n demo -r fake -s store-local -v -1 --yes
# ksctl delete ha-azure -n ha-demo -r fake -s store-local -v -1 --yes
#
# - name: aws delete
# run: |
# set -xe
# # ksctl delete aws -n demo -r fake -s store-local -v -1 --yes
# ksctl delete ha-aws -n ha-demo -r fake -s store-local -v -1 --yes
#
# - name: local delete
# run: |
# set -xe
# ksctl delete local -n demolocal -v -1 -s store-local --yes
#
# - name: local delete mongodb
# if: ${{ matrix.os == 'ubuntu-latest' }}
# run: |
# set -xe
# unset KSCTL_FAKE_FLAG_ENABLED
# export MONGODB_URI="mongodb://root:[email protected]:27017"
# ksctl delete local -n demolocal-extmongo -v -1 -s external-store-mongodb --yes
#
# - name: storage provider
# run: |
# set -xe
# ksctl create local -n demolocal -s store-local -v -1 --yes
# ksctl create local -n demolocal -s external-store-mongodb -v -1 --yes || echo "Expected to fail :) due to missing env vars"
# ksctl create local -n demolocal -s store-local123 -v -1 --yes || echo "Expected to fail :) due to invalid provider name"
2 changes: 1 addition & 1 deletion cli/cmd/addNodesHAAws.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ksctl create ha-aws add-nodes -n demo -r ap-south-1 -s store-local --noWP 3 --no
cli.Client.Metadata.K8sVersion = k8sVer
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := createApproval(ctx, log, cmd.Flags().Lookup("approve").Changed); err != nil {
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/addNodesHAAzure.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ksctl create ha-azure add-nodes -n demo -r eastus -s store-local --noWP 3 --node
cli.Client.Metadata.K8sVersion = k8sVer
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := createApproval(ctx, log, cmd.Flags().Lookup("approve").Changed); err != nil {
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/addNodesHACivo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ksctl create ha-civo add-nodes -n demo -r LON1 -s store-local --noWP 3 --nodeSiz
cli.Client.Metadata.IsHA = true
cli.Client.Metadata.StateLocation = consts.KsctlStore(storage)

if err := createApproval(ctx, log, cmd.Flags().Lookup("approve").Changed); err != nil {
if err := createApproval(ctx, log, cmd.Flags().Lookup("yes").Changed); err != nil {
log.Error(ctx, "createApproval", "Reason", err)
os.Exit(1)
}
Expand Down
Loading

0 comments on commit e8c6704

Please sign in to comment.