Skip to content

Commit

Permalink
Modify environment check
Browse files Browse the repository at this point in the history
Use API resource to check the type of environment.
This approach avoid generating unwanted "error" strings in log output.

Signed-off-by: yogananth subramanian <[email protected]>
  • Loading branch information
yogananth-subramanian committed Aug 1, 2024
1 parent 591ff90 commit 99d69a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions common_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,20 @@ check_cluster_version() {
log "Unable to connect to the cluster, please check if it's up and make sure the KUBECONFIG is set correctly"
exit 1
fi
kubectl get clusterversion || log "Not an OpenShift environment"
if [[ $(kubectl api-resources --api-group=apiserver.openshift.io --no-headers=true|wc -l) -gt 0 ]];
then
kubectl get clusterversion
else
log "Not an OpenShift environment"
fi
}

# sets kubernetes distribution in krkn config if platform is kubernetes included automatically
# on all the builds to keep krkn compatible with both the platform
# called in the checks method below

set_kubernetes_platform() {
if ! kubectl get clusterversion;
if [[ $(kubectl api-resources --api-group=apiserver.openshift.io --no-headers=true|wc -l) -eq 0 ]];
then
yq -i '.kraken.distribution="kubernetes"' /home/krkn/kraken/config/config.yaml.template
fi
Expand Down

0 comments on commit 99d69a6

Please sign in to comment.