@@ -13,24 +13,22 @@ import (
1313 servicetypes "github.com/render-oss/cli/pkg/types/service"
1414)
1515
16- var ServiceUpdateCmd = & cobra.Command {
17- Use : "update <service>" ,
18- Args : cobra .ExactArgs (1 ),
19- Short : "Update configuration for an existing service" ,
20- Long : `Update a service on Render. This command only runs in non-interactive modes.
16+ func newServiceUpdateCmd (deps * dependencies.Dependencies ) * cobra.Command {
17+ cmd := & cobra.Command {
18+ Use : "update <service>" ,
19+ Args : cobra .ExactArgs (1 ),
20+ Short : "Update configuration for an existing service" ,
21+ Long : `Update a service on Render. This command only runs in non-interactive modes.
2122
2223Provide configuration updates with flags.` ,
23- Example : ` # Rename a service
24+ Example : ` # Rename a service
2425 render services update my-service --name my-new-name --output json
2526
2627 # Change a service plan
2728 render services update srv-abc123 --plan pro --output json` ,
28- }
29-
30- func init () {
31- servicesCmd .AddCommand (ServiceUpdateCmd )
29+ }
3230
33- ServiceUpdateCmd .RunE = func (cmd * cobra.Command , args []string ) error {
31+ cmd .RunE = func (cmd * cobra.Command , args []string ) error {
3432 var cliInput servicetypes.ServiceUpdateInput
3533 if err := command .ParseCommand (cmd , args , & cliInput ); err != nil {
3634 return fmt .Errorf ("failed to parse command: %w" , err )
@@ -47,7 +45,7 @@ func init() {
4745 ctx := cmd .Context ()
4846
4947 nonInteractive , err := command .NonInteractiveWithConfirm (cmd , func () (* client.Service , error ) {
50- return updateServiceNonInteractive (ctx , cliInput )
48+ return updateServiceNonInteractive (ctx , deps , cliInput )
5149 }, func (svc * client.Service ) string {
5250 return text .FormatStringF ("Updated service %s (%s)" , svc .Name , svc .Id )
5351 }, nil )
@@ -63,56 +61,57 @@ func init() {
6361 }
6462
6563 // Identity and source flags
66- ServiceUpdateCmd .Flags ().String ("name" , "" , "Service name" )
67- ServiceUpdateCmd .Flags ().String ("repo" , "" , "Git repository URL" )
68- ServiceUpdateCmd .Flags ().String ("branch" , "" , "Git branch" )
69- ServiceUpdateCmd .Flags ().String ("image" , "" , "Docker image URL" )
64+ cmd .Flags ().String ("name" , "" , "Service name" )
65+ cmd .Flags ().String ("repo" , "" , "Git repository URL" )
66+ cmd .Flags ().String ("branch" , "" , "Git branch" )
67+ cmd .Flags ().String ("image" , "" , "Docker image URL" )
7068
7169 // Deployment configuration flags
72- ServiceUpdateCmd .Flags ().String ("plan" , "" , "Service plan" )
70+ cmd .Flags ().String ("plan" , "" , "Service plan" )
7371 runtimeFlag := command .NewEnumInput (servicetypes .ServiceRuntimeValues (), false )
74- ServiceUpdateCmd .Flags ().Var (runtimeFlag , "runtime" , "Runtime environment" )
75- ServiceUpdateCmd .Flags ().String ("root-directory" , "" , "Root directory" )
72+ cmd .Flags ().Var (runtimeFlag , "runtime" , "Runtime environment" )
73+ cmd .Flags ().String ("root-directory" , "" , "Root directory" )
7674
7775 // Build and start commands
78- ServiceUpdateCmd .Flags ().String ("build-command" , "" , "Build command" )
79- ServiceUpdateCmd .Flags ().String ("start-command" , "" , "Start command" )
80- ServiceUpdateCmd .Flags ().String ("pre-deploy-command" , "" , "Pre-deploy command" )
76+ cmd .Flags ().String ("build-command" , "" , "Build command" )
77+ cmd .Flags ().String ("start-command" , "" , "Start command" )
78+ cmd .Flags ().String ("pre-deploy-command" , "" , "Pre-deploy command" )
8179
8280 // Type-specific flags
83- ServiceUpdateCmd .Flags ().String ("health-check-path" , "" , "Health check path" )
84- ServiceUpdateCmd .Flags ().String ("publish-directory" , "" , "Publish directory" )
85- ServiceUpdateCmd .Flags ().String ("cron-command" , "" , "Cron command" )
86- ServiceUpdateCmd .Flags ().String ("cron-schedule" , "" , "Cron schedule" )
81+ cmd .Flags ().String ("health-check-path" , "" , "Health check path" )
82+ cmd .Flags ().String ("publish-directory" , "" , "Publish directory" )
83+ cmd .Flags ().String ("cron-command" , "" , "Cron command" )
84+ cmd .Flags ().String ("cron-schedule" , "" , "Cron schedule" )
8785
8886 // Registry flag
89- ServiceUpdateCmd .Flags ().String ("registry-credential" , "" , "Registry credential" )
87+ cmd .Flags ().String ("registry-credential" , "" , "Registry credential" )
9088
9189 // Behavior flags
92- ServiceUpdateCmd .Flags ().Bool ("auto-deploy" , false , "Enable auto-deploy" )
90+ cmd .Flags ().Bool ("auto-deploy" , false , "Enable auto-deploy" )
9391
9492 // Build filter flags
95- ServiceUpdateCmd .Flags ().StringArray ("build-filter-path" , nil , "Build filter path (can be specified multiple times)" )
96- ServiceUpdateCmd .Flags ().StringArray ("build-filter-ignored-path" , nil , "Build filter ignored path (can be specified multiple times)" )
93+ cmd .Flags ().StringArray ("build-filter-path" , nil , "Build filter path (can be specified multiple times)" )
94+ cmd .Flags ().StringArray ("build-filter-ignored-path" , nil , "Build filter ignored path (can be specified multiple times)" )
9795
9896 // Instance and scaling flags
99- ServiceUpdateCmd .Flags ().Int ("num-instances" , 0 , "Number of instances" )
100- ServiceUpdateCmd .Flags ().Int ("max-shutdown-delay" , 0 , "Max shutdown delay in seconds" )
97+ cmd .Flags ().Int ("num-instances" , 0 , "Number of instances" )
98+ cmd .Flags ().Int ("max-shutdown-delay" , 0 , "Max shutdown delay in seconds" )
10199
102100 // Preview and preview generation flags
103101 previewsFlag := command .NewEnumInput (servicetypes .PreviewsGenerationValues (), false )
104- ServiceUpdateCmd .Flags ().Var (previewsFlag , "previews" , "Preview generation mode" )
102+ cmd .Flags ().Var (previewsFlag , "previews" , "Preview generation mode" )
105103
106104 // Maintenance mode flags
107- ServiceUpdateCmd .Flags ().Bool ("maintenance-mode" , false , "Enable maintenance mode" )
108- ServiceUpdateCmd .Flags ().String ("maintenance-mode-uri" , "" , "Maintenance mode URI" )
105+ cmd .Flags ().Bool ("maintenance-mode" , false , "Enable maintenance mode" )
106+ cmd .Flags ().String ("maintenance-mode-uri" , "" , "Maintenance mode URI" )
109107
110108 // IP allow list flag
111- ServiceUpdateCmd .Flags ().StringArray ("ip-allow-list" , nil , "IP allow list entry in cidr=..., description=... format (can be specified multiple times)" )
109+ cmd .Flags ().StringArray ("ip-allow-list" , nil , "IP allow list entry in cidr=..., description=... format (can be specified multiple times)" )
110+
111+ return cmd
112112}
113113
114- func updateServiceNonInteractive (ctx context.Context , cliInput servicetypes.ServiceUpdateInput ) (* client.Service , error ) {
115- deps := dependencies .GetFromContext (ctx )
114+ func updateServiceNonInteractive (ctx context.Context , deps * dependencies.Dependencies , cliInput servicetypes.ServiceUpdateInput ) (* client.Service , error ) {
116115 serviceRepo := deps .ServiceRepo ()
117116
118117 // Resolve service ID
0 commit comments