Skip to content

Commit

Permalink
feat(core): Add Halyard Maven Artifact account support (#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelchio authored and jkschneider committed Feb 8, 2019
1 parent 6a17b5b commit 9906f59
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 1 deletion.
Expand Up @@ -26,6 +26,7 @@
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.gitlab.GitlabArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.helm.HelmArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.http.HttpArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.maven.MavenArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.oracle.OracleArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.s3.S3ArtifactProviderCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.templates.ArtifactTemplateCommand;
Expand Down Expand Up @@ -54,6 +55,7 @@ public ArtifactProviderCommand() {
registerSubcommand(new HttpArtifactProviderCommand());
registerSubcommand(new HelmArtifactProviderCommand());
registerSubcommand(new S3ArtifactProviderCommand());
registerSubcommand(new MavenArtifactProviderCommand());
registerSubcommand((new ArtifactTemplateCommand()));
}

Expand Down
@@ -0,0 +1,48 @@
/*
* Copyright 2019 Pivotal, 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.artifacts.maven;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.account.AbstractAddArtifactAccountCommand;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.maven.MavenArtifactAccount;
import com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount;

@Parameters(separators = "=")
public class MavenAddArtifactAccountCommand extends AbstractAddArtifactAccountCommand {
@Parameter(
names = "--repository-url",
required = true,
description = MavenArtifactCommandProperties.REPOSITORY_URL_DESCRIPTION
)
private String repositoryUrl;

@Override
protected ArtifactAccount buildArtifactAccount(String accountName) {
return new MavenArtifactAccount().setName(accountName).setRepositoryUrl(repositoryUrl);
}

@Override
protected ArtifactAccount emptyArtifactAccount() {
return new MavenArtifactAccount();
}

@Override
protected String getArtifactProviderName() {
return "maven";
}
}
@@ -0,0 +1,33 @@
/*
* Copyright 2019 Pivotal, 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.artifacts.maven;

import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.AbstractArtifactAccountCommand;

@Parameters(separators = "=")
public class MavenArtifactAccountCommand extends AbstractArtifactAccountCommand {
@Override
protected String getArtifactProviderName() {
return "maven";
}

public MavenArtifactAccountCommand() {
registerSubcommand(new MavenAddArtifactAccountCommand());
registerSubcommand(new MavenEditArtifactAccountCommand());
}
}
@@ -0,0 +1,22 @@
/*
* Copyright 2019 Pivotal, 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.artifacts.maven;

public class MavenArtifactCommandProperties {
public static final String REPOSITORY_URL_DESCRIPTION = "Full URI for the "
+ "Maven repository ie. `http://some.host.com/repository/path`";
}
@@ -0,0 +1,32 @@
/*
* Copyright 2019 Pivotal, 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.artifacts.maven;

import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.AbstractNamedArtifactProviderCommand;

@Parameters(separators = "=")
public class MavenArtifactProviderCommand extends AbstractNamedArtifactProviderCommand {
@Override
protected String getArtifactProviderName() {
return "maven";
}

public MavenArtifactProviderCommand() {
registerSubcommand(new MavenArtifactAccountCommand());
}
}
@@ -0,0 +1,44 @@
/*
* Copyright 2019 Pivotal, 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.artifacts.maven;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.artifacts.account.AbstractArtifactEditAccountCommand;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.maven.MavenArtifactAccount;
import com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount;

@Parameters(separators = "=")
public class MavenEditArtifactAccountCommand extends AbstractArtifactEditAccountCommand<MavenArtifactAccount> {
@Parameter(
names = "--repository-url",
description = MavenArtifactCommandProperties.REPOSITORY_URL_DESCRIPTION
)
private String repositoryUrl;

@Override
protected ArtifactAccount editArtifactAccount(MavenArtifactAccount account) {
account.setRepositoryUrl(isSet(repositoryUrl) ? repositoryUrl : account.getRepositoryUrl());

return account;
}

@Override
protected String getArtifactProviderName() {
return "maven";
}
}
@@ -0,0 +1,28 @@
/*
* Copyright 2019 Pivotal, 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.config.model.v1.artifacts.maven;

import com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class MavenArtifactAccount extends ArtifactAccount {
String name;
String repositoryUrl;
}
@@ -0,0 +1,30 @@
/*
* Copyright 2019 Pivotal, 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.config.model.v1.artifacts.maven;

import com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class MavenArtifactProvider extends ArtifactProvider<MavenArtifactAccount> {
@Override
public ProviderType providerType() {
return ProviderType.MAVEN;
}
}
Expand Up @@ -56,7 +56,8 @@ public enum ProviderType {
GITLAB("gitlab"),
HELM("helm"),
HTTP("http"),
S3("s3");
S3("s3"),
MAVEN("maven");

@Getter
final private String name;
Expand Down
Expand Up @@ -25,6 +25,7 @@
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.gitlab.GitlabArtifactProvider;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.helm.HelmArtifactProvider;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.http.HttpArtifactProvider;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.maven.MavenArtifactProvider;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.oracle.OracleArtifactProvider;
import com.netflix.spinnaker.halyard.config.model.v1.artifacts.s3.S3ArtifactProvider;
import lombok.Data;
Expand All @@ -48,6 +49,7 @@ public class Artifacts extends Node {
HttpArtifactProvider http = new HttpArtifactProvider();
HelmArtifactProvider helm = new HelmArtifactProvider();
S3ArtifactProvider s3 = new S3ArtifactProvider();
MavenArtifactProvider maven = new MavenArtifactProvider();
List<ArtifactTemplate> templates = new ArrayList<>();

@Override
Expand Down

0 comments on commit 9906f59

Please sign in to comment.