You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add on_exists param with behaviour fail, ignore and overwrite (#207)
This PR adds a feature where you can customize the behaviour when a resource exists. It has three options:
- `fail` (default): Fail and halt seqerakit
- `ignore`: Keep going and ignore the error
- `overwrite`: Use the existing overwrite behaviour
With this, we can repeatedly set up a 'showcase' and it will only create resources where they don't exist and launch pipelines, meaning we can be fairly frugal with resource set up.
The downside is status drift may occur, where the platform resources have diverged from the YAML templates which will not be captured and will be ignored by seqerakit. Not ideal, but a problem even for things like [Terraform](https://developer.hashicorp.com/terraform/tutorials/state/resource-drift).
---------
Co-authored-by: ejseqera <[email protected]>
Co-authored-by: Esha Joshi <[email protected]>
Copy file name to clipboardexpand all lines: README.md
+26-4
Original file line number
Diff line number
Diff line change
@@ -301,14 +301,34 @@ params:
301
301
302
302
**Note**: If duplicate parameters are provided, the parameters provided as key-value pairs inside the `params` nested dictionary of the YAML file will take precedence **over** values in the provided `params-file`.
303
303
304
-
### 2. `overwrite` Functionality
304
+
### 2. `on_exists` Functionality
305
305
306
-
For every entity defined in your YAML file, you can specify `overwrite: True` to overwrite any existing entities in Seqera Platform of the same name.
306
+
For every entity defined in your YAML file, you can specify how to handle cases where the entity already exists using the `on_exists` parameter with one of three options:
307
307
308
-
`seqerakit`will first check to see if the name of the entity exists, if so, it will invoke a `tw <subcommand> delete` command before attempting to create it based on the options defined in the YAML file.
308
+
- `fail` (default): Raise an error if the entity already exists
309
+
- `ignore`: Skip creation if the entity already exists
310
+
- `overwrite`: Delete the existing entity and create a new one based on the YAML configuration
311
+
312
+
Example usage in YAML:
313
+
314
+
```yaml
315
+
workspaces:
316
+
- name: 'showcase'
317
+
organization: 'seqerakit_automation'
318
+
on_exists: 'overwrite' # Will delete and recreate if exists
319
+
```
320
+
321
+
```yaml
322
+
credentials:
323
+
- name: 'github_credentials'
324
+
workspace: 'seqerakit_automation/showcase'
325
+
on_exists: 'ignore' # Will skip if already exists
326
+
```
327
+
328
+
When using the `overwrite` option, `seqerakit` will first check if the entity exists, and if so, it will invoke a `tw <subcommand> delete` command before attempting to create it based on the options defined in the YAML file:
309
329
310
330
```console
311
-
DEBUG:root: Overwrite is set to 'True' for organizations
331
+
DEBUG:root: on_exists is set to 'overwrite' for organizations
312
332
313
333
DEBUG:root: Running command: tw -o json organizations list
314
334
DEBUG:root: The attempted organizations resource already exists. Overwriting.
DEBUG:root: Running command: tw organizations add --name $SEQERA_ORGANIZATION_NAME --full-name $SEQERA_ORGANIZATION_NAME --description 'Example of an organization'
318
338
```
319
339
340
+
> **Note**: For backward compatibility, the `overwrite: True|False` parameter is still supported but deprecated. It will be mapped to `on_exists: 'overwrite'|'fail'` respectively.
341
+
320
342
### 3. Specifying JSON configuration files with `file-path`
321
343
322
344
The Seqera Platform CLI allows export and import of entities through JSON configuration files for pipelines and compute environments. To use these files to add a pipeline or compute environment to a workspace, use the `file-path` key to specify a path to a JSON configuration file.
0 commit comments