Skip to content

Commit 185d58d

Browse files
committed
Make remote flag internal-only and strip from output
1 parent eac75de commit 185d58d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@noxify/gitlab-ci-builder": patch
3+
---
4+
5+
Fix: remote flag is now internal-only
6+
7+
- The `remote` option for jobs/templates is now used only for merge logic and is stripped from the final YAML output.
8+
- Prevents leaking internal flags into exported pipeline definitions.

src/config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ export interface GlobalOptions {
6262
* A global OOP-style GitLab CI configurator.
6363
*/
6464
export class Config {
65+
/**
66+
* Remove internal-only properties (like remote) from job/template definitions before output.
67+
*/
68+
private static stripInternalProps<T extends object>(obj: T): T {
69+
// Remove 'remote' property (internal use only)
70+
const { remote: _remote, ...rest } = obj as Record<string, unknown>
71+
return rest as T
72+
}
6573
// Internal state directly on the instance instead of nested plain object
6674
private stagesValue: string[] = []
6775
private jobsValue: Record<string, JobDefinitionWithRemote> = {}
@@ -627,6 +635,15 @@ export class Config {
627635
public getPlainObject() {
628636
// Create a deep copy to avoid mutating internal state
629637
// Merge templates and jobs (templates first, then jobs can override)
638+
// Prepare jobs/templates for output, removing internal-only props
639+
const jobsOut: Record<string, JobDefinition> = {}
640+
for (const [name, job] of Object.entries(this.templatesValue)) {
641+
jobsOut[name] = Config.stripInternalProps(job)
642+
}
643+
for (const [name, job] of Object.entries(this.jobsValue)) {
644+
jobsOut[name] = Config.stripInternalProps(job)
645+
}
646+
630647
const copy: GitLabCi = JSON.parse(
631648
JSON.stringify({
632649
stages: this.stagesValue.length ? [...this.stagesValue] : undefined,
@@ -640,7 +657,7 @@ export class Config {
640657
default: this.defaultValue,
641658
variables: Object.keys(this.variablesValue).length ? { ...this.variablesValue } : undefined,
642659
include: this.includeValue.length ? [...this.includeValue] : undefined,
643-
jobs: { ...this.templatesValue, ...this.jobsValue },
660+
jobs: jobsOut,
644661
}),
645662
) as GitLabCi
646663

0 commit comments

Comments
 (0)