diff --git a/README.md b/README.md index 3b725fe..33a4c4d 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,13 @@ 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 ` - Update an environment variable +- `coolify app env update `- Update an environment variable + - `--key ` - Variable key (required) + - `--value ` - Variable value (required) + - `--preview` - Available in preview deployments + - `--build-time` - Available at build time + - `--is-literal` - Treat value as literal (don't interpolate variables) + - `--is-multiline` - Value is multiline - `coolify app env delete ` - Delete an environment variable - `coolify app env sync ` - Sync environment variables from a .env file - `--file ` - Path to .env file (required) diff --git a/cmd/service/env/update.go b/cmd/service/env/update.go index a78b8ee..cc864bd 100644 --- a/cmd/service/env/update.go +++ b/cmd/service/env/update.go @@ -12,23 +12,20 @@ import ( func NewUpdateCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "update ", + Use: "update ", Short: "Update an environment variable", - Long: `Update an existing environment variable. First UUID is the service, second is the specific environment variable to update.`, - Args: cli.ExactArgs(2, " "), + Long: `Update an existing environment variable. UUID is the service.`, + Args: cli.ExactArgs(1, ""), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() serviceUUID := args[0] - envUUID := args[1] client, err := cli.GetAPIClient(cmd) if err != nil { return fmt.Errorf("failed to get API client: %w", err) } - req := &models.ServiceEnvironmentVariableUpdateRequest{ - UUID: envUUID, - } + req := &models.ServiceEnvironmentVariableUpdateRequest{} // Only set fields that were provided if cmd.Flags().Changed("key") { diff --git a/internal/models/service.go b/internal/models/service.go index 4d3581c..89aaddc 100644 --- a/internal/models/service.go +++ b/internal/models/service.go @@ -100,7 +100,6 @@ type ServiceEnvironmentVariableCreateRequest struct { // ServiceEnvironmentVariableUpdateRequest represents the request to update a service environment variable type ServiceEnvironmentVariableUpdateRequest struct { - UUID string `json:"uuid"` Key *string `json:"key,omitempty"` Value *string `json:"value,omitempty"` IsBuildTime *bool `json:"is_build_time,omitempty"` diff --git a/internal/service/service_test.go b/internal/service/service_test.go index 4a1834e..5072ad5 100644 --- a/internal/service/service_test.go +++ b/internal/service/service_test.go @@ -330,8 +330,7 @@ func TestService_UpdateEnv(t *testing.T) { newKey := "UPDATED_VAR" env, err := svc.UpdateEnv(context.Background(), "service-uuid-123", &models.ServiceEnvironmentVariableUpdateRequest{ - UUID: "env-123", - Key: &newKey, + Key: &newKey, }) require.NoError(t, err)