Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(provider/kubernetes): Don't store-unowned artifacts #1969

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class KubernetesArtifactConverter {
protected String getType(KubernetesManifest manifest) {
return String.join("/",
KubernetesCloudProvider.getID(),
manifest.getApiVersion().toString() + ":" + manifest.getKind().toString()
manifest.getApiVersion().toString() + "|" + manifest.getKind().toString()
);
}

Expand All @@ -48,7 +48,7 @@ private String[] getLatterType(Artifact artifact) {
throw new IllegalArgumentException("Not a kubernetes artifact: " + artifact);
}

split = String.join("/", Arrays.copyOfRange(split, 1, split.length)).split(":");
split = String.join("/", Arrays.copyOfRange(split, 1, split.length)).split("\\|");

if (split.length != 2) {
throw new IllegalArgumentException("Not a kubernetes artifact: " + artifact);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public class KubernetesCacheDataConverter {
public static CacheData convertAsArtifact(String account, ObjectMapper mapper, Object resource) {
KubernetesManifest manifest = mapper.convertValue(resource, KubernetesManifest.class);
Artifact artifact = KubernetesManifestAnnotater.getArtifact(manifest);
if (artifact.getType() == null) {
log.info("No assigned artifact type for this resource.");
return null;
}

Map<String, Object> attributes = new ImmutableMap.Builder<String, Object>()
.put("artifact", artifact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public DeploymentResult operate(List _unused) {
getTask().updateStatus(OP_NAME, "Beginning deployment of manifest...");

KubernetesManifest manifest = description.getManifest();
if (StringUtils.isEmpty(manifest.getNamespace())) {
manifest.setNamespace(credentials.getDefaultNamespace());
}

KubernetesResourceProperties properties = findResourceProperties(manifest);
KubernetesDeployer deployer = properties.getDeployer();
KubernetesArtifactConverter converter = properties.getConverter();
Expand All @@ -75,10 +79,6 @@ public DeploymentResult operate(List _unused) {
Moniker moniker = description.getMoniker();
KubernetesManifestSpinnakerRelationships relationships = description.getRelationships();

if (StringUtils.isEmpty(manifest.getNamespace())) {
manifest.setNamespace(credentials.getDefaultNamespace());
}

getTask().updateStatus(OP_NAME, "Annotating manifest with artifact, relationships & moniker...");
KubernetesManifestAnnotater.annotateManifest(manifest, artifact);
KubernetesManifestAnnotater.annotateManifest(manifest, relationships);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class KubernetesUnversionedArtifactConverterSpec extends Specification {
@Unroll
def "correctly infer unversioned artifact properties"() {
expect:
def type = "kubernetes/$apiVersion:$kind"
def type = "kubernetes/$apiVersion|$kind"

def artifact = Artifact.builder()
.type(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class KubernetesVersionedArtifactConverterSpec extends Specification {
@Unroll
def "correctly infer versioned artifact properties"() {
expect:
def type = "kubernetes/$apiVersion:$kind"
def type = "kubernetes/$apiVersion|$kind"

def artifact = Artifact.builder()
.type(type)
Expand Down