Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

refactor functions and add test case in miscellaneous.go & miscellaneous_test.go and others which impacted #404

Merged
merged 3 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .ci/test
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,12 @@ fi
cd "${SOURCE_PATH}"



function check() {
if [ $? -eq 0 ]; then
echo "PASS"
else
echo "FAIL"
fi
}

if [ $1x == "local"x ]; then
echo "====aws cli===="
go run cmd/gardenctl/main.go aws -- --version > /dev/null
check
echo "====az cli===="
go run cmd/gardenctl/main.go az -- -h > /dev/null
check
echo "====gcloud cli===="
go run cmd/gardenctl/main.go gcloud -- -v > /dev/null
check

else
# Build the Ginkgo (test framework) binary to be able to execute the tests.
go install -mod=vendor ./vendor/github.com/onsi/ginkgo/ginkgo

###############################################################################

ginkgo -v -progress -cover -r -mod=vendor pkg/...
fi




Expand Down
90 changes: 90 additions & 0 deletions .ci/test_local
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env bash

set -xeo pipefail

# For the test step concourse will set the following environment variables:
# SOURCE_PATH - path to component repository root directory.

if [[ -z "${SOURCE_PATH}" ]]; then
export SOURCE_PATH="$(readlink -f "$(dirname ${0})/..")"
else
export SOURCE_PATH="$(readlink -f "${SOURCE_PATH}")"
fi

gardener_project="gardenctl"
shoot_namespace="garden-${gardener_project}"
gardener_url="https://gardener.garden.dev.k8s.ondemand.com"
gardenctl_cmd=( "go" "run" "cmd/gardenctl/main.go" )
shoot_name="gctl-aws"

function check() {
if [ $? -eq 0 ]; then
echo "PASS"
else
echo "FAIL"
fi
}

gardenctl_clis(){
echo "====aws cli===="
go run cmd/gardenctl/main.go target --server https://gardener.garden.dev.k8s.ondemand.com --project gardenctl --shoot gctl-aws > /dev/null
go run cmd/gardenctl/main.go aws --version > /dev/null && check
echo "====az cli===="
go run cmd/gardenctl/main.go target --server https://gardener.garden.dev.k8s.ondemand.com --project gardenctl --shoot gctl-az > /dev/null
go run cmd/gardenctl/main.go az -h > /dev/null && check
echo "====gcloud cli===="
go run cmd/gardenctl/main.go target --server https://gardener.garden.dev.k8s.ondemand.com --project gardenctl --shoot gctl-gcp > /dev/null
go run cmd/gardenctl/main.go gcloud -v > /dev/null && check
}


gardenctl_get(){
echo "=====target/seed/shoot====="
go run cmd/gardenctl/main.go target --server https://gardener.garden.dev.k8s.ondemand.com --seed aws --shoot gctl-aws > /dev/null && check

echo "===get===garden/seed/shoot==="
go run cmd/gardenctl/main.go get garden > /dev/null && check
go run cmd/gardenctl/main.go get seed > /dev/null && check
go run cmd/gardenctl/main.go get shoot > /dev/null && check

echo "=====target/project/shoot====="
go run cmd/gardenctl/main.go target --server https://gardener.garden.dev.k8s.ondemand.com --project gardenctl --shoot gctl-aws > /dev/null && check
echo "===get===project/shoot/seed==="
go run cmd/gardenctl/main.go get garden > /dev/null && check
go run cmd/gardenctl/main.go get project > /dev/null && check
go run cmd/gardenctl/main.go get shoot > /dev/null && check
go run cmd/gardenctl/main.go get seed > /dev/null && check
}

gardenctl_logs(){
echo "===logs===logPodGardenImproved/logPod/logsKubernetesDashboard==="
go run cmd/gardenctl/main.go logs gardener-controller-manager > /dev/null && check
go run cmd/gardenctl/main.go logs api > /dev/null && check
go run cmd/gardenctl/main.go logs kubernetes-dashboard > /dev/null && check

}

gardenctl_show(){
echo "===show===showPrometheus/showGrafana==="
go run cmd/gardenctl/main.go show prometheus > /dev/null && check
go run cmd/gardenctl/main.go show grafana > /dev/null && check
}

gardenctl_ssh(){
echo "===SSH==="
go run cmd/gardenctl/main.go ssh > /dev/null && check
}

gardenctl_infra(){
echo "===infra==="
go run cmd/gardenctl/main.go infra orphan list > /dev/null && check

}


gardenctl_clis
gardenctl_get
gardenctl_logs
gardenctl_show
gardenctl_ssh
gardenctl_infra
2 changes: 1 addition & 1 deletion pkg/cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func downloadTerraformFiles(option string, targetReader TargetReader) string {
namespace := ""
target := targetReader.ReadTarget(pathTarget)
// return path allow non operator download key file
if getRole() == "user" {
if getRole(targetReader) == "user" {
if (len(target.Stack()) < 3) || (len(target.Stack()) == 3 && target.Stack()[2].Kind == "namespace") {
fmt.Println("No Shoot targeted")
os.Exit(2)
Expand Down
Loading