-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
✨ (Only valid for those who consume Kubebuilder as a lib) - Allow usage of custom marker names #3993
✨ (Only valid for those who consume Kubebuilder as a lib) - Allow usage of custom marker names #3993
Conversation
Welcome @beatrausch! |
Hi @beatrausch. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@@ -69,3 +80,17 @@ type CodeFragments []string | |||
|
|||
// CodeFragmentsMap binds Markers and CodeFragments together | |||
type CodeFragmentsMap map[Marker]CodeFragments | |||
|
|||
func markerPrefix(prefix string) string { | |||
trimmed := strings.TrimSpace(prefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the trim revert the change:
Bug fix to ensure consistent spacing in marker annotations (#3904).
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@camilamacedo86 Please, correct my when I am wrong, but what I understand from the issue is, that it requests a constant string representation of the marker. This is still achieved by adding a space between the comment and the prefix:
func (m Marker) String() string {
return m.comment + " " + m.prefix + m.value
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right 👍
Context("String", func() { | ||
DescribeTable("should return the right string representation", | ||
func(marker Marker, str string) { Expect(marker.String()).To(Equal(str)) }, | ||
Entry("for yaml files", NewMarkerFor("test.yaml", "test"), "# +kubebuilder:scaffold:test"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need more one test with //
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I will add tests for //
pkg/machinery/marker.go
Outdated
@@ -33,16 +33,27 @@ var commentsByExt = map[string]string{ | |||
|
|||
// Marker represents a machine-readable comment that will be used for scaffolding purposes | |||
type Marker struct { | |||
prefix string | |||
comment string | |||
value string | |||
} | |||
|
|||
// NewMarkerFor creates a new marker customized for the specific file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to change the comment here to make clear that will create the marker with kbPrefix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some more details on what prefix is used
/ok-to-test |
pkg/machinery/marker_test.go
Outdated
Entry("for yaml files", NewMarkerWithPrefixFor("+custom:scaffold", "test.yaml", "test"), "# +custom:scaffold:test"), | ||
Entry("for yaml files", NewMarkerWithPrefixFor("custom:scaffold:", "test.yaml", "test"), "# +custom:scaffold:test"), | ||
Entry("for yaml files", NewMarkerWithPrefixFor("+custom:scaffold:", "test.yaml", "test"), "# +custom:scaffold:test"), | ||
Entry("for yaml files", NewMarkerWithPrefixFor(" +custom:scaffold: ", "test.yaml", "test"), "# +custom:scaffold:test"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not passing in the linter due the sieze of the line,
Could you please break the line?
pkg/machinery/marker_test.go:65: line is 122 characters (lll)
Entry("for yaml files", NewMarkerWithPrefixFor(" +custom:scaffold: ", "test.yaml", "test"), "#
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the linter issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @beatrausch
That is great and shows good to fly !!!
Could you please just squash all commits for we get it merged?
We have a policy to keep 1 commit per PR (unless we have a real reason to split but in this case we usually have more PRs instead of)
291718e
to
8d8d091
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: beatrausch, camilamacedo86 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 |
This PR adds a code implementation which allow Kubebuilder lib consumes use custom names for the markers
Closes: #3990