Skip to content

Commit e4b5356

Browse files
authored
feat(cli): allow setting default values for Control Plane and CAS (#109)
Signed-off-by: Daniel Liszka <[email protected]>
1 parent 90c6765 commit e4b5356

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

app/cli/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,19 @@ We leverage buf.io to lint and generate proto files. Make sure you [install buf]
5757
make api
5858
```
5959

60+
### Updating default values
61+
62+
By default CLI uses the following values for the Control Plane and Artifacts CAS API endpoints:
63+
64+
- Artifacts CAS: api.cas.chainloop.dev:443
65+
- Control Plane API: api.cp.chainloop.dev:443
66+
67+
If you want to change them to your custom endpoints, you can do that at build time. We will use `ldflags` and the following variables: `defaultCASAPI` and `defaultCPAPI`. We assume in this example that we have our instance of Chainloop running at the following locations: `api.cas.acme.com:443` and `api.cp.acme.com:443`.
68+
69+
```
70+
go build -ldflags "-X 'github.com/chainloop-dev/chainloop/app/cli/cmd.defaultCASAPI=api.cas.acme.com:443' -X 'github.com/chainloop-dev/chainloop/app/cli/cmd.defaultCPAPI=api.cp.acme.com:443'" app/cli/main.go
71+
```
72+
6073
## Contribution guidelines
6174

6275
Please make sure to review the [Contribution guidelines](../../CONTRIBUTING.md) and feel free to reach out if you have any questions!

app/cli/cmd/root.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ var (
3737
flagOutputFormat string
3838
actionOpts *action.ActionsOpts
3939
logger zerolog.Logger
40+
defaultCPAPI = "api.cp.chainloop.dev:443"
41+
defaultCASAPI = "api.cas.chainloop.dev:443"
4042
)
4143

4244
const useWorkflowRobotAccount = "withWorkflowRobotAccount"
@@ -92,11 +94,12 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command {
9294
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
9395

9496
rootCmd.PersistentFlags().StringVarP(&flagCfgFile, "config", "c", "", "Path to an existing config file (default is $HOME/.config/chainloop/config.toml)")
95-
rootCmd.PersistentFlags().String(confOptions.controlplaneAPI.flagName, "api.cp.chainloop.dev:443", "URL for the Control Plane API")
97+
98+
rootCmd.PersistentFlags().String(confOptions.controlplaneAPI.flagName, defaultCPAPI, "URL for the Control Plane API")
9699
err := viper.BindPFlag(confOptions.controlplaneAPI.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.controlplaneAPI.flagName))
97100
cobra.CheckErr(err)
98101

99-
rootCmd.PersistentFlags().String(confOptions.CASAPI.flagName, "api.cas.chainloop.dev:443", "URL for the Artifacts Content Addressable Storage (CAS)")
102+
rootCmd.PersistentFlags().String(confOptions.CASAPI.flagName, defaultCASAPI, "URL for the Artifacts Content Addressable Storage (CAS)")
100103
err = viper.BindPFlag(confOptions.CASAPI.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.CASAPI.flagName))
101104
cobra.CheckErr(err)
102105

devel/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ You will get redirected to the pre-configured local OIDC provider (DEX) where th
6969
- `[email protected]`/`password`
7070

7171
Once logged in, please refer to our [Getting Started guide](https://docs.chainloop.dev/getting-started/setup) to learn how to setup an OCI registry.
72+

0 commit comments

Comments
 (0)