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

feature: add --dry-run kubectl option #667

Merged
merged 3 commits into from
Jan 28, 2022
Merged

feature: add --dry-run kubectl option #667

merged 3 commits into from
Jan 28, 2022

Conversation

jjo
Copy link
Contributor

@jjo jjo commented Jan 26, 2022

Fixes #666.

  • add --dry-run kubectl option to apply,
    delete, prune
  • add some simple testing to pkg/kubernetes/client

Fixes #666.

* add --dry-run kubectl option to `apply`,
  `delete`, `prune`
* add some simple testing to pkg/kubernetes/client
@jjo
Copy link
Contributor Author

jjo commented Jan 26, 2022

FYI this is how it looks, from a setup following https://grafana.com/blog/2021/07/12/best-practices-for-consistent-configuration-management-at-scale-with-tanka/

  • apply --dry-run=server:
$ ~/go/bin/tk apply --dry-run=server environments/grafana --name grafana/kind-kind
Warning: There are no differences. Your apply may not do anything at all.
namespace/grafana unchanged (server dry run)
configmap/grafana-config unchanged (server dry run)
configmap/grafana-dashboard-provisioning unchanged (server dry run)
configmap/grafana-datasources configured (server dry run)
configmap/grafana-notification-channels configured (server dry run)
service/grafana unchanged (server dry run)
deployment.apps/grafana unchanged (server dry run)
  • delete --dry-run=server:
$ ~/go/bin/tk delete --dry-run=server environments/grafana --name grafana/kind-kind
WARNING: version difference between client (1.23) and server (1.21) exceeds the supported minor version skew of +/-1
deployment.apps "grafana" deleted (server dry run)
service "grafana" deleted (server dry run)
configmap "grafana-notification-channels" deleted (server dry run)
configmap "grafana-datasources" deleted (server dry run)
configmap "grafana-dashboard-provisioning" deleted (server dry run)
configmap "grafana-config" deleted (server dry run)
namespace "grafana" deleted (server dry run)

Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Thanks for adding tests!

CHANGELOG.md Outdated Show resolved Hide resolved
pkg/kubernetes/client/apply.go Outdated Show resolved Hide resolved
Copy link
Contributor

@inkel inkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave the approval to the maintainers, as they've more context about the changes and how it affects overall, but from my end it looks good to get merged. I've left a minor comment regarding Go style.

cmd/tk/workflow.go Outdated Show resolved Hide resolved
Copy link
Contributor

@inkel inkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@julienduchesne julienduchesne merged commit cf14318 into main Jan 28, 2022
@julienduchesne julienduchesne deleted the jjo-add-dry-run branch January 28, 2022 12:30
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.

Feature request: add --dry-run option
3 participants