@@ -83,7 +83,7 @@ def show_variable_cmd(
8383 "-p" ,
8484 "--project-id" ,
8585 type = click .UUID ,
86- required = True ,
86+ default = None ,
8787 help = "UUID of the project in which to deploy the variable" ,
8888)
8989@click .option (
@@ -120,13 +120,13 @@ def set_variable_cmd(
120120 variable : dict [str , tp .Any ] | None = None
121121
122122 if utils .is_valid_uuid (var_uuid_or_name ):
123- var_uuid = var_uuid_or_name
123+ var_uuid = str (var_uuid_or_name )
124+ # Try to find variable by UUID
124125 try :
125126 variable = variable_lib .get_variable (client , sys_uuid .UUID (var_uuid ))
126- except bazooka_exc .NotFoundError as exc :
127- raise click .ClickException (
128- f"Variable with UUID { var_uuid } not found"
129- ) from exc
127+ except bazooka_exc .NotFoundError :
128+ # No message found, just to create a variable with specified UUID
129+ pass
130130 else :
131131 variables = variable_lib .list_variables (client , name = var_uuid_or_name )
132132 if len (variables ) > 1 :
@@ -137,7 +137,8 @@ def set_variable_cmd(
137137 variable = variables [0 ]
138138 var_uuid = variable ["uuid" ]
139139
140- if variable is None or var_uuid is None :
140+ # No variable found, create new one
141+ if variable is None :
141142 root_ctx = ctx .find_root ()
142143 project_id = project_id or root_ctx .params .get ("project_id" )
143144 if project_id is None :
@@ -146,13 +147,13 @@ def set_variable_cmd(
146147 "Provide it via '--project-id' (or set 'project_id' in config)."
147148 )
148149
149- variable_name = name if name is not None else var_uuid_or_name
150- variable_description = description if description is not None else ""
150+ variable_name = name if name else var_uuid_or_name
151+ variable_description = description if description else ""
151152
152153 created = variable_lib .add_variable (
153154 client ,
154155 {
155- "uuid" : str (sys_uuid .uuid4 ()),
156+ "uuid" : var_uuid if var_uuid else str (sys_uuid .uuid4 ()),
156157 "project_id" : str (project_id ),
157158 "name" : variable_name ,
158159 "description" : variable_description ,
0 commit comments