-
Notifications
You must be signed in to change notification settings - Fork 80
[RFE] Add bro-tool CLI for support use
#908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b5f4b0b
Move version from cmd to pkg
mallardduck 5e1bb4c
add basic tool command
mallardduck 0546e43
setup go multi-module repo fully
mallardduck 7c67b9e
Build `resource-set:view` subcommand for tool
mallardduck dea6f34
Build `resource-set:check` subcommand for tool
mallardduck 618c974
feat: make bro-tool infer Kubernetes resource apiVersion for built-in…
mallardduck 2488c15
Sync go.mod across workspace
mallardduck 4762b72
Create bro-tool docs
mallardduck 645154b
Update ci scripts and tooling for go workspace
mallardduck 0689cf4
Implement various copilot suggestions
mallardduck 5df8b38
Update docs/bro-tool.md
mallardduck fc8087b
Implement a few more copilot suggestions
mallardduck c150877
Improver resourceset extraction logic
mallardduck f375206
Update cmd/tool/internal/chart/render.go
mallardduck 9c8516a
Support multiple source files per resource selector
mallardduck cc09ec0
Refactor infer_crd_versions logic to group by schema.GroupKind instea…
mallardduck 92fa2e3
Refactor infer_crd_versions to extract preferredAPIVersion logic into…
mallardduck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # bro-tool | ||
|
|
||
| `bro-tool` is a CLI helper for the [backup-restore-operator (BRO)](../../README.md). It provides one-off operations for managing backup and restore resources outside of the operator's control loop. | ||
|
|
||
| ## Versioning and compatibility | ||
|
|
||
| `bro-tool` is built and versioned alongside BRO. Each release of `bro-tool` is fully compatible with the BRO version it was built for. | ||
|
|
||
| **Newer tool, older BRO:** A newer `bro-tool` can generally interact with older BRO installations and data. Logical compatibility is maintained across versions where possible. | ||
|
|
||
| **Older tool, newer BRO:** An older `bro-tool` is only expected to work with newer BRO versions within the same major version. Cross-major-version use is unsupported. | ||
|
|
||
| In short: prefer keeping `bro-tool` at the same version as your BRO installation, and upgrade the tool before downgrading it. | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| bro-tool [flags] <command> [command flags] | ||
| ``` | ||
|
|
||
| Run `bro-tool --help` to list available commands and flags. | ||
|
|
||
| ### Subcommands | ||
|
|
||
| 1. `bro-tool resource-set:view` - View the resources managed by a specific BRO version. | ||
| - `--version` - The BRO version to view - will pull from GitHub or Charts repo. | ||
| - `--path` - The path to the rancher backup chart to use. | ||
| - `--output` - Output format: yaml, json, or table | ||
| 2. `bro-tool resource-set:check` - Validate that a specific k8s resource is covered by a ResourceSet rule | ||
| - `--version` - The BRO version to check against - will pull from GitHub or Charts repo. | ||
| - `--path` - The path to the rancher backup chart to use. | ||
| - `--resource` - The k8s resource to check - should be in the format "kind/name" | ||
| - `--resource-path` - The path to the k8s resource to check - should be in the format `path/to/resource.yaml | ||
mallardduck marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 3. `bro-tool resource-set:diff` - Compare two ResourceSets and identify differences in managed resources | ||
| - Takes two positional arguments: Either a version or path | ||
| - First argument: The base to compare against | ||
| - Second argument: The target to compare against | ||
|
|
||
mallardduck marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ### How | ||
|
|
||
| Each command should follow a similar pattern: | ||
| - Parse inputs and validate, | ||
| - If needed fetch remote resources (use a bro-tool cache dir when possible), | ||
| - Render the helm template and extract the ResourceSet resources, | ||
| - Extract the actual Rules from the ResourceSet resources, | ||
| - Do sub-command specific work. | ||
|
|
||
| So that should help define what core/foundation code this new subpackage needs. | ||
| As that should be easy to share between all the sub-commands we have in mind so far. | ||
|
|
||
| And obviously, the new dependency of helm and such can apply only to the tool due to our multi-module setup. | ||
|
|
||
| - The `resource-set:view` subcommand is basically just the core workflow + pretty print options. | ||
| - The `resource-set:check` subcommand is the core workflow + taking user input to do a matcher validation. | ||
| - The `resource-set:diff` subcommand is the core workflow + do it again with another version + diffing both. | ||
|
|
||
| ## Dev Rules | ||
|
|
||
| Anything for the new bro tool alone should be added to `cmd/tool/go.mod` only and not other go modules. | ||
| None of the bro-tool code is considered part of the BRO project; rather, bro-tool is a consumer of BRO built along side it. | ||
| The bro-tool code is not considered a public API for reuse outside bro-tool. | ||
| The bro-tool is provided as-is and is not intended for production use – it is a tool for development, testing and debugging. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| module github.com/rancher/backup-restore-operator/cmd/tool | ||
|
|
||
| go 1.25.0 | ||
|
|
||
| replace github.com/rancher/backup-restore-operator => ../../ | ||
|
|
||
| require ( | ||
| github.com/rancher/backup-restore-operator v0.0.0 | ||
| github.com/sirupsen/logrus v1.9.4 | ||
| helm.sh/helm/v3 v3.20.0 | ||
| k8s.io/apimachinery v0.35.0 | ||
| k8s.io/client-go v0.35.0 | ||
| sigs.k8s.io/yaml v1.6.0 | ||
| ) | ||
|
|
||
| require ( | ||
| dario.cat/mergo v1.0.2 // indirect | ||
| github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 // indirect | ||
| github.com/BurntSushi/toml v1.6.0 // indirect | ||
| github.com/Masterminds/goutils v1.1.1 // indirect | ||
| github.com/Masterminds/semver/v3 v3.4.0 // indirect | ||
| github.com/Masterminds/sprig/v3 v3.3.0 // indirect | ||
| github.com/beorn7/perks v1.0.1 // indirect | ||
| github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
| github.com/cyphar/filepath-securejoin v0.6.1 // indirect | ||
| github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
| github.com/emicklei/go-restful/v3 v3.12.2 // indirect | ||
| github.com/evanphx/json-patch v5.9.11+incompatible // indirect | ||
| github.com/fxamacker/cbor/v2 v2.9.0 // indirect | ||
| github.com/go-logr/logr v1.4.3 // indirect | ||
| github.com/go-openapi/jsonpointer v0.21.0 // indirect | ||
| github.com/go-openapi/jsonreference v0.21.0 // indirect | ||
| github.com/go-openapi/swag v0.23.0 // indirect | ||
| github.com/gobwas/glob v0.2.3 // indirect | ||
| github.com/google/gnostic-models v0.7.0 // indirect | ||
| github.com/google/go-cmp v0.7.0 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/huandu/xstrings v1.5.0 // indirect | ||
| github.com/josharian/intern v1.0.0 // indirect | ||
| github.com/json-iterator/go v1.1.12 // indirect | ||
| github.com/mailru/easyjson v0.9.0 // indirect | ||
| github.com/mitchellh/copystructure v1.2.0 // indirect | ||
| github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
| github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect | ||
| github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
| github.com/pkg/errors v0.9.1 // indirect | ||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
| github.com/prometheus/client_golang v1.23.2 // indirect | ||
| github.com/prometheus/client_model v0.6.2 // indirect | ||
| github.com/prometheus/common v0.66.1 // indirect | ||
| github.com/prometheus/procfs v0.16.1 // indirect | ||
| github.com/rancher/lasso v0.2.6 // indirect | ||
| github.com/rancher/wrangler/v3 v3.4.0 // indirect | ||
| github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect | ||
| github.com/shopspring/decimal v1.4.0 // indirect | ||
| github.com/spf13/cast v1.7.0 // indirect | ||
| github.com/x448/float16 v0.8.4 // indirect | ||
| go.yaml.in/yaml/v2 v2.4.3 // indirect | ||
| go.yaml.in/yaml/v3 v3.0.4 // indirect | ||
| golang.org/x/crypto v0.47.0 // indirect | ||
| golang.org/x/net v0.49.0 // indirect | ||
| golang.org/x/oauth2 v0.30.0 // indirect | ||
| golang.org/x/sync v0.19.0 // indirect | ||
| golang.org/x/sys v0.40.0 // indirect | ||
| golang.org/x/term v0.39.0 // indirect | ||
| golang.org/x/text v0.33.0 // indirect | ||
| golang.org/x/time v0.12.0 // indirect | ||
| google.golang.org/protobuf v1.36.8 // indirect | ||
| gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect | ||
| gopkg.in/inf.v0 v0.9.1 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| k8s.io/api v0.35.0 // indirect | ||
| k8s.io/apiextensions-apiserver v0.35.0 // indirect | ||
| k8s.io/klog/v2 v2.130.1 // indirect | ||
| k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect | ||
| k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect | ||
| sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect | ||
| sigs.k8s.io/randfill v1.0.0 // indirect | ||
| sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.