Replace kubectl with oc for apply 41/1541/1
authorYolanda Robla <yroblamo@redhat.com>
Thu, 5 Sep 2019 10:56:15 +0000 (12:56 +0200)
committerYolanda Robla <yroblamo@redhat.com>
Thu, 5 Sep 2019 10:57:22 +0000 (12:57 +0200)
When applying certain manifests, kubectl could
throw an error because it is not dealing properly
with openshift manifests. Switch to oc client that
is totally matching the installer version.

Signed-off-by: Yolanda Robla <yroblamo@redhat.com>
Change-Id: I4de5e230577e7f10f1c181b166770d14cb7f3465

pkg/site/site.go
pkg/utils/utils.go

index 0400627..39f98a1 100644 (file)
@@ -415,16 +415,15 @@ func (s Site) ApplyWorkloads(kubeconfigFile string) {
        out := utils.ApplyKustomize(fmt.Sprintf("%s/kustomize", binariesPath), fmt.Sprintf("%s/blueprint/sites/site/02_cluster-addons", siteBuildPath))
        if string(out) != "" {
                // now we can apply it
-               utils.ApplyKubectl(fmt.Sprintf("%s/kubectl", binariesPath), out, kubeconfigFile)
+               utils.ApplyOc(fmt.Sprintf("%s/oc", binariesPath), out, kubeconfigFile)
        } else {
                log.Println(fmt.Sprintf("No manifests found for %s/blueprint/sites/site/02_cluster-addons", siteBuildPath))
        }
-
        log.Println(fmt.Sprintf("Applying workloads from %s/blueprint/sites/site/03_services", siteBuildPath))
        out = utils.ApplyKustomize(fmt.Sprintf("%s/kustomize", binariesPath), fmt.Sprintf("%s/blueprint/sites/site/03_services", siteBuildPath))
        if string(out) != "" {
                // now we can apply it
-               utils.ApplyKubectl(fmt.Sprintf("%s/kubectl", binariesPath), out, kubeconfigFile)
+               utils.ApplyOc(fmt.Sprintf("%s/oc", binariesPath), out, kubeconfigFile)
        } else {
                log.Println(fmt.Sprintf("No manifests found for %s/blueprint/sites/site/03_services", siteBuildPath))
        }
index d1ca628..cd11002 100644 (file)
@@ -52,8 +52,8 @@ func ApplyKustomize(kustomizeBinary string, kustomizePath string) []byte {
        return out
 }
 
-// utility to apply kubectl for a given output
-func ApplyKubectl(kubectlBinary string, kubectlContent []byte, kubeconfigPath string) {
+// utility to apply OC for a given output
+func ApplyOc(ocBinary string, kubectlContent []byte, kubeconfigPath string) {
        // write content to be applied to temporary file
        tmpFile, err := ioutil.TempFile(os.TempDir(), "kubectl-")
        if err != nil {
@@ -73,7 +73,7 @@ func ApplyKubectl(kubectlBinary string, kubectlContent []byte, kubeconfigPath st
                envVars = []string{fmt.Sprintf("KUBECONFIG=%s", kubeconfigPath)}
        }
        for i := 1; i <= 5; i++ {
-               _, err := ExecuteCommand("", envVars, false, true, kubectlBinary, "apply", "-f", tmpFile.Name())
+               _, err := ExecuteCommand("", envVars, false, true, ocBinary, "apply", "-f", tmpFile.Name())
 
                if err == nil {
                        // it is ok, stop the loop