Skip to content
Closed
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
57 changes: 47 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29779,6 +29779,7 @@ class DeploymentEntry {
* @param {string} params.service_tag - Service image tag
* @param {string} [params.namespace] - Kubernetes namespace
* @param {string} [params.account] - Cloud account identifier
* @param {string} [params.image] - Full container image URL without tag (e.g. "us-east1-docker.pkg.dev/project/repo/service")
*/
constructor({
service_dir,
Expand All @@ -29793,7 +29794,8 @@ class DeploymentEntry {
deployment_folder_path,
service_tag,
namespace,
account
account,
image
}) {
this.service_dir = service_dir;
this.service_name = service_name;
Expand All @@ -29808,6 +29810,7 @@ class DeploymentEntry {
this.service_tag = service_tag;
this.namespace = namespace;
this.account = account;
this.image = image || '';
}

/**
Expand Down Expand Up @@ -29839,6 +29842,7 @@ class DeploymentEntry {
};
if (this.namespace) obj.namespace = this.namespace;
if (this.account) obj.account = this.account;
if (this.image) obj.image = this.image;
return obj;
}
}
Expand Down Expand Up @@ -29985,10 +29989,12 @@ class SkyhookConfig {

/**
* @param {Object} params
* @param {string} [params.registry] - Repo-level container registry prefix
* @param {SkyhookService[]} params.services - Array of service configurations
* @param {SkyhookEnvironment[]} params.environments - Array of environment configurations
*/
constructor({ services = [], environments = [] }) {
constructor({ registry = '', services = [], environments = [] }) {
this.registry = registry;
this.services = services.map(s => new SkyhookService(s));
this.environments = environments.map(e => new SkyhookEnvironment(e));
}
Expand All @@ -30000,10 +30006,12 @@ class SkyhookConfig {
*/
static fromObject(obj) {
return new SkyhookConfig({
registry: obj.registry || '',
services: obj.services || [],
environments: obj.environments || []
});
}

}

/**
Expand All @@ -30018,12 +30026,13 @@ class SkyhookService {
* @param {string} [params.deploymentRepoPath] - Path within deployment repo
* @param {Object} [params.buildTool] - Build tool configuration
*/
constructor({ name, path, deploymentRepo, deploymentRepoPath, buildTool }) {
constructor({ name, path, deploymentRepo, deploymentRepoPath, buildTool, image }) {
this.name = name;
this.path = path;
this.deploymentRepo = deploymentRepo;
this.deploymentRepoPath = deploymentRepoPath;
this.buildTool = buildTool;
this.image = image || '';
}
}

Expand All @@ -30040,13 +30049,14 @@ class SkyhookEnvironment {
* @param {string} [params.location] - Cluster location/zone
* @param {string} [params.namespace] - Kubernetes namespace
*/
constructor({ name, clusterName, cloudProvider, account, location, namespace }) {
constructor({ name, clusterName, cloudProvider, account, location, namespace, registry }) {
this.name = name;
this.clusterName = clusterName;
this.cloudProvider = cloudProvider;
this.account = account;
this.location = location;
this.namespace = namespace;
this.registry = registry || '';
}
}

Expand Down Expand Up @@ -30208,6 +30218,26 @@ module.exports = {
const core = __nccwpck_require__(7484);
const { DeploymentMatrix, DeploymentEntry } = __nccwpck_require__(9439);

/**
* Resolve the full image URL for a service+environment combination.
* Resolution order (highest to lowest precedence):
* 1. service.image — explicit per-service full URL override
* 2. env.registry/serviceName — per-environment registry
* 3. rootRegistry/serviceName — repo-level registry
*
* @param {string} serviceName
* @param {Object} service - Service config (may have .image)
* @param {Object} env - Environment config (may have .registry)
* @param {string} rootRegistry - Repo-level registry from skyhook.yaml root
* @returns {string} Full image URL without tag, or '' if unresolvable
*/
function resolveImage(serviceName, service, env, rootRegistry) {
if (service.image) return service.image;
if (env.registry) return `${env.registry}/${serviceName}`;
if (rootRegistry) return `${rootRegistry}/${serviceName}`;
return '';
}

/**
* Build a DeploymentMatrix from Skyhook services and environments
* @param {Array} services - Array of service configurations from skyhook.yaml
Expand All @@ -30217,10 +30247,11 @@ const { DeploymentMatrix, DeploymentEntry } = __nccwpck_require__(9439);
* @param {string} options.serviceRepo - Source repository (e.g., "KoalaOps/orbit")
* @param {string} [options.envFilter] - Environment filter (optional)
* @param {Map<string, number>} [options.serviceCounters] - Per-service counters from Koala
* @param {string} [options.rootRegistry] - Repo-level registry prefix from skyhook.yaml
* @returns {DeploymentMatrix}
*/
function buildMatrixFromSkyhook(services, environments, options = {}) {
const { tag, serviceRepo, envFilter, serviceCounters = new Map() } = options;
const { tag, serviceRepo, envFilter, serviceCounters = new Map(), rootRegistry = '' } = options;
const matrix = new DeploymentMatrix();

// Clone the counters map so we can modify it
Expand Down Expand Up @@ -30249,8 +30280,9 @@ function buildMatrixFromSkyhook(services, environments, options = {}) {
const nextCounter = currentCounter + 1;
counters.set(service.name, nextCounter);

const image = resolveImage(service.name, service, env, rootRegistry);
core.info(`\n🔧 Creating entry for ${service.name} (counter: ${nextCounter}):`);
const entry = createDeploymentEntry(service, env, tag, serviceRepo, nextCounter);
const entry = createDeploymentEntry(service, env, tag, serviceRepo, nextCounter, image);
matrix.addEntry(entry);
}
}
Expand All @@ -30265,9 +30297,10 @@ function buildMatrixFromSkyhook(services, environments, options = {}) {
* @param {string} tag - Image tag
* @param {string} serviceRepo - Source repository
* @param {number} counter - Counter for unique service tag (per-service)
* @param {string} image - Resolved full image URL without tag
* @returns {DeploymentEntry}
*/
function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
function createDeploymentEntry(service, env, tag, serviceRepo, counter, image) {
const counterStr = String(counter).padStart(2, '0');
const serviceTag = `${service.name}_${tag}_${counterStr}`;

Expand All @@ -30285,6 +30318,7 @@ function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
core.info(` account: "${env.account || ''}" (from skyhook.yaml environments[].account)`);
core.info(` auto_deploy: "true" (default value)`);
core.info(` service_tag: "${serviceTag}" (computed: {service_name}_{tag}_{counter})`);
core.info(` image: "${image}" (resolved from registry hierarchy)`);

return new DeploymentEntry({
service_name: service.name,
Expand All @@ -30299,7 +30333,8 @@ function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
namespace: env.namespace,
account: env.account,
auto_deploy: 'true',
service_tag: serviceTag
service_tag: serviceTag,
image
});
}

Expand All @@ -30325,7 +30360,8 @@ function mergeMatrices(matrix1, matrix2) {
module.exports = {
buildMatrixFromSkyhook,
createDeploymentEntry,
mergeMatrices
mergeMatrices,
resolveImage
};


Expand Down Expand Up @@ -32444,7 +32480,8 @@ async function processSkyhookConfig(skyhookPath, tag, overlay, repoPath, service
tag,
serviceRepo,
envFilter: overlay,
serviceCounters: mergedCounters
serviceCounters: mergedCounters,
rootRegistry: config.registry
});

return matrix;
Expand Down
6 changes: 5 additions & 1 deletion src/DeploymentMatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DeploymentEntry {
* @param {string} params.service_tag - Service image tag
* @param {string} [params.namespace] - Kubernetes namespace
* @param {string} [params.account] - Cloud account identifier
* @param {string} [params.image] - Full container image URL without tag (e.g. "us-east1-docker.pkg.dev/project/repo/service")
*/
constructor({
service_dir,
Expand All @@ -31,7 +32,8 @@ class DeploymentEntry {
deployment_folder_path,
service_tag,
namespace,
account
account,
image
}) {
this.service_dir = service_dir;
this.service_name = service_name;
Expand All @@ -46,6 +48,7 @@ class DeploymentEntry {
this.service_tag = service_tag;
this.namespace = namespace;
this.account = account;
this.image = image || '';
}

/**
Expand Down Expand Up @@ -77,6 +80,7 @@ class DeploymentEntry {
};
if (this.namespace) obj.namespace = this.namespace;
if (this.account) obj.account = this.account;
if (this.image) obj.image = this.image;
return obj;
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/config/SkyhookConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ class SkyhookConfig {

/**
* @param {Object} params
* @param {string} [params.registry] - Repo-level container registry prefix
* @param {SkyhookService[]} params.services - Array of service configurations
* @param {SkyhookEnvironment[]} params.environments - Array of environment configurations
*/
constructor({ services = [], environments = [] }) {
constructor({ registry = '', services = [], environments = [] }) {
this.registry = registry;
this.services = services.map(s => new SkyhookService(s));
this.environments = environments.map(e => new SkyhookEnvironment(e));
}
Expand All @@ -21,10 +23,12 @@ class SkyhookConfig {
*/
static fromObject(obj) {
return new SkyhookConfig({
registry: obj.registry || '',
services: obj.services || [],
environments: obj.environments || []
});
}

}

/**
Expand All @@ -39,12 +43,13 @@ class SkyhookService {
* @param {string} [params.deploymentRepoPath] - Path within deployment repo
* @param {Object} [params.buildTool] - Build tool configuration
*/
constructor({ name, path, deploymentRepo, deploymentRepoPath, buildTool }) {
constructor({ name, path, deploymentRepo, deploymentRepoPath, buildTool, image }) {
this.name = name;
this.path = path;
this.deploymentRepo = deploymentRepo;
this.deploymentRepoPath = deploymentRepoPath;
this.buildTool = buildTool;
this.image = image || '';
}
}

Expand All @@ -61,13 +66,14 @@ class SkyhookEnvironment {
* @param {string} [params.location] - Cluster location/zone
* @param {string} [params.namespace] - Kubernetes namespace
*/
constructor({ name, clusterName, cloudProvider, account, location, namespace }) {
constructor({ name, clusterName, cloudProvider, account, location, namespace, registry }) {
this.name = name;
this.clusterName = clusterName;
this.cloudProvider = cloudProvider;
this.account = account;
this.location = location;
this.namespace = namespace;
this.registry = registry || '';
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ async function processSkyhookConfig(skyhookPath, tag, overlay, repoPath, service
tag,
serviceRepo,
envFilter: overlay,
serviceCounters: mergedCounters
serviceCounters: mergedCounters,
rootRegistry: config.registry
});

return matrix;
Expand Down
36 changes: 31 additions & 5 deletions src/matrix/matrix-builder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
const core = require('@actions/core');
const { DeploymentMatrix, DeploymentEntry } = require('../DeploymentMatrix');

/**
* Resolve the full image URL for a service+environment combination.
* Resolution order (highest to lowest precedence):
* 1. service.image — explicit per-service full URL override
* 2. env.registry/serviceName — per-environment registry
* 3. rootRegistry/serviceName — repo-level registry
*
* @param {string} serviceName
* @param {Object} service - Service config (may have .image)
* @param {Object} env - Environment config (may have .registry)
* @param {string} rootRegistry - Repo-level registry from skyhook.yaml root
* @returns {string} Full image URL without tag, or '' if unresolvable
*/
function resolveImage(serviceName, service, env, rootRegistry) {
if (service.image) return service.image;
if (env.registry) return `${env.registry}/${serviceName}`;
if (rootRegistry) return `${rootRegistry}/${serviceName}`;
return '';
}

/**
* Build a DeploymentMatrix from Skyhook services and environments
* @param {Array} services - Array of service configurations from skyhook.yaml
Expand All @@ -10,10 +30,11 @@ const { DeploymentMatrix, DeploymentEntry } = require('../DeploymentMatrix');
* @param {string} options.serviceRepo - Source repository (e.g., "KoalaOps/orbit")
* @param {string} [options.envFilter] - Environment filter (optional)
* @param {Map<string, number>} [options.serviceCounters] - Per-service counters from Koala
* @param {string} [options.rootRegistry] - Repo-level registry prefix from skyhook.yaml
* @returns {DeploymentMatrix}
*/
function buildMatrixFromSkyhook(services, environments, options = {}) {
const { tag, serviceRepo, envFilter, serviceCounters = new Map() } = options;
const { tag, serviceRepo, envFilter, serviceCounters = new Map(), rootRegistry = '' } = options;
const matrix = new DeploymentMatrix();

// Clone the counters map so we can modify it
Expand Down Expand Up @@ -42,8 +63,9 @@ function buildMatrixFromSkyhook(services, environments, options = {}) {
const nextCounter = currentCounter + 1;
counters.set(service.name, nextCounter);

const image = resolveImage(service.name, service, env, rootRegistry);
core.info(`\n🔧 Creating entry for ${service.name} (counter: ${nextCounter}):`);
const entry = createDeploymentEntry(service, env, tag, serviceRepo, nextCounter);
const entry = createDeploymentEntry(service, env, tag, serviceRepo, nextCounter, image);
matrix.addEntry(entry);
}
}
Expand All @@ -58,9 +80,10 @@ function buildMatrixFromSkyhook(services, environments, options = {}) {
* @param {string} tag - Image tag
* @param {string} serviceRepo - Source repository
* @param {number} counter - Counter for unique service tag (per-service)
* @param {string} image - Resolved full image URL without tag
* @returns {DeploymentEntry}
*/
function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
function createDeploymentEntry(service, env, tag, serviceRepo, counter, image) {
const counterStr = String(counter).padStart(2, '0');
const serviceTag = `${service.name}_${tag}_${counterStr}`;

Expand All @@ -78,6 +101,7 @@ function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
core.info(` account: "${env.account || ''}" (from skyhook.yaml environments[].account)`);
core.info(` auto_deploy: "true" (default value)`);
core.info(` service_tag: "${serviceTag}" (computed: {service_name}_{tag}_{counter})`);
core.info(` image: "${image}" (resolved from registry hierarchy)`);

return new DeploymentEntry({
service_name: service.name,
Expand All @@ -92,7 +116,8 @@ function createDeploymentEntry(service, env, tag, serviceRepo, counter) {
namespace: env.namespace,
account: env.account,
auto_deploy: 'true',
service_tag: serviceTag
service_tag: serviceTag,
image
});
}

Expand All @@ -118,5 +143,6 @@ function mergeMatrices(matrix1, matrix2) {
module.exports = {
buildMatrixFromSkyhook,
createDeploymentEntry,
mergeMatrices
mergeMatrices,
resolveImage
};
Loading
Loading