Skip to content

Commit

Permalink
Add atmos describe affected command
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh committed Dec 15, 2022
1 parent e3f4a89 commit 20b89ae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cmd/describe_affected.go
Expand Up @@ -27,8 +27,8 @@ func init() {
describeAffectedCmd.PersistentFlags().String("ref", "", "Git reference with which to compare the current branch: atmos describe affected --ref refs/heads/main. Refer to https://git-scm.com/book/en/v2/Git-Internals-Git-References for more details")
describeAffectedCmd.PersistentFlags().String("sha", "", "Git commit SHA with which to compare the current branch: atmos describe affected --sha 3a5eafeab90426bd82bf5899896b28cc0bab3073")
describeAffectedCmd.PersistentFlags().String("file", "", "Write the result to the file: atmos describe affected --ref refs/tags/v1.16.0 --file affected.json")
describeAffectedCmd.PersistentFlags().String("format", "json", "The output format: atmos describe affected --ref refs/heads/main --format=json|yaml ('json' is default)")
describeAffectedCmd.PersistentFlags().Bool("verbose", false, "atmos describe affected --ref refs/heads/main --verbose=true")
describeAffectedCmd.PersistentFlags().String("format", "json", "The output format: atmos describe affected --format=json|yaml ('json' is default)")
describeAffectedCmd.PersistentFlags().Bool("verbose", false, "Print more detailed output when cloning and checking out the Git repository: atmos describe affected --verbose=true")

describeCmd.AddCommand(describeAffectedCmd)
}
20 changes: 10 additions & 10 deletions internal/exec/describe_affected.go
Expand Up @@ -315,7 +315,7 @@ func findAffected(
ComponentType: "terraform",
Component: componentName,
Stack: stackName,
Affected: "metadata",
Affected: "stack.metadata",
}
res = append(res, affected)
continue
Expand All @@ -328,7 +328,7 @@ func findAffected(
ComponentType: "terraform",
Component: componentName,
Stack: stackName,
Affected: "terraform",
Affected: "component",
}
res = append(res, affected)
continue
Expand All @@ -341,7 +341,7 @@ func findAffected(
ComponentType: "terraform",
Component: componentName,
Stack: stackName,
Affected: "vars",
Affected: "stack.vars",
}
res = append(res, affected)
continue
Expand All @@ -354,7 +354,7 @@ func findAffected(
ComponentType: "terraform",
Component: componentName,
Stack: stackName,
Affected: "env",
Affected: "stack.env",
}
res = append(res, affected)
continue
Expand All @@ -367,7 +367,7 @@ func findAffected(
ComponentType: "terraform",
Component: componentName,
Stack: stackName,
Affected: "settings",
Affected: "stack.settings",
}
res = append(res, affected)
continue
Expand All @@ -392,7 +392,7 @@ func findAffected(
ComponentType: "helmfile",
Component: componentName,
Stack: stackName,
Affected: "metadata",
Affected: "stack.metadata",
}
res = append(res, affected)
continue
Expand All @@ -405,7 +405,7 @@ func findAffected(
ComponentType: "helmfile",
Component: componentName,
Stack: stackName,
Affected: "helmfile",
Affected: "component",
}
res = append(res, affected)
continue
Expand All @@ -418,7 +418,7 @@ func findAffected(
ComponentType: "helmfile",
Component: componentName,
Stack: stackName,
Affected: "vars",
Affected: "stack.vars",
}
res = append(res, affected)
continue
Expand All @@ -431,7 +431,7 @@ func findAffected(
ComponentType: "helmfile",
Component: componentName,
Stack: stackName,
Affected: "env",
Affected: "stack.env",
}
res = append(res, affected)
continue
Expand All @@ -444,7 +444,7 @@ func findAffected(
ComponentType: "helmfile",
Component: componentName,
Stack: stackName,
Affected: "settings",
Affected: "stack.settings",
}
res = append(res, affected)
continue
Expand Down
23 changes: 11 additions & 12 deletions website/docs/cli/commands/describe/describe-affected.md
Expand Up @@ -15,9 +15,9 @@ Use this command to show a list of the affected Atmos components and stacks give
:::info
For the first commit, the command assumes that the repo root is a Git checkout.

The second commit is specified on the command line by using the `--ref` or `--sha` flags.
The second commit is specified on the command line by using the `--ref` (Git Reference) or `--sha` (commit SHA) flags.

If the flags are not provided, the `ref` will be the default branch (e.g. `main`) and the `sha` will point to the `HEAD` of the branch.
If the flags are not provided, the `ref` will be the default branch (e.g. `main`) and the commit SHA will point to the `HEAD` of the branch.
:::

## Usage
Expand Down Expand Up @@ -74,15 +74,14 @@ where:

- `stack` is the affected Atmos stack
- `component` is the affected Atmos component in the stack
- `component_type` is the type of the affected Atmos component (`terraform` or `helmfile`)
- `component_type` is the type of the component (`terraform` or `helmfile`)
- `affected` shows what was changed for the component. The possible values are:

- `vars` - the `vars` component section in the stack config has been modified
- `env` - the `env` component section in the stack config has been modified
- `settings` - the `settings` component section in the stack config has been modified
- `metadata` - the `metadata` component section in the stack config has been modified
- `terraform` - the Terraform component (Terraform files) that the affected Atmos component provisions has been changed
- `helmfile` - the Helmfile component (Helmfile files) that the affected Atmos component provisions has been changed
- `stack.vars` - the `vars` component section in the stack config has been modified
- `stack.env` - the `env` component section in the stack config has been modified
- `stack.settings` - the `settings` component section in the stack config has been modified
- `stack.metadata` - the `metadata` component section in the stack config has been modified
- `component` - the Terraform or Helmfile component (Terraform/Helmfile files) that the affected Atmos component provisions has been changed

<br/>

Expand All @@ -94,19 +93,19 @@ For example:
"stack": "tenant2-ue2-staging",
"component_type": "terraform",
"component": "infra/vpc",
"affected": "terraform"
"affected": "component"
},
{
"stack": "tenant1-ue2-prod",
"component_type": "terraform",
"component": "test/test-component-override-3",
"affected": "env"
"affected": "stack.env"
},
{
"stack": "tenant1-ue2-dev",
"component_type": "terraform",
"component": "test/test-component-override-3",
"affected": "vars"
"affected": "stack.vars"
}
]
```

0 comments on commit 20b89ae

Please sign in to comment.