diff --git a/app/cli/README.md b/app/cli/README.md index 10aa56c59..5d1f1b265 100644 --- a/app/cli/README.md +++ b/app/cli/README.md @@ -57,6 +57,19 @@ We leverage buf.io to lint and generate proto files. Make sure you [install buf] make api ``` +### Updating default values + +By default CLI uses the following values for the Control Plane and Artifacts CAS API endpoints: + +- Artifacts CAS: api.cas.chainloop.dev:443 +- Control Plane API: api.cp.chainloop.dev:443 + +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`. + +``` +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 +``` + ## Contribution guidelines Please make sure to review the [Contribution guidelines](../../CONTRIBUTING.md) and feel free to reach out if you have any questions! diff --git a/app/cli/cmd/root.go b/app/cli/cmd/root.go index 80d9ed5e9..254588ac8 100644 --- a/app/cli/cmd/root.go +++ b/app/cli/cmd/root.go @@ -37,6 +37,8 @@ var ( flagOutputFormat string actionOpts *action.ActionsOpts logger zerolog.Logger + defaultCPAPI = "api.cp.chainloop.dev:443" + defaultCASAPI = "api.cas.chainloop.dev:443" ) const useWorkflowRobotAccount = "withWorkflowRobotAccount" @@ -92,11 +94,12 @@ func NewRootCmd(l zerolog.Logger) *cobra.Command { rootCmd.SetHelpCommand(&cobra.Command{Hidden: true}) rootCmd.PersistentFlags().StringVarP(&flagCfgFile, "config", "c", "", "Path to an existing config file (default is $HOME/.config/chainloop/config.toml)") - rootCmd.PersistentFlags().String(confOptions.controlplaneAPI.flagName, "api.cp.chainloop.dev:443", "URL for the Control Plane API") + + rootCmd.PersistentFlags().String(confOptions.controlplaneAPI.flagName, defaultCPAPI, "URL for the Control Plane API") err := viper.BindPFlag(confOptions.controlplaneAPI.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.controlplaneAPI.flagName)) cobra.CheckErr(err) - rootCmd.PersistentFlags().String(confOptions.CASAPI.flagName, "api.cas.chainloop.dev:443", "URL for the Artifacts Content Addressable Storage (CAS)") + rootCmd.PersistentFlags().String(confOptions.CASAPI.flagName, defaultCASAPI, "URL for the Artifacts Content Addressable Storage (CAS)") err = viper.BindPFlag(confOptions.CASAPI.viperKey, rootCmd.PersistentFlags().Lookup(confOptions.CASAPI.flagName)) cobra.CheckErr(err) diff --git a/devel/README.md b/devel/README.md index 572b4fa00..ed4234693 100644 --- a/devel/README.md +++ b/devel/README.md @@ -69,3 +69,4 @@ You will get redirected to the pre-configured local OIDC provider (DEX) where th - `john@chainloop.local`/`password` 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. +