-
Notifications
You must be signed in to change notification settings - Fork 85
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
mockkubeapiserver: Support stringData when creating a secret #383
mockkubeapiserver: Support stringData when creating a secret #383
Conversation
2699368
to
e09355f
Compare
e09355f
to
9e7a576
Compare
9e7a576
to
41b0c21
Compare
Hmmm .... this no longer needs a rebase (at least it shouldn't)... I'll try a retest /retest |
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.
A bit of a nit, but still: the errors could be more descriptive.
Also, wouldn't hurt to cover/document this behavior in tests :)
mockkubeapiserver/postresource.go
Outdated
if !ok { | ||
return fmt.Errorf("unexpected type for v1.Secret stringData entry, got %T", vAny) | ||
} | ||
dataMap[k] = base64.StdEncoding.EncodeToString([]byte(v)) |
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 not familiar enough with what Go will do through all of these casts; will this actually end up mutating obj
? Or does it just mutate the dataMap
we've created, but not actually propagate those changes back?
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.
So the answer is yes, and the test will (hopefully!) prove it. I'll have a go at rewriting it to be more self-evidently true though, I agree there's too much happening here.
A great point, I was thinking about that the other day. This change was to support testing in k8s-config-connector, so it got test coverage there, but we could easily create some simple tests directly in this repo - let me do that! |
6ad6bda
to
7a17600
Compare
7c2a843
to
161f176
Compare
427f43b
to
0f0006b
Compare
This is escalating a bit ... looks like I need to break out a new module to avoid a circular dependency: #398 |
3d17dbd
to
bf72339
Compare
The developer experience of working without go.work is pretty bad - we have to break changes into lots of PRs. We're going to try checking in go.work instead.
This is an edge case in the kube apiserver, but there is special handling for the stringData field of a secret, that is mapped to base64 data. Co-authored-by: Tomas Aschan <[email protected]>
Not (yet) applying this everywhere to keep the changes reasonable, but for our new tests it is much easier to read.
This avoids a circular (module) dependency between mockkubeapiserver and kdp itself.
bf72339
to
454214e
Compare
454214e
to
82a46e7
Compare
Had a bit of trouble with the go.sum / go.mod checking (dev/format-gomod), but I finally figured out that the go.sum difference was to do with my cache; I did |
This might be much easier if we merged a (basically empty) |
I tried staging the ktest module in #400. I think that would mean I could back out the |
Found a repo that checks in go.work: kubernetes/kubernetes ! I think we're on solid ground :-) |
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
/approve
This PR has so many wonderful pieces and make the code base cleaner and more readable. It is definitely more than just secret.
k8syaml "k8s.io/apimachinery/pkg/util/yaml" | ||
) | ||
|
||
func ParseObjects(ctx context.Context, manifest string) ([]*unstructured.Unstructured, error) { |
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.
2 years passed and we still have to write this. 🤣
} | ||
|
||
func beforeSecretCreation(ctx context.Context, obj *unstructured.Unstructured) error { | ||
// If there is any stringData, merge it into data |
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.
➕
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb, yuwenma 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 is an edge case in the kube apiserver, but there is special
handling for the stringData field of a secret, that is mapped to
base64 data.