Skip to content

Commit

Permalink
Relax result type validation to avoid nightly build failure
Browse files Browse the repository at this point in the history
This commit fixes the string result type validation, PR tektoncd#4779 adds
result type and asumes that the default type should be string via
mutating webhook. PR tektoncd#4818 adds the validation for this. However,
resources that did already exist in etcd didn't get the default. So this
commit relaxes this validation.
  • Loading branch information
Yongxuanzhang committed Jun 27, 2022
1 parent 7d7d96f commit 8f5f111
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/result_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type TaskResult struct {

// Description is a human-readable description of the result
// +optional
Description string `json:"description"`
Description string `json:"description,omitempty"`
}

// TaskRunResult used to describe the results of a task
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/pipeline/v1beta1/result_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@ func (tr TaskResult) Validate(ctx context.Context) (errs *apis.FieldError) {
return errs.Also(ValidateEnabledAPIFields(ctx, "results type", config.AlphaAPIFields))
}

if tr.Type != ResultsTypeString {
return apis.ErrInvalidValue(tr.Type, "type", fmt.Sprintf("type must be string"))
}

return nil
}
15 changes: 0 additions & 15 deletions pkg/apis/pipeline/v1beta1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,21 +1226,6 @@ func TestTaskSpecValidateError(t *testing.T) {
Paths: []string{"results[0].name"},
Details: "Name must consist of alphanumeric characters, '-', '_', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my-name', or 'my_name', regex used for validation is '^([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]$')",
},
}, {
name: "result type not validate",
fields: fields{
Steps: validSteps,
Results: []v1beta1.TaskResult{{
Name: "MY-RESULT",
Type: "wrong",
Description: "my great result",
}},
},
expectedError: apis.FieldError{
Message: `invalid value: wrong`,
Paths: []string{"results[0].type"},
Details: "type must be string",
},
}, {
name: "context not validate",
fields: fields{
Expand Down

0 comments on commit 8f5f111

Please sign in to comment.