From 2893bdbc6b0adfb2671263eb255af7b8ed6f3e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Mu=C3=B1oz=20Redondo?= <105782439+JaimeSeqLabs@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:26:18 +0200 Subject: [PATCH] Add overwrite option when importing pipelines and ces (#333) * pipelines import cmd, add overwrite flag * update reflection files * compEnv import cmd, add overwrite flag * fix: missing mock resets --------- Co-authored-by: JK19 --- conf/reflect-config.json | 404 ++---------------- .../cli/commands/computeenvs/ImportCmd.java | 21 + .../cli/commands/pipelines/ImportCmd.java | 14 + .../cli/computeenvs/ComputeEnvsCmdTest.java | 56 +++ .../tower/cli/pipelines/PipelinesCmdTest.java | 127 +++++- 5 files changed, 258 insertions(+), 364 deletions(-) diff --git a/conf/reflect-config.json b/conf/reflect-config.json index 0ba67222..dd075eb4 100644 --- a/conf/reflect-config.json +++ b/conf/reflect-config.json @@ -122,6 +122,9 @@ "name":"com.sun.crypto.provider.TlsPrfGenerator$V12", "methods":[{"name":"","parameterTypes":[] }] }, +{ + "name":"groovy.lang.Closure" +}, { "name":"io.seqera.tower.cli.Tower", "allDeclaredFields":true, @@ -2035,37 +2038,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getConfig","parameterTypes":[] }, - {"name":"getDateCreated","parameterTypes":[] }, - {"name":"getEvent","parameterTypes":[] }, - {"name":"getHookId","parameterTypes":[] }, - {"name":"getHookUrl","parameterTypes":[] }, - {"name":"getId","parameterTypes":[] }, - {"name":"getLabels","parameterTypes":[] }, - {"name":"getLastSeen","parameterTypes":[] }, - {"name":"getLastUpdated","parameterTypes":[] }, - {"name":"getLaunch","parameterTypes":[] }, - {"name":"getMessage","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"getSource","parameterTypes":[] }, - {"name":"getStatus","parameterTypes":[] }, - {"name":"setConfig","parameterTypes":["io.seqera.tower.model.ActionConfigType"] }, - {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setEvent","parameterTypes":["io.seqera.tower.model.ActionEventType"] }, - {"name":"setHookId","parameterTypes":["java.lang.String"] }, - {"name":"setHookUrl","parameterTypes":["java.lang.String"] }, - {"name":"setId","parameterTypes":["java.lang.String"] }, - {"name":"setLabels","parameterTypes":["java.util.List"] }, - {"name":"setLastSeen","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setLaunch","parameterTypes":["io.seqera.tower.model.Launch"] }, - {"name":"setMessage","parameterTypes":["java.lang.String"] }, - {"name":"setName","parameterTypes":["java.lang.String"] }, - {"name":"setSource","parameterTypes":["io.seqera.tower.model.ActionSource"] }, - {"name":"setStatus","parameterTypes":["io.seqera.tower.model.ActionStatus"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getConfig","parameterTypes":[] }, {"name":"getDateCreated","parameterTypes":[] }, {"name":"getEvent","parameterTypes":[] }, {"name":"getHookId","parameterTypes":[] }, {"name":"getHookUrl","parameterTypes":[] }, {"name":"getId","parameterTypes":[] }, {"name":"getLabels","parameterTypes":[] }, {"name":"getLastSeen","parameterTypes":[] }, {"name":"getLastUpdated","parameterTypes":[] }, {"name":"getLaunch","parameterTypes":[] }, {"name":"getMessage","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getSource","parameterTypes":[] }, {"name":"getStatus","parameterTypes":[] }, {"name":"setConfig","parameterTypes":["io.seqera.tower.model.ActionConfigType"] }, {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setEvent","parameterTypes":["io.seqera.tower.model.ActionEventType"] }, {"name":"setHookId","parameterTypes":["java.lang.String"] }, {"name":"setHookUrl","parameterTypes":["java.lang.String"] }, {"name":"setId","parameterTypes":["java.lang.String"] }, {"name":"setLabels","parameterTypes":["java.util.List"] }, {"name":"setLastSeen","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setLaunch","parameterTypes":["io.seqera.tower.model.Launch"] }, {"name":"setMessage","parameterTypes":["java.lang.String"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setSource","parameterTypes":["io.seqera.tower.model.ActionSource"] }, {"name":"setStatus","parameterTypes":["io.seqera.tower.model.ActionStatus"] }] }, { "name":"io.seqera.tower.model.ActionSource", @@ -2118,15 +2091,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getConnectionId","parameterTypes":[] }, - {"name":"getDiscriminator","parameterTypes":[] }, - {"name":"getShared","parameterTypes":[] }, - {"name":"getWorkDir","parameterTypes":[] }, - {"name":"setConnectionId","parameterTypes":["java.lang.String"] }, - {"name":"setWorkDir","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getConnectionId","parameterTypes":[] }, {"name":"getDiscriminator","parameterTypes":[] }, {"name":"getShared","parameterTypes":[] }, {"name":"getWorkDir","parameterTypes":[] }, {"name":"setConnectionId","parameterTypes":["java.lang.String"] }, {"name":"setWorkDir","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.AltairPbsComputeConfig", @@ -2139,43 +2104,28 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getSiteId","parameterTypes":[] }, - {"name":"getUrl","parameterTypes":[] }, - {"name":"setSiteId","parameterTypes":["java.lang.Integer"] }, - {"name":"setUrl","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getSiteId","parameterTypes":[] }, {"name":"getUrl","parameterTypes":[] }, {"name":"setSiteId","parameterTypes":["java.lang.Integer"] }, {"name":"setUrl","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.AssociateActionLabelsRequest", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getActionIds","parameterTypes":[] }, - {"name":"getLabelIds","parameterTypes":[] } - ] + "methods":[{"name":"getActionIds","parameterTypes":[] }, {"name":"getLabelIds","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.AssociatePipelineLabelsRequest", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getLabelIds","parameterTypes":[] }, - {"name":"getPipelineIds","parameterTypes":[] } - ] + "methods":[{"name":"getLabelIds","parameterTypes":[] }, {"name":"getPipelineIds","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.AssociateWorkflowLabelsRequest", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getLabelIds","parameterTypes":[] }, - {"name":"getWorkflowIds","parameterTypes":[] } - ] + "methods":[{"name":"getLabelIds","parameterTypes":[] }, {"name":"getWorkflowIds","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.Avatar", @@ -2258,50 +2208,13 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getConfig","parameterTypes":[] }, - {"name":"getCredentialsId","parameterTypes":[] }, - {"name":"getDateCreated","parameterTypes":[] }, - {"name":"getDeleted","parameterTypes":[] }, - {"name":"getDescription","parameterTypes":[] }, - {"name":"getId","parameterTypes":[] }, - {"name":"getLabels","parameterTypes":[] }, - {"name":"getLastUpdated","parameterTypes":[] }, - {"name":"getLastUsed","parameterTypes":[] }, - {"name":"getMessage","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"getOrgId","parameterTypes":[] }, - {"name":"getPlatform","parameterTypes":[] }, - {"name":"getPrimary","parameterTypes":[] }, - {"name":"getStatus","parameterTypes":[] }, - {"name":"getWorkspaceId","parameterTypes":[] }, - {"name":"setConfig","parameterTypes":["io.seqera.tower.model.ComputeConfig"] }, - {"name":"setCredentialsId","parameterTypes":["java.lang.String"] }, - {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setDeleted","parameterTypes":["java.lang.Boolean"] }, - {"name":"setDescription","parameterTypes":["java.lang.String"] }, - {"name":"setId","parameterTypes":["java.lang.String"] }, - {"name":"setLabels","parameterTypes":["java.util.List"] }, - {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setLastUsed","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setMessage","parameterTypes":["java.lang.String"] }, - {"name":"setName","parameterTypes":["java.lang.String"] }, - {"name":"setOrgId","parameterTypes":["java.lang.Long"] }, - {"name":"setPlatform","parameterTypes":["io.seqera.tower.model.ComputeEnvResponseDto$PlatformEnum"] }, - {"name":"setPrimary","parameterTypes":["java.lang.Boolean"] }, - {"name":"setStatus","parameterTypes":["io.seqera.tower.model.ComputeEnvStatus"] }, - {"name":"setWorkspaceId","parameterTypes":["java.lang.Long"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getConfig","parameterTypes":[] }, {"name":"getCredentialsId","parameterTypes":[] }, {"name":"getDateCreated","parameterTypes":[] }, {"name":"getDeleted","parameterTypes":[] }, {"name":"getDescription","parameterTypes":[] }, {"name":"getId","parameterTypes":[] }, {"name":"getLabels","parameterTypes":[] }, {"name":"getLastUpdated","parameterTypes":[] }, {"name":"getLastUsed","parameterTypes":[] }, {"name":"getMessage","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getOrgId","parameterTypes":[] }, {"name":"getPlatform","parameterTypes":[] }, {"name":"getPrimary","parameterTypes":[] }, {"name":"getStatus","parameterTypes":[] }, {"name":"getWorkspaceId","parameterTypes":[] }, {"name":"setConfig","parameterTypes":["io.seqera.tower.model.ComputeConfig"] }, {"name":"setCredentialsId","parameterTypes":["java.lang.String"] }, {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setDeleted","parameterTypes":["java.lang.Boolean"] }, {"name":"setDescription","parameterTypes":["java.lang.String"] }, {"name":"setId","parameterTypes":["java.lang.String"] }, {"name":"setLabels","parameterTypes":["java.util.List"] }, {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setLastUsed","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setMessage","parameterTypes":["java.lang.String"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setOrgId","parameterTypes":["java.lang.Long"] }, {"name":"setPlatform","parameterTypes":["io.seqera.tower.model.ComputeEnvResponseDto$PlatformEnum"] }, {"name":"setPrimary","parameterTypes":["java.lang.Boolean"] }, {"name":"setStatus","parameterTypes":["io.seqera.tower.model.ComputeEnvStatus"] }, {"name":"setWorkspaceId","parameterTypes":["java.lang.Long"] }] }, { "name":"io.seqera.tower.model.ComputeEnvResponseDto$PlatformEnum", "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "methods":[ - {"name":"fromValue","parameterTypes":["java.lang.String"] }, - {"name":"getValue","parameterTypes":[] } - ] + "methods":[{"name":"fromValue","parameterTypes":["java.lang.String"] }, {"name":"getValue","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.ComputeEnvStatus", @@ -2326,16 +2239,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getDiscriminator","parameterTypes":[] }, - {"name":"getPassword","parameterTypes":[] }, - {"name":"getRegistry","parameterTypes":[] }, - {"name":"getUserName","parameterTypes":[] }, - {"name":"setPassword","parameterTypes":["java.lang.String"] }, - {"name":"setRegistry","parameterTypes":["java.lang.String"] }, - {"name":"setUserName","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getDiscriminator","parameterTypes":[] }, {"name":"getPassword","parameterTypes":[] }, {"name":"getRegistry","parameterTypes":[] }, {"name":"getUserName","parameterTypes":[] }, {"name":"setPassword","parameterTypes":["java.lang.String"] }, {"name":"setRegistry","parameterTypes":["java.lang.String"] }, {"name":"setUserName","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.CreateActionRequest", @@ -2378,46 +2282,28 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getDescription","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] } - ] + "methods":[{"name":"getDescription","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.CreateDatasetResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setDataset","parameterTypes":["io.seqera.tower.model.Dataset"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setDataset","parameterTypes":["io.seqera.tower.model.Dataset"] }] }, { "name":"io.seqera.tower.model.CreateLabelRequest", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getIsDefault","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"getResource","parameterTypes":[] }, - {"name":"getValue","parameterTypes":[] } - ] + "methods":[{"name":"getIsDefault","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getResource","parameterTypes":[] }, {"name":"getValue","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.CreateLabelResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setId","parameterTypes":["java.lang.Long"] }, - {"name":"setIsDefault","parameterTypes":["java.lang.Boolean"] }, - {"name":"setName","parameterTypes":["java.lang.String"] }, - {"name":"setResource","parameterTypes":["java.lang.Boolean"] }, - {"name":"setValue","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setId","parameterTypes":["java.lang.Long"] }, {"name":"setIsDefault","parameterTypes":["java.lang.Boolean"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setResource","parameterTypes":["java.lang.Boolean"] }, {"name":"setValue","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.CreateOrganizationRequest", @@ -2448,20 +2334,14 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getName","parameterTypes":[] }, - {"name":"getValue","parameterTypes":[] } - ] + "methods":[{"name":"getName","parameterTypes":[] }, {"name":"getValue","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.CreatePipelineSecretResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setSecretId","parameterTypes":["java.lang.Long"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setSecretId","parameterTypes":["java.lang.Long"] }] }, { "name":"io.seqera.tower.model.CreateTeamMemberRequest", @@ -2509,50 +2389,14 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getDateCreated","parameterTypes":[] }, - {"name":"getDeleted","parameterTypes":[] }, - {"name":"getDescription","parameterTypes":[] }, - {"name":"getId","parameterTypes":[] }, - {"name":"getLastUpdated","parameterTypes":[] }, - {"name":"getMediaType","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setDeleted","parameterTypes":["java.lang.Boolean"] }, - {"name":"setDescription","parameterTypes":["java.lang.String"] }, - {"name":"setId","parameterTypes":["java.lang.String"] }, - {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setMediaType","parameterTypes":["java.lang.String"] }, - {"name":"setName","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getDateCreated","parameterTypes":[] }, {"name":"getDeleted","parameterTypes":[] }, {"name":"getDescription","parameterTypes":[] }, {"name":"getId","parameterTypes":[] }, {"name":"getLastUpdated","parameterTypes":[] }, {"name":"getMediaType","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setDeleted","parameterTypes":["java.lang.Boolean"] }, {"name":"setDescription","parameterTypes":["java.lang.String"] }, {"name":"setId","parameterTypes":["java.lang.String"] }, {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setMediaType","parameterTypes":["java.lang.String"] }, {"name":"setName","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.DatasetVersionDbDto", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getDatasetDescription","parameterTypes":[] }, - {"name":"getDatasetId","parameterTypes":[] }, - {"name":"getDatasetName","parameterTypes":[] }, - {"name":"getFileName","parameterTypes":[] }, - {"name":"getHasHeader","parameterTypes":[] }, - {"name":"getLastUpdated","parameterTypes":[] }, - {"name":"getMediaType","parameterTypes":[] }, - {"name":"getUrl","parameterTypes":[] }, - {"name":"getVersion","parameterTypes":[] }, - {"name":"setDatasetDescription","parameterTypes":["java.lang.String"] }, - {"name":"setDatasetId","parameterTypes":["java.lang.String"] }, - {"name":"setDatasetName","parameterTypes":["java.lang.String"] }, - {"name":"setFileName","parameterTypes":["java.lang.String"] }, - {"name":"setHasHeader","parameterTypes":["java.lang.Boolean"] }, - {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setMediaType","parameterTypes":["java.lang.String"] }, - {"name":"setUrl","parameterTypes":["java.lang.String"] }, - {"name":"setVersion","parameterTypes":["java.lang.Long"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getDatasetDescription","parameterTypes":[] }, {"name":"getDatasetId","parameterTypes":[] }, {"name":"getDatasetName","parameterTypes":[] }, {"name":"getFileName","parameterTypes":[] }, {"name":"getHasHeader","parameterTypes":[] }, {"name":"getLastUpdated","parameterTypes":[] }, {"name":"getMediaType","parameterTypes":[] }, {"name":"getUrl","parameterTypes":[] }, {"name":"getVersion","parameterTypes":[] }, {"name":"setDatasetDescription","parameterTypes":["java.lang.String"] }, {"name":"setDatasetId","parameterTypes":["java.lang.String"] }, {"name":"setDatasetName","parameterTypes":["java.lang.String"] }, {"name":"setFileName","parameterTypes":["java.lang.String"] }, {"name":"setHasHeader","parameterTypes":["java.lang.Boolean"] }, {"name":"setLastUpdated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setMediaType","parameterTypes":["java.lang.String"] }, {"name":"setUrl","parameterTypes":["java.lang.String"] }, {"name":"setVersion","parameterTypes":["java.lang.Long"] }] }, { "name":"io.seqera.tower.model.DescribeActionResponse", @@ -2578,10 +2422,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setDataset","parameterTypes":["io.seqera.tower.model.Dataset"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setDataset","parameterTypes":["io.seqera.tower.model.Dataset"] }] }, { "name":"io.seqera.tower.model.DescribeLaunchResponse", @@ -2619,10 +2460,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setLaunch","parameterTypes":["io.seqera.tower.model.WorkflowLaunchResponse"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setLaunch","parameterTypes":["io.seqera.tower.model.WorkflowLaunchResponse"] }] }, { "name":"io.seqera.tower.model.DescribeWorkflowResponse", @@ -2713,55 +2551,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getBootDiskSizeGb","parameterTypes":[] }, - {"name":"getCopyImage","parameterTypes":[] }, - {"name":"getCpuPlatform","parameterTypes":[] }, - {"name":"getDebugMode","parameterTypes":[] }, - {"name":"getDiscriminator","parameterTypes":[] }, - {"name":"getEnvironment","parameterTypes":[] }, - {"name":"getFusion2Enabled","parameterTypes":[] }, - {"name":"getHeadJobCpus","parameterTypes":[] }, - {"name":"getHeadJobMemoryMb","parameterTypes":[] }, - {"name":"getLabels","parameterTypes":[] }, - {"name":"getLocation","parameterTypes":[] }, - {"name":"getMachineType","parameterTypes":[] }, - {"name":"getNetwork","parameterTypes":[] }, - {"name":"getNfsMount","parameterTypes":[] }, - {"name":"getNfsTarget","parameterTypes":[] }, - {"name":"getPostRunScript","parameterTypes":[] }, - {"name":"getPreRunScript","parameterTypes":[] }, - {"name":"getProjectId","parameterTypes":[] }, - {"name":"getServiceAccount","parameterTypes":[] }, - {"name":"getSpot","parameterTypes":[] }, - {"name":"getSshDaemon","parameterTypes":[] }, - {"name":"getSshImage","parameterTypes":[] }, - {"name":"getSubnetwork","parameterTypes":[] }, - {"name":"getUsePrivateAddress","parameterTypes":[] }, - {"name":"getWaveEnabled","parameterTypes":[] }, - {"name":"getWorkDir","parameterTypes":[] }, - {"name":"setBootDiskSizeGb","parameterTypes":["java.lang.Integer"] }, - {"name":"setCopyImage","parameterTypes":["java.lang.String"] }, - {"name":"setCpuPlatform","parameterTypes":["java.lang.String"] }, - {"name":"setDebugMode","parameterTypes":["java.lang.Integer"] }, - {"name":"setEnvironment","parameterTypes":["java.util.List"] }, - {"name":"setHeadJobCpus","parameterTypes":["java.lang.Integer"] }, - {"name":"setHeadJobMemoryMb","parameterTypes":["java.lang.Integer"] }, - {"name":"setLabels","parameterTypes":["java.util.Map"] }, - {"name":"setLocation","parameterTypes":["java.lang.String"] }, - {"name":"setMachineType","parameterTypes":["java.lang.String"] }, - {"name":"setNfsMount","parameterTypes":["java.lang.String"] }, - {"name":"setNfsTarget","parameterTypes":["java.lang.String"] }, - {"name":"setPostRunScript","parameterTypes":["java.lang.String"] }, - {"name":"setPreRunScript","parameterTypes":["java.lang.String"] }, - {"name":"setProjectId","parameterTypes":["java.lang.String"] }, - {"name":"setSpot","parameterTypes":["java.lang.Boolean"] }, - {"name":"setSshDaemon","parameterTypes":["java.lang.Boolean"] }, - {"name":"setSshImage","parameterTypes":["java.lang.String"] }, - {"name":"setUsePrivateAddress","parameterTypes":["java.lang.Boolean"] }, - {"name":"setWorkDir","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getBootDiskSizeGb","parameterTypes":[] }, {"name":"getCopyImage","parameterTypes":[] }, {"name":"getCpuPlatform","parameterTypes":[] }, {"name":"getDebugMode","parameterTypes":[] }, {"name":"getDiscriminator","parameterTypes":[] }, {"name":"getEnvironment","parameterTypes":[] }, {"name":"getFusion2Enabled","parameterTypes":[] }, {"name":"getHeadJobCpus","parameterTypes":[] }, {"name":"getHeadJobMemoryMb","parameterTypes":[] }, {"name":"getLabels","parameterTypes":[] }, {"name":"getLocation","parameterTypes":[] }, {"name":"getMachineType","parameterTypes":[] }, {"name":"getNetwork","parameterTypes":[] }, {"name":"getNfsMount","parameterTypes":[] }, {"name":"getNfsTarget","parameterTypes":[] }, {"name":"getPostRunScript","parameterTypes":[] }, {"name":"getPreRunScript","parameterTypes":[] }, {"name":"getProjectId","parameterTypes":[] }, {"name":"getServiceAccount","parameterTypes":[] }, {"name":"getSpot","parameterTypes":[] }, {"name":"getSshDaemon","parameterTypes":[] }, {"name":"getSshImage","parameterTypes":[] }, {"name":"getSubnetwork","parameterTypes":[] }, {"name":"getUsePrivateAddress","parameterTypes":[] }, {"name":"getWaveEnabled","parameterTypes":[] }, {"name":"getWorkDir","parameterTypes":[] }, {"name":"setBootDiskSizeGb","parameterTypes":["java.lang.Integer"] }, {"name":"setCopyImage","parameterTypes":["java.lang.String"] }, {"name":"setCpuPlatform","parameterTypes":["java.lang.String"] }, {"name":"setDebugMode","parameterTypes":["java.lang.Integer"] }, {"name":"setEnvironment","parameterTypes":["java.util.List"] }, {"name":"setHeadJobCpus","parameterTypes":["java.lang.Integer"] }, {"name":"setHeadJobMemoryMb","parameterTypes":["java.lang.Integer"] }, {"name":"setLabels","parameterTypes":["java.util.Map"] }, {"name":"setLocation","parameterTypes":["java.lang.String"] }, {"name":"setMachineType","parameterTypes":["java.lang.String"] }, {"name":"setNfsMount","parameterTypes":["java.lang.String"] }, {"name":"setNfsTarget","parameterTypes":["java.lang.String"] }, {"name":"setPostRunScript","parameterTypes":["java.lang.String"] }, {"name":"setPreRunScript","parameterTypes":["java.lang.String"] }, {"name":"setProjectId","parameterTypes":["java.lang.String"] }, {"name":"setSpot","parameterTypes":["java.lang.Boolean"] }, {"name":"setSshDaemon","parameterTypes":["java.lang.Boolean"] }, {"name":"setSshImage","parameterTypes":["java.lang.String"] }, {"name":"setUsePrivateAddress","parameterTypes":["java.lang.Boolean"] }, {"name":"setWorkDir","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.GoogleLifeSciencesConfig", @@ -2803,19 +2593,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getId","parameterTypes":[] }, - {"name":"getIsDefault","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"getResource","parameterTypes":[] }, - {"name":"getValue","parameterTypes":[] }, - {"name":"setId","parameterTypes":["java.lang.Long"] }, - {"name":"setIsDefault","parameterTypes":["java.lang.Boolean"] }, - {"name":"setName","parameterTypes":["java.lang.String"] }, - {"name":"setResource","parameterTypes":["java.lang.Boolean"] }, - {"name":"setValue","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getId","parameterTypes":[] }, {"name":"getIsDefault","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"getResource","parameterTypes":[] }, {"name":"getValue","parameterTypes":[] }, {"name":"setId","parameterTypes":["java.lang.Long"] }, {"name":"setIsDefault","parameterTypes":["java.lang.Boolean"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setResource","parameterTypes":["java.lang.Boolean"] }, {"name":"setValue","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.LabelType", @@ -2878,31 +2656,21 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setVersions","parameterTypes":["java.util.List"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setVersions","parameterTypes":["java.util.List"] }] }, { "name":"io.seqera.tower.model.ListDatasetsResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setDatasets","parameterTypes":["java.util.List"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setDatasets","parameterTypes":["java.util.List"] }] }, { "name":"io.seqera.tower.model.ListLabelsResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setLabels","parameterTypes":["java.util.List"] }, - {"name":"setTotalSize","parameterTypes":["java.lang.Long"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setLabels","parameterTypes":["java.util.List"] }, {"name":"setTotalSize","parameterTypes":["java.lang.Long"] }] }, { "name":"io.seqera.tower.model.ListMembersResponse", @@ -2921,11 +2689,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setPipelineSecrets","parameterTypes":["java.util.List"] }, - {"name":"setTotalSize","parameterTypes":["java.lang.Long"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setPipelineSecrets","parameterTypes":["java.util.List"] }, {"name":"setTotalSize","parameterTypes":["java.lang.Long"] }] }, { "name":"io.seqera.tower.model.ListPipelinesResponse", @@ -2981,22 +2745,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getComputeQueue","parameterTypes":[] }, - {"name":"getDiscriminator","parameterTypes":[] }, - {"name":"getEnvironment","parameterTypes":[] }, - {"name":"getHeadJobOptions","parameterTypes":[] }, - {"name":"getHeadQueue","parameterTypes":[] }, - {"name":"getHostName","parameterTypes":[] }, - {"name":"getLaunchDir","parameterTypes":[] }, - {"name":"getMaxQueueSize","parameterTypes":[] }, - {"name":"getPort","parameterTypes":[] }, - {"name":"getPostRunScript","parameterTypes":[] }, - {"name":"getPreRunScript","parameterTypes":[] }, - {"name":"getPropagateHeadJobOptions","parameterTypes":[] }, - {"name":"getUserName","parameterTypes":[] }, - {"name":"getWorkDir","parameterTypes":[] } - ] + "methods":[{"name":"getComputeQueue","parameterTypes":[] }, {"name":"getDiscriminator","parameterTypes":[] }, {"name":"getEnvironment","parameterTypes":[] }, {"name":"getHeadJobOptions","parameterTypes":[] }, {"name":"getHeadQueue","parameterTypes":[] }, {"name":"getHostName","parameterTypes":[] }, {"name":"getLaunchDir","parameterTypes":[] }, {"name":"getMaxQueueSize","parameterTypes":[] }, {"name":"getPort","parameterTypes":[] }, {"name":"getPostRunScript","parameterTypes":[] }, {"name":"getPreRunScript","parameterTypes":[] }, {"name":"getPropagateHeadJobOptions","parameterTypes":[] }, {"name":"getUserName","parameterTypes":[] }, {"name":"getWorkDir","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.NavbarConfig", @@ -3052,10 +2801,7 @@ "name":"io.seqera.tower.model.ParticipantType", "allDeclaredFields":true, "queryAllDeclaredMethods":true, - "methods":[ - {"name":"fromValue","parameterTypes":["java.lang.String"] }, - {"name":"getValue","parameterTypes":[] } - ] + "methods":[{"name":"fromValue","parameterTypes":["java.lang.String"] }, {"name":"getValue","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.PipelineDbDto", @@ -3068,16 +2814,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"getDateCreated","parameterTypes":[] }, - {"name":"getId_JsonNullable","parameterTypes":[] }, - {"name":"getLastUpdated","parameterTypes":[] }, - {"name":"getLastUsed","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] }, - {"name":"setId_JsonNullable","parameterTypes":["org.openapitools.jackson.nullable.JsonNullable"] }, - {"name":"setName","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"getDateCreated","parameterTypes":[] }, {"name":"getId_JsonNullable","parameterTypes":[] }, {"name":"getLastUpdated","parameterTypes":[] }, {"name":"getLastUsed","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }, {"name":"setId_JsonNullable","parameterTypes":["org.openapitools.jackson.nullable.JsonNullable"] }, {"name":"setName","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.PodCleanupPolicy", @@ -3198,32 +2935,21 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getDescription","parameterTypes":[] }, - {"name":"getName","parameterTypes":[] } - ] + "methods":[{"name":"getDescription","parameterTypes":[] }, {"name":"getName","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.UpdateLabelRequest", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"getName","parameterTypes":[] }, - {"name":"getValue","parameterTypes":[] } - ] + "methods":[{"name":"getName","parameterTypes":[] }, {"name":"getValue","parameterTypes":[] }] }, { "name":"io.seqera.tower.model.UpdateLabelResponse", "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setId","parameterTypes":["java.lang.Long"] }, - {"name":"setName","parameterTypes":["java.lang.String"] }, - {"name":"setValue","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setId","parameterTypes":["java.lang.Long"] }, {"name":"setName","parameterTypes":["java.lang.String"] }, {"name":"setValue","parameterTypes":["java.lang.String"] }] }, { "name":"io.seqera.tower.model.UpdateMemberRoleRequest", @@ -3273,10 +2999,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setVersion","parameterTypes":["io.seqera.tower.model.DatasetVersionDbDto"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setVersion","parameterTypes":["io.seqera.tower.model.DatasetVersionDbDto"] }] }, { "name":"io.seqera.tower.model.UserDbDto", @@ -3290,12 +3013,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setGithubToken","parameterTypes":["java.lang.String"] }, - {"name":"setHubspotId","parameterTypes":["java.lang.Long"] }, - {"name":"setMaxRuns","parameterTypes":["java.lang.Integer"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setGithubToken","parameterTypes":["java.lang.String"] }, {"name":"setHubspotId","parameterTypes":["java.lang.Long"] }, {"name":"setMaxRuns","parameterTypes":["java.lang.Integer"] }] }, { "name":"io.seqera.tower.model.Visibility", @@ -3344,32 +3062,7 @@ "allDeclaredFields":true, "queryAllDeclaredMethods":true, "queryAllDeclaredConstructors":true, - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"setComputeEnv","parameterTypes":["io.seqera.tower.model.ComputeEnv"] }, - {"name":"setConfigProfiles","parameterTypes":["java.util.List"] }, - {"name":"setConfigText","parameterTypes":["java.lang.String"] }, - {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, - {"name":"setEntryName","parameterTypes":["java.lang.String"] }, - {"name":"setId","parameterTypes":["java.lang.String"] }, - {"name":"setMainScript","parameterTypes":["java.lang.String"] }, - {"name":"setParamsText","parameterTypes":["java.lang.String"] }, - {"name":"setPipeline","parameterTypes":["java.lang.String"] }, - {"name":"setPostRunScript","parameterTypes":["java.lang.String"] }, - {"name":"setPreRunScript","parameterTypes":["java.lang.String"] }, - {"name":"setPullLatest","parameterTypes":["java.lang.Boolean"] }, - {"name":"setResume","parameterTypes":["java.lang.Boolean"] }, - {"name":"setResumeCommitId","parameterTypes":["java.lang.String"] }, - {"name":"setResumeDir","parameterTypes":["java.lang.String"] }, - {"name":"setRevision","parameterTypes":["java.lang.String"] }, - {"name":"setSchemaName","parameterTypes":["java.lang.String"] }, - {"name":"setSessionId","parameterTypes":["java.lang.String"] }, - {"name":"setStubRun","parameterTypes":["java.lang.Boolean"] }, - {"name":"setTowerConfig","parameterTypes":["java.lang.String"] }, - {"name":"setUserSecrets","parameterTypes":["java.util.List"] }, - {"name":"setWorkDir","parameterTypes":["java.lang.String"] }, - {"name":"setWorkspaceSecrets","parameterTypes":["java.util.List"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"setComputeEnv","parameterTypes":["io.seqera.tower.model.ComputeEnv"] }, {"name":"setConfigProfiles","parameterTypes":["java.util.List"] }, {"name":"setConfigText","parameterTypes":["java.lang.String"] }, {"name":"setDateCreated","parameterTypes":["java.time.OffsetDateTime"] }, {"name":"setEntryName","parameterTypes":["java.lang.String"] }, {"name":"setId","parameterTypes":["java.lang.String"] }, {"name":"setMainScript","parameterTypes":["java.lang.String"] }, {"name":"setParamsText","parameterTypes":["java.lang.String"] }, {"name":"setPipeline","parameterTypes":["java.lang.String"] }, {"name":"setPostRunScript","parameterTypes":["java.lang.String"] }, {"name":"setPreRunScript","parameterTypes":["java.lang.String"] }, {"name":"setPullLatest","parameterTypes":["java.lang.Boolean"] }, {"name":"setResume","parameterTypes":["java.lang.Boolean"] }, {"name":"setResumeCommitId","parameterTypes":["java.lang.String"] }, {"name":"setResumeDir","parameterTypes":["java.lang.String"] }, {"name":"setRevision","parameterTypes":["java.lang.String"] }, {"name":"setSchemaName","parameterTypes":["java.lang.String"] }, {"name":"setSessionId","parameterTypes":["java.lang.String"] }, {"name":"setStubRun","parameterTypes":["java.lang.Boolean"] }, {"name":"setTowerConfig","parameterTypes":["java.lang.String"] }, {"name":"setUserSecrets","parameterTypes":["java.util.List"] }, {"name":"setWorkDir","parameterTypes":["java.lang.String"] }, {"name":"setWorkspaceSecrets","parameterTypes":["java.util.List"] }] }, { "name":"io.seqera.tower.model.WorkflowLoad", @@ -3558,10 +3251,7 @@ }, { "name":"java.sql.DriverManager", - "methods":[ - {"name":"getConnection","parameterTypes":["java.lang.String"] }, - {"name":"getDriver","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"getConnection","parameterTypes":["java.lang.String"] }, {"name":"getDriver","parameterTypes":["java.lang.String"] }] }, { "name":"java.sql.Time", @@ -3734,10 +3424,7 @@ }, { "name":"javax.naming.InitialContext", - "methods":[ - {"name":"","parameterTypes":[] }, - {"name":"lookup","parameterTypes":["java.lang.String"] } - ] + "methods":[{"name":"","parameterTypes":[] }, {"name":"lookup","parameterTypes":["java.lang.String"] }] }, { "name":"javax.security.auth.x500.X500Principal", @@ -3846,13 +3533,7 @@ }, { "name":"org.glassfish.jersey.internal.util.collection.ConcurrentHashMapV8", - "fields":[ - {"name":"baseCount"}, - {"name":"cellsBusy"}, - {"name":"sizeCtl"}, - {"name":"transferIndex"}, - {"name":"transferOrigin"} - ] + "fields":[{"name":"baseCount"}, {"name":"cellsBusy"}, {"name":"sizeCtl"}, {"name":"transferIndex"}, {"name":"transferOrigin"}] }, { "name":"org.glassfish.jersey.internal.util.collection.ConcurrentHashMapV8$CounterCell", @@ -4084,10 +3765,7 @@ { "name":"sun.misc.Unsafe", "allDeclaredFields":true, - "methods":[ - {"name":"objectFieldOffset","parameterTypes":["java.lang.reflect.Field"] }, - {"name":"putBoolean","parameterTypes":["java.lang.Object","long","boolean"] } - ] + "methods":[{"name":"objectFieldOffset","parameterTypes":["java.lang.reflect.Field"] }, {"name":"putBoolean","parameterTypes":["java.lang.Object","long","boolean"] }] }, { "name":"sun.security.pkcs.SignerInfo[]" diff --git a/src/main/java/io/seqera/tower/cli/commands/computeenvs/ImportCmd.java b/src/main/java/io/seqera/tower/cli/commands/computeenvs/ImportCmd.java index f2afec75..a7333ebc 100644 --- a/src/main/java/io/seqera/tower/cli/commands/computeenvs/ImportCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/computeenvs/ImportCmd.java @@ -14,10 +14,15 @@ import io.seqera.tower.ApiException; import io.seqera.tower.cli.commands.computeenvs.add.AbstractAddCmd; import io.seqera.tower.cli.commands.computeenvs.platforms.Platform; +import io.seqera.tower.cli.exceptions.ComputeEnvNotFoundException; +import io.seqera.tower.cli.exceptions.PipelineNotFoundException; import io.seqera.tower.cli.responses.Response; import io.seqera.tower.cli.utils.FilesHelper; import io.seqera.tower.model.ComputeConfig; import io.seqera.tower.model.ComputeEnv; +import io.seqera.tower.model.ComputeEnvDbDto; +import io.seqera.tower.model.ComputeEnvResponseDto; +import io.seqera.tower.model.PipelineDbDto; import picocli.CommandLine; import java.io.IOException; @@ -30,14 +35,22 @@ description = "Add a compute environment from file content." ) public class ImportCmd extends AbstractAddCmd { + @CommandLine.Option(names = {"--overwrite"}, description = "Overwrite the compute env if it already exists.", defaultValue = "false") + public Boolean overwrite; @CommandLine.Parameters(index = "0", paramLabel = "FILENAME", description = "File name to import.", arity = "1") Path fileName = null; @Override protected Response exec() throws ApiException, IOException { + ComputeConfig configObj = parseJson(FilesHelper.readString(fileName), ComputeConfig.class); ComputeEnv.PlatformEnum platform = ComputeEnv.PlatformEnum.fromValue(configObj.getDiscriminator()); + + Long wspId = workspaceId(workspace.workspace); + + if (overwrite) deleteCE(name, wspId); + return addComputeEnv(platform, configObj); } @@ -45,4 +58,12 @@ protected Response exec() throws ApiException, IOException { protected Platform getPlatform() { throw new UnsupportedOperationException("Unknown platform"); } + + private void deleteCE(String name, Long wspId) throws ApiException { + try { + ComputeEnvResponseDto ce = computeEnvByRef(wspId, name); + api().deleteComputeEnv(ce.getId(), wspId); + } catch (ComputeEnvNotFoundException ignored) {} + } + } diff --git a/src/main/java/io/seqera/tower/cli/commands/pipelines/ImportCmd.java b/src/main/java/io/seqera/tower/cli/commands/pipelines/ImportCmd.java index b3d78e44..75d6f90d 100644 --- a/src/main/java/io/seqera/tower/cli/commands/pipelines/ImportCmd.java +++ b/src/main/java/io/seqera/tower/cli/commands/pipelines/ImportCmd.java @@ -13,12 +13,14 @@ import io.seqera.tower.ApiException; import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions; +import io.seqera.tower.cli.exceptions.PipelineNotFoundException; import io.seqera.tower.cli.exceptions.TowerException; import io.seqera.tower.cli.responses.Response; import io.seqera.tower.cli.responses.pipelines.PipelinesAdded; import io.seqera.tower.cli.utils.FilesHelper; import io.seqera.tower.model.ComputeEnvResponseDto; import io.seqera.tower.model.CreatePipelineRequest; +import io.seqera.tower.model.PipelineDbDto; import io.seqera.tower.model.WorkflowLaunchRequest; import picocli.CommandLine; @@ -43,6 +45,9 @@ public class ImportCmd extends AbstractPipelinesCmd { @CommandLine.Option(names = {"-c", "--compute-env"}, description = "Compute environment name [default: as defined in json environment file].") public String computeEnv; + @CommandLine.Option(names = {"--overwrite"}, description = "Overwrite the pipeline if it already exists.", defaultValue = "false") + public Boolean overwrite; + @CommandLine.Parameters(index = "0", paramLabel = "FILENAME", description = "File name to import.", arity = "1") Path fileName = null; @@ -73,8 +78,17 @@ protected Response exec() throws ApiException, IOException { launch.setPreRunScript(preRunScriptValue); launch.setPostRunScript(postRunScriptValue); + if (overwrite) deletePipeline(name, wspId); + api().createPipeline(request, wspId); return new PipelinesAdded(workspaceRef(wspId), name); } + + private void deletePipeline(String name, Long wspId) throws ApiException { + try { + PipelineDbDto pipe = pipelineByName(wspId, name); + api().deletePipeline(pipe.getPipelineId(), wspId); + } catch (PipelineNotFoundException ignored) {} + } } diff --git a/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java b/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java index 182a7c0f..3a28fd7b 100644 --- a/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/computeenvs/ComputeEnvsCmdTest.java @@ -364,6 +364,62 @@ void testImport(OutputType format, MockServerClient mock) throws IOException { assertOutput(format, out, new ComputeEnvAdded(ComputeEnv.PlatformEnum.AWS_BATCH.getValue(), "3T6xWeFD63QIuzdAowvSTC", "json", null, USER_WORKSPACE_NAME)); } + @ParameterizedTest + @EnumSource(OutputType.class) + void testImportWithOverwrite(OutputType format, MockServerClient mock) throws IOException { + + mock.when( + request().withMethod("GET").withPath("/compute-envs"), exactly(1) + ).respond( + response().withStatusCode(200).withBody("{" + + "\"computeEnvs\":[" + + "{" + + "\"id\":\"isnEDBLvHDAIteOEF44ow\"," + + "\"name\":\"demo\"," + + "\"platform\":\"aws-batch\"," + + "\"status\":\"AVAILABLE\"," + + "\"message\":null," + + "\"lastUsed\":null," + + "\"primary\":null," + + "\"workspaceName\":null," + + "\"visibility\":null" + + "}" + + "]}" + ).withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/compute-envs/isnEDBLvHDAIteOEF44ow"), exactly(1) + ).respond( + response() + .withStatusCode(200) + .withBody(loadResource("compute_env_view")) + .withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("POST").withPath("/compute-envs").withBody("{\"computeEnv\":{\"name\":\"demo\",\"platform\":\"aws-batch\",\"config\":{\"region\":\"eu-west-1\",\"cliPath\":\"/home/ec2-user/miniconda/bin/aws\",\"workDir\":\"s3://nextflow-ci/jordeu\",\"forge\":{\"type\":\"SPOT\",\"minCpus\":0,\"maxCpus\":123,\"gpuEnabled\":false,\"ebsAutoScale\":true,\"disposeOnDeletion\":true,\"fusionEnabled\":false,\"efsCreate\":true},\"discriminator\":\"aws-batch\"},\"credentialsId\":\"6g0ER59L4ZoE5zpOmUP48D\"}}"), exactly(1) + ).respond( + response().withStatusCode(200).withBody("{\"computeEnvId\":\"3T6xWeFD63QIuzdAowvSTC\"}").withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("DELETE").withPath("/compute-envs/isnEDBLvHDAIteOEF44ow"), + exactly(1) + ).respond( + response().withStatusCode(200) + ); + + mock.when( + request().withMethod("GET").withPath("/credentials").withQueryStringParameter("platformId", "aws-batch"), exactly(1) + ).respond( + response().withStatusCode(200).withBody("{\"credentials\":[{\"id\":\"6g0ER59L4ZoE5zpOmUP48D\",\"name\":\"aws\",\"description\":null,\"discriminator\":\"aws\",\"baseUrl\":null,\"category\":null,\"deleted\":null,\"lastUsed\":\"2021-09-09T07:20:53Z\",\"dateCreated\":\"2021-09-08T05:48:51Z\",\"lastUpdated\":\"2021-09-08T05:48:51Z\"}]}").withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(format, mock, "compute-envs", "import", "--overwrite", tempFile(new String(loadResource("cejson"), StandardCharsets.UTF_8), "ce", "json"), "-n", "demo", "-c", "6g0ER59L4ZoE5zpOmUP48D"); + assertOutput(format, out, new ComputeEnvAdded(ComputeEnv.PlatformEnum.AWS_BATCH.getValue(), "3T6xWeFD63QIuzdAowvSTC", "demo", null, USER_WORKSPACE_NAME)); + } + @ParameterizedTest @EnumSource(OutputType.class) void testPrimaryGet(OutputType format, MockServerClient mock) throws JsonProcessingException { diff --git a/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java b/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java index db7c580c..8d8629ac 100644 --- a/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java +++ b/src/test/java/io/seqera/tower/cli/pipelines/PipelinesCmdTest.java @@ -44,7 +44,6 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.mockserver.client.MockServerClient; -import org.mockserver.matchers.Times; import org.mockserver.model.JsonBody; import org.mockserver.model.MediaType; @@ -68,6 +67,8 @@ class PipelinesCmdTest extends BaseCmdTest { @Test void testUpdate(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep_one_minute"), exactly(1) ).respond( @@ -217,6 +218,8 @@ void testUpdatePipelineInvalidName(MockServerClient mock) { @Test void testAdd(MockServerClient mock) throws IOException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs").withQueryStringParameter("status", "AVAILABLE"), exactly(1) ).respond( @@ -246,6 +249,8 @@ void testAdd(MockServerClient mock) throws IOException { @Test void testAddWithComputeEnv(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs").withQueryStringParameter("status", "AVAILABLE"), exactly(1) ).respond( @@ -275,6 +280,8 @@ void testAddWithComputeEnv(MockServerClient mock) { @Test void testAddWithStagingScripts(MockServerClient mock) throws IOException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs").withQueryStringParameter("status", "AVAILABLE"), exactly(1) ).respond( @@ -304,6 +311,8 @@ void testAddWithStagingScripts(MockServerClient mock) throws IOException { @Test void testMissingComputeEnvironment(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs").withQueryStringParameter("status", "AVAILABLE"), exactly(1) ).respond( @@ -320,6 +329,9 @@ void testMissingComputeEnvironment(MockServerClient mock) { @Test void testDelete(MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep"), exactly(1) ).respond( @@ -341,6 +353,9 @@ void testDelete(MockServerClient mock) { @Test void testDeleteNotFound(MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep_all"), exactly(1) ).respond( @@ -356,6 +371,9 @@ void testDeleteNotFound(MockServerClient mock) { @Test void testDeleteMultipleMatch(MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "hello"), exactly(1) ).respond( @@ -373,6 +391,8 @@ void testDeleteMultipleMatch(MockServerClient mock) { @EnumSource(OutputType.class) void testList(OutputType format, MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines"), exactly(1) ).respond( @@ -399,6 +419,14 @@ void testList(OutputType format, MockServerClient mock) { @Test void testListWithOffset(MockServerClient mock) { + mock.reset(); + + mock.when( + request().withMethod("GET").withPath("/user-info"), exactly(1) + ).respond( + response().withStatusCode(200).withBody(loadResource("user")).withContentType(MediaType.APPLICATION_JSON) + ); + mock.when( request().withMethod("GET").withPath("/pipelines") .withQueryStringParameter("offset", "1") @@ -424,6 +452,8 @@ void testListWithOffset(MockServerClient mock) { @Test void testListWithPage(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines") .withQueryStringParameter("offset", "0") @@ -455,6 +485,8 @@ void testListWithPage(MockServerClient mock) { @Test void testListWithConflictingPageable(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines") .withQueryStringParameter("offset", "0") @@ -473,6 +505,8 @@ void testListWithConflictingPageable(MockServerClient mock) { @Test void testListEmpty(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines"), exactly(1) ).respond( @@ -495,6 +529,8 @@ void testListEmpty(MockServerClient mock) { @Test void testView(MockServerClient mock) throws JsonProcessingException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep_one_minute").withQueryStringParameter("visibility", "all"), exactly(1) ).respond( @@ -550,6 +586,8 @@ void testView(MockServerClient mock) throws JsonProcessingException { @Test void testListFromWorkspace(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/user-info"), exactly(1) ).respond( @@ -578,6 +616,8 @@ void testListFromWorkspace(MockServerClient mock) { @Test void testListFromWorkspaceNotFound(MockServerClient mock) { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/user-info"), exactly(1) ).respond( @@ -599,6 +639,9 @@ void testListFromWorkspaceNotFound(MockServerClient mock) { @Test void testExport(MockServerClient mock) throws JsonProcessingException { + + mock.reset(); + mock.when( request().withMethod("GET").withPath("/pipelines").withQueryStringParameter("search", "sleep"), exactly(1) ).respond( @@ -638,6 +681,8 @@ void testExport(MockServerClient mock) throws JsonProcessingException { @Test void testImport(MockServerClient mock) throws IOException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs"), exactly(1) ).respond( @@ -671,6 +716,8 @@ void testImport(MockServerClient mock) throws IOException { @Test void testImportWithComputeEnv(MockServerClient mock) throws IOException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs"), exactly(1) ).respond( @@ -704,6 +751,8 @@ void testImportWithComputeEnv(MockServerClient mock) throws IOException { @Test void testImportWithoutWorkdir(MockServerClient mock) throws IOException { + mock.reset(); + mock.when( request().withMethod("GET").withPath("/compute-envs"), exactly(1) ).respond( @@ -734,9 +783,79 @@ void testImportWithoutWorkdir(MockServerClient mock) throws IOException { assertEquals(0, out.exitCode); } + @Test + void testImportWithOverwrite(MockServerClient mock) throws IOException { + + mock.reset(); + + mock.when( + request().withMethod("GET").withPath("/compute-envs"), exactly(1) + ).respond( + response().withStatusCode(200).withBody("{\"computeEnvs\":[{\"id\":\"isnEDBLvHDAIteOEF44ow\",\"name\":\"demo\",\"platform\":\"aws-batch\",\"status\":\"AVAILABLE\",\"message\":null,\"lastUsed\":null,\"primary\":null,\"workspaceName\":null,\"visibility\":null}]}").withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/compute-envs/isnEDBLvHDAIteOEF44ow"), exactly(1) + ).respond( + response() + .withStatusCode(200) + .withBody(loadResource("compute_env_view")) + .withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("GET").withPath("/pipelines"), + exactly(1) + ).respond( + response() + .withStatusCode(200) + .withBody(loadResource("pipelines_list")) + .withContentType(MediaType.APPLICATION_JSON) + ); + + mock.when( + request().withMethod("DELETE").withPath("/pipelines/183522618315672"), + exactly(1) + ).respond( + response() + .withStatusCode(200) + ); + + mock.when( + request().withMethod("POST").withPath("/pipelines") + .withBody(JsonBody.json("{" + + "\"name\":\"sleep_one_minute\"," + + "\"launch\":{" + + "\"computeEnvId\":\"isnEDBLvHDAIteOEF44ow\"," + + "\"pipeline\":\"https://github.com/grananda/nextflow-hello\"," + + "\"workDir\":\"s3://nextflow-ci/julio\"," + + "\"revision\":\"main\"," + + "\"resume\":false," + + "\"pullLatest\":false," + + "\"stubRun\":false" + + "}" + + "}")) + .withContentType(MediaType.APPLICATION_JSON), exactly(1) + ).respond( + response() + .withStatusCode(200) + .withBody(loadResource("pipelines_add_response")) + .withContentType(MediaType.APPLICATION_JSON) + ); + + ExecOut out = exec(mock, "pipelines", "import", "--overwrite", tempFile(new String(loadResource("pipelines_add"), StandardCharsets.UTF_8), "data", ".json"), "-n", "sleep_one_minute"); + + assertEquals("", out.stdErr); + assertEquals(new PipelinesAdded(USER_WORKSPACE_NAME, "sleep_one_minute").toString(), out.stdOut); + assertEquals(0, out.exitCode); + } + @ParameterizedTest @EnumSource(OutputType.class) void testApplyLabels(OutputType format, MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET") .withPath("/pipelines") @@ -854,6 +973,9 @@ void testApplyLabels(OutputType format, MockServerClient mock) { @ParameterizedTest @EnumSource(OutputType.class) void testAppendLabels(OutputType format, MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET") .withPath("/pipelines") @@ -943,6 +1065,9 @@ void testAppendLabels(OutputType format, MockServerClient mock) { @ParameterizedTest @EnumSource(OutputType.class) void testRemoveLabels(OutputType format, MockServerClient mock) { + + mock.reset(); + mock.when( request().withMethod("GET") .withPath("/pipelines")