Skip to content

Commit

Permalink
chore(update): gen-manifests update (#31)
Browse files Browse the repository at this point in the history
* fix(config): parse 'oauthScopes' stanzas that were incorrectly written (spinnaker#1376)

* refactor(config): remove a pointless try/catch block

* refactor(tests): remove an unused import

* fix(config): parse 'oauthScopes' stanzas that were incorrectly written

The old version of Lombok used in Halyard <=1.21 didn't copy
@JsonProperty annotations to the generated methods. This means Jackson
was seeing the field as 'oAuthScopes' and the getter/setter as a
separate 'oauthScopes' property. The same data would be written to both
properties, and during parsing whichever came last in the file would be
persisted into the object.

With new versions of Lombok (>=1.18.8), the @JsonProperty annotation is
copied to the bean methods, so the 'oauthScopes' property disappears and
Jackson can no longer parse those old files.

This commit adds some methods to support parsing the files generated by
previous versions of Halyard, but will no longer write out the
incorrect duplicate data.

* chore(copyright): add a missing copyright header

* chore(dependencies): Autobump korkVersion (spinnaker#1375)

* fix(core): Fix reading of external files as binary instead of text (spinnaker#1380)

* feat(secret): decrypt secrets before sending to deck (spinnaker#1379)

* feat(secret): decrypt secrets before sending to deck

* code review changes

* chore(dependencies): Autobump korkVersion (spinnaker#1383)

* fix(build): remove old usage of korkVersion (spinnaker#1385)

* chore(dependencies): Autobump korkVersion (spinnaker#1384)

* chore(build): Update cloudbuild.yaml file (spinnaker#1388)

Remove the $REPO_NAME variable from the cloudbuild.yaml file; this is being used
to decide the name of the image to push which will not always correspond to the
image name. In particular, if we start publishing both alpine and ubuntu images
we'll want the image name to have a suffix reflecting that.

* chore(dependencies): Autobump korkVersion (spinnaker#1389)

* chore(dependencies): Autobump korkVersion (spinnaker#1390)

* feat(plugins): adding halyard commands for plugins (spinnaker#1386)

* feat(plugins): adding halyard commands for plugins

* chore(refactor): use toMap instead of a concurrentMap collector

* feat(notifications): Add Github Status support (spinnaker#1374)

* chore(dependencies): Autobump korkVersion (spinnaker#1392)

* feat(plugins): enable/disable downloading plugins (spinnaker#1393)

* chore(dependencies): Autobump korkVersion (spinnaker#1394)

* chore(dependencies): Autobump korkVersion (spinnaker#1395)

* feat(kubernetes): Support for tolerations (spinnaker#1396)

* fix(kubernetes): Added support for tolerationn

Signed-off-by: rverma-nikiai <[email protected]>

* feat(kubernetes): Added support for Tolerations

Added support for tolerations

Signed-off-by: rverma-nikiai <[email protected]>

* feat(kubernetes): Support for tolerations

* fix(kubernetes): Added support for Tolerations, fixed access

* chore(dependencies): Autobump korkVersion (spinnaker#1397)

* feat(artifacts): add feature flag to turn on artifactsRewrite (spinnaker#1398)

* feat(deployments): Update component sizing command to allow container component sizing. (spinnaker#1387)

* feat(deploy/kubernetes): Option to select the image variant to deploy (spinnaker#1401)

* refactor(deploy/kubernetes): Removed duplicated code

* feat(deploy/kubernetes): Option to select the image variant to deploy

Supports `slim` and `ubuntu`, the former being the default.
Ubuntu image supported starting with v1.16.0.

* chore(dependencies): Autobump korkVersion (spinnaker#1403)

* fix(docs): s/Kubenretes/Kubernetes (spinnaker#1402)

* fix(ldap): Fix allowing back blank ldap search base when using search filter (spinnaker#1391)

* chore(dependencies): Autobump korkVersion (spinnaker#1404)

* chore(plugins): rename plugin downloading commands to kebab-case (spinnaker#1408)

* chore(dependencies): Autobump korkVersion (spinnaker#1410)

* refactor(deploy): Adapt to changes in kork-config (spinnaker#1407)

* fix(notifications): fix editing notifications in halyard (spinnaker#1413)

Broken in spinnaker#1374

Closes spinnaker/spinnaker#4834

* chore(dependencies): Autobump korkVersion (spinnaker#1415)

* feat(front50): Support AWS S3 SSE (spinnaker#1399)

* chore(dependencies): Autobump korkVersion (spinnaker#1417)

* chore(dependencies): Autobump korkVersion (spinnaker#1418)

* chore(dependencies): Autobump korkVersion (spinnaker#1419)

* feat(telemetry): adds endpoint and enable settings for stats collection (spinnaker#1406)

* feat(telemetry): adds endpoint and enable settings for telemetry

* chore(dependencies): Autobump korkVersion (spinnaker#1421)

* fix(eks): Halyard doesn't work with new EKS kube config (spinnaker#1382)

Fixes spinnaker/spinnaker#4712

Signed-off-by: Constantin Muraru <[email protected]>

* fix(stats): Replace UUID with ULID as spinnaker instance idententifier (spinnaker#1423)

* feat(secrets): Support SAML metadata as secret (spinnaker#1411)

* chore(dependencies): Autobump korkVersion (spinnaker#1426)

* fix(saml): make email address configurable (spinnaker#1427)

* fix(saml): make email address configurable

* update commands for saml email

* feat(canary): add newrelic as canary service (spinnaker#1422)

* chore(core): Compile using the java compiler (spinnaker#1432)

Only test code is written in groovy, so we never have to worry about
java code depending on groovy code; remove the override that is
causing java source files to be compiled with the groovy compiler.

* fix(kubeconfig): Get contents of local kubeconfig files (spinnaker#1425)

* chore(dependencies): Autobump korkVersion (spinnaker#1433)

* chore(dependencies): Autobump korkVersion (spinnaker#1440)

* feat(plugins): enable plugin config overrides (spinnaker#1439)

* feat(plugins): enable plugin config overrides

* chore(plugins): create getPluginConfigurations in Plugins class

* feat(build): Ubuntu base image support (spinnaker#1438)

* Composing the docker images build by having a shared first stage to build the JAR.
* Release scripts support both default and ubuntu image variants. Fully backward compatible as the existing tagging convention is left untouched, the new ubuntu images have their version tag appended with `-ubuntu`.
* Deleted unused Dockerfile and cloudbuild config files.

*  fix(install): fix the problem with JDK 13.0 (spinnaker#1445)

* feat(signalfx): add endpoint, scope and location configuration (spinnaker#1429)

* feat(secrets/gcs): Support for decrypting spinnaker secrets in GCS (spinnaker#1441)

* feat(monitoring): add new relic monitoring daemon config (spinnaker#1442)

* feat(canary): add new relic monitoring daemon config

* feat(monitoring): replace short description for metric store commands

s/authentication method/metric store

* feat(kubernetes): add flag for Kubernetes custom resources (spinnaker#1436)

* feat(kubernetes): add flag for Kubernetes custom resources

Adds flag `--custom-resources` to specify CRDs that should be cached by clouddriver. Defining custom resources here is required for them to be used in patch and delete pipeline stages.

* feat(kubernetes) validation for customResources and allow setting all fields

* Update docs for custom resources flag

* feat(kubernetes): clean up CLI arguments for adding custom resources

Switched from serialized format for setting fields to only allowing adding custom resource when editing an account.

`--spinnaker-kind` and `--versioned` are optional but are not valid arguments without `--add-custom-resource`.

* feat(kubernetes): fix docs

* chore(dependencies): Autobump korkVersion (spinnaker#1447)

* fix(kubernetes): remove user-facing references to todo(lwander) (spinnaker#1449)

* fix(kubernetes): remove user-facing references to todo(lwander)

* fix(kubernetes): formatting

* test(k8s): Verify propagation of service account name to pod spec. (spinnaker#1450)

* fix(plugins): plugins should be able to reference their own config values (spinnaker#1444)

* fix(halyard): Change deployment to support new Kubernetes API (… (spinnaker#1443)

* chore(core): remove unused jobs feature flag (spinnaker#1451)

* chore(dependencies): Autobump korkVersion (spinnaker#1448)

* refactor(google): Update to latest google credentials style. (spinnaker#1452)

* fix(deployments): Fix sub-service name for HA echo in warning m… (spinnaker#1435)

* feat(slack): Allow configurable slack endpoint (spinnaker#1446)

* chore(dependencies): Autobump korkVersion (spinnaker#1453)

* feat(config): HalconfigDirStruct source of truth, allow override (spinnaker#1454)

* feat(artifacts): add git repo artifact support (spinnaker#1458)

* fix(provider/aws): Support for specifying lifecycle hooks for AWS accounts (spinnaker#1420)

* fix(provider/aws): Support for specifying lifecycle hooks for AWS accounts

* fix(config): fix anonymous Google storage credentials (spinnaker#1462)

* fix(build): Missing Ubuntu image dependency (spinnaker#1464)

* fix(build): `spinnaker` user/group id=1000 in Ubuntu image (spinnaker#1465)

The slim/alpine image uses 1000/1000 as the uid and gid for the `spinnaker` user. Doing the same thing for the Ubuntu image makes it simpler for installers like the Helm chart to use either image variant.

* fix(saml): get saml file path instead of file contents in saml validator (spinnaker#1455)

* fix(saml): get saml file path instead of file contents in saml validator

* remove redundant SecretSessionManager

* fix(artifacts/gitrepo): use Boolean class instead of primitive (spinnaker#1466)

* feat(halyard/localfiles): Support relative local files in hal config (spinnaker#1416)

* feat(localfiles): Support relative local files to hal config home

Usually when referencing local files in main hal config with a relative
path, halyard throws this error:

Problems in Global:
! ERROR Failed to backup user file: default/files/kubeconfig-main

- Failed to generate config.

With this change, relative files will be automatically resolved relative
from hal config home.

* feat(localfiles): Only prefix files in subdirectories of input prefix

* feat(halyard/localfiles): Use getter for hal config directory

* feat(halyard/localfiles): Error on relative files escaping hal home

* feat(localfiles): Normalize path on comparison for removing prefix

* chore(localfiles): Paths for building a path instead of string concat

* chore(localfiles): Save field references to child nodes

* chore(localfiles): Removed {%halconfig-dir%}, moved some code to parser

* chore(localfiles): Support backups made with {%halconfig-dir%}

* chore(localfiles): Support backups made with {%halconfig-dir%}

* chore(localfiles): Using java Path instead of string handling

* chore(localfiles): New FileService for getting file paths and contents

* chore(localfiles): Use FileService for getting files

* chore(dependencies): Autobump korkVersion (spinnaker#1460)

* feat(mergify): Allow OSS approvers to autosubmit (spinnaker#1470)

* chore(dependencies): Autobump korkVersion (spinnaker#1469)

* chore(dependencies): Autobump korkVersion (spinnaker#1471)

* feat(huaweicloud): first commit for huaweicloud (spinnaker#1461)

* feat(huaweicloud): first commit for huaweicloud

    r 3e29b2c feat(huaweicloud): first commit for huaweicloud
    r 14f49c4 feat(huaweicloud): add commands about account

* feat(huaweicloud): add commands of account

    r 3e29b2c feat(huaweicloud): first commit for huaweicloud
    r 14f49c4 feat(huaweicloud): add commands about account

* refactor(huaweicloud): add validator and change the way to input password

* feat(huaweicloud): add commands of bakery

* style(huaweicloud): add missed copyrights

* style(huaweicloud): make code simple

* Revert "feat(huaweicloud): first commit for huaweicloud (spinnaker#1461)" (spinnaker#1473)

This reverts commit d35767d.

* fix(deployments): Fixed k8s manifests templates generating invalid yaml (spinnaker#1456)

manifest templates were adding unnecessary commas when podAnnotations, podLabels, or serviceLabels were supplied causing deployments to fail.

* chore(dependencies): Autobump korkVersion (spinnaker#1475)

* chore(dependencies): Autobump korkVersion (spinnaker#1477)

* feat(huaweicloud): add provider of huaweicloud (spinnaker#1476)

* feat(huaweicloud): first commit for huaweicloud

    r 3e29b2c feat(huaweicloud): first commit for huaweicloud
    r 14f49c4 feat(huaweicloud): add commands about account

* feat(huaweicloud): add commands of account

    r 3e29b2c feat(huaweicloud): first commit for huaweicloud
    r 14f49c4 feat(huaweicloud): add commands about account

* refactor(huaweicloud): add validator and change the way to input password

* feat(huaweicloud): add commands of bakery

* style(huaweicloud): add missed copyrights

* style(huaweicloud): make code simple

* fix(huaweicloud): fix the bakery validate exception

* chore(dependencies): Autobump korkVersion (spinnaker#1478)

* chore(tools): Pulled latest changes from upstream master

* chore(logging): Log validation problems
  • Loading branch information
german-muzquiz authored and ncknt committed Dec 10, 2019
1 parent a6df74e commit cce821c
Show file tree
Hide file tree
Showing 59 changed files with 1,966 additions and 455 deletions.
34 changes: 34 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pull_request_rules:
- name: Automatically merge on CI success and review
conditions:
- status-success=continuous-integration/travis-ci/pr
- "label=ready to merge"
- "approved-reviews-by=@oss-approvers"
actions:
merge:
method: squash
strict: smart
label:
add: ["auto merged"]
- name: Automatically merge PRs from maintainers on CI success and review
conditions:
- status-success=continuous-integration/travis-ci/pr
- "label=ready to merge"
- "author=@oss-approvers"
actions:
merge:
method: squash
strict: smart
label:
add: ["auto merged"]
- name: Automatically merge kork autobump PRs on CI success
conditions:
- status-success=continuous-integration/travis-ci/pr
- "label~=autobump-*"
- "author:spinnakerbot"
actions:
merge:
method: squash
strict: smart
label:
add: ["auto merged"]
3 changes: 2 additions & 1 deletion Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV AWS_CLI_VERSION=1.16.208
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y \
openjdk-8-jre-headless \
curl \
python-pip && \
pip install awscli==${AWS_CLI_VERSION} --upgrade
Expand All @@ -24,6 +25,6 @@ RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECT
RUN curl -o /usr/local/bin/aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/${KUBECTL_RELEASE}/${AWS_BINARY_RELEASE_DATE}/bin/linux/amd64/aws-iam-authenticator && \
chmod +x /usr/local/bin/aws-iam-authenticator

RUN adduser --disabled-login --system spinnaker
RUN adduser --disabled-login --system --group --uid 1000 spinnaker
USER spinnaker
CMD "/opt/halyard/bin/halyard"
366 changes: 366 additions & 0 deletions docs/commands.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Mon Oct 28 20:24:06 UTC 2019
#Mon Dec 09 19:56:50 UTC 2019
enablePublishing=false
korkVersion=6.15.1
korkVersion=6.22.1
org.gradle.parallel=true
1 change: 0 additions & 1 deletion halyard-backup/halyard-backup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ dependencies {

implementation project(':halyard-config')
implementation project(':halyard-core')
implementation project(':halyard-deploy')
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@

package com.netflix.spinnaker.halyard.backup.services.v1;

import static com.netflix.spinnaker.halyard.core.problem.v1.Problem.Severity.FATAL;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;

import com.netflix.spinnaker.halyard.config.config.v1.HalconfigDirectoryStructure;
import com.netflix.spinnaker.halyard.config.config.v1.HalconfigParser;
import com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig;
import com.netflix.spinnaker.halyard.config.model.v1.node.LocalFile;
import com.netflix.spinnaker.halyard.config.model.v1.node.Node;
import com.netflix.spinnaker.halyard.config.services.v1.FileService;
import com.netflix.spinnaker.halyard.core.error.v1.HalException;
import com.netflix.spinnaker.halyard.core.problem.v1.Problem;
import java.io.BufferedOutputStream;
Expand All @@ -33,9 +37,9 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Objects;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveException;
Expand All @@ -44,6 +48,7 @@
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

Expand All @@ -54,23 +59,40 @@ public class BackupService {

@Autowired HalconfigDirectoryStructure directoryStructure;

@Autowired private FileService fileService;

static String[] omitPaths = {"service-logs"};

public void restore(String backupTar) {
String halconfigDir = directoryStructure.getHalconfigDirectory();
untarHalconfig(halconfigDir, backupTar);

// This is only needed to support old backups where file paths were prefixed with
// {%halconfig-dir%}
Halconfig halconfig = halconfigParser.getHalconfig();
halconfig.makeLocalFilesAbsolute(halconfigDir);
removeHalconfigDirPrefix(halconfig);
halconfigParser.saveConfig();
}

/**
* Removes {@link
* com.netflix.spinnaker.halyard.config.model.v1.node.LocalFile#RELATIVE_PATH_PLACEHOLDER}
* instances from a backup. This is held for backwards compatibility reading old backups, new
* backups don't use the prefix and relative file paths are always resolved to hal config home.
*
* @param halconfig instance from backup.
*/
@Deprecated
private void removeHalconfigDirPrefix(Halconfig halconfig) {
makeAbsoluteFilesRelative(halconfig, LocalFile.RELATIVE_PATH_PLACEHOLDER);
}

public String create() {
String halconfigDir = directoryStructure.getHalconfigDirectory();
halconfigParser.backupConfig();
Halconfig halconfig = halconfigParser.getHalconfig();
halconfig.backupLocalFiles(directoryStructure.getBackupConfigDependenciesPath().toString());
halconfig.makeLocalFilesRelative(halconfigDir);
backupLocalFiles(halconfig, directoryStructure.getBackupConfigDependenciesPath().toString());
makeAbsoluteFilesRelative(halconfig, halconfigDir);
halconfigParser.saveConfig();

SimpleDateFormat dateFormatter =
Expand Down Expand Up @@ -211,4 +233,74 @@ private void addFileToTar(
e);
}
}

public List<String> backupLocalFiles(Node node, String outputPath) {
List<String> files = new ArrayList<>();

Consumer<Node> fileFinder =
n ->
files.addAll(
n.localFiles().stream()
.map(
f -> {
try {
Path fPath = fileService.getLocalFilePath(n.getStringFieldValue(f));
if (fPath == null) {
return null;
}
File fFile = fPath.toFile();
String fName = fFile.getName().replaceAll("[^-._a-zA-Z0-9]", "-");

// Hash the path to uniquely flatten all files into the output directory
Path newName =
Paths.get(outputPath, Math.abs(fPath.hashCode()) + "-" + fName);
File parent = newName.toFile().getParentFile();
if (!parent.exists()) {
parent.mkdirs();
} else if (fFile.getParent() != null
&& fFile.getParent().equals(parent.toString())) {
// Don't move paths that are already in the right folder
return fPath.toString();
}
Files.copy(fPath, newName, REPLACE_EXISTING);

n.setStringFieldValue(f, newName.toString());
return newName.toString();
} catch (IOException e) {
throw new HalException(
FATAL, "Failed to backup user file: " + e.getMessage(), e);
}
})
.filter(Objects::nonNull)
.collect(Collectors.toList()));
node.recursiveConsume(fileFinder);

return files;
}

/**
* Changes all file paths of Halconfig and beginning with "root" from being absolute, to a
* relative path by removing "root".
*
* @param halconfig instance to transform.
* @param root prefix to remove from the local path.
*/
private void makeAbsoluteFilesRelative(Halconfig halconfig, String root) {
halconfig.recursiveConsume(
n ->
n.localFiles()
.forEach(
field -> {
String fPath = n.getStringFieldValue(field);
if (StringUtils.isEmpty(fPath)) {
return;
}
Path localPath = Paths.get(fPath);
if (localPath.isAbsolute() || localPath.startsWith(root)) {
Path rootPath = Paths.get(root);
Path relativePath = rootPath.relativize(localPath);
n.setStringFieldValue(field, relativePath.toString());
}
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class GitRepoAddArtifactAccountCommand extends AbstractAddArtifactAccount
@Parameter(
names = "--ssh-trust-unknown-hosts",
description = "Setting this to true allows Spinnaker to authenticate with unknown hosts")
private Boolean sshTrustUnknownHosts = null;
private Boolean sshTrustUnknownHosts;

@Override
protected ArtifactAccount buildArtifactAccount(String accountName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class GitRepoEditArtifactAccountCommand
@Parameter(
names = "--ssh-trust-unknown-hosts",
description = "Setting this to true allows Spinnaker to authenticate with unknown hosts")
private Boolean sshTrustUnknownHosts = null;
private Boolean sshTrustUnknownHosts;

@Override
protected ArtifactAccount editArtifactAccount(GitRepoArtifactAccount account) {
Expand All @@ -89,7 +89,7 @@ protected ArtifactAccount editArtifactAccount(GitRepoArtifactAccount account) {
account.setSshKnownHostsFilePath(
isSet(sshKnownHostsFilePath) ? sshKnownHostsFilePath : account.getSshKnownHostsFilePath());
account.setSshTrustUnknownHosts(
isSet(sshTrustUnknownHosts) ? sshTrustUnknownHosts : account.isSshTrustUnknownHosts());
isSet(sshTrustUnknownHosts) ? sshTrustUnknownHosts : account.getSshTrustUnknownHosts());
return account;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.dockerRegistry.DockerRegistryCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.ecs.EcsCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.google.GoogleCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.huaweicloud.HuaweiCloudCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.kubernetes.KubernetesCommand;
import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -52,6 +53,7 @@ public ProviderCommand() {
registerSubcommand(new DockerRegistryCommand());
registerSubcommand(new EcsCommand());
registerSubcommand(new GoogleCommand());
registerSubcommand(new HuaweiCloudCommand());
registerSubcommand(new KubernetesCommand());
registerSubcommand(
new com.netflix.spinnaker.halyard.cli.command.v1.config.providers.oracle.OracleCommand());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2019 Huawei Technologies Co.,Ltd.
*
* 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.providers.huaweicloud;

import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.AbstractAccountCommand;

@Parameters(separators = "=")
public class HuaweiCloudAccountCommand extends AbstractAccountCommand {
protected String getProviderName() {
return "huaweicloud";
}

public HuaweiCloudAccountCommand() {
super();
registerSubcommand(new HuaweiCloudAddAccountCommand());
registerSubcommand(new HuaweiCloudEditAccountCommand());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright 2019 Huawei Technologies Co.,Ltd.
*
* 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.providers.huaweicloud;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractAddAccountCommand;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.huaweicloud.HuaweiCloudAccount;
import java.util.ArrayList;
import java.util.List;

@Parameters(separators = "=")
public class HuaweiCloudAddAccountCommand extends AbstractAddAccountCommand {
protected String getProviderName() {
return "huaweicloud";
}

@Parameter(
names = "--account-type",
description = HuaweiCloudCommandProperties.ACCOUNT_TYPE_DESCRIPTION)
private String accountType;

@Parameter(
names = "--auth-url",
required = true,
description = HuaweiCloudCommandProperties.AUTH_URL_DESCRIPTION)
private String authUrl;

@Parameter(
names = "--username",
required = true,
description = HuaweiCloudCommandProperties.USERNAME_DESCRIPTION)
private String username;

@Parameter(
names = "--password",
required = true,
password = true,
description = HuaweiCloudCommandProperties.PASSWORD_DESCRIPTION)
private String password;

@Parameter(
names = "--project-name",
required = true,
description = HuaweiCloudCommandProperties.PROJECT_NAME_DESCRIPTION)
private String projectName;

@Parameter(
names = "--domain-name",
required = true,
description = HuaweiCloudCommandProperties.DOMAIN_NAME_DESCRIPTION)
private String domainName;

@Parameter(
names = "--regions",
required = true,
variableArity = true,
description = HuaweiCloudCommandProperties.REGIONS_DESCRIPTION)
private List<String> regions = new ArrayList<>();

@Parameter(names = "--insecure", description = HuaweiCloudCommandProperties.INSECURE_DESCRIPTION)
private boolean insecure;

@Override
protected Account buildAccount(String accountName) {
HuaweiCloudAccount account = (HuaweiCloudAccount) new HuaweiCloudAccount().setName(accountName);
account
.setAccountType(accountType)
.setAuthUrl(authUrl)
.setUsername(username)
.setPassword(password)
.setProjectName(projectName)
.setDomainName(domainName)
.setInsecure(insecure)
.setRegions(regions);

return account;
}

@Override
protected Account emptyAccount() {
return new HuaweiCloudAccount();
}
}
Loading

0 comments on commit cce821c

Please sign in to comment.