Skip to content

Commit

Permalink
propagating params to beta
Browse files Browse the repository at this point in the history
Propagated Parameters was deployed as an alpha feature in release v0.36.0. This PR promotes it to beta by removing the constraints applied under the alpha feature. This PR addresses issue #4955.
  • Loading branch information
chitrangpatel committed Oct 14, 2022
1 parent d416770 commit ff4f015
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 44 deletions.
4 changes: 3 additions & 1 deletion docs/pipelineruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ go through the complexity of checking each `Pipeline` and providing only the req

#### Propagated Parameters

**([alpha only](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#alpha-features))**
([beta feature](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#beta-features))

When using an inlined spec, parameters from the parent `PipelineRun` will be
propagated to any inlined specs without needing to be explicitly defined. This
Expand Down Expand Up @@ -668,6 +668,8 @@ status:

##### Object Parameters

**([alpha only](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#alpha-features))**

When using an inlined spec, object parameters from the parent `PipelineRun` will also be
propagated to any inlined specs without needing to be explicitly defined. This
allows authors to simplify specs by automatically propagating top-level
Expand Down
2 changes: 1 addition & 1 deletion docs/taskruns.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ spec:

#### Propagated Parameters

**([alpha only](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#alpha-features))**
([beta feature](https://github.com/tektoncd/pipeline/blob/main/docs/install.md#beta-features))

When using an inlined `taskSpec`, parameters from the parent `TaskRun` will be
available to the `Task` without needing to be explicitly defined.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestTaskSpecValidatePropagatedParamsAndWorkspaces(t *testing.T) {
Workspaces: tt.fields.Workspaces,
Results: tt.fields.Results,
}
ctx := config.EnableAlphaAPIFields(context.Background())
ctx := config.EnableBetaAPIFields(context.Background())
ts.SetDefaults(ctx)
ctx = config.SkipValidationDueToPropagatedParametersAndWorkspaces(ctx, true)
if err := ts.Validate(ctx); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/pipeline/v1/taskrun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestTaskRun_Invalidate(t *testing.T) {
Message: `non-existent variable in "$(params.task-words[*])"`,
Paths: []string{"spec.steps[0].args[0]"},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params not provided but used by step",
taskRun: &v1.TaskRun{
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params from taskrun to steps",
taskRun: &v1.TaskRun{
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params with one declared in taskspec and other provided by taskrun",
taskRun: &v1.TaskRun{
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating partial object params with multiple keys",
taskRun: &v1.TaskRun{
Expand Down Expand Up @@ -385,7 +385,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "object params without propagation",
taskRun: &v1.TaskRun{
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/pipeline/v1beta1/taskrun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestTaskRun_Invalidate(t *testing.T) {
Message: `non-existent variable in "$(params.task-words[*])"`,
Paths: []string{"spec.steps[0].args[0]"},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params not provided but used by step",
taskRun: &v1beta1.TaskRun{
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params with taskrun",
taskRun: &v1beta1.TaskRun{
Expand Down Expand Up @@ -255,7 +255,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating object params with one declared in taskspec and other provided by taskrun",
taskRun: &v1beta1.TaskRun{
Expand Down Expand Up @@ -324,7 +324,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "propagating partial object params with multiple keys",
taskRun: &v1beta1.TaskRun{
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestTaskRun_Validate(t *testing.T) {
},
},
},
wc: config.EnableAlphaAPIFields,
wc: config.EnableBetaAPIFields,
}, {
name: "object params without propagation",
taskRun: &v1beta1.TaskRun{
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func ApplyReplacements(ctx context.Context, p *v1beta1.PipelineSpec, replacement
}

func propagateParams(ctx context.Context, t v1beta1.PipelineTask, replacements map[string]string, arrayReplacements map[string][]string, objectReplacements map[string]map[string]string) (v1beta1.PipelineTask, map[string]string, map[string][]string, map[string]map[string]string) {
if t.TaskSpec != nil && config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields == "alpha" {
if t.TaskSpec != nil && (config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields == config.BetaAPIFields || config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields == config.AlphaAPIFields) {
// check if there are task parameters defined that match the params at pipeline level
if len(t.Params) > 0 {
for _, par := range t.Params {
Expand Down
50 changes: 24 additions & 26 deletions pkg/reconciler/pipelinerun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestApplyParameters(t *testing.T) {
original v1beta1.PipelineSpec
params []v1beta1.Param
expected v1beta1.PipelineSpec
alpha bool
wc func(context.Context) context.Context
}{{
name: "single parameter",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation string into finally task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation array no task or task default winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation array finally task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation object no task or task default winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "parameter propagation object finally task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "parameter propagation with task default but no task winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation with task scoping Finally task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -321,7 +321,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation array with task default but no task winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -359,7 +359,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation array with task scoping Finally task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation array with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "Finally task parameter propagation array with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -485,7 +485,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -529,7 +529,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "Finally task parameter propagation with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -573,7 +573,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "parameter propagation object with task default but no task winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -628,7 +628,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "Finally task parameter propagation object with task default but no task winner pipeline",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -683,7 +683,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "parameter propagation object with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -747,7 +747,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "Finally task parameter propagation object with task default and task winner task",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -811,7 +811,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "single parameter with when expression",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -1345,7 +1345,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableBetaAPIFields,
}, {
name: "object parameter with resolver",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -1421,7 +1421,7 @@ func TestApplyParameters(t *testing.T) {
},
}},
},
alpha: true,
wc: config.EnableAlphaAPIFields,
}, {
name: "single parameter in finally workspace subpath",
original: v1beta1.PipelineSpec{
Expand Down Expand Up @@ -1465,13 +1465,11 @@ func TestApplyParameters(t *testing.T) {
},
},
} {
tt := tt // capture range variable
ctx := context.Background()
if tt.alpha {
cfg := config.FromContextOrDefaults(ctx)
cfg.FeatureFlags = &config.FeatureFlags{EnableAPIFields: "alpha"}
ctx = config.ToContext(ctx, cfg)
if tt.wc != nil {
ctx = tt.wc(ctx)
}
tt := tt // capture range variable
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
run := &v1beta1.PipelineRun{
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/taskrun/validate_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func missingParamsNames(neededParams []string, providedParams []string, paramSpe
}

func extraParamsNames(ctx context.Context, neededParams []string, providedParams []string) []string {
// If alpha features are enabled, disable checking for extra params.
// If alpha or beta features are enabled, disable checking for extra params.
// Extra params are needed to support
// https://github.com/tektoncd/community/blob/main/teps/0023-implicit-mapping.md
// So that parent params can be passed down to subresources (even if they
// are not explicitly used).
if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != "alpha" {
if config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.BetaAPIFields && config.FromContextOrDefaults(ctx).FeatureFlags.EnableAPIFields != config.AlphaAPIFields {
return list.DiffLeft(providedParams, neededParams)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/taskrun/validate_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestValidateResolvedTaskResources_ValidParams(t *testing.T) {
}

t.Run("alpha-extra-params", func(t *testing.T) {
ctx := config.ToContext(ctx, &config.Config{FeatureFlags: &config.FeatureFlags{EnableAPIFields: "alpha"}})
ctx := config.ToContext(ctx, &config.Config{FeatureFlags: &config.FeatureFlags{EnableAPIFields: config.BetaAPIFields}})
extra := v1beta1.Param{
Name: "extra",
Value: *v1beta1.NewStructuredValues("i am an extra param"),
Expand Down
2 changes: 1 addition & 1 deletion test/propagated_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestPropagatedParams(t *testing.T) {
defer cancel()

propagatedParamFlags := requireAllGates(map[string]string{
"enable-api-fields": "alpha",
"enable-api-fields": "beta",
})
c, namespace := setup(ctx, t, propagatedParamFlags)

Expand Down

0 comments on commit ff4f015

Please sign in to comment.