Skip to content

Commit

Permalink
Merge branch 'main' into i4k-prepare-release-v0.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
i4ki authored Dec 20, 2023
2 parents e99d2d1 + e6a25a1 commit e68a4f9
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Given a version number `MAJOR.MINOR.PATCH`, we increment the:
### Fixed

- fix(generate): blocks with context=root were ignored if defined in stacks.
- fix(generate): dot files were ignored while detecting existent files.

## 0.4.3

Expand Down
4 changes: 2 additions & 2 deletions docs/cli/cmdline/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ prev:
link: '/cli/cmdline/run-order'

next:
text: 'Trigger'
link: '/cli/cmdline/trigger'
text: 'Script Info'
link: '/cli/cmdline/script/info'
---

# Run
Expand Down
49 changes: 49 additions & 0 deletions docs/cli/cmdline/script/info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: terramate script info - Command
description: The script info command gives you information about a script

prev:
text: 'Run'
link: '/cli/cmdline/run'

next:
text: 'Script List'
link: '/cli/cmdline/script/list'
---

# Script Info

**Note:** This is an experimental command that is likely subject to change in the future.

The `script info LABEL...` command lists details about all script definitions matching the given LABELs (see [script run](./run) command for details about matching labels). The information provided by `script info` includes:

| Name | Meaning |
| ----------- | --------------------------------------------------------------------------- |
| Definition | Where the script is defined |
| Description | The description attribute in the script |
| Stacks | The stacks within the scope of the script (i.e. those stacks it can run on) |
| Jobs | The commands that comprise the script |

This information is always relative to the current directory (or the value of `-C`).

**Note: ** Scripts with the same name that are overridden in child directories are considered separate scripts.

## Usage

`terramate experimental script info LABEL...`

## Examples

Show information about a script called "deploy" defined at /scripts.tm.hcl

```bash
$ terramate experimental script info deploy
Definition: /scripts.tm.hcl:1,1-8,2
Description: dummy deploy
Stacks:
/dev/ec2
/prd/ec2
/stg/ec2
Jobs:
* ["echo","deploying ${global.env}"]
```
22 changes: 22 additions & 0 deletions docs/cli/cmdline/script/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: terramate script list - Command
description: The script list command shows a list of scripts that can be run in the current directory

prev:
text: 'Script Info'
link: '/cli/cmdline/script/info'

next:
text: 'Script Run'
link: '/cli/cmdline/script/run'
---

# Script List

**Note:** This is an experimental command that is likely subject to change in the future.

Shows a list of all uniquely-named scripts that can be executed with `script run` in the current directory. If there are multiple definitions with the same name, a parent is selected over a child, or a first sibling over a later sibling (ordered by directory name).

## Usage

`terramate experimental script list`
61 changes: 61 additions & 0 deletions docs/cli/cmdline/script/run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: terramate script run - Command
description: With the terramate

prev:
text: 'Script List'
link: '/cli/cmdline/script/list'

next:
text: 'Script Tree'
link: '/cli/cmdline/script/tree'
---

# Script Run

**Note:** This is an experimental command that is likely subject to change in the future.

The `script run LABEL...` command will run a Terramate script over a set of stacks. The `LABEL` (one or more) needs to exactly match the labels defined in the `script` block:

```
script "label1" "label2" {
...
}
```

The above script could therefore be called with `script run label1 label2`.

The script will run on all stacks under the current working directory where:

- the script is available (scripts follow the same inheritance rules as globals)
- any filters match. `script run` currently supports `--changed` and `--tags` filters.

## Usage

`terramate experimental script run [options] SCRIPT-LABEL...`

## Examples

Run a script called "deploy" on all stacks where it is available:

```bash
terramate experimental script run deploy
```

Run a script called "deploy" on all changed stacks where it is available:

```bash
terramate experimental script run --changed deploy
```

Do a dry run of running the deploy script:

```bash
terramate experimental script run --dry-run deploy
```

Run a script called "deploy" in a specific stack without recursing into subdirectories:

```bash
terramate -C path/to/stack experimental script run --no-recursive deploy
```
37 changes: 37 additions & 0 deletions docs/cli/cmdline/script/tree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: terramate script tree - Command
description: The script tree command shows a tree of all scripts

prev:
text: 'Script Run'
link: '/cli/cmdline/script/run'

next:
text: 'Trigger'
link: '/cli/cmdline/trigger'
---

# Script Tree

Shows a tree-view of all scripts relative to the current directory (or a specific directory with the -C flag). The tree expands all sub-directories, and the parent path back to the project root, showing script definitions per directory.

## Usage

`terramate experimental script tree`

## Example

```bash
$ terramate experimental script tree
/
* deploy: "deploy the infra"
├── dev
│ └── #ec2
~ deploy
├── prd
│ └── #ec2
~ deploy
└── stg
└── #ec2
~ deploy
```
4 changes: 2 additions & 2 deletions docs/cli/cmdline/trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ title: terramate trigger - Command
description: With the terramate trigger command you can mark a stack to be considered by the change detection.

prev:
text: 'Run'
link: '/cli/cmdline/run'
text: 'Script Tree'
link: '/cli/cmdline/script/tree'

next:
text: 'Vendor Download'
Expand Down
4 changes: 0 additions & 4 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,6 @@ processSubdirs:
}

for _, entry := range entries {
if config.Skip(entry.Name()) {
continue
}

if entry.IsDir() {
isStack := config.IsStack(root, filepath.Join(absSubdir, entry.Name()))
if isStack {
Expand Down
9 changes: 7 additions & 2 deletions generate/generate_hcl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,7 @@ func TestGenerateHCLCleanupOldFilesIgnoreSymlinks(t *testing.T) {
})
}

func TestGenerateHCLCleanupOldFilesIgnoreDotDirs(t *testing.T) {
func TestGenerateHCLCleanupOldFilesDONTIgnoreDotDirs(t *testing.T) {
t.Parallel()

s := sandbox.NoGit(t, true)
Expand All @@ -1701,7 +1701,12 @@ func TestGenerateHCLCleanupOldFilesIgnoreDotDirs(t *testing.T) {
test.WriteFile(t, filepath.Join(s.RootDir(), ".terramate"), "test.tf", genhcl.Header)
test.WriteFile(t, filepath.Join(s.RootDir(), ".another"), "test.tf", genhcl.Header)

assertEqualReports(t, s.Generate(), generate.Report{})
assertEqualReports(t, s.Generate(), generate.Report{
Successes: []generate.Result{
{Dir: project.NewPath("/.another"), Deleted: []string{"test.tf"}},
{Dir: project.NewPath("/.terramate"), Deleted: []string{"test.tf"}},
},
})
}

func TestGenerateHCLTerramateRootMetadata(t *testing.T) {
Expand Down
10 changes: 8 additions & 2 deletions generate/generate_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,19 @@ func TestGeneratedFilesListing(t *testing.T) {
},
},
{
name: "ignores dot dirs and files",
// https://github.com/terramate-io/terramate/issues/1260
// dotfiles should not be ignored if not inside a .tmskip
name: "regression test: should not ignore dotdirs and dotfiles",
layout: []string{
genfile(".name.tf"),
genfile(".dir/1.tf"),
genfile(".dir/2.tf"),
},
want: []string{},
want: []string{
".name.tf",
".dir/1.tf",
".dir/2.tf",
},
},
}

Expand Down
Loading

0 comments on commit e68a4f9

Please sign in to comment.