Skip to content

Commit

Permalink
refactor(provider/kubernetes): remove obsolete source check (#2283)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored Jan 9, 2018
1 parent a496273 commit 87b76ec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class KubernetesDeployManifestConverter extends AbstractAtomicOperationsC

@Override
public AtomicOperation convertOperation(Map input) {
return new KubernetesDeployManifestOperation(convertDescription(input), registry, artifactProvider, artifactDownloader);
return new KubernetesDeployManifestOperation(convertDescription(input), registry, artifactProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package com.netflix.spinnaker.clouddriver.kubernetes.v2.op.manifest;

import com.netflix.spinnaker.clouddriver.artifacts.ArtifactDownloader;
import com.netflix.spinnaker.clouddriver.data.task.Task;
import com.netflix.spinnaker.clouddriver.data.task.TaskRepository;
import com.netflix.spinnaker.clouddriver.kubernetes.KubernetesCloudProvider;
Expand All @@ -41,29 +40,24 @@
import com.netflix.spinnaker.moniker.Namer;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static com.netflix.spinnaker.clouddriver.kubernetes.v2.description.manifest.KubernetesDeployManifestDescription.Source.text;

public class KubernetesDeployManifestOperation implements AtomicOperation<OperationResult> {
private final KubernetesDeployManifestDescription description;
private final KubernetesV2Credentials credentials;
private final ArtifactDownloader artifactDownloader;
private final ArtifactProvider provider;
private final Namer namer;
private final KubernetesResourcePropertyRegistry registry;
private static final String OP_NAME = "DEPLOY_KUBERNETES_MANIFEST";

public KubernetesDeployManifestOperation(KubernetesDeployManifestDescription description, KubernetesResourcePropertyRegistry registry, ArtifactProvider provider, ArtifactDownloader artifactDownloader) {
public KubernetesDeployManifestOperation(KubernetesDeployManifestDescription description, KubernetesResourcePropertyRegistry registry, ArtifactProvider provider) {
this.description = description;
this.credentials = (KubernetesV2Credentials) description.getCredentials().getCredentials();
this.registry = registry;
this.provider = provider;
this.artifactDownloader = artifactDownloader;
this.namer = NamerRegistry.lookup()
.withProvider(KubernetesCloudProvider.getID())
.withAccount(description.getCredentials().getName())
Expand All @@ -78,23 +72,7 @@ private static Task getTask() {
public OperationResult operate(List _unused) {
getTask().updateStatus(OP_NAME, "Beginning deployment of manifest...");

KubernetesManifest manifest;
KubernetesDeployManifestDescription.Source source = description.getSource();
source = source == null ? text : source;
switch (source) {
case text:
manifest = description.getManifest();
break;
case artifact:
try {
manifest = artifactDownloader.downloadAsYaml(description.getManifestArtifact(), KubernetesManifest.class);
} catch (IOException e) {
throw new IllegalStateException("Failed to fetch artifact '" + description.getManifestArtifact() + "'", e);
}
break;
default:
throw new IllegalArgumentException("Unsupported artifact source: " + source);
}
KubernetesManifest manifest = description.getManifest();

if (StringUtils.isEmpty(manifest.getNamespace())) {
manifest.setNamespace(credentials.getDefaultNamespace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ metadata:
.withAccount(ACCOUNT)
.setNamer(KubernetesManifest.class, new KubernetesManifestNamer())

def deployOp = new KubernetesDeployManifestOperation(deployDescription, registry, null, null)
def deployOp = new KubernetesDeployManifestOperation(deployDescription, registry, null)

return deployOp
}
Expand Down

0 comments on commit 87b76ec

Please sign in to comment.