Skip to content

Commit

Permalink
add feature flag to reconciler context
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomcli authored and ScrapCodes committed Jun 28, 2021
1 parent 0594c4e commit f239d2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
20 changes: 2 additions & 18 deletions tekton-catalog/pipeline-loops/cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strings"

pipelineloopv1alpha1 "github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops/pkg/apis/pipelineloop/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops/pkg/reconciler/pipelinelooprun"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -186,29 +186,13 @@ func validatePipelineLoopEmbedded(bytes []byte) error {
return validatePipelineLoop(marshalBytes)
}

func enableCustomTaskFeatureFlag(ctx context.Context) context.Context {
defaults, _ := config.NewDefaultsFromMap(map[string]string{})
featureFlags, _ := config.NewFeatureFlagsFromMap(map[string]string{
"enable-custom-tasks": "true",
})
artifactBucket, _ := config.NewArtifactBucketFromMap(map[string]string{})
artifactPVC, _ := config.NewArtifactPVCFromMap(map[string]string{})
c := &config.Config{
Defaults: defaults,
FeatureFlags: featureFlags,
ArtifactBucket: artifactBucket,
ArtifactPVC: artifactPVC,
}
return config.ToContext(ctx, c)
}

func validatePipelineLoop(bytes []byte) error {
pipelineLoop := pipelineloopv1alpha1.PipelineLoop{}
if err := json.Unmarshal(bytes, &pipelineLoop); err != nil {
return err
}
ctx := context.Background()
ctx = enableCustomTaskFeatureFlag(ctx)
ctx = pipelinelooprun.EnableCustomTaskFeatureFlag(ctx)
pipelineLoop.SetDefaults(ctx)
if err := pipelineLoop.Validate(ctx); err != nil {
return fmt.Errorf("PipelineLoop name:%s\n %s", pipelineLoop.Name, err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
pipelineloopv1alpha1 "github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops/pkg/apis/pipelineloop/v1alpha1"
pipelineloopclientset "github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops/pkg/client/clientset/versioned"
listerspipelineloop "github.com/kubeflow/kfp-tekton/tekton-catalog/pipeline-loops/pkg/client/listers/pipelineloop/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/config"
"github.com/tektoncd/pipeline/pkg/apis/pipeline"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
Expand Down Expand Up @@ -167,7 +168,24 @@ func (c *Reconciler) ReconcileKind(ctx context.Context, run *v1alpha1.Run) pkgre
return merr
}

func EnableCustomTaskFeatureFlag(ctx context.Context) context.Context {
defaults, _ := config.NewDefaultsFromMap(map[string]string{})
featureFlags, _ := config.NewFeatureFlagsFromMap(map[string]string{
"enable-custom-tasks": "true",
})
artifactBucket, _ := config.NewArtifactBucketFromMap(map[string]string{})
artifactPVC, _ := config.NewArtifactPVCFromMap(map[string]string{})
c := &config.Config{
Defaults: defaults,
FeatureFlags: featureFlags,
ArtifactBucket: artifactBucket,
ArtifactPVC: artifactPVC,
}
return config.ToContext(ctx, c)
}

func (c *Reconciler) reconcile(ctx context.Context, run *v1alpha1.Run, status *pipelineloopv1alpha1.PipelineLoopRunStatus) error {
ctx = EnableCustomTaskFeatureFlag(ctx)
logger := logging.FromContext(ctx)

// Get the PipelineLoop referenced by the Run
Expand Down

0 comments on commit f239d2d

Please sign in to comment.