Skip to content

Commit

Permalink
allow skipping workspace check (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Lindamood authored Aug 22, 2022
1 parent 529fcbe commit abbd8f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ inputs:
slackWebhookURL:
description: 'Slack webhook URL to send notifications to'
required: false
skipWorkspaceCheck:
description: 'If true, skip the workspace/ls check'
required: false
default: "false"
runs:
using: 'docker'
image: 'Dockerfile'
env:
ATLANTIS_HOST: '{{ inputs.atlantisHost }}'
ATLANTIS_TOKEN: '{{ inputs.atlantisToken }}'
REPO: '{{ inputs.repo }}'
SLACK_WEBHOOK_URL: '{{ inputs.slackWebhookURL }}'
SLACK_WEBHOOK_URL: '{{ inputs.slackWebhookURL }}'
SKIP_WORKSPACE_CHECK: '{{ inputs.skipWorkspaceCheck }}'
10 changes: 6 additions & 4 deletions cmd/atlantis-drift-detection/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type config struct {
AtlantisToken string `env:"ATLANTIS_TOKEN,required"`
DirectoryWhitelist []string `env:"DIRECTORY_WHITELIST,required"`
SlackWebhookURL string `env:"SLACK_WEBHOOK_URL"`
SkipWorkspaceCheck bool `env:"SKIP_WORKSPACE_CHECK"`
}

func loadEnvIfExists() error {
Expand Down Expand Up @@ -108,10 +109,11 @@ func main() {
Token: cfg.AtlantisToken,
HTTPClient: http.DefaultClient,
},
Cloner: cloner,
GithubClient: ghClient,
Terraform: &tf,
Notification: notif,
Cloner: cloner,
GithubClient: ghClient,
Terraform: &tf,
Notification: notif,
SkipWorkspaceCheck: cfg.SkipWorkspaceCheck,
}
if err := d.Drift(ctx); err != nil {
logger.Panic("failed to drift", zap.Error(err))
Expand Down
4 changes: 4 additions & 0 deletions internal/drifter/drifter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Drifter struct {
Notification notification.Notification
AtlantisClient *atlantis.Client
DirectoryWhitelist []string
SkipWorkspaceCheck bool
}

func (d *Drifter) Drift(ctx context.Context) error {
Expand Down Expand Up @@ -89,6 +90,9 @@ func (d *Drifter) FindDriftedWorkspaces(ctx context.Context, ws atlantis.Directo
}

func (d *Drifter) FindExtraWorkspaces(ctx context.Context, ws atlantis.DirectoriesWithWorkspaces) error {
if d.SkipWorkspaceCheck {
return nil
}
for _, dir := range ws.SortedKeys() {
if d.shouldSkipDirectory(dir) {
d.Logger.Info("Skipping directory", zap.String("dir", dir))
Expand Down

0 comments on commit abbd8f5

Please sign in to comment.