-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support updating the name of Tower entities (#327)
* organization cmd update org name * workspaces cmd update wsp name * pipelines cmd update pipeline name * update reflection files * use 'distribution' instead of 'version' in CI pipeline * update jdk to 17.0.8 * set language level in nativeCompile task options * update reflection files * fix: update pipeline test * actions cmd update actions name * compute-env cmd update CE name * unit tests for CE update cmd * update reflection files
- Loading branch information
1 parent
845d6d7
commit df3870c
Showing
19 changed files
with
611 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,29 @@ | ||
{ | ||
"resources":{ | ||
"includes":[ | ||
{ | ||
"pattern":"\\QMETA-INF/build-info.properties\\E" | ||
}, | ||
{ | ||
"pattern":"\\QMETA-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator\\E" | ||
}, | ||
{ | ||
"pattern":"\\QMETA-INF/services/org.glassfish.jersey.internal.inject.InjectionManagerFactory\\E" | ||
}, | ||
{ | ||
"pattern":"\\QMETA-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable\\E" | ||
} | ||
]}, | ||
"bundles":[ | ||
{ | ||
"name":"org.glassfish.jersey.client.internal.localization", | ||
"locales":["und"] | ||
}, | ||
{ | ||
"name":"org.glassfish.jersey.internal.localization", | ||
"locales":["und"] | ||
}, | ||
{ | ||
"name":"org.glassfish.jersey.media.multipart.internal.localization" | ||
} | ||
] | ||
"includes":[{ | ||
"pattern":"\\QMETA-INF/build-info.properties\\E" | ||
}, { | ||
"pattern":"\\QMETA-INF/services/org.glassfish.hk2.extension.ServiceLocatorGenerator\\E" | ||
}, { | ||
"pattern":"\\QMETA-INF/services/org.glassfish.jersey.internal.inject.InjectionManagerFactory\\E" | ||
}, { | ||
"pattern":"\\QMETA-INF/services/org.glassfish.jersey.internal.spi.AutoDiscoverable\\E" | ||
}, { | ||
"pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt67b/nfkc.nrm\\E" | ||
}, { | ||
"pattern":"java.base:\\Qjdk/internal/icu/impl/data/icudt67b/uprops.icu\\E" | ||
}, { | ||
"pattern":"java.base:\\Qsun/net/idn/uidna.spp\\E" | ||
}, { | ||
"pattern":"java.base:\\Qsun/text/resources/LineBreakIteratorData\\E" | ||
}]}, | ||
"bundles":[{ | ||
"name":"org.glassfish.jersey.client.internal.localization", | ||
"locales":["", "und"] | ||
}, { | ||
"name":"org.glassfish.jersey.internal.localization", | ||
"locales":["", "und"] | ||
}, { | ||
"name":"org.glassfish.jersey.media.multipart.internal.localization" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
[ | ||
] | ||
{ | ||
"types":[ | ||
], | ||
"lambdaCapturingTypes":[ | ||
], | ||
"proxies":[ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/io/seqera/tower/cli/commands/computeenvs/UpdateCmd.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2021, Seqera Labs. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* This Source Code Form is "Incompatible With Secondary Licenses", as | ||
* defined by the Mozilla Public License, v. 2.0. | ||
*/ | ||
|
||
package io.seqera.tower.cli.commands.computeenvs; | ||
|
||
import io.seqera.tower.ApiException; | ||
import io.seqera.tower.cli.commands.global.WorkspaceOptionalOptions; | ||
import io.seqera.tower.cli.exceptions.ComputeEnvNotFoundException; | ||
import io.seqera.tower.cli.exceptions.InvalidResponseException; | ||
import io.seqera.tower.cli.responses.Response; | ||
import io.seqera.tower.cli.responses.computeenvs.ComputeEnvUpdated; | ||
import io.seqera.tower.model.ComputeEnvResponseDto; | ||
import io.seqera.tower.model.UpdateComputeEnvRequest; | ||
import picocli.CommandLine.Command; | ||
import picocli.CommandLine.Mixin; | ||
import picocli.CommandLine.Option; | ||
|
||
import java.io.IOException; | ||
|
||
@Command( | ||
name = "update", | ||
description = "Update compute environments." | ||
) | ||
public class UpdateCmd extends AbstractComputeEnvCmd { | ||
|
||
@Mixin | ||
public ComputeEnvRefOptions computeEnvRefOptions; | ||
|
||
@Mixin | ||
public WorkspaceOptionalOptions workspace; | ||
|
||
@Option(names = {"--new-name"}, description = "Compute environment new name.") | ||
public String newName; | ||
|
||
@Override | ||
protected Response exec() throws ApiException, IOException { | ||
Long wspId = workspaceId(workspace.workspace); | ||
|
||
if (newName != null) { | ||
try { | ||
api().validateComputeEnvName(wspId, newName); | ||
} catch (ApiException ex) { | ||
throw new InvalidResponseException(String.format("Compute environment name '%s' is not valid", newName)); | ||
} | ||
} | ||
ComputeEnvResponseDto ce = describeCE(computeEnvRefOptions, wspId); | ||
|
||
|
||
UpdateComputeEnvRequest req = new UpdateComputeEnvRequest() | ||
.name(newName != null ? newName : ce.getName()); | ||
|
||
api().updateComputeEnv(ce.getId(), req, wspId); | ||
|
||
|
||
return new ComputeEnvUpdated(workspaceRef(wspId), ce.getName()); | ||
|
||
} | ||
|
||
private ComputeEnvResponseDto describeCE(ComputeEnvRefOptions computeEnvRefOptions, Long wspId) throws ComputeEnvNotFoundException, ApiException { | ||
try { | ||
return fetchComputeEnv(computeEnvRefOptions, wspId); | ||
|
||
} catch (ApiException e) { | ||
if (e.getCode() == 403) { | ||
String ref = computeEnvRefOptions.computeEnv.computeEnvId != null | ||
? computeEnvRefOptions.computeEnv.computeEnvId | ||
: computeEnvRefOptions.computeEnv.computeEnvName; | ||
// Customize the forbidden message | ||
throw new ComputeEnvNotFoundException(ref, workspaceRef(wspId)); | ||
} | ||
|
||
throw e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.