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

tk export: Expand merging capabilities with --merge-strategy flag #760

Merged
merged 7 commits into from Sep 26, 2022

Conversation

julienduchesne
Copy link
Member

@julienduchesne julienduchesne commented Sep 20, 2022

Documented in exporting.md. This option expands the existing --merge flag (now deprecated) to allow us to delete the previously exported manifests for an environment before exporting. This strategy has been in-use (in private code) for about 6 months here at Grafana Labs.

This is useful when exporting a single environment and merging the result with an existing GitOps repository, rather than re-exporting all environments.

I also added benchmark and a test for the export code.

@github-actions
Copy link

github-actions bot commented Sep 20, 2022

Benchstat (compared to main):

name              old time/op    new time/op    delta
pkg:github.com/grafana/tanka/pkg/jsonnet goos:linux goarch:amd64
GetSnippetHash-2    24.7ms ± 8%    23.3ms ± 7%  -5.53%  (p=0.043 n=9+10)

name              old alloc/op   new alloc/op   delta
pkg:github.com/grafana/tanka/pkg/jsonnet goos:linux goarch:amd64
GetSnippetHash-2    3.86MB ± 0%    3.86MB ± 0%    ~     (p=0.243 n=9+10)

name              old allocs/op  new allocs/op  delta
pkg:github.com/grafana/tanka/pkg/jsonnet goos:linux goarch:amd64
GetSnippetHash-2     32.3k ± 0%     32.3k ± 0%    ~     (p=0.670 n=10+10)

@julienduchesne julienduchesne marked this pull request as ready for review September 20, 2022 12:55
@julienduchesne julienduchesne requested review from Duologic, sh0rez and a team September 20, 2022 12:55
Documented in `exporting.md`. This option allows us to delete the previously exported manifests for an environment.

This is useful when exporting a single environment and merging the result with an existing GitOps repository, rather than re-exporting all environments.

I also added benchmark and a test for the export code.
@julienduchesne julienduchesne force-pushed the julienduchesne/add-delete-previous branch from 372e749 to 628c729 Compare September 21, 2022 11:20
@julienduchesne julienduchesne force-pushed the julienduchesne/add-delete-previous branch from 6629165 to 5ae2be3 Compare September 21, 2022 11:27
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.

Not a Tanka core team member, but changes LGTM. Left some minor suggestions.

pkg/tanka/export.go Outdated Show resolved Hide resolved
pkg/tanka/export.go Outdated Show resolved Hide resolved
@julienduchesne julienduchesne changed the title Add --delete-previous option to tk export tk export: Expand merging capabilities with --merge-strategy flag Sep 26, 2022
@julienduchesne
Copy link
Member Author

Not a Tanka core team member, but changes LGTM. Left some minor suggestions.

All input is valued, regardless of status. Thanks!

Copy link
Member

@iainlane iainlane left a comment

Choose a reason for hiding this comment

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

👍

cmd/tk/export.go Outdated Show resolved Hide resolved
@julienduchesne julienduchesne merged commit c9d4827 into main Sep 26, 2022
@julienduchesne julienduchesne deleted the julienduchesne/add-delete-previous branch September 26, 2022 19:16
julienduchesne added a commit that referenced this pull request Oct 3, 2022
This command is powerful when used with the `--merge-strategy=replace-envs` flag added here: #760

Given a repository with a large number of Tanka environments, exporting the whole set can be very time consuming if done on every commit.
What a user probably wants to do is to only export the environments that have changed.
To do this, we need to actually find out what files affect which environments, and this is what this new command does.
A user can now pass the list of files modified in a git commit, and run `tk export` on the set of environments affected by those files.
julienduchesne added a commit that referenced this pull request Oct 3, 2022
This command is powerful when used with the `--merge-strategy=replace-envs` flag added here: #760

Given a repository with a large number of Tanka environments, exporting the whole set can be very time consuming if done on every commit.
What a user probably wants to do is to only export the environments that have changed.
To do this, we need to actually find out what files affect which environments, and this is what this new command does.
A user can now pass the list of files modified in a git commit, and run `tk export` on the set of environments affected by those files.
julienduchesne added a commit that referenced this pull request Oct 4, 2022
* Add new `tk tool importers` command

This command is powerful when used with the `--merge-strategy=replace-envs` flag added here: #760

Given a repository with a large number of Tanka environments, exporting the whole set can be very time consuming if done on every commit.
What a user probably wants to do is to only export the environments that have changed.
To do this, we need to actually find out what files affect which environments, and this is what this new command does.
A user can now pass the list of files modified in a git commit, and run `tk export` on the set of environments affected by those files.

* Add comments and simplify functions
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.

None yet

3 participants