Skip to content

Commit d52e319

Browse files
committed
Add --name option for storage profile clis.
1 parent 92c11da commit d52e319

File tree

8 files changed

+20
-17
lines changed

8 files changed

+20
-17
lines changed

admin-cli/src/main/java/cloud/katta/cli/commands/hub/AbstractStorageProfile.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ public abstract class AbstractStorageProfile extends AbstractAuthorizationCode i
1919
@CommandLine.Option(names = {"--uuid"}, description = "The uuid.", required = true)
2020
String uuid;
2121

22+
@CommandLine.Option(names = {"--name"}, description = "The name.", required = true)
23+
String name;
24+
2225
@Override
2326
public Void call() throws Exception {
2427
final String accessToken = login();
25-
call(hubUrl, accessToken, uuid);
28+
call(hubUrl, accessToken, uuid, name);
2629
return null;
2730
}
2831

29-
protected void call(final String hubUrl, final String accessToken, final String uuid) throws ApiException {
32+
protected void call(final String hubUrl, final String accessToken, final String uuid, final String name) throws ApiException {
3033
final ApiClient apiClient = new ApiClient();
3134
apiClient.setBasePath(hubUrl);
3235
apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
33-
call(UUID.fromString(uuid), apiClient);
36+
call(UUID.fromString(uuid), name, apiClient);
3437
}
3538

36-
37-
protected abstract void call(final UUID uuid, final ApiClient apiClient) throws ApiException;
39+
protected abstract void call(final UUID uuid, final String name, final ApiClient apiClient) throws ApiException;
3840
}

admin-cli/src/main/java/cloud/katta/cli/commands/hub/StorageProfileArchive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
public class StorageProfileArchive extends AbstractStorageProfile {
2525

2626
@Override
27-
protected void call(final UUID uuid, final ApiClient apiClient) throws ApiException {
27+
protected void call(final UUID uuid, final String name, final ApiClient apiClient) throws ApiException {
2828
final StorageProfileResourceApi storageProfileResourceApi = new StorageProfileResourceApi(apiClient);
2929
call(uuid, storageProfileResourceApi);
3030
}

admin-cli/src/main/java/cloud/katta/cli/commands/hub/StorageProfileAwsStaticSetup.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
public class StorageProfileAwsStaticSetup extends AbstractStorageProfile {
2727

2828
@Override
29-
protected void call(final UUID uuid, final ApiClient apiClient) throws ApiException {
29+
protected void call(final UUID uuid, final String name, final ApiClient apiClient) throws ApiException {
3030
final StorageProfileResourceApi storageProfileResourceApi = new StorageProfileResourceApi(apiClient);
3131

32-
call(uuid, storageProfileResourceApi);
32+
call(uuid, name, storageProfileResourceApi);
3333
}
3434

35-
protected void call(UUID uuid, StorageProfileResourceApi storageProfileResourceApi) throws ApiException {
35+
protected void call(final UUID uuid, final String name, final StorageProfileResourceApi storageProfileResourceApi) throws ApiException {
3636
storageProfileResourceApi.apiStorageprofileS3staticPost(new StorageProfileS3StaticDto()
3737
.id(uuid)
38-
.name("AWS S3 static")
38+
.name(name)
3939
.protocol(Protocol.S3_STATIC)
4040
.storageClass(S3STORAGECLASSES.STANDARD)
4141
.archived(false)

admin-cli/src/main/java/cloud/katta/cli/commands/hub/StorageProfileAwsStsSetup.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ public class StorageProfileAwsStsSetup extends AbstractStorageProfile {
3535
String bucketPrefix;
3636

3737
@Override
38-
protected void call(final UUID uuid, final ApiClient apiClient) throws ApiException {
38+
protected void call(final UUID uuid, final String name, final ApiClient apiClient) throws ApiException {
3939
final StorageProfileResourceApi storageProfileResourceApi = new StorageProfileResourceApi(apiClient);
4040

41-
call(uuid, storageProfileResourceApi);
41+
call(uuid, name, storageProfileResourceApi);
4242
}
4343

44-
protected void call(UUID uuid, StorageProfileResourceApi storageProfileResourceApi) throws ApiException {
44+
protected void call(final UUID uuid, final String name, final StorageProfileResourceApi storageProfileResourceApi) throws ApiException {
4545
storageProfileResourceApi.apiStorageprofileS3stsPost(new StorageProfileS3STSDto()
4646
.id(uuid)
47-
.name("AWS S3 STS")
47+
.name(name)
4848
.bucketPrefix(bucketPrefix)
4949
.protocol(Protocol.S3_STS)
5050
.storageClass(S3STORAGECLASSES.STANDARD)

admin-cli/src/test/java/cloud/katta/cli/commands/hub/StorageProfileArchiveIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testStorageProfileArchive() throws Exception {
5454
assertTrue(profile.isPresent());
5555
assertFalse(profile.get().getArchived());
5656
}
57-
new StorageProfileArchive().call("http://localhost:8280", accessToken, storageProfileId);
57+
new StorageProfileArchive().call("http://localhost:8280", accessToken, storageProfileId, "S3 static");
5858
{
5959
final Optional<StorageProfileS3StaticDto> profile = storageProfileResourceApi.apiStorageprofileGet(null).stream().filter(p -> StorageProfileDtoWrapper.coerce(p).getId().toString().toLowerCase().equals(storageProfileId)).map(StorageProfileDto::getActualInstance).map(StorageProfileS3StaticDto.class::cast).findFirst();
6060
assertTrue(profile.isPresent());

admin-cli/src/test/java/cloud/katta/cli/commands/hub/StorageProfileAwsStaticSetupTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void testCall() throws ApiException {
2424
final StorageProfileResourceApi api = Mockito.mock(StorageProfileResourceApi.class);
2525
final UUID vaultId = UUID.randomUUID();
2626
final StorageProfileAwsStaticSetup cli = new StorageProfileAwsStaticSetup();
27-
cli.call(vaultId, api);
27+
cli.call(vaultId, "AWS S3 static", api);
2828

2929
final StorageProfileS3StaticDto dto = new StorageProfileS3StaticDto();
3030
dto.setId(vaultId);

admin-cli/src/test/java/cloud/katta/cli/commands/hub/StorageProfileAwsStsSetupIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void testStorageProfileAwsStsSetup() throws Exception {
3535
"--hubUrl", "http://localhost:8280",
3636
"--accessToken", accessToken,
3737
"--uuid", storageProfileId.toString(),
38+
"--name", "AWS S3 STS",
3839
"--rolePrefix", "arn:aws:iam::linguine:role/farfalle"
3940
);
4041
assertEquals(0, rc);

admin-cli/src/test/java/cloud/katta/cli/commands/hub/StorageProfileAwsStsSetupTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void testCall() throws ApiException {
2828
final StorageProfileAwsStsSetup cli = new StorageProfileAwsStsSetup();
2929
cli.bucketPrefix = "fancy";
3030
cli.rolePrefix = "arn:aws:iam::1234:role/testing.katta.cloud-kc-realms-pepper";
31-
cli.call(vaultId, api);
31+
cli.call(vaultId, "AWS S3 STS", api);
3232

3333
final StorageProfileS3STSDto dto = new StorageProfileS3STSDto();
3434
dto.setId(vaultId);

0 commit comments

Comments
 (0)