Skip to content

Commit

Permalink
Inverse dry-run defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
VOID404 committed Jan 23, 2025
1 parent eadf175 commit 5136b15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions hack/runtime-migrator/cmd/crb-cleanup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ The cleanup script is run locally, with kubeconfig pointing to the cluster.
| `-kubeconfig` | Path to the kubeconfig file | in-cluster config |
| `-oldLabel` | Label selector for old CRBs | `kyma-project.io/deprecation=to-be-removed-soon,reconciler.kyma-project.io/managed-by=provisioner` |
| `-newLabel` | Label selector for new CRBs | `reconciler.kyma-project.io/managed-by=infrastructure-manager` |
| `-output` | Output dir for created logs. | _empty_ (acts like `./ `) |
| `-dry-run` | Don't perform any destructive actions | `false` |
| `-output` | Output dir for created logs. | _empty_ (acts like `./ `) |
| `-dry-run` | Don't perform any destructive actions | `true` |
| `-verbose` | Print detailed logs | `false` |
| `-force` | Delete old CRBs even if they have no new equivalent | `false` |

> [!NOTE]
> if `-output` doesn't end with `/`, the name of the files will be prefixed with last segment.
> eg. `-output=./dev/log/cluster_a-` will create files like `./dev/log/cluster_a-missing.json`, `./dev/log/cluster_a-removed.json`, etc.
> [!WARNING]
> without `-dry-run=false` the script won't delete anything, even with a `-force` flag
## Usage

To run cleanup script, execute:

```bash
go run ./cmd/crb-cleanup -output=./dev/logs/my-cluster/ -kubeconfig=./dev/kubeconfig
go run ./cmd/crb-cleanup -output=./dev/logs/my-cluster/ -kubeconfig=./dev/kubeconfig -dry-run=false
```

If there are missing CRBs, the script will print a list of them and exit with a zero status code.
Expand All @@ -44,5 +47,5 @@ All of the log files will be created either way.

### `-dry-run` mode

When running the script with `-dry-run` flag, CRBs that _would_ be removed will be listed as JSON in `./dev/logs/my-cluster/removed.json`.
When running the script without `-dry-run=false` flag, CRBs that _would_ be removed will be listed as JSON in `./dev/logs/my-cluster/removed.json`.
No destructive actions will be performed.
2 changes: 1 addition & 1 deletion hack/runtime-migrator/cmd/crb-cleanup/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func ParseConfig() Config {
flag.StringVar(&cfg.OldLabel, "oldLabel", LabelSelectorOld, "Label marking old CRBs")
flag.StringVar(&cfg.NewLabel, "newLabel", LabelSelectorNew, "Label marking new CRBs")
flag.StringVar(&cfg.Output, "output", "", "Output folder for created files. Can also contain file prefix, if it doesn't end with `/` (can be a folder, eg ./foo/)")
flag.BoolVar(&cfg.DryRun, "dry-run", false, "Don't remove CRBs, write what would be removed to ./removed.json")
flag.BoolVar(&cfg.DryRun, "dry-run", true, "Don't remove CRBs, write what would be removed to ./removed.json")
flag.BoolVar(&cfg.Verbose, "verbose", false, "Increase the log level to debug (default: info)")
flag.BoolVar(&cfg.Force, "force", false, "Force remove CRBs without checking migration status")
flag.Parse()
Expand Down

0 comments on commit 5136b15

Please sign in to comment.