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

PLT-1670 - Propagate the labels to Pod for the argo workflow templates #80

Merged
merged 2 commits into from
May 29, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,4 @@ The project is licensed under the MIT License, see the [LICENSE](LICENSE) file f

- Q&A: [Github Discussions](https://github.com/atlanhq/argopm/discussions)
- You can also reach out to engineering@atlan.com

20 changes: 17 additions & 3 deletions lib/k8s.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ function enableClusterScope(yamlObject) {
}
}

function copyLabelsToPodMetaData(yamlObject, kind) {
if (kind === constants.ARGO_WORKFLOW_TEMPLATES_KIND || kind === constants.ARGO_CLUSTER_WORKFLOW_TEMPLATES_KIND) {
let metadata = yamlObject.metadata;
let spec = yamlObject.spec;
// Copy labels from metadata to spec.podMetadata.labels
spec.podMetadata = spec.podMetadata || {};
spec.podMetadata.labels = Object.assign({}, spec.podMetadata.labels, metadata.labels);
}
return yamlObject;
}

class K8sInstaller {
/**
* Installs the given package to Argo K8s deployment
Expand Down Expand Up @@ -261,7 +272,7 @@ class K8sInstaller {
if (preProcessFn) {
yamlData = preProcessFn(yamlData);
}
const apmYAML = mainThis.addAPMLabels(yamlData, folder, fileName);
const apmYAML = mainThis.addAPMLabels(yamlData, folder, fileName, kind);
return fn(
mainThis.package.name,
mainThis.namespace,
Expand All @@ -275,11 +286,13 @@ class K8sInstaller {
});
});
}

/**
* @param {Object} yamlObject YAML object
*/
convertS3ArtifactsToAzureBlob(yamlObject) {
const searchKey = "s3";

// Recursive function to search for the key
function searchForKey(obj) {
if (typeof obj !== "object" || obj === null) {
Expand All @@ -297,6 +310,7 @@ class K8sInstaller {
searchForKey(obj[prop]);
}
}

// Start the search
searchForKey(yamlObject);

Expand All @@ -307,7 +321,7 @@ class K8sInstaller {
* Installs the given package to Argo K8s deployment
* @param {Object} yamlObject YAML object
*/
addAPMLabels(yamlObject, folder, fileName) {
addAPMLabels(yamlObject, folder, fileName, kind) {
let metadata = yamlObject.metadata;
if (!metadata.name) {
metadata.name = this.package.name.replace(/@/g, "-").replace(/\//g, "-").replace(/:/g, "-");
Expand Down Expand Up @@ -338,7 +352,7 @@ class K8sInstaller {
});

yamlObject.metadata = metadata;
return yamlObject;
return copyLabelsToPodMetaData(yamlObject, kind);
}
}

Expand Down
Loading
Loading