Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/cmd/dynamic_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func getDynamicSecretList(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -171,7 +171,7 @@ func createDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -342,7 +342,7 @@ func renewDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -477,7 +477,7 @@ func revokeDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -605,7 +605,7 @@ func listDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -705,7 +705,7 @@ func listDynamicSecretLeaseByName(cmd *cobra.Command, args []string) {
func init() {
dynamicSecretLeaseCreateCmd.Flags().StringP("path", "p", "/", "The path from where dynamic secret should be leased from")
dynamicSecretLeaseCreateCmd.Flags().String("token", "", "Create dynamic secret leases using machine identity access token")
dynamicSecretLeaseCreateCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth")
dynamicSecretLeaseCreateCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
dynamicSecretLeaseCreateCmd.Flags().String("project-slug", "", "Manually set the project-slug to create lease in")
dynamicSecretLeaseCreateCmd.Flags().String("ttl", "", "The lease lifetime TTL. If not provided the default TTL of dynamic secret will be used.")
dynamicSecretLeaseCreateCmd.Flags().Bool("plain", false, "Print leased credentials without formatting, one per line")
Expand All @@ -720,30 +720,30 @@ func init() {

dynamicSecretLeaseListCmd.Flags().StringP("path", "p", "/", "The path from where dynamic secret should be leased from")
dynamicSecretLeaseListCmd.Flags().String("token", "", "Fetch dynamic secret leases machine identity access token")
dynamicSecretLeaseListCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth")
dynamicSecretLeaseListCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
dynamicSecretLeaseListCmd.Flags().String("project-slug", "", "Manually set the project-slug to list leases from")
util.AddOutputFlagsToCmd(dynamicSecretLeaseListCmd, "The output to format the dynamic secret leases in.")
dynamicSecretLeaseCmd.AddCommand(dynamicSecretLeaseListCmd)

dynamicSecretLeaseRenewCmd.Flags().StringP("path", "p", "/", "The path from where dynamic secret should be leased from")
dynamicSecretLeaseRenewCmd.Flags().String("token", "", "Renew dynamic secrets machine identity access token")
dynamicSecretLeaseRenewCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth")
dynamicSecretLeaseRenewCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
dynamicSecretLeaseRenewCmd.Flags().String("project-slug", "", "Manually set the project-slug to renew lease in")
dynamicSecretLeaseRenewCmd.Flags().String("ttl", "", "The lease lifetime TTL. If not provided the default TTL of dynamic secret will be used.")
util.AddOutputFlagsToCmd(dynamicSecretLeaseRenewCmd, "The output to format the dynamic secret lease renewal in.")
dynamicSecretLeaseCmd.AddCommand(dynamicSecretLeaseRenewCmd)

dynamicSecretLeaseRevokeCmd.Flags().StringP("path", "p", "/", "The path from where dynamic secret should be leased from")
dynamicSecretLeaseRevokeCmd.Flags().String("token", "", "Delete dynamic secrets using machine identity access token")
dynamicSecretLeaseRevokeCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth")
dynamicSecretLeaseRevokeCmd.Flags().String("projectId", "", "Manually set the projectId to fetch leased from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
dynamicSecretLeaseRevokeCmd.Flags().String("project-slug", "", "Manually set the project-slug to revoke lease from")
util.AddOutputFlagsToCmd(dynamicSecretLeaseRevokeCmd, "The output to format the dynamic secret lease revocation in.")
dynamicSecretLeaseCmd.AddCommand(dynamicSecretLeaseRevokeCmd)

dynamicSecretCmd.AddCommand(dynamicSecretLeaseCmd)

dynamicSecretCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
dynamicSecretCmd.Flags().String("projectId", "", "Manually set the projectId to fetch dynamic-secret when using machine identity based auth")
dynamicSecretCmd.Flags().String("projectId", "", "Manually set the projectId to fetch dynamic-secret when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
dynamicSecretCmd.Flags().String("project-slug", "", "Manually set the project-slug to fetch dynamic-secret from")
dynamicSecretCmd.PersistentFlags().String("env", "dev", "Used to select the environment name on which actions should be taken on")
dynamicSecretCmd.Flags().String("path", "/", "get dynamic secret within a folder path")
Expand Down
4 changes: 2 additions & 2 deletions packages/cmd/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var exportCmd = &cobra.Command{
util.HandleError(err)
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err)
}
Expand Down Expand Up @@ -271,7 +271,7 @@ func init() {
exportCmd.Flags().Bool("include-imports", true, "Imported linked secrets")
exportCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
exportCmd.Flags().StringP("tags", "t", "", "filter secrets by tag slugs")
exportCmd.Flags().String("projectId", "", "manually set the projectId to export secrets from")
exportCmd.Flags().String("projectId", "", "manually set the projectId to export secrets from. Can also be set via INFISICAL_PROJECT_ID env variable")
exportCmd.Flags().String("path", "/", "get secrets within a folder path")
exportCmd.Flags().String("template", "", "The path to the template file used to render secrets")
exportCmd.Flags().StringP("output-file", "o", "", "The path to write the output file to. Can be a full file path, directory, or filename. If not specified, output will be printed to stdout")
Expand Down
6 changes: 3 additions & 3 deletions packages/cmd/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var getCmd = &cobra.Command{
}
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -110,7 +110,7 @@ var createCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -202,7 +202,7 @@ var deleteCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var runCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func filterReservedEnvVars(env map[string]models.SingleEnvironmentVariable) {
func init() {
RootCmd.AddCommand(runCmd)
runCmd.Flags().String("token", "", "fetch secrets using service token or machine identity access token")
runCmd.Flags().String("projectId", "", "manually set the project ID to fetch secrets from when using machine identity based auth")
runCmd.Flags().String("projectId", "", "manually set the project ID to fetch secrets from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
runCmd.Flags().StringP("env", "e", "dev", "set the environment (dev, prod, etc.) from which your secrets should be pulled from")
runCmd.Flags().Bool("expand", true, "parse shell parameter expansions in your secrets")
runCmd.Flags().Bool("include-imports", true, "import linked secrets ")
Expand Down
26 changes: 13 additions & 13 deletions packages/cmd/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var secretsCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -191,7 +191,7 @@ var secretsSetCmd = &cobra.Command{
}
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -341,7 +341,7 @@ var secretsDeleteCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -454,7 +454,7 @@ func getSecretsByNames(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -597,7 +597,7 @@ func generateExampleEnv(cmd *cobra.Command, args []string) {
util.HandleError(err, "Unable to parse flag")
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -812,12 +812,12 @@ func getSecretsByKeys(secrets []models.SingleEnvironmentVariable) map[string]mod
func init() {
// not doing this one
secretsGenerateExampleEnvCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
secretsGenerateExampleEnvCmd.Flags().String("projectId", "", "manually set the projectId when using machine identity based auth")
secretsGenerateExampleEnvCmd.Flags().String("projectId", "", "manually set the projectId when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
secretsGenerateExampleEnvCmd.Flags().String("path", "/", "Fetch secrets from within a folder path")
secretsCmd.AddCommand(secretsGenerateExampleEnvCmd)

secretsGetCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
secretsGetCmd.Flags().String("projectId", "", "manually set the project ID to fetch secrets from when using machine identity based auth")
secretsGetCmd.Flags().String("projectId", "", "manually set the project ID to fetch secrets from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
secretsGetCmd.Flags().String("path", "/", "get secrets within a folder path")
secretsGetCmd.Flags().Bool("plain", false, "print values without formatting, one per line")
secretsGetCmd.Flags().Bool("raw-value", false, "deprecated. Returns only the value of secret, only works with one secret. Use --plain instead")
Expand All @@ -831,15 +831,15 @@ func init() {

secretsCmd.AddCommand(secretsSetCmd)
secretsSetCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
secretsSetCmd.Flags().String("projectId", "", "manually set the project ID to for setting secrets when using machine identity based auth")
secretsSetCmd.Flags().String("projectId", "", "manually set the project ID to for setting secrets when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
secretsSetCmd.Flags().String("path", "/", "set secrets within a folder path")
secretsSetCmd.Flags().String("type", util.SECRET_TYPE_SHARED, "the type of secret to create: personal or shared")
secretsSetCmd.Flags().String("file", "", "Load secrets from the specified file. File format: .env or YAML (comments: # or //). This option is mutually exclusive with command-line secrets arguments.")
util.AddOutputFlagsToCmd(secretsSetCmd, "The output to format the secrets in.")

secretsDeleteCmd.Flags().String("type", "personal", "the type of secret to delete: personal or shared (default: personal)")
secretsDeleteCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
secretsDeleteCmd.Flags().String("projectId", "", "manually set the projectId to delete secrets from when using machine identity based auth")
secretsDeleteCmd.Flags().String("projectId", "", "manually set the projectId to delete secrets from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
secretsDeleteCmd.Flags().String("path", "/", "get secrets within a folder path")
util.AddOutputFlagsToCmd(secretsDeleteCmd, "The output to format the secrets in.")
secretsCmd.AddCommand(secretsDeleteCmd)
Expand All @@ -850,22 +850,22 @@ func init() {
// Add getCmd, createCmd and deleteCmd flags here
getCmd.Flags().StringP("path", "p", "/", "The path from where folders should be fetched from")
getCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
getCmd.Flags().String("projectId", "", "manually set the projectId to fetch folders from when using machine identity based auth")
getCmd.Flags().String("projectId", "", "manually set the projectId to fetch folders from when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
util.AddOutputFlagsToCmd(getCmd, "The output to format the folders in.")
folderCmd.AddCommand(getCmd)

// Add createCmd flags here
createCmd.Flags().StringP("path", "p", "/", "Path to where the folder should be created")
createCmd.Flags().StringP("name", "n", "", "Name of the folder to be created in selected `--path`")
createCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
createCmd.Flags().String("projectId", "", "manually set the project ID for creating folders in when using machine identity based auth")
createCmd.Flags().String("projectId", "", "manually set the project ID for creating folders in when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
util.AddOutputFlagsToCmd(createCmd, "The output to format the folders in.")
folderCmd.AddCommand(createCmd)

// Add deleteCmd flags here
deleteCmd.Flags().StringP("path", "p", "/", "Path to the folder to be deleted")
deleteCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
deleteCmd.Flags().String("projectId", "", "manually set the projectId to delete folders when using machine identity based auth")
deleteCmd.Flags().String("projectId", "", "manually set the projectId to delete folders when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
deleteCmd.Flags().StringP("name", "n", "", "Name of the folder to be deleted within selected `--path`")
util.AddOutputFlagsToCmd(deleteCmd, "The output to format the folders in.")
folderCmd.AddCommand(deleteCmd)
Expand All @@ -875,7 +875,7 @@ func init() {
// ** End of folders sub command

secretsCmd.Flags().String("token", "", "Fetch secrets using service token or machine identity access token")
secretsCmd.Flags().String("projectId", "", "manually set the projectId to fetch secrets when using machine identity based auth")
secretsCmd.Flags().String("projectId", "", "manually set the projectId to fetch secrets when using machine identity based auth. Can also be set via INFISICAL_PROJECT_ID env variable")
secretsCmd.PersistentFlags().String("env", "dev", "Used to select the environment name on which actions should be taken on")
secretsCmd.Flags().Bool("expand", true, "Parse shell parameter expansions in your secrets, and process your referenced secrets")
secretsCmd.Flags().Bool("include-imports", true, "Imported linked secrets ")
Expand Down
4 changes: 2 additions & 2 deletions packages/cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ func sshAddHost(cmd *cobra.Command, args []string) {
infisicalToken = loggedInUserDetails.UserCredentials.JTWToken
}

projectId, err := cmd.Flags().GetString("projectId")
projectId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse --projectId flag")
}
Expand Down Expand Up @@ -1127,7 +1127,7 @@ func init() {
sshCmd.AddCommand(sshConnectCmd)

sshAddHostCmd.Flags().String("token", "", "Use a machine identity access token")
sshAddHostCmd.Flags().String("projectId", "", "Project ID the host belongs to (required)")
sshAddHostCmd.Flags().String("projectId", "", "Project ID the host belongs to (required). Can also be set via INFISICAL_PROJECT_ID env variable")
sshAddHostCmd.Flags().String("hostname", "", "Hostname of the SSH host (required)")
sshAddHostCmd.Flags().String("alias", "", "Alias for the SSH host")
sshAddHostCmd.Flags().Bool("write-user-ca-to-file", false, "Write User CA public key to /etc/ssh/infisical_user_ca.pub")
Expand Down
4 changes: 2 additions & 2 deletions packages/cmd/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var tokensCreateCmd = &cobra.Command{
util.HandleError(err, "Unable to parse flag")
}

workspaceId, err := cmd.Flags().GetString("projectId")
workspaceId, err := util.GetProjectIdFromFlag(cmd)
if err != nil {
util.HandleError(err, "Unable to parse flag")
}
Expand Down Expand Up @@ -167,7 +167,7 @@ var tokensCreateCmd = &cobra.Command{
}

func init() {
tokensCreateCmd.Flags().String("projectId", "", "The project ID you'd like to create the service token for. Default: will use linked Infisical project in .infisical.json")
tokensCreateCmd.Flags().String("projectId", "", "The project ID you'd like to create the service token for. Default: will use linked Infisical project in .infisical.json. Can also be set via INFISICAL_PROJECT_ID env variable")
tokensCreateCmd.Flags().StringSliceP("scope", "s", []string{}, "Environment and secret path. Example format: <env-slug>:<folder-path>")
tokensCreateCmd.Flags().StringP("name", "n", "Service token generated via CLI", "Service token name")
tokensCreateCmd.Flags().StringSliceP("access-level", "a", []string{}, "The type of access the service token should have. Can be 'read' and or 'write'")
Expand Down
1 change: 1 addition & 0 deletions packages/util/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
INFISICAL_LDAP_USERNAME = "INFISICAL_LDAP_USERNAME"
INFISICAL_LDAP_PASSWORD = "INFISICAL_LDAP_PASSWORD"
INFISICAL_ORGANIZATION_ID = "INFISICAL_ORGANIZATION_ID"
INFISICAL_PROJECT_ID_NAME = "INFISICAL_PROJECT_ID"

INFISICAL_GATEWAY_TOKEN_NAME_LEGACY = "TOKEN" // backwards compatibility with gateway helm chart, where token was the only supported auth method

Expand Down
Loading