Skip to content
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

Force name and namespace from --merge-into target #286

Merged
merged 1 commit into from
Oct 4, 2019
Merged

Conversation

mkmik
Copy link
Collaborator

@mkmik mkmik commented Oct 2, 2019

A frequent operation is to take an existing sealed secrets and update a single entry in it.

We even have a fancy command now that helps this tedious operation: --merge-into (documented in the README).

The rationale for implementing that command was not only to help lazy users to merge strings into the right place
into a YAML file but also to address one of the most common and confusing user errors:

$ echo -n foo | kubectl create secret generic goodname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal >sealed.yml
$ echo -n bar | kubectl create secret generic baadname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal --merge-into sealed.yml

It's even more subtle when the namespace is concerned, since it's often taken from the current kubeconfig context.

This PR turns --merge-into into what it was intended: a helper that helps, leaning more on the "do what I mean"
rather than blindly "do what I told you":

It treats the state of the existing sealed secret the user is merging new values into as the home for the sensible
parameters of the sealing process.

A subsequent PR will do something similar for the "scope", since that also affects how the entries are encrypted and has subtle consequences when you get it wrong (and it's harder to deal with in one-liners, since you cannot set an annotation during kubectl create secret...).

Possibly relevant for #285


Enhances the tests for the mergeInto command so that they also decrypt the values.
This resulted in a noisy refactoring due to the fact that until now the kubeseal code only encrypted values
using a dummy public key for which we had no private key.

@mkmik mkmik requested review from atomatt and jjo October 2, 2019 16:31
A frequent operation is to take an existing sealed secrets and update a single entry in it.

We even have a fancy command now that helps this tedious operation: `--merge-into` (documented in the README).

The rationale for implementing that command was not only to help lazy users to merge strings into the right place
into a YAML file but also to address one of the most common and confusing user errors:

```bash
$ echo -n foo | kubectl create secret generic goodname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal >sealed.yml
$ echo -n bar | kubectl create secret generic baadname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal --merge-into sealed.yml
```

It's even more subtle when the namespace is concerned, since it's often taken from the current kubeconfig context.

This PR turns `--merge-into` into what it was intended: a helper that helps, leaning more on the "do what I mean"
rather than blindly "do what I told you":

It treats the state of the existing sealed secret the user is merging new values into as the home for the sensible
parameters of the sealing process.

A subsequent PR will do something similar for the "scope", since that also affects how the entries are encrypted and has subtle consequences when you get it wrong (and it's harder to deal with in one-liners, since you cannot set an annotation during `kubectl create secret...`).

---

Enhances the tests for the mergeInto command so that they also decrypt the values.
This resulted in a noisy refactoring due to the fact that until now the kubeseal code only encrypted values
using a dummy public key for which we had no private key.
@mkmik mkmik added this to the v0.9.2 milestone Oct 2, 2019
@mkmik
Copy link
Collaborator Author

mkmik commented Oct 4, 2019

bors r+

bors bot added a commit that referenced this pull request Oct 4, 2019
286: Force name and namespace from --merge-into target r=mkmik a=mkmik

A frequent operation is to take an existing sealed secrets and update a single entry in it.

We even have a fancy command now that helps this tedious operation: `--merge-into` (documented in the README).

The rationale for implementing that command was not only to help lazy users to merge strings into the right place
into a YAML file but also to address one of the most common and confusing user errors:

```bash
$ echo -n foo | kubectl create secret generic goodname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal >sealed.yml
$ echo -n bar | kubectl create secret generic baadname --dry-run  --from-file=bar=/dev/stdin -o json \
  | kubeseal --merge-into sealed.yml
```

It's even more subtle when the namespace is concerned, since it's often taken from the current kubeconfig context.

This PR turns `--merge-into` into what it was intended: a helper that helps, leaning more on the "do what I mean"
rather than blindly "do what I told you":

It treats the state of the existing sealed secret the user is merging new values into as the home for the sensible
parameters of the sealing process.

A subsequent PR will do something similar for the "scope", since that also affects how the entries are encrypted and has subtle consequences when you get it wrong (and it's harder to deal with in one-liners, since you cannot set an annotation during `kubectl create secret...`).

Possibly relevant for #285

---

Enhances the tests for the mergeInto command so that they also decrypt the values.
This resulted in a noisy refactoring due to the fact that until now the kubeseal code only encrypted values
using a dummy public key for which we had no private key.

Co-authored-by: Marko Mikulicic <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 4, 2019

Build succeeded

@bors bors bot merged commit 515b6cf into master Oct 4, 2019
@bors bors bot deleted the mergecheck branch October 4, 2019 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants