Skip to content

Commit

Permalink
Install kn tasks only on architectures with knative client
Browse files Browse the repository at this point in the history
Which, currently, does not include ARM.  If/when that changes, it is
suggested to simply add "arm64" instead of making these unconditional
again (as was done in commit 4c80f34).
  • Loading branch information
yselkowitz committed May 26, 2022
1 parent 5861901 commit c122a0c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package tektonaddon

import (
"path"
"runtime"

mf "github.com/manifestival/manifestival"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand Down Expand Up @@ -73,7 +74,14 @@ func GeneratePipelineTemplates(templatePath string, manifest *mf.Manifest) error
workspacedTaskGenerators := []taskGenerator{
&pipeline{environment: "openshift", nameSuffix: "", generateDeployTask: openshiftDeployTask},
&pipeline{environment: "kubernetes", nameSuffix: "-deployment", generateDeployTask: kubernetesDeployTask},
&pipeline{environment: "knative", nameSuffix: "-knative", generateDeployTask: knativeDeployTask},
}

// install knative tasks only where knative is available
switch runtime.GOARCH {
case "amd64", "ppc64le", "s390x":
workspacedTaskGenerators = append(workspacedTaskGenerators,
&pipeline{environment: "knative", nameSuffix: "-knative", generateDeployTask: knativeDeployTask},
)
}

wps, err := generateBasePipeline(workspacedTemplate, workspacedTaskGenerators, !usingPipelineResource)
Expand Down
23 changes: 22 additions & 1 deletion pkg/reconciler/openshift/tektonaddon/tektonaddon.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/tektoncd/operator/pkg/reconciler/openshift"
"os"
"path/filepath"
"runtime"
"strings"

mf "github.com/manifestival/manifestival"
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
Expand Down Expand Up @@ -205,7 +207,26 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ta *v1alpha1.TektonAddon
func applyAddons(manifest *mf.Manifest, subpath string) error {
koDataDir := os.Getenv(common.KoEnvKey)
addonLocation := filepath.Join(koDataDir, "tekton-addon", "addons", subpath)
return common.AppendManifest(manifest, addonLocation)
addons, err := mf.ManifestFrom(mf.Recursive(addonLocation))
if err != nil {
return err
}
// install knative addons only where knative is available
switch runtime.GOARCH {
case "amd64", "ppc64le", "s390x":
default:
version := common.TargetVersion((*v1alpha1.TektonPipeline)(nil))
version_formated := strings.Replace(version, ".", "-", -1)
addons = addons.Filter(
mf.Not(mf.Any(
mf.ByName("kn"),
mf.ByName("kn-v"+version_formated),
mf.ByName("kn-apply"),
mf.ByName("kn-apply-v"+version_formated),
)))
}
*manifest = manifest.Append(addons)
return nil
}

// addonTransform mutates the passed manifest to one with common, component
Expand Down

0 comments on commit c122a0c

Please sign in to comment.