Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom releases in ci-operator validations #1410

Conversation

GeoBK
Copy link
Contributor

@GeoBK GeoBK commented Nov 11, 2020

No description provided.

@@ -684,7 +684,18 @@ func validateLiteralTestStepCommon(fieldRoot string, step LiteralTestStep, seen
switch obj {
case PipelineImageStream, ReleaseStreamFor(LatestReleaseName), ReleaseStreamFor(InitialReleaseName), ReleaseImageStream:
default:
ret = append(ret, fmt.Errorf("%s.from: unknown imagestream '%s'", fieldRoot, imageParts[0]))
releaseParts := strings.Split(obj, "-")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should just use ReleaseNameFrom

if len(releaseParts) != 2 || (len(releaseParts) == 2 && releaseParts[0] != StableImageStream) {
ret = append(ret, fmt.Errorf("%s.from: '%s' is not a valid imagestream reference", fieldRoot, step.From))
} else {
names := sets.NewString()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all we need is the set, why pass the full releases map through the call chain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect that performance-wise there wouldn't be much difference since its probably just a pointer being passed around?
If so I would prefer to create the set near where its actually being used (unless it is being reused somewhere else)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance-wise, creating new data structures (the set) on every validation is certainly worse.

The stronger argument, though, is that you should not pass data that is not needed. The callers need to know a list of valid releases (or, even, a closure that could validate an ImageStream) and not anything else. Exposing more data than necessary to other parts of a program leads to bad encapsulation and creep.

@GeoBK GeoBK force-pushed the fix/ci-operator/custom-imagestream-validation branch from 7fae688 to 9f71830 Compare November 16, 2020 15:30
@stevekuznetsov
Copy link
Contributor

stevekuznetsov commented Nov 16, 2020

Implements DPTP-1671

@GeoBK GeoBK force-pushed the fix/ci-operator/custom-imagestream-validation branch from 9f71830 to d00f97b Compare November 16, 2020 20:43
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GeoBK, stevekuznetsov

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 16, 2020
@openshift-merge-robot openshift-merge-robot merged commit 3d1a1ae into openshift:master Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants