From 0c1d6096d366aab51924aba91fbc35bdcecd83c6 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Wed, 13 Nov 2019 20:27:20 -0800 Subject: [PATCH 1/4] Fix verb tense --- scripts/post-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/post-release.sh b/scripts/post-release.sh index d8327de0..2e353e14 100755 --- a/scripts/post-release.sh +++ b/scripts/post-release.sh @@ -20,7 +20,7 @@ productbuild --package "dist/$pkg_name" "dist/$final_pkg_name" rm "dist/$pkg_name" # upload the package -echo "Upload macOS pkg to GitHub" +echo "Uploading macOS pkg to GitHub" URL="https://uploads.github.com/repos/DopplerHQ/cli/releases/$github_release_id/assets?name=$final_pkg_name" RESPONSE_CODE=$(curl -T "dist/$final_pkg_name" -X POST -u "$GITHUB_USER:$GITHUB_TOKEN" -H "Content-Type: application/octet-stream" $URL -s -w "%{http_code}" -o /dev/null) if [[ "$(echo $RESPONSE_CODE | head -c2)" != "20" ]]; then From dedc984d37fb4afe0b5426c211166ea52c9d1065 Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Wed, 13 Nov 2019 20:42:47 -0800 Subject: [PATCH 2/4] Support short flags for key, project, and config --- pkg/cmd/configs.go | 28 ++++++++++++++-------------- pkg/cmd/environments.go | 2 +- pkg/cmd/projects.go | 6 +++--- pkg/cmd/root.go | 2 +- pkg/cmd/run.go | 4 ++-- pkg/cmd/secrets.go | 20 ++++++++++---------- pkg/cmd/setup.go | 4 ++-- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/pkg/cmd/configs.go b/pkg/cmd/configs.go index 9095a4ea..600a36da 100644 --- a/pkg/cmd/configs.go +++ b/pkg/cmd/configs.go @@ -192,13 +192,13 @@ var configsLogsRollbackCmd = &cobra.Command{ } func init() { - configsCmd.Flags().String("project", "", "doppler project (e.g. backend)") + configsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") - configsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsGetCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsCmd.AddCommand(configsGetCmd) - configsCreateCmd.Flags().String("project", "", "doppler project (e.g. backend)") + configsCreateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") configsCreateCmd.Flags().String("name", "", "config name") configsCreateCmd.Flags().String("environment", "", "config environment") configsCreateCmd.Flags().Bool("defaults", true, "populate config with environment's default secrets") @@ -206,32 +206,32 @@ func init() { configsCreateCmd.MarkFlagRequired("environment") configsCmd.AddCommand(configsCreateCmd) - configsUpdateCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsUpdateCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsUpdateCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsUpdateCmd.Flags().String("name", "", "config name") configsUpdateCmd.Flags().Bool("silent", false, "don't output the response") configsUpdateCmd.MarkFlagRequired("name") configsCmd.AddCommand(configsUpdateCmd) - configsDeleteCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsDeleteCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsDeleteCmd.Flags().Bool("silent", false, "don't output the response") configsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation") configsCmd.AddCommand(configsDeleteCmd) - configsLogsCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsLogsCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsLogsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsLogsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsLogsCmd.Flags().IntP("number", "n", 5, "max number of logs to display") configsCmd.AddCommand(configsLogsCmd) configsLogsGetCmd.Flags().String("log", "", "audit log id") - configsLogsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsLogsGetCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsLogsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsLogsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsLogsCmd.AddCommand(configsLogsGetCmd) configsLogsRollbackCmd.Flags().String("log", "", "audit log id") - configsLogsRollbackCmd.Flags().String("project", "", "doppler project (e.g. backend)") - configsLogsRollbackCmd.Flags().String("config", "", "doppler config (e.g. dev)") + configsLogsRollbackCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + configsLogsRollbackCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") configsLogsRollbackCmd.Flags().Bool("silent", false, "don't output the response") configsLogsCmd.AddCommand(configsLogsRollbackCmd) diff --git a/pkg/cmd/environments.go b/pkg/cmd/environments.go index 12ec0f65..f6a3cb73 100644 --- a/pkg/cmd/environments.go +++ b/pkg/cmd/environments.go @@ -57,7 +57,7 @@ var environmentsGetCmd = &cobra.Command{ } func init() { - environmentsGetCmd.Flags().String("project", "", "output json") + environmentsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") environmentsCmd.AddCommand(environmentsGetCmd) rootCmd.AddCommand(environmentsCmd) diff --git a/pkg/cmd/projects.go b/pkg/cmd/projects.go index 021c5756..0ab98e1a 100644 --- a/pkg/cmd/projects.go +++ b/pkg/cmd/projects.go @@ -130,7 +130,7 @@ var projectsUpdateCmd = &cobra.Command{ } func init() { - projectsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)") + projectsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") projectsCmd.AddCommand(projectsGetCmd) projectsCreateCmd.Flags().Bool("silent", false, "don't output the response") @@ -140,11 +140,11 @@ func init() { projectsDeleteCmd.Flags().Bool("silent", false, "don't output the response") projectsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation") - projectsDeleteCmd.Flags().String("project", "", "doppler project (e.g. backend)") + projectsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") projectsCmd.AddCommand(projectsDeleteCmd) projectsUpdateCmd.Flags().Bool("silent", false, "don't output the response") - projectsUpdateCmd.Flags().String("project", "", "doppler project (e.g. backend)") + projectsUpdateCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") projectsUpdateCmd.Flags().String("name", "", "project name") projectsUpdateCmd.Flags().String("description", "", "project description") projectsUpdateCmd.MarkFlagRequired("name") diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 065f38e2..e6b0a6c0 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -60,7 +60,7 @@ func init() { rootCmd.Version = version.ProgramVersion rootCmd.SetVersionTemplate(rootCmd.Version + "\n") - rootCmd.PersistentFlags().String("key", "", "doppler api key") + rootCmd.PersistentFlags().StringP("key", "k", "", "doppler api key") rootCmd.PersistentFlags().String("api-host", "https://api.doppler.com", "api host") rootCmd.PersistentFlags().String("deploy-host", "https://deploy.doppler.com", "deploy host") rootCmd.PersistentFlags().Bool("insecure", false, "support TLS connections with invalid certificate") diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index c8b67093..de90b072 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -128,8 +128,8 @@ func readFallbackFile(path string) map[string]string { } func init() { - runCmd.Flags().String("project", "", "doppler project (e.g. backend)") - runCmd.Flags().String("config", "", "doppler config (e.g. dev)") + runCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + runCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") runCmd.Flags().String("fallback", "", "write secrets to this file after connecting to Doppler. secrets will be read from this file if future connection attempts are unsuccessful.") runCmd.Flags().Bool("fallback-readonly", false, "don't update or modify the fallback file") diff --git a/pkg/cmd/secrets.go b/pkg/cmd/secrets.go index 45f09c74..2c4855e3 100644 --- a/pkg/cmd/secrets.go +++ b/pkg/cmd/secrets.go @@ -171,35 +171,35 @@ doppler secrets download /root/test.env`, } func init() { - secretsCmd.Flags().String("project", "", "doppler project (e.g. backend)") - secretsCmd.Flags().String("config", "", "doppler config (e.g. dev)") + secretsCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + secretsCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") secretsCmd.Flags().Bool("plain", false, "print values without formatting") secretsCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsCmd.Flags().Bool("only-names", false, "only print the secret names; omit all values") - secretsGetCmd.Flags().String("project", "", "doppler project (e.g. backend)") - secretsGetCmd.Flags().String("config", "", "doppler config (e.g. dev)") + secretsGetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + secretsGetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") secretsGetCmd.Flags().Bool("plain", false, "print values without formatting") secretsGetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsCmd.AddCommand(secretsGetCmd) - secretsSetCmd.Flags().String("project", "", "doppler project (e.g. backend)") - secretsSetCmd.Flags().String("config", "", "doppler config (e.g. dev)") + secretsSetCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + secretsSetCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") secretsSetCmd.Flags().Bool("plain", false, "print values without formatting") secretsSetCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsSetCmd.Flags().Bool("silent", false, "don't output the response") secretsCmd.AddCommand(secretsSetCmd) - secretsDeleteCmd.Flags().String("project", "", "doppler project (e.g. backend)") - secretsDeleteCmd.Flags().String("config", "", "doppler config (e.g. dev)") + secretsDeleteCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + secretsDeleteCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") secretsDeleteCmd.Flags().Bool("plain", false, "print values without formatting") secretsDeleteCmd.Flags().Bool("raw", false, "print the raw secret value without processing variables") secretsDeleteCmd.Flags().Bool("silent", false, "don't output the response") secretsDeleteCmd.Flags().Bool("yes", false, "proceed without confirmation") secretsCmd.AddCommand(secretsDeleteCmd) - secretsDownloadCmd.Flags().String("project", "", "doppler project (e.g. backend)") - secretsDownloadCmd.Flags().String("config", "", "doppler config (e.g. dev)") + secretsDownloadCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + secretsDownloadCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") secretsDownloadCmd.Flags().Bool("metadata", true, "add metadata to the downloaded file (helps cache busting)") secretsDownloadCmd.Flags().Bool("silent", false, "don't output the response") secretsCmd.AddCommand(secretsDownloadCmd) diff --git a/pkg/cmd/setup.go b/pkg/cmd/setup.go index 09ad4a90..9d2c9286 100644 --- a/pkg/cmd/setup.go +++ b/pkg/cmd/setup.go @@ -91,8 +91,8 @@ var setupCmd = &cobra.Command{ } func init() { - setupCmd.Flags().String("project", "", "doppler project (e.g. backend)") - setupCmd.Flags().String("config", "", "doppler config (e.g. dev)") + setupCmd.Flags().StringP("project", "p", "", "enclave project (e.g. backend)") + setupCmd.Flags().StringP("config", "c", "", "enclave config (e.g. dev)") setupCmd.Flags().Bool("silent", false, "don't output the response") rootCmd.AddCommand(setupCmd) } From d74012adecc8556a57a1f07bf83070f52fabeccc Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Fri, 15 Nov 2019 00:31:06 -0800 Subject: [PATCH 3/4] Rename doppler to enclave --- README.md | 4 ++-- pkg/cmd/root.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee3fd200..165bc4e9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Warning: This tool is current pre-release. For the current stable version, please use the [node-cli](https://github.com/DopplerHQ/node-cli). -The Doppler CLI is the official tool for interacting with your Doppler secrets and configuration. +The Doppler CLI is the official tool for interacting with your Enclave secrets and configuration. **You can:** @@ -189,7 +189,7 @@ Note: The release will automatically fail if the tag and HEAD have diverged: #### Generate a GPG key -Store the keys and passphrase in your doppler config +Store the keys and passphrase in your enclave config ``` $ gpg --full-generate-key diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index e6b0a6c0..e2f7e6bb 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -65,7 +65,7 @@ func init() { rootCmd.PersistentFlags().String("deploy-host", "https://deploy.doppler.com", "deploy host") rootCmd.PersistentFlags().Bool("insecure", false, "support TLS connections with invalid certificate") - rootCmd.PersistentFlags().Bool("no-read-env", false, "don't read doppler config from the environment") + rootCmd.PersistentFlags().Bool("no-read-env", false, "don't read enclave config from the environment") rootCmd.PersistentFlags().String("scope", ".", "the directory to scope your config to") rootCmd.PersistentFlags().String("configuration", configuration.ConfigFile, "config file") rootCmd.PersistentFlags().Bool("json", false, "output json") From 53ec1d1ba435326cc55700870b066abba1a7c57d Mon Sep 17 00:00:00 2001 From: Thomas Piccirello Date: Fri, 15 Nov 2019 00:32:48 -0800 Subject: [PATCH 4/4] Rename key to token --- README.md | 8 ++++---- pkg/cmd/activity.go | 4 ++-- pkg/cmd/configs.go | 18 +++++++++--------- pkg/cmd/configure.go | 4 ++-- pkg/cmd/environments.go | 4 ++-- pkg/cmd/projects.go | 12 ++++++------ pkg/cmd/root.go | 2 +- pkg/cmd/run.go | 2 +- pkg/cmd/secrets.go | 12 ++++++------ pkg/cmd/settings.go | 4 ++-- pkg/cmd/setup.go | 6 +++--- pkg/configuration/config.go | 32 ++++++++++++++++---------------- pkg/configuration/migration.go | 2 +- pkg/models/config.go | 4 ++-- pkg/utils/print.go | 8 ++++---- 15 files changed, 61 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 165bc4e9..7695bf30 100644 --- a/README.md +++ b/README.md @@ -112,11 +112,11 @@ Here's an example Dockerfile showing how you can build on top of Doppler's base FROM dopplerhq/cli:node # doppler args are passed at runtime -ENV DOPPLER_API_KEY="" DOPPLER_PROJECT="" DOPPLER_CONFIG="" +ENV DOPPLER_TOKEN="" DOPPLER_PROJECT="" DOPPLER_CONFIG="" COPY . . -ENTRYPOINT doppler run --key="$DOPPLER_API_KEY" --project="$DOPPLER_PROJECT" --config="$DOPPLER_CONFIG" -- node index.js +ENTRYPOINT doppler run --token="$DOPPLER_TOKEN" --project="$DOPPLER_PROJECT" --config="$DOPPLER_CONFIG" -- node index.js ``` ### Other @@ -130,12 +130,12 @@ You can also directly download the generated `.deb` and `.rpm` packages. If a bi Once installed, you can access the Doppler CLI with the `doppler` command. ```sh -$ doppler configure set key=$YOUR_API_KEY # set local credentials +$ doppler configure set token=$YOUR_TOKEN # set local credentials $ doppler setup # select your project and config $ doppler configure --all # (optional) view local configuration ``` -The first command will save your api key to the local configuration file, and it will be scoped to the current directory. You can modify this scope by specifying the `--scope` flag. See `doppler help configure set` for more info, or run `doppler configure --all` to view your current configuration. +The first command will save your api token to the local configuration file, and it will be scoped to the current directory. You can modify this scope by specifying the `--scope` flag. See `doppler help configure set` for more info, or run `doppler configure --all` to view your current configuration. For a list of all commands: diff --git a/pkg/cmd/activity.go b/pkg/cmd/activity.go index 42f42ee6..8424ab1e 100644 --- a/pkg/cmd/activity.go +++ b/pkg/cmd/activity.go @@ -31,7 +31,7 @@ var activityCmd = &cobra.Command{ localConfig := configuration.LocalConfig(cmd) number := utils.GetIntFlag(cmd, "number", 16) - _, activity := api.GetAPIActivityLogs(cmd, localConfig.APIHost.Value, localConfig.Key.Value) + _, activity := api.GetAPIActivityLogs(cmd, localConfig.APIHost.Value, localConfig.Token.Value) utils.PrintLogs(activity, number, jsonFlag) }, @@ -50,7 +50,7 @@ var activityGetCmd = &cobra.Command{ log = args[0] } - _, activity := api.GetAPIActivityLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, log) + _, activity := api.GetAPIActivityLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, log) utils.PrintLog(activity, jsonFlag) }, diff --git a/pkg/cmd/configs.go b/pkg/cmd/configs.go index 600a36da..e3e282d7 100644 --- a/pkg/cmd/configs.go +++ b/pkg/cmd/configs.go @@ -35,7 +35,7 @@ var configsCmd = &cobra.Command{ jsonFlag := utils.JSON localConfig := configuration.LocalConfig(cmd) - _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value) + _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value) utils.PrintConfigsInfo(configs, jsonFlag) }, @@ -54,7 +54,7 @@ var configsGetCmd = &cobra.Command{ config = args[0] } - _, configInfo := api.GetAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config) + _, configInfo := api.GetAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config) utils.PrintConfigInfo(configInfo, jsonFlag) }, @@ -76,7 +76,7 @@ var configsCreateCmd = &cobra.Command{ } localConfig := configuration.LocalConfig(cmd) - _, info := api.CreateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, name, environment, defaults) + _, info := api.CreateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, name, environment, defaults) if !silent { utils.PrintConfigInfo(info, jsonFlag) @@ -100,10 +100,10 @@ var configsDeleteCmd = &cobra.Command{ } if yes || utils.ConfirmationPrompt("Delete config "+config) { - api.DeleteAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config) + api.DeleteAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config) if !silent { - _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value) + _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value) utils.PrintConfigsInfo(configs, jsonFlag) } } @@ -125,7 +125,7 @@ var configsUpdateCmd = &cobra.Command{ config = args[0] } - _, info := api.UpdateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, config, name) + _, info := api.UpdateAPIConfig(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, config, name) if !silent { utils.PrintConfigInfo(info, jsonFlag) @@ -142,7 +142,7 @@ var configsLogsCmd = &cobra.Command{ localConfig := configuration.LocalConfig(cmd) number := utils.GetIntFlag(cmd, "number", 16) - _, logs := api.GetAPIConfigLogs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value) + _, logs := api.GetAPIConfigLogs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value) utils.PrintLogs(logs, number, jsonFlag) }, @@ -161,7 +161,7 @@ var configsLogsGetCmd = &cobra.Command{ log = args[0] } - _, configLog := api.GetAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, log) + _, configLog := api.GetAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, log) // TODO print diff (like node cli environments:logs:view command) utils.PrintLog(configLog, jsonFlag) @@ -182,7 +182,7 @@ var configsLogsRollbackCmd = &cobra.Command{ log = args[0] } - _, configLog := api.RollbackAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, log) + _, configLog := api.RollbackAPIConfigLog(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, log) if !silent { // TODO print diff (like node cli environments:logs:view command) diff --git a/pkg/cmd/configure.go b/pkg/cmd/configure.go index f95286f4..5a2cf3a4 100644 --- a/pkg/cmd/configure.go +++ b/pkg/cmd/configure.go @@ -56,8 +56,8 @@ var configureCmd = &cobra.Command{ if jsonFlag { confMap := make(map[string]map[string]string) - if config.Key != (models.Pair{}) { - storeInMap(&confMap, "key", config.Key) + if config.Token != (models.Pair{}) { + storeInMap(&confMap, "token", config.Token) } if config.Project != (models.Pair{}) { diff --git a/pkg/cmd/environments.go b/pkg/cmd/environments.go index f6a3cb73..3f4b0d0e 100644 --- a/pkg/cmd/environments.go +++ b/pkg/cmd/environments.go @@ -35,7 +35,7 @@ var environmentsCmd = &cobra.Command{ project = args[0] } - _, info := api.GetAPIEnvironments(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project) + _, info := api.GetAPIEnvironments(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project) utils.PrintEnvironmentsInfo(info, jsonFlag) }, @@ -50,7 +50,7 @@ var environmentsGetCmd = &cobra.Command{ localConfig := configuration.LocalConfig(cmd) environment := args[0] - _, info := api.GetAPIEnvironment(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, environment) + _, info := api.GetAPIEnvironment(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, environment) utils.PrintEnvironmentInfo(info, jsonFlag) }, diff --git a/pkg/cmd/projects.go b/pkg/cmd/projects.go index 0ab98e1a..8a57a470 100644 --- a/pkg/cmd/projects.go +++ b/pkg/cmd/projects.go @@ -30,7 +30,7 @@ var projectsCmd = &cobra.Command{ jsonFlag := utils.JSON localConfig := configuration.LocalConfig(cmd) - _, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Key.Value) + _, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Token.Value) utils.PrintProjectsInfo(info, jsonFlag) }, @@ -49,7 +49,7 @@ var projectsGetCmd = &cobra.Command{ project = args[0] } - _, info := api.GetAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project) + _, info := api.GetAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project) utils.PrintProjectInfo(info, jsonFlag) }, @@ -70,7 +70,7 @@ var projectsCreateCmd = &cobra.Command{ } localConfig := configuration.LocalConfig(cmd) - _, info := api.CreateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, name, description) + _, info := api.CreateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, name, description) if !silent { utils.PrintProjectInfo(info, jsonFlag) @@ -94,10 +94,10 @@ var projectsDeleteCmd = &cobra.Command{ } if yes || utils.ConfirmationPrompt("Delete project "+project) { - api.DeleteAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project) + api.DeleteAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project) if !silent { - _, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Key.Value) + _, info := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Token.Value) utils.PrintProjectsInfo(info, jsonFlag) } } @@ -121,7 +121,7 @@ var projectsUpdateCmd = &cobra.Command{ name := cmd.Flag("name").Value.String() description := cmd.Flag("description").Value.String() - _, info := api.UpdateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project, name, description) + _, info := api.UpdateAPIProject(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project, name, description) if !silent { utils.PrintProjectInfo(info, jsonFlag) diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index e2f7e6bb..30ef9b24 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -60,7 +60,7 @@ func init() { rootCmd.Version = version.ProgramVersion rootCmd.SetVersionTemplate(rootCmd.Version + "\n") - rootCmd.PersistentFlags().StringP("key", "k", "", "doppler api key") + rootCmd.PersistentFlags().StringP("token", "t", "", "doppler token") rootCmd.PersistentFlags().String("api-host", "https://api.doppler.com", "api host") rootCmd.PersistentFlags().String("deploy-host", "https://deploy.doppler.com", "deploy host") rootCmd.PersistentFlags().Bool("insecure", false, "support TLS connections with invalid certificate") diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index de90b072..3bfbec6c 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -85,7 +85,7 @@ func getSecrets(cmd *cobra.Command, localConfig models.ScopedConfig, fallbackPat return readFallbackFile(fallbackPath) } - response, err := api.GetDeploySecrets(cmd, localConfig.DeployHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value) + response, err := api.GetDeploySecrets(cmd, localConfig.DeployHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value) if !useFallbackFile && err != nil { utils.Err(err) diff --git a/pkg/cmd/secrets.go b/pkg/cmd/secrets.go index 2c4855e3..7b1ad264 100644 --- a/pkg/cmd/secrets.go +++ b/pkg/cmd/secrets.go @@ -34,7 +34,7 @@ type secretsResponse struct { var secretsCmd = &cobra.Command{ Use: "secrets", - Short: "Fetch all Doppler secrets", + Short: "Fetch all Enclave secrets", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { jsonFlag := utils.JSON @@ -43,7 +43,7 @@ var secretsCmd = &cobra.Command{ onlyNames := utils.GetBoolFlag(cmd, "only-names") localConfig := configuration.LocalConfig(cmd) - _, secrets := api.GetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value) + _, secrets := api.GetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value) if onlyNames { utils.PrintSecretsNames(secrets, jsonFlag, plain) @@ -67,7 +67,7 @@ doppler secrets get api_key crypto_key`, raw := utils.GetBoolFlag(cmd, "raw") localConfig := configuration.LocalConfig(cmd) - _, secrets := api.GetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value) + _, secrets := api.GetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value) utils.PrintSecrets(secrets, args, jsonFlag, plain, raw) }, @@ -100,7 +100,7 @@ doppler secrets set api_key=123 crypto_key=456`, } localConfig := configuration.LocalConfig(cmd) - _, response := api.SetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, secrets) + _, response := api.SetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, secrets) if !silent { utils.PrintSecrets(response, keys, jsonFlag, plain, raw) @@ -130,7 +130,7 @@ doppler secrets delete api_key crypto_key`, } localConfig := configuration.LocalConfig(cmd) - _, response := api.SetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, secrets) + _, response := api.SetAPISecrets(cmd, localConfig.APIHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, secrets) if !silent { utils.PrintSecrets(response, []string{}, jsonFlag, plain, raw) @@ -157,7 +157,7 @@ doppler secrets download /root/test.env`, } localConfig := configuration.LocalConfig(cmd) - body := api.DownloadSecrets(cmd, localConfig.DeployHost.Value, localConfig.Key.Value, localConfig.Project.Value, localConfig.Config.Value, metadata) + body := api.DownloadSecrets(cmd, localConfig.DeployHost.Value, localConfig.Token.Value, localConfig.Project.Value, localConfig.Config.Value, metadata) err := ioutil.WriteFile(filePath, body, 0600) if err != nil { diff --git a/pkg/cmd/settings.go b/pkg/cmd/settings.go index 80c6fedf..38bfda54 100644 --- a/pkg/cmd/settings.go +++ b/pkg/cmd/settings.go @@ -33,7 +33,7 @@ var settingsCmd = &cobra.Command{ jsonFlag := utils.JSON localConfig := configuration.LocalConfig(cmd) - _, info := api.GetAPIWorkplaceSettings(cmd, localConfig.APIHost.Value, localConfig.Key.Value) + _, info := api.GetAPIWorkplaceSettings(cmd, localConfig.APIHost.Value, localConfig.Token.Value) utils.PrintSettings(info, jsonFlag) }, @@ -66,7 +66,7 @@ var settingsUpdateCmd = &cobra.Command{ settings := models.WorkplaceSettings{Name: name, BillingEmail: email} localConfig := configuration.LocalConfig(cmd) - _, info := api.SetAPIWorkplaceSettings(cmd, localConfig.APIHost.Value, localConfig.Key.Value, settings) + _, info := api.SetAPIWorkplaceSettings(cmd, localConfig.APIHost.Value, localConfig.Token.Value, settings) if !silent { utils.PrintSettings(info, jsonFlag) diff --git a/pkg/cmd/setup.go b/pkg/cmd/setup.go index 9d2c9286..81b9f702 100644 --- a/pkg/cmd/setup.go +++ b/pkg/cmd/setup.go @@ -33,7 +33,7 @@ var setupCmd = &cobra.Command{ silent := utils.GetBoolFlag(cmd, "silent") scope := cmd.Flag("scope").Value.String() localConfig := configuration.LocalConfig(cmd) - _, projects := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Key.Value) + _, projects := api.GetAPIProjects(cmd, localConfig.APIHost.Value, localConfig.Token.Value) project := "" if cmd.Flags().Changed("project") { @@ -64,7 +64,7 @@ var setupCmd = &cobra.Command{ if cmd.Flags().Changed("config") { config = localConfig.Config.Value } else { - _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Key.Value, project) + _, configs := api.GetAPIConfigs(cmd, localConfig.APIHost.Value, localConfig.Token.Value, project) var configOptions []string for _, val := range configs { @@ -84,7 +84,7 @@ var setupCmd = &cobra.Command{ if !silent { // don't fetch the LocalConfig since we don't care about env variables or cmd flags conf := configuration.Get(scope) - rows := [][]string{{"key", conf.Key.Value, conf.Key.Scope}, {"project", conf.Project.Value, conf.Project.Scope}, {"config", conf.Config.Value, conf.Config.Scope}} + rows := [][]string{{"token", conf.Token.Value, conf.Token.Scope}, {"project", conf.Project.Value, conf.Project.Scope}, {"config", conf.Config.Value, conf.Config.Scope}} utils.PrintTable([]string{"name", "value", "scope"}, rows) } }, diff --git a/pkg/configuration/config.go b/pkg/configuration/config.go index 89677530..797ecfe3 100644 --- a/pkg/configuration/config.go +++ b/pkg/configuration/config.go @@ -72,10 +72,10 @@ func Get(scope string) models.ScopedConfig { continue } - if conf.Key != "" { - if scopedConfig.Key == (models.Pair{}) || len(confScope) > len(scopedConfig.Key.Scope) { - scopedConfig.Key.Value = conf.Key - scopedConfig.Key.Scope = confScope + if conf.Token != "" { + if scopedConfig.Token == (models.Pair{}) || len(confScope) > len(scopedConfig.Token.Scope) { + scopedConfig.Token.Value = conf.Token + scopedConfig.Token.Scope = confScope } } @@ -118,10 +118,10 @@ func LocalConfig(cmd *cobra.Command) models.ScopedConfig { // environment variables if !utils.GetBoolFlag(cmd, "no-read-env") { - key := os.Getenv("DOPPLER_API_KEY") - if key != "" { - localConfig.Key.Value = key - localConfig.Key.Scope = "" + token := os.Getenv("DOPPLER_TOKEN") + if token != "" { + localConfig.Token.Value = token + localConfig.Token.Scope = "" } project := os.Getenv("DOPPLER_PROJECT") @@ -150,9 +150,9 @@ func LocalConfig(cmd *cobra.Command) models.ScopedConfig { } // individual flags (highest priority) - if cmd.Flags().Changed("key") || localConfig.Key.Value == "" { - localConfig.Key.Value = cmd.Flag("key").Value.String() - localConfig.Key.Scope = "" + if cmd.Flags().Changed("token") || localConfig.Token.Value == "" { + localConfig.Token.Value = cmd.Flag("token").Value.String() + localConfig.Token.Scope = "" } if cmd.Flags().Changed("project") || localConfig.Project.Value == "" { @@ -276,13 +276,13 @@ func parseScope(scope string) (string, error) { // IsValidConfigOption whether the specified key is a valid option func IsValidConfigOption(key string) bool { - return key == "key" || key == "project" || key == "config" || key == "api-host" || key == "deploy-host" + return key == "token" || key == "project" || key == "config" || key == "api-host" || key == "deploy-host" } // GetScopedConfigValue get the value of the specified key within the config func GetScopedConfigValue(conf models.ScopedConfig, key string) (string, string) { - if key == "key" { - return conf.Key.Value, conf.Key.Scope + if key == "token" { + return conf.Token.Value, conf.Token.Scope } if key == "project" { return conf.Project.Value, conf.Project.Scope @@ -302,8 +302,8 @@ func GetScopedConfigValue(conf models.ScopedConfig, key string) (string, string) // SetConfigValue set the value for the specified key in the config func SetConfigValue(conf *models.Config, key string, value string) { - if key == "key" { - (*conf).Key = value + if key == "token" { + (*conf).Token = value } else if key == "project" { (*conf).Project = value } else if key == "config" { diff --git a/pkg/configuration/migration.go b/pkg/configuration/migration.go index 2dc34206..6ad5d1be 100644 --- a/pkg/configuration/migration.go +++ b/pkg/configuration/migration.go @@ -47,7 +47,7 @@ func convertOldConfig(oldConfig map[string]oldConfig) map[string]models.Config { config := make(map[string]models.Config) for key, val := range oldConfig { - config[key] = models.Config{Project: val.Pipeline, Config: val.Environment, Key: val.Key} + config[key] = models.Config{Project: val.Pipeline, Config: val.Environment, Token: val.Key} } return config diff --git a/pkg/models/config.go b/pkg/models/config.go index f0c8a23a..5de5bfe4 100644 --- a/pkg/models/config.go +++ b/pkg/models/config.go @@ -17,18 +17,18 @@ package models // Config options type Config struct { + Token string `json:"token"` Project string `json:"project"` Config string `json:"config"` - Key string `json:"key"` APIHost string `json:"api-host"` DeployHost string `json:"deploy-host"` } // ScopedConfig options with their scope type ScopedConfig struct { + Token Pair `json:"token"` Project Pair `json:"project"` Config Pair `json:"config"` - Key Pair `json:"key"` APIHost Pair `json:"api-host"` DeployHost Pair `json:"deploy-host"` } diff --git a/pkg/utils/print.go b/pkg/utils/print.go index 3a6703ef..30b80e7d 100644 --- a/pkg/utils/print.go +++ b/pkg/utils/print.go @@ -302,8 +302,8 @@ func PrintSettings(settings models.WorkplaceSettings, jsonFlag bool) { func PrintScopedConfig(conf models.ScopedConfig) { var rows [][]string - if conf.Key != (models.Pair{}) { - rows = append(rows, []string{"key", conf.Key.Value, conf.Key.Scope}) + if conf.Token != (models.Pair{}) { + rows = append(rows, []string{"token", conf.Token.Value, conf.Token.Scope}) } if conf.Project != (models.Pair{}) { rows = append(rows, []string{"project", conf.Project.Value, conf.Project.Scope}) @@ -330,8 +330,8 @@ func PrintConfigs(configs map[string]models.Config, jsonFlag bool) { var rows [][]string for scope, config := range configs { - if config.Key != "" { - rows = append(rows, []string{"key", config.Key, scope}) + if config.Token != "" { + rows = append(rows, []string{"token", config.Token, scope}) } if config.Project != "" { rows = append(rows, []string{"project", config.Project, scope})