-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
option for origin data as annotation #4065
option for origin data as annotation #4065
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: natasha41575 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 |
2acd45c
to
271f2e9
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.
Thanks for tackling this. It's complicated.
@@ -151,20 +153,20 @@ func (kt *KustTarget) addHashesToNames( | |||
// holding customized resources and the data/rules used | |||
// to do so. The name back references and vars are | |||
// not yet fixed. | |||
func (kt *KustTarget) AccumulateTarget() ( | |||
func (kt *KustTarget) AccumulateTarget(origin *resource.Origin) ( |
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.
This is an important entry point, and its argument should be explained.
Does the method change it / take ownership of it (presumably yes, since a ptr is sent).
Is the outside owner expected to consult it?
What makes it change?
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 a comment explanation
api/internal/target/kusttarget.go
Outdated
} | ||
if origin.Ref != "" { | ||
anno = anno + "ref: " + origin.Ref + "\n" | ||
} |
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.
Likewise, this anno construction code should live in origin, with regression coverage (examples) in origin_test.go
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.
Moved and tests are added in origin_test.go
9157d46
to
4769871
Compare
4769871
to
cec1a0d
Compare
cec1a0d
to
3350c72
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
thanks!
This is brilliant, it's exactly what I've been looking for. I don't see any way to specify the top-level origin without invoking kustomize directly on a remote base though. If I'm looking at a deployed resource with
ideally I want to see something about where that serviceAccount.yaml came from. I presume the best option here is to inject your own annotations with Kustomize commonAnnotations at the top level with an originating repo URI or the like. That should work well enough, though it'll be a bit fragile with layering. Ideally I'd want to be able to tell Kustomize the "origin" of the top level, so it records top-level origins fully qualified as well. In any case, brilliant to see this, and thankyou. |
@ringerc I'm not sure I understand the use case. If you use a remote base, you should see the repo and ref in the origin annotation as well. e.g. kustomization.yaml
will have the following annotation:
Is this a different scenario from the one you are describing? EDIT: I think I understand what you mean actually. Yeah, I think your use case is best done by using |
Addresses #3979
This PR adds a top-level field to the kustomization:
This will add the following annotation to local files:
where
path
is the path to the file where the resource originated from, rooted at the directory upon whichkustomize build
is invoked.For resources from remote bases, e.g. with the following
kustomization.yaml
:this will add the following annotation
where
path
is the path to the resource rooted at the root of the remote repository.ref
will be omitted if the remote URL doesn't have one.See tests at
buildoptions_test.go
andremoteload_test.go
.ALLOW_MODULE_SPAN