-
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
🐛 (kustomize/v2-alpha): use marker to track samples and do not create tracks for core types #3102
🐛 (kustomize/v2-alpha): use marker to track samples and do not create tracks for core types #3102
Conversation
/lgtm |
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.
Generally looks good! Just some small nits and questions.
It feels more safe and efficient to use marker with insert than the previous approach! 👍🏼
@@ -95,6 +82,13 @@ func (s *apiScaffolder) Scaffold() error { | |||
); err != nil { | |||
return fmt.Errorf("error scaffolding kustomize API manifests: %v", err) | |||
} | |||
|
|||
// If the gvk is non-empty | |||
if s.resource.Group != "" || s.resource.Version != "" || s.resource.Kind != "" { |
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.
nits: Just wondering in which case this gvk
might be empty so that this sample kustomization should be prevented?
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 only to prevent somewhere the validation was not made before.
I believe that when we call create API and say that we want only the controller if we do not add the check here it will create a duplication.
if err := scaffold.Execute(&samples.Kustomization{}); err != nil { | ||
return fmt.Errorf("error scaffolding manifests: %v", err) | ||
} | ||
} |
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.
nits: we may remove the method generateManifestsPath
as it is unused.
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.
good catcher :-)
func (f *Kustomization) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = filepath.Join("config", "samples", "kustomization.yaml") | ||
} | ||
f.Path = f.Resource.Replacer().Replace(f.Path) |
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'm wondering why we'd like to update f.Path
here? Will it be values other than config/samples/kustomization.yaml
by calling replacer
?
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.
Good catcher, we do not need this here.
// GetCodeFragments implements file.Inserter | ||
func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap { | ||
return machinery.CodeFragmentsMap{ | ||
machinery.NewMarkerFor(f.Path, samplesMarker): []string{fmt.Sprintf(samplesCodeFragment, f.makeCRFileName())}, |
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.
nits: will it be good/necessary if we declare a new method like:
func (f *Kustomization) sampleMarker() machinery.Marker {
return machinery.NewMarkerFor(f.Path, samplesMarker)
}
So that we may keep consistency to use sample marker in various places in the 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 this case I think we only use here. right? But we could improve.
…se marker instead of overwritting
e88e238
to
e615d6a
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.
Changes look good to me!
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, everettraven 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 |
Description
Instead of overwriting the file, we can use a marker so we will just append new values instead.
Motivations