Skip to content

OSD-8714 - Automate STS diff in osdctl#155

Merged
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Tessg22:add-sts-policy-diff
Nov 2, 2021
Merged

OSD-8714 - Automate STS diff in osdctl#155
openshift-merge-robot merged 1 commit intoopenshift:masterfrom
Tessg22:add-sts-policy-diff

Conversation

@Tessg22
Copy link
Contributor

@Tessg22 Tessg22 commented Oct 25, 2021

OSDCTL can output diff between two versions of OCP STS policy or the current permission set of a version of OCP.
Resolves: https://issues.redhat.com/browse/OSD-8714

Copy link
Contributor

@fahlmant fahlmant left a comment

Choose a reason for hiding this comment

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

This is great. Minor issue: when passing a version with only x.y (i.e. 4.9) the command fails with exit status 1error: exit status 1 (formatting issue) and leaves the /tmp/crs-4.9 behind. Since the images will use x.y.z, the arguments should be validated to ensure all three numbers are present, with failure (and documentation) showing the correct formatting of the version. Also the /tmp/crs- directory should be removed if the command errors out if possible.

@Tessg22
Copy link
Contributor Author

Tessg22 commented Oct 27, 2021

Thank you, @fahlmant, for catching this issue. I have fixed the code for both of your concerns.

@fahlmant
Copy link
Contributor

@Tessg22 Looks great! Mind squashing?

return cmdutil.UsageErrorf(cmd, "Release version is required for policy command")
}

re := regexp.MustCompile(`^[0-9]{1}\.[0-9]{1}\.[0-9]{1,2}$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

This regex would have issues once we get to 4.10 I think (2-digit y-streams)

Maybe overkill for this task, but semver is an awesome package for verifying versions.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mrbarge Ah nice catch :) Let's go with that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fahlmant @mrbarge Looking at how much additional code semver would require for version validation, I would rather change ^[0-9]{1}.[0-9]{1}.[0-9]{1,2}$ to ^[0-9]{1}.[0-9]{1,2}.[0-9]{1,2}$. I haven't seen yet minor or patch with 3 letters.

}

for _, s := range args {
re := regexp.MustCompile(`^[0-9]{1}\.[0-9]{1}\.[0-9]{1,2}$`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here as per elsewhere.

@fahlmant
Copy link
Contributor

@Tessg22 One more question: Why is this being placed under the cluster command? IMO that command is for interacting with a specific cluster

@Tessg22
Copy link
Contributor Author

Tessg22 commented Nov 2, 2021

@fahlmant I see your point. Do you think $ osdctl sts policy or $ osdctl sts policy-diff would be clear to everyone?

@fahlmant
Copy link
Contributor

fahlmant commented Nov 2, 2021

@Tessg22 Yes that looks good to me!

docs(): add section for policy and policy-diff commands

fix(): add version validation

refactor(): add parent sts command and fix regex version validation
Copy link
Contributor

@fahlmant fahlmant left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
This is awesome! Thanks for the work! :)

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 2, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 2, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fahlmant, Tessg22

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

The pull request process is described here

Details 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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2021
@openshift-merge-robot openshift-merge-robot merged commit 3657a2f into openshift:master Nov 2, 2021
@Tessg22 Tessg22 deleted the add-sts-policy-diff branch September 22, 2022 10:51
devppratik pushed a commit to devppratik/osdctl that referenced this pull request Aug 23, 2023
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