Repository navigation
kubectl-ate: add update egress-policy - #1813
Conversation
f61b0f6 to
d7d4b34
Compare
| @@ -37,6 +37,8 @@ var ( | |||
There was a problem hiding this comment.
in the future, you might want to consider doing this
var (
egressPolicyFlags struct {
atespace string
filename string
}
)
Having separate flag vars for each independent use seems to be overkill.
There was a problem hiding this comment.
we may also want to just put this in its own package
There was a problem hiding this comment.
Done in the first commit as you suggested for the commands to share the variables for flag values. However, actor.go and actortemplate.go still keep per-verb vars.
we may also want to just put this in its own package
Do you mean putting flags for all commands in a separate package, or one package per resource type? I can address this in a follow-up so this PR stays about update.
|
As a follow up, I think we should have a --force flag for |
get and create each declared their own atespace and filename flag vars, though a process only ever runs one verb. One egressPolicyFlags struct now backs both, and the update verb registers onto it next.
Reading and parsing the -f manifest into an EgressPolicy moves out of create into loadEgressPolicyManifest so the update verb can share it.
`kubectl ate update egress-policy <actor-name> -a <atespace> -f <manifest>` replaces an actor's egress policy with the manifest and prints the result. The manifest must carry the metadata.uid and metadata.version, and the server rejects them when they no longer match the stored ones, so the command never overwrites a change made since the read.
d7d4b34 to
96a0307
Compare
Agreed as a follow-up, tracked in #1861. --force would read the stored policy and copy them, as the server rejects an update without uid and version . |
Part of #1550.
Adds
kubectl ate update egress-policy <actor-name> -a <atespace> -f <manifest>, which replaces an actor's egress policy and prints the result. To prevent an edit from overwriting a change made since the read, the server rejects a manifest withmetadata.uidandmetadata.versionthat mismatch stored ones. On NotFound the command says whether the actor or the policy is missing; on Aborted (due to uid/version mismatch) it points back atget -o yaml.Testing
go test -race ./cmd/kubectl-ate/...,go vet,gofmt. On kind: get, edit, update round trip; stale version, missing uid and version, atespace mismatch, and update with no policy all exit 1 with the policy unchanged.🤖 This PR was developed with AI assistance. I have reviewed and tested all changes.