Merge pull request #1505 from pikasTech/fix/hwlab-refresh-pipeline-name-1499
fix(cicd): align HWLAB refresh apply pipeline name
This commit is contained in:
@@ -136,10 +136,17 @@ function renderControlPlane() {
|
|||||||
async function applyPipeline() {
|
async function applyPipeline() {
|
||||||
const pipelinePath = path.join(renderDir, overlay.tektonDir, "pipeline.yaml");
|
const pipelinePath = path.join(renderDir, overlay.tektonDir, "pipeline.yaml");
|
||||||
if (!existsSync(pipelinePath)) throw new Error(`rendered Pipeline missing: ${pipelinePath}`);
|
if (!existsSync(pipelinePath)) throw new Error(`rendered Pipeline missing: ${pipelinePath}`);
|
||||||
const pipelineText = readFileSync(pipelinePath, "utf8");
|
const YAML = yamlModule();
|
||||||
const pipeline = yamlModule().parse(pipelineText);
|
const pipeline = YAML.parse(readFileSync(pipelinePath, "utf8"));
|
||||||
const pipelineName = pipeline?.metadata?.name;
|
if (!pipeline || typeof pipeline !== "object") throw new Error(`rendered Pipeline is not an object: ${pipelinePath}`);
|
||||||
if (typeof pipelineName !== "string" || pipelineName.length === 0) throw new Error(`rendered Pipeline metadata.name missing: ${pipelinePath}`);
|
const renderedPipelineName = pipeline?.metadata?.name;
|
||||||
|
if (typeof renderedPipelineName !== "string" || renderedPipelineName.length === 0) {
|
||||||
|
throw new Error(`rendered Pipeline metadata.name missing: ${pipelinePath}`);
|
||||||
|
}
|
||||||
|
const pipelineName = requiredOverlayString("pipelineName");
|
||||||
|
pipeline.metadata = pipeline.metadata && typeof pipeline.metadata === "object" ? pipeline.metadata : {};
|
||||||
|
pipeline.metadata.name = pipelineName;
|
||||||
|
const pipelineText = YAML.stringify(pipeline);
|
||||||
await kubeRequest(
|
await kubeRequest(
|
||||||
"PATCH",
|
"PATCH",
|
||||||
`/apis/tekton.dev/v1/namespaces/${encodeURIComponent(tektonNamespace)}/pipelines/${encodeURIComponent(pipelineName)}?fieldManager=${encodeURIComponent(fieldManager)}&force=true`,
|
`/apis/tekton.dev/v1/namespaces/${encodeURIComponent(tektonNamespace)}/pipelines/${encodeURIComponent(pipelineName)}?fieldManager=${encodeURIComponent(fieldManager)}&force=true`,
|
||||||
|
|||||||
Reference in New Issue
Block a user