Skip to content
Merged
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ Commands can use `server` or `servers` interchangeably.
- `--build-time` - Available at build time
- `--is-literal` - Treat value as literal (don't interpolate variables)
- `--is-multiline` - Value is multiline
- `coolify app env update <app_uuid>` - Update an environment variable
- `--key <key>` - Variable key (required)
- `coolify app env update <app_uuid> <env_uuid_or_key>` - Update an environment variable
- `--value <value>` - Variable value (required)
- `--key <key>` - New variable key (optional, for renaming)
- `--preview` - Available in preview deployments
- `--build-time` - Available at build time
- `--is-literal` - Treat value as literal (don't interpolate variables)
Expand Down Expand Up @@ -239,9 +239,9 @@ Commands can use `server` or `servers` interchangeably.
- `coolify service env get <service_uuid> <env_uuid_or_key>` - Get a specific environment variable
- `coolify service env create <service_uuid>` - Create a new environment variable
- Same flags as application environment variables
- `coolify service env update <service_uuid>` - Update an environment variable
- `--key <key>` - Variable key (required)
- `coolify service env update <service_uuid> <env_uuid_or_key>` - Update an environment variable
- `--value <value>` - Variable value (required)
- `--key <key>` - New variable key (optional, for renaming)
- `--build-time` - Available at build time
- `--is-literal` - Treat value as literal (don't interpolate variables)
- `--is-multiline` - Value is multiline
Expand Down
2 changes: 1 addition & 1 deletion cmd/application/env/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewCreateEnvCommand() *cobra.Command {
return fmt.Errorf("failed to create environment variable: %w", err)
}

fmt.Printf("Environment variable '%s' created successfully.\n", env.Key)
fmt.Printf("Environment variable '%s' created successfully.\n", key)
fmt.Printf("UUID: %s\n", env.UUID)
return nil
},
Expand Down
27 changes: 18 additions & 9 deletions cmd/application/env/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (

func NewUpdateEnvCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "update <app_uuid>",
Use: "update <app_uuid> <env_uuid_or_key>",
Short: "Update an environment variable",
Long: `Update an existing environment variable. UUID is the application.`,
Args: cli.ExactArgs(1, "<app_uuid>"),
Long: `Update an existing environment variable. Identify it by UUID or key name.`,
Args: cli.ExactArgs(2, "<app_uuid> <env_uuid_or_key>"),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
appUUID := args[0]
envIdentifier := args[1]

client, err := cli.GetAPIClient(cmd)
if err != nil {
Expand All @@ -30,12 +31,24 @@ func NewUpdateEnvCommand() *cobra.Command {
return err
}

appSvc := service.NewApplicationService(client)

// Look up the env var to resolve its key
existingEnv, err := appSvc.GetEnv(ctx, appUUID, envIdentifier)
if err != nil {
return fmt.Errorf("failed to find environment variable '%s': %w", envIdentifier, err)
}

req := &models.EnvironmentVariableUpdateRequest{}

// Use existing key unless --key flag explicitly provides a new one
if cmd.Flags().Changed("key") {
key, _ := cmd.Flags().GetString("key")
req.Key = &key
} else {
req.Key = &existingEnv.Key
}

if cmd.Flags().Changed("value") {
value, _ := cmd.Flags().GetString("value")
req.Value = &value
Expand Down Expand Up @@ -65,14 +78,10 @@ func NewUpdateEnvCommand() *cobra.Command {
req.Comment = &comment
}

if req.Key == nil {
return fmt.Errorf("--key is required")
}
if req.Value == nil {
return fmt.Errorf("--value is required")
}

appSvc := service.NewApplicationService(client)
env, err := appSvc.UpdateEnv(ctx, appUUID, req)
if err != nil {
return fmt.Errorf("failed to update environment variable: %w", err)
Expand All @@ -83,8 +92,8 @@ func NewUpdateEnvCommand() *cobra.Command {
},
}

cmd.Flags().String("key", "", "New environment variable key")
cmd.Flags().String("value", "", "New environment variable value")
cmd.Flags().String("key", "", "New environment variable key (rename)")
cmd.Flags().String("value", "", "New environment variable value (required)")
cmd.Flags().Bool("build-time", true, "Available at build time (default: true)")
cmd.Flags().Bool("preview", false, "Available in preview deployments")
cmd.Flags().Bool("is-literal", false, "Treat value as literal")
Expand Down
4 changes: 2 additions & 2 deletions cmd/database/env/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func NewCreateCommand() *cobra.Command {
}

dbSvc := service.NewDatabaseService(client)
env, err := dbSvc.CreateEnv(ctx, uuid, req)
_, err = dbSvc.CreateEnv(ctx, uuid, req)
if err != nil {
return fmt.Errorf("failed to create environment variable: %w", err)
}

fmt.Printf("Environment variable '%s' created successfully.\n", env.Key)
fmt.Printf("Environment variable '%s' created successfully.\n", key)
return nil
},
}
Expand Down
27 changes: 18 additions & 9 deletions cmd/database/env/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (

func NewUpdateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "update <database_uuid>",
Use: "update <database_uuid> <env_uuid_or_key>",
Short: "Update an environment variable",
Long: `Update an existing environment variable. UUID is the database.`,
Args: cli.ExactArgs(1, "<database_uuid>"),
Long: `Update an existing environment variable. Identify it by UUID or key name.`,
Args: cli.ExactArgs(2, "<database_uuid> <env_uuid_or_key>"),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
dbUUID := args[0]
envIdentifier := args[1]

client, err := cli.GetAPIClient(cmd)
if err != nil {
Expand All @@ -30,12 +31,24 @@ func NewUpdateCommand() *cobra.Command {
return err
}

dbSvc := service.NewDatabaseService(client)

// Look up the env var to resolve its key
existingEnv, err := dbSvc.GetEnv(ctx, dbUUID, envIdentifier)
if err != nil {
return fmt.Errorf("failed to find environment variable '%s': %w", envIdentifier, err)
}

req := &models.DatabaseEnvironmentVariableUpdateRequest{}

// Use existing key unless --key flag explicitly provides a new one
if cmd.Flags().Changed("key") {
key, _ := cmd.Flags().GetString("key")
req.Key = &key
} else {
req.Key = &existingEnv.Key
}

if cmd.Flags().Changed("value") {
value, _ := cmd.Flags().GetString("value")
req.Value = &value
Expand All @@ -57,14 +70,10 @@ func NewUpdateCommand() *cobra.Command {
req.Comment = &comment
}

if req.Key == nil {
return fmt.Errorf("--key is required")
}
if req.Value == nil {
return fmt.Errorf("--value is required")
}

dbSvc := service.NewDatabaseService(client)
env, err := dbSvc.UpdateEnv(ctx, dbUUID, req)
if err != nil {
return fmt.Errorf("failed to update environment variable: %w", err)
Expand All @@ -75,8 +84,8 @@ func NewUpdateCommand() *cobra.Command {
},
}

cmd.Flags().String("key", "", "New environment variable key")
cmd.Flags().String("value", "", "New environment variable value")
cmd.Flags().String("key", "", "New environment variable key (rename)")
cmd.Flags().String("value", "", "New environment variable value (required)")
cmd.Flags().Bool("is-literal", false, "Treat value as literal")
cmd.Flags().Bool("is-multiline", false, "Value is multiline")
cmd.Flags().Bool("is-shown-once", false, "Only show value once")
Expand Down
4 changes: 2 additions & 2 deletions cmd/service/env/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func NewCreateCommand() *cobra.Command {
}

serviceSvc := service.NewService(client)
env, err := serviceSvc.CreateEnv(ctx, uuid, req)
_, err = serviceSvc.CreateEnv(ctx, uuid, req)
if err != nil {
return fmt.Errorf("failed to create environment variable: %w", err)
}

fmt.Printf("Environment variable '%s' created successfully.\n", env.Key)
fmt.Printf("Environment variable '%s' created successfully.\n", key)
return nil
},
}
Expand Down
28 changes: 18 additions & 10 deletions cmd/service/env/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (

func NewUpdateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "update <service_uuid>",
Use: "update <service_uuid> <env_uuid_or_key>",
Short: "Update an environment variable",
Long: `Update an existing environment variable. UUID is the service.`,
Args: cli.ExactArgs(1, "<service_uuid>"),
Long: `Update an existing environment variable. Identify it by UUID or key name.`,
Args: cli.ExactArgs(2, "<service_uuid> <env_uuid_or_key>"),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
serviceUUID := args[0]
envIdentifier := args[1]

client, err := cli.GetAPIClient(cmd)
if err != nil {
Expand All @@ -30,13 +31,24 @@ func NewUpdateCommand() *cobra.Command {
return err
}

serviceSvc := service.NewService(client)

// Look up the env var to resolve its key
existingEnv, err := serviceSvc.GetEnv(ctx, serviceUUID, envIdentifier)
if err != nil {
return fmt.Errorf("failed to find environment variable '%s': %w", envIdentifier, err)
}

req := &models.ServiceEnvironmentVariableUpdateRequest{}

// Only set fields that were provided
// Use existing key unless --key flag explicitly provides a new one
if cmd.Flags().Changed("key") {
key, _ := cmd.Flags().GetString("key")
req.Key = &key
} else {
req.Key = &existingEnv.Key
}

if cmd.Flags().Changed("value") {
value, _ := cmd.Flags().GetString("value")
req.Value = &value
Expand All @@ -62,14 +74,10 @@ func NewUpdateCommand() *cobra.Command {
req.Comment = &comment
}

if req.Key == nil {
return fmt.Errorf("--key is required")
}
if req.Value == nil {
return fmt.Errorf("--value is required")
}

serviceSvc := service.NewService(client)
env, err := serviceSvc.UpdateEnv(ctx, serviceUUID, req)
if err != nil {
return fmt.Errorf("failed to update environment variable: %w", err)
Expand All @@ -80,8 +88,8 @@ func NewUpdateCommand() *cobra.Command {
},
}

cmd.Flags().String("key", "", "New environment variable key")
cmd.Flags().String("value", "", "New environment variable value")
cmd.Flags().String("key", "", "New environment variable key (rename)")
cmd.Flags().String("value", "", "New environment variable value (required)")
cmd.Flags().Bool("build-time", true, "Available at build time (default: true)")
cmd.Flags().Bool("is-literal", false, "Treat value as literal (don't interpolate variables)")
cmd.Flags().Bool("is-multiline", false, "Value is multiline")
Expand Down
30 changes: 15 additions & 15 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ Parameters:
description: Make all variables available at runtime (default: true)
required: false

Command: coolify app env update <app_uuid>
Description: Update an existing environment variable. UUID is the application.
Command: coolify app env update <app_uuid> <env_uuid_or_key>
Description: Update an existing environment variable. Identify it by UUID or key name.
Parameters:
- name: --build-time
type: boolean
Expand All @@ -603,7 +603,7 @@ Parameters:
required: false
- name: --key
type: string
description: New environment variable key
description: New environment variable key (rename)
required: false
- name: --preview
type: boolean
Expand All @@ -615,8 +615,8 @@ Parameters:
required: false
- name: --value
type: string
description: New environment variable value
required: false
description: New environment variable value (required)
required: true

Command: coolify app get <uuid>
Description: Retrieve detailed information about a specific application.
Expand Down Expand Up @@ -1146,8 +1146,8 @@ Parameters:
description: Treat all values as literal (don't interpolate variables)
required: false

Command: coolify database env update <database_uuid>
Description: Update an existing environment variable. UUID is the database.
Command: coolify database env update <database_uuid> <env_uuid_or_key>
Description: Update an existing environment variable. Identify it by UUID or key name.
Parameters:
- name: --comment
type: string
Expand All @@ -1167,12 +1167,12 @@ Parameters:
required: false
- name: --key
type: string
description: New environment variable key
description: New environment variable key (rename)
required: false
- name: --value
type: string
description: New environment variable value
required: false
description: New environment variable value (required)
required: true

Command: coolify database get <uuid>
Description: Get detailed information about a specific database by UUID.
Expand Down Expand Up @@ -1614,8 +1614,8 @@ Parameters:
description: Make all variables available at runtime (default: true)
required: false

Command: coolify service env update <service_uuid>
Description: Update an existing environment variable. UUID is the service.
Command: coolify service env update <service_uuid> <env_uuid_or_key>
Description: Update an existing environment variable. Identify it by UUID or key name.
Parameters:
- name: --build-time
type: boolean
Expand All @@ -1635,16 +1635,16 @@ Parameters:
required: false
- name: --key
type: string
description: New environment variable key
description: New environment variable key (rename)
required: false
- name: --runtime
type: boolean
description: Available at runtime (default: true)
required: false
- name: --value
type: string
description: New environment variable value
required: false
description: New environment variable value (required)
required: true

Command: coolify service get <uuid>
Description: Get detailed information about a specific service.
Expand Down
Loading