-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(codebuild): Add support for manipulating AWS CodeBuild accounts (#…
- Loading branch information
1 parent
eff6b69
commit e21b588
Showing
15 changed files
with
665 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
...netflix/spinnaker/halyard/cli/command/v1/config/ci/account/AbstractGetAccountCommand.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,48 @@ | ||
/* | ||
* Copyright 2020 Amazon, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.netflix.spinnaker.halyard.cli.command.v1.config.ci.account; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon; | ||
import com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler; | ||
import com.netflix.spinnaker.halyard.cli.ui.v1.AnsiFormatUtils; | ||
import com.netflix.spinnaker.halyard.config.model.v1.node.CIAccount; | ||
import lombok.Getter; | ||
|
||
@Parameters(separators = "=") | ||
public abstract class AbstractGetAccountCommand<T extends CIAccount> | ||
extends AbstractHasAccountCommand { | ||
@Getter private String commandName = "get"; | ||
|
||
public String getShortDescription() { | ||
return "Get the account details for " + getCiFullName() + "."; | ||
} | ||
|
||
@Override | ||
protected void executeThis() { | ||
String currentDeployment = getCurrentDeployment(); | ||
String masterName = getAccountName(); | ||
String ciName = getCiName(); | ||
new OperationHandler<CIAccount>() | ||
.setOperation(Daemon.getMaster(currentDeployment, ciName, masterName, !noValidate)) | ||
.setFailureMesssage(String.format("Failed to get %s account.", getCiFullName())) | ||
.setFormat(AnsiFormatUtils.Format.STRING) | ||
.setUserFormatted(true) | ||
.get(); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...flix/spinnaker/halyard/cli/command/v1/config/ci/codebuild/AwsCodeBuildAccountCommand.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,56 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.netflix.spinnaker.halyard.cli.command.v1.config.ci.codebuild; | ||
|
||
import com.beust.jcommander.Parameters; | ||
import com.netflix.spinnaker.halyard.cli.command.v1.config.ci.AbstractAccountCommand; | ||
|
||
/** Interact with AWS CodeBuild's accounts */ | ||
@Parameters(separators = "=") | ||
public class AwsCodeBuildAccountCommand extends AbstractAccountCommand { | ||
protected String getCiName() { | ||
return "codebuild"; | ||
} | ||
|
||
@Override | ||
protected String getCiFullName() { | ||
return "AWS CodeBuild"; | ||
} | ||
|
||
@Override | ||
public String getCommandName() { | ||
return "account"; | ||
} | ||
|
||
public AwsCodeBuildAccountCommand() { | ||
super(); | ||
registerSubcommand(new AwsCodeBuildAddAccountCommand()); | ||
registerSubcommand(new AwsCodeBuildEditAccountCommand()); | ||
registerSubcommand(new AwsCodeBuildGetAccountCommand()); | ||
} | ||
|
||
@Override | ||
public String getShortDescription() { | ||
return "Manage and view Spinnaker configuration for AWS CodeBuild service account."; | ||
} | ||
|
||
@Override | ||
protected void executeThis() { | ||
showHelp(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...x/spinnaker/halyard/cli/command/v1/config/ci/codebuild/AwsCodeBuildAddAccountCommand.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,61 @@ | ||
/* | ||
* Copyright 2020 Amazon.com, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License") | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.halyard.cli.command.v1.config.ci.codebuild; | ||
|
||
import com.beust.jcommander.Parameter; | ||
import com.beust.jcommander.Parameters; | ||
import com.netflix.spinnaker.halyard.cli.command.v1.config.ci.account.AbstractAddAccountCommand; | ||
import com.netflix.spinnaker.halyard.config.model.v1.ci.codebuild.AwsCodeBuildAccount; | ||
|
||
@Parameters(separators = "=") | ||
public class AwsCodeBuildAddAccountCommand extends AbstractAddAccountCommand { | ||
protected String getCiName() { | ||
return "codebuild"; | ||
} | ||
|
||
@Override | ||
protected String getCiFullName() { | ||
return "AWS CodeBuild"; | ||
} | ||
|
||
@Parameter( | ||
names = "--account-id", | ||
required = true, | ||
description = AwsCodeBuildCommandProperties.ACCOUNT_ID_DESCRIPTION) | ||
private String accountId; | ||
|
||
@Parameter( | ||
names = "--assume-role", | ||
required = true, | ||
description = AwsCodeBuildCommandProperties.ASSUME_ROLE_DESCRIPTION) | ||
private String assumeRole; | ||
|
||
@Parameter( | ||
names = "--region", | ||
required = true, | ||
description = AwsCodeBuildCommandProperties.REGION_DESCRIPTION) | ||
private String region; | ||
|
||
@Override | ||
protected AwsCodeBuildAccount buildAccount(String accountName) { | ||
return new AwsCodeBuildAccount() | ||
.setName(accountName) | ||
.setAccountId(accountId) | ||
.setAssumeRole(assumeRole) | ||
.setRegion(region); | ||
} | ||
} |
Oops, something went wrong.