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

Adds support for img labels and anno. in build create cmd #68

Merged
merged 1 commit into from
Nov 2, 2021

Conversation

sm43
Copy link
Contributor

@sm43 sm43 commented Oct 29, 2021

This adds support to specify labels and annotation for
output image.
There are 2 flags added for the build create command

  • output-image-label
  • output-image-annotation

Part of #66

Signed-off-by: Shivam Mukhade [email protected]

Changes

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.

Release Notes

Adds support to specify on Build objects labels and annotations to be set on output images

@sm43
Copy link
Contributor Author

sm43 commented Oct 29, 2021

/cc @otaviof

@openshift-ci openshift-ci bot requested a review from otaviof October 29, 2021 10:39
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 29, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 29, 2021
@sm43 sm43 changed the title Adds support to specify image labels and annotations Adds support for img labels and anno. in build create cmd Oct 29, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Thank you, solid work. Please correct the handling of values with none or multiple = characters.

pkg/shp/util/env.go Outdated Show resolved Hide resolved
@SaschaSchwarze0 SaschaSchwarze0 added the kind/feature Categorizes issue or PR as related to a new feature. label Oct 29, 2021
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

Thank you for the update, looks good now for me. One more small change to the flag name.

pkg/shp/flags/flags.go Outdated Show resolved Hide resolved
@gabemontero
Copy link
Member

hey @sm43 - thanks for the contribution

per our PR template at https://github.com/shipwright-io/cli/blob/main/.github/pull_request_template.md we have PR authors craft the release note that should go along with their change

ultimately, when my PR #62 merges, our CI will enforce the creation of the release note. But in the interim, and given you are new the project, I took the liberty of assisting you and modifying your PR description for you. Please take a look, and if you think the release note needs modification, please do edit your description accordingly.

I'll next take a peek at your changes

thanks again

Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 left a comment

Choose a reason for hiding this comment

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

/approve
/assign gabemontero

Nice work. I have to admit that I do not know the e2e test framework from this repo good enough. Leaving it to Gabe for a final assessment.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SaschaSchwarze0

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2021
Copy link
Member

@gabemontero gabemontero left a comment

Choose a reason for hiding this comment

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

ideally we've have e2e tests to go along with this, but I'm good either opening a follow up issue for that, or taking that on if the buildrun stuff does in fact happen soonish

otherwise, a couple of minor suggestions on the help text

pkg/shp/flags/flags.go Outdated Show resolved Hide resolved
pkg/shp/flags/flags.go Outdated Show resolved Hide resolved
@sm43
Copy link
Contributor Author

sm43 commented Oct 30, 2021

@gabemontero Thanks for release notes 🙂 will keep in mind to fill it from next time.
e2e framework used is new for me so will address the e2e test in a follow up PR.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2021
@sm43
Copy link
Contributor Author

sm43 commented Nov 2, 2021

/hold
will try adding e2e!

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 2, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2021
@sm43
Copy link
Contributor Author

sm43 commented Nov 2, 2021

/hold cancel
@gabemontero added a e2e test, ptal.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 2, 2021
Copy link
Member

@otaviof otaviof left a comment

Choose a reason for hiding this comment

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

I would rather pursue the pflag.Value approach, so we can keep flags package responsible for providing a BuildSpec/BuildRunSpec without side effects, improved testability and more.

Please consider the changes in #69, and the example usage of flags package.

This adds support to specify labels and annotation for
output image.
There are 2 flags added for the `build create` command
- output-image-label
- output-image-annotation

Signed-off-by: Shivam Mukhade <[email protected]>
@sm43
Copy link
Contributor Author

sm43 commented Nov 2, 2021

I would rather pursue the pflag.Value approach, so we can keep flags package responsible for providing a BuildSpec/BuildRunSpec without side effects, improved testability and more.

Please consider the changes in #69, and the example usage of flags package.

Thanks @otaviof updated the pr.
cc @gabemontero

Copy link
Member

@otaviof otaviof left a comment

Choose a reason for hiding this comment

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

Aside of nit comments, it looks good!

/lgtm

spec := &buildv1alpha1.BuildSpec{Output: buildv1alpha1.Image{
Labels: map[string]string{},
}}
c := NewMapValue(spec.Output.Labels)
Copy link
Member

Choose a reason for hiding this comment

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

nit: rename this variable to m it follows the original type.

run kubectl delete buildruns.shipwright.io --all
}

@test "shp output image labels and annotation lifecycle" {
Copy link
Member

Choose a reason for hiding this comment

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

great, thank you!

// Type analogous to the pflag "stringArray" type, where each flag entry will be translated to a
// single array (slice) entry, therefore the comma (",") is accepted as part of the value, as any
// other special character.
func (c *MapValue) Type() string {
Copy link
Member

Choose a reason for hiding this comment

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

nit: rename c to _, since it's not in use.

"",
"specify a set of key-value pairs that correspond to labels to set on the output image",
)

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove empty line.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 2, 2021
@openshift-merge-robot openshift-merge-robot merged commit f1930e7 into shipwright-io:main Nov 2, 2021
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.7.0 milestone Dec 13, 2021
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. hackday kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants