Skip to content

Commit

Permalink
feat(provider/kubernetes): Deploy baked docker images (#3588)
Browse files Browse the repository at this point in the history
  • Loading branch information
brujoand authored and danielpeach committed Apr 27, 2017
1 parent ff79bda commit 7af5217
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions app/scripts/modules/kubernetes/cluster/configure/CommandBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ module.exports = angular.module('spinnaker.kubernetes.clusterCommandBuilder.serv
}

function buildImageId(image) {
if (image.fromContext) {
if (image.fromFindImage) {
return `${image.cluster} ${image.pattern}`;
} else if (image.fromBake) {
return `${image.repository} (Baked during execution)`;
} else if (image.fromTrigger && !image.tag) {
return `${image.registry}/${image.repository} (Tag resolved at runtime)`;
} else {
Expand Down Expand Up @@ -173,7 +175,7 @@ module.exports = angular.module('spinnaker.kubernetes.clusterCommandBuilder.serv
return result;
}

function findUpstreamImages(current, all, visited = {}) {
function findContextImages(current, all, visited = {}) {
// This actually indicates a loop in the stage dependencies.
if (visited[current.refId]) {
return [];
Expand All @@ -184,16 +186,25 @@ module.exports = angular.module('spinnaker.kubernetes.clusterCommandBuilder.serv
if (current.type === 'findImage') {
result.push({
fromContext: true,
fromFindImage: true,
cluster: current.cluster,
pattern: current.imageNamePattern,
repository: current.name,
stageId: current.refId
});
} else if (current.type === 'bake') {
result.push({
fromContext: true,
fromBake: true,
repository: current.ami_name,
organization: current.organization,
stageId: current.refId
});
}
current.requisiteStageRefIds.forEach(function(id) {
let next = all.find((stage) => stage.refId === id);
if (next) {
result = result.concat(findUpstreamImages(next, all, visited));
result = result.concat(findContextImages(next, all, visited));
}
});

Expand All @@ -216,7 +227,7 @@ module.exports = angular.module('spinnaker.kubernetes.clusterCommandBuilder.serv
}

function buildNewClusterCommandForPipeline(current, pipeline) {
let contextImages = findUpstreamImages(current, pipeline.stages) || [];
let contextImages = findContextImages(current, pipeline.stages) || [];
contextImages = contextImages.concat(findTriggerImages(pipeline.triggers));
return {
strategy: '',
Expand All @@ -232,7 +243,7 @@ module.exports = angular.module('spinnaker.kubernetes.clusterCommandBuilder.serv

function buildClusterCommandFromPipeline(app, originalCommand, current, pipeline) {
let command = _.cloneDeep(originalCommand);
let contextImages = findUpstreamImages(current, pipeline.stages) || [];
let contextImages = findContextImages(current, pipeline.stages) || [];
contextImages = contextImages.concat(findTriggerImages(pipeline.triggers));
command.containers = reconcileUpstreamImages(command.containers, contextImages);
command.containers.map((container) => {
Expand Down

0 comments on commit 7af5217

Please sign in to comment.