Skip to content

Create driftignore generator command#433

Merged
sundowndev merged 2 commits intov0.8from
feat/genDriftIgnore
May 4, 2021
Merged

Create driftignore generator command#433
sundowndev merged 2 commits intov0.8from
feat/genDriftIgnore

Conversation

@sundowndev
Copy link
Copy Markdown
Contributor

@sundowndev sundowndev commented Apr 13, 2021

Q A
🐛 Bug fix? no
🚀 New feature? yes
⚠ Deprecations? no
❌ BC Break no
🔗 Related issues #415
❓ Documentation yes

TL;DR: The purpose of this change is to be able to generate a .driftignore file containing current drifts.

Context

New users can struggle when trying the tool because the output is too large and hard to read. They might want to ignore all the current drifts so they can start introduce the tool in their workflow quickly and fix the current issues later. This feature allows them to create a driftignore file from a JSON output.

Flags

  • --exclude-unmanaged allows to control whether unmanaged resources are included or not
  • --exclude-missing allows to control whether missing resources are included or not
  • --exclude-changed allows to control whether changed resources are included or not

Examples

# Ignore all current drifts
$ driftctl scan -o json://stdout | driftctl gen-driftignore -f /dev/stdin > .driftignore

# Changed resources will not be included
$ driftctl scan --from tfstate://state1.tfstate -o json://stdout | driftctl gen-driftignore --exclude-changed

# Unmanaged resources will not be included
$ cat result.json | driftctl gen-driftignore --exclude-unmanaged

@sundowndev sundowndev added the kind/enhancement New feature or improvement label Apr 13, 2021
@sundowndev sundowndev added this to the v0.8.0 milestone Apr 13, 2021
@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch from bb9ca22 to 874a0fb Compare April 13, 2021 15:40
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2021

Codecov Report

Merging #433 (ef4e270) into v0.8 (5e1f9f8) will increase coverage by 0.21%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             v0.8     #433      +/-   ##
==========================================
+ Coverage   70.76%   70.98%   +0.21%     
==========================================
  Files         287      288       +1     
  Lines        6496     6545      +49     
==========================================
+ Hits         4597     4646      +49     
  Misses       1522     1522              
  Partials      377      377              
Impacted Files Coverage Δ
pkg/analyser/analysis.go 97.95% <100.00%> (+0.55%) ⬆️
pkg/cmd/driftctl.go 80.39% <100.00%> (+0.39%) ⬆️
pkg/cmd/gen_driftignore.go 100.00% <100.00%> (ø)

@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch 4 times, most recently from e706f8c to 31faf3a Compare April 16, 2021 13:31
@eliecharra
Copy link
Copy Markdown
Contributor

To rebase on v0.8 and change target branch

@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch 2 times, most recently from 30d5ecd to 563ef04 Compare April 16, 2021 13:43
@sundowndev sundowndev changed the base branch from main to v0.8 April 16, 2021 13:44
@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch 2 times, most recently from 6cda13a to f7b513b Compare April 16, 2021 16:42
@sundowndev sundowndev marked this pull request as ready for review April 16, 2021 16:49
@sundowndev sundowndev requested a review from a team as a code owner April 16, 2021 16:49
@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch 2 times, most recently from 79436ed to 8a8bbb6 Compare April 16, 2021 16:57
@sundowndev sundowndev self-assigned this Apr 26, 2021
lotoussa
lotoussa previously approved these changes Apr 26, 2021
Copy link
Copy Markdown
Contributor

@lotoussa lotoussa left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

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

Maybe it could be usefull to introduce a --force flag to overwrite an existing .driftignore file too.

Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/filter/driftignore.go Outdated
Comment thread pkg/filter/driftignore.go Outdated
Comment thread pkg/filter/driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/analyser/analysis.go Outdated
Comment thread pkg/filter/driftignore.go Outdated
"github.com/sirupsen/logrus"
)

const DriftIgnoreFilename = ".driftignore"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This exported const is not required anymore

Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/gen_driftignore.go Outdated
Comment thread pkg/cmd/testdata/output_stdin_valid.txt
@sundowndev sundowndev force-pushed the feat/genDriftIgnore branch from 73f303a to fd563fd Compare May 4, 2021 15:14
Copy link
Copy Markdown
Contributor

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

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

Great job 👍🏻

@sundowndev sundowndev merged commit 8299671 into v0.8 May 4, 2021
@sundowndev sundowndev deleted the feat/genDriftIgnore branch May 4, 2021 15:47
sundowndev added a commit that referenced this pull request May 10, 2021
sundowndev added a commit that referenced this pull request May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants