@firestartr/cli 2.11.0-snapshot-patch-claims-3 → 2.11.0-snapshot-mco-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/build/index.js +2263 -2034
  2. package/build/packages/cdk8s_renderer/index.d.ts +2 -0
  3. package/build/packages/cdk8s_renderer/src/claims/github/repositoryFeature.d.ts +3 -0
  4. package/build/packages/cdk8s_renderer/src/overriders/base.d.ts +1 -1
  5. package/build/packages/cdk8s_renderer/src/overriders/featureOverride.d.ts +11 -2
  6. package/build/packages/cdk8s_renderer/src/overriders/githubRepositoryOverride.d.ts +1 -1
  7. package/build/packages/cdk8s_renderer/src/patches/base.d.ts +2 -2
  8. package/build/packages/cdk8s_renderer/src/renderer/claims-render.d.ts +1 -1
  9. package/build/packages/cdk8s_renderer/src/renderer/patches-extractor.d.ts +1 -1
  10. package/build/packages/cdk8s_renderer/src/utils/repositoryClaimUtils.d.ts +4 -3
  11. package/build/packages/features_preparer/src/index.d.ts +2 -5
  12. package/build/packages/features_preparer/src/installer.d.ts +4 -2
  13. package/build/packages/features_preparer/src/renderer.d.ts +0 -2
  14. package/build/packages/features_renderer/index.d.ts +1 -4
  15. package/build/packages/features_renderer/src/auxiliar.d.ts +14 -6
  16. package/build/packages/features_renderer/src/render.d.ts +1 -2
  17. package/build/packages/features_renderer/src/schema.d.ts +1 -7
  18. package/build/packages/importer/src/decanter/config.d.ts +37 -0
  19. package/build/packages/importer/src/decanter/index.d.ts +1 -1
  20. package/build/packages/operator/src/crdMonitor.d.ts +12 -0
  21. package/build/packages/operator/src/status.d.ts +1 -0
  22. package/package.json +1 -1
  23. package/build/packages/cdk8s_renderer/src/claims/stitching/errors.d.ts +0 -14
  24. package/build/packages/cdk8s_renderer/src/claims/stitching/protectedPaths.d.ts +0 -3
  25. package/build/packages/cdk8s_renderer/src/claims/stitching/stitching.d.ts +0 -19
@@ -9,6 +9,8 @@ export { InitializerDefault } from './src/defaults/initializer';
9
9
  export { InitializerClaimRef } from './src/initializers/claimRef';
10
10
  export { GithubRepositoryOverrider } from './src/overriders/githubRepositoryOverride';
11
11
  export { InitializerPatches as Initializer } from './src/initializers/base';
12
+ export { resolveCodeownersRef } from './src/utils/repositoryClaimUtils';
13
+ export { setRenderedClaim, emptyRenderedClaims } from './src/refresolver';
12
14
  import { runComparer } from './src/comparer';
13
15
  import { AllowedProviders, setDefaultBranch, setPath, setRepositoryUrl } from './src/config';
14
16
  import { render } from './src/renderer/renderer';
@@ -16,6 +16,9 @@ export interface IGithubRepositoryFeatureClaim extends IClaim {
16
16
  version?: string;
17
17
  ref?: string;
18
18
  repo?: string;
19
+ sha?: string;
20
+ tags?: string[];
21
+ url?: string;
19
22
  };
20
23
  repositoryTarget: FirestartrGithubRepositoryFeatureSpecRepositoryTarget;
21
24
  files: Array<IGithubRepositoryFeatureFileClaim>;
@@ -1,7 +1,7 @@
1
1
  import { BasePatches } from '../patches/base';
2
2
  export declare abstract class OverriderPatches extends BasePatches {
3
3
  abstract __validate(): Promise<boolean>;
4
- __patches(claim: any, _previousCR: any): Promise<ICustomResourcePatch[]>;
4
+ __patches(claim: any, _previousCR: any, _crs?: any): Promise<ICustomResourcePatch[]>;
5
5
  validate(): Promise<boolean>;
6
6
  }
7
7
  export declare class OverriderError extends Error {
@@ -12,7 +12,7 @@ export declare class FeaturesOverrider extends OverriderPatches {
12
12
  getFeatureConfig(cr: any): any;
13
13
  setUpAndRunRenderer(cr: any): any;
14
14
  __validate(): Promise<boolean>;
15
- __patches(claim: any, _previousCR: any): Promise<{
15
+ __patches(claim: any, _previousCR: any): Promise<({
16
16
  validate(_cr: any): boolean;
17
17
  apply(cr: any): Promise<any>;
18
18
  identify(): string;
@@ -20,5 +20,14 @@ export declare class FeaturesOverrider extends OverriderPatches {
20
20
  applicableProviders: string[];
21
21
  };
22
22
  post(cr: any): Promise<import("../claims/github/repositoryFeature").IGithubRepositoryFeatureClaim>;
23
- }[]>;
23
+ isPostPatch?: undefined;
24
+ } | {
25
+ isPostPatch: boolean;
26
+ validate(): boolean;
27
+ apply(cr: any): Promise<any>;
28
+ identify(): string;
29
+ applicable(): {
30
+ applicableProviders: string[];
31
+ };
32
+ })[]>;
24
33
  }
@@ -2,7 +2,7 @@ import { ICustomResourcePatch, OverriderPatches } from './base';
2
2
  export declare class GithubRepositoryOverrider extends OverriderPatches {
3
3
  applicableProviders: string[];
4
4
  __validate(): Promise<boolean>;
5
- __patches(claim: any, previousCR: any): Promise<ICustomResourcePatch[]>;
5
+ __patches(claim: any, previousCR: any, crs?: any): Promise<ICustomResourcePatch[]>;
6
6
  private additionalPermissions;
7
7
  private additionalCodeownersRules;
8
8
  }
@@ -3,6 +3,6 @@ export declare abstract class BasePatches {
3
3
  constructor();
4
4
  abstract get applicableProviders(): string[];
5
5
  abstract __validate(data: any): Promise<boolean>;
6
- abstract __patches(claim: any, previousCR: any): Promise<ICustomResourcePatch[]>;
7
- patches(claim: any, previousCR: any): Promise<any[]>;
6
+ abstract __patches(claim: any, previousCR: any, crs?: any): Promise<ICustomResourcePatch[]>;
7
+ patches(claim: any, previousCR: any, crs?: any): Promise<any[]>;
8
8
  }
@@ -8,5 +8,5 @@ export declare function renderClaims(catalogScope: Construct, firestartrScope: C
8
8
  crs: any;
9
9
  renames?: IRenameResult[];
10
10
  }): Promise<RenderedCrMap>;
11
- export declare function renderClaim(catalogScope: Construct, firestartrScope: Construct, claim: any, patches: ICustomResourcePatch[], previousCR?: any | null, claimPath?: string, variableSectionPreviousCR?: any | false, variableSectionPatches?: ICustomResourcePatch[]): Promise<IRenderClaimResult>;
11
+ export declare function renderClaim(catalogScope: Construct, firestartrScope: Construct, claim: any, patches: ICustomResourcePatch[], previousCR?: any | null, claimPath?: string, variableSectionPreviousCR?: any | false, variableSectionPatches?: ICustomResourcePatch[], crs?: any): Promise<IRenderClaimResult>;
12
12
  export declare function renameVariantCrFiles(outputDir: string, renderedMap: RenderedCrMap): void;
@@ -1,3 +1,3 @@
1
1
  import { ICustomResourcePatch } from '../patches';
2
2
  import { RenderClaimData } from './types';
3
- export declare function extractPatches(claimToRenderData: RenderClaimData, previousCR: any): Promise<ICustomResourcePatch[]>;
3
+ export declare function extractPatches(claimToRenderData: RenderClaimData, previousCR: any, crs?: any): Promise<ICustomResourcePatch[]>;
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @returns Permission
9
9
  */
10
- export declare function createPermissionFor(claimRef: `group:${string}` | `user:${string}` | `collaborator:${string}`, permission: 'admin' | 'push' | 'pull' | 'maintain'): Permission | CollaboratorPermission;
10
+ export declare function createPermissionFor(claimRef: `group:${string}` | `user:${string}` | `collaborator:${string}`, permission: 'admin' | 'push' | 'pull' | 'maintain', crs?: any): Permission | CollaboratorPermission;
11
11
  /**
12
12
  * @description This method creates a list of permissions for a given claimRefs and permission
13
13
  *
@@ -17,7 +17,7 @@ export declare function createPermissionFor(claimRef: `group:${string}` | `user:
17
17
  *
18
18
  * @returns Permission[]
19
19
  */
20
- export declare function createPermissionsListFor(claimRefs: (`group:${string}` | `user:${string}` | `collaborator:${string}`)[], permission: 'admin' | 'push' | 'pull' | 'maintain'): (Permission | CollaboratorPermission)[];
20
+ export declare function createPermissionsListFor(claimRefs: (`group:${string}` | `user:${string}` | `collaborator:${string}`)[], permission: 'admin' | 'push' | 'pull' | 'maintain', crs?: any): (Permission | CollaboratorPermission)[];
21
21
  export declare function createCRrefFrom(claimRef: `group:${string}` | `user:${string}` | `collaborator:${string}`, needsSecret: boolean): {
22
22
  ref: {
23
23
  kind: string;
@@ -44,7 +44,8 @@ export interface CollaboratorPermission {
44
44
  *
45
45
  * @returns string
46
46
  */
47
- export declare function createCodeOwnersData(claim: any, additionalRules?: any[]): string;
47
+ export declare function createCodeOwnersData(claim: any, additionalRules?: any[], crs?: any): string;
48
+ export declare function resolveCodeownersRef(ref: string, org: string, crs?: any): string;
48
49
  /**
49
50
  * A reference to a secret, which can be an internal or external source.
50
51
  */
@@ -1,11 +1,8 @@
1
- import { getFeatureConfigFromRef, getFeatureConfig, getFeatureClaimPatches, getFeatureClaimPatchesFromRef, prepareFeature } from './installer';
2
- import { renderFeature, renderFeatureFromPath, getFeatureClaimPatchesFromPath } from './renderer';
1
+ import { getFeatureConfigFromRef, getFeatureConfig, prepareFeature } from './installer';
2
+ import { renderFeature, renderFeatureFromPath } from './renderer';
3
3
  declare const _default: {
4
4
  renderFeature: typeof renderFeature;
5
5
  renderFeatureFromPath: typeof renderFeatureFromPath;
6
- getFeatureClaimPatches: typeof getFeatureClaimPatches;
7
- getFeatureClaimPatchesFromRef: typeof getFeatureClaimPatchesFromRef;
8
- getFeatureClaimPatchesFromPath: typeof getFeatureClaimPatchesFromPath;
9
6
  getFeatureConfigFromRef: typeof getFeatureConfigFromRef;
10
7
  getFeatureConfig: typeof getFeatureConfig;
11
8
  prepareFeature: typeof prepareFeature;
@@ -2,7 +2,9 @@ export declare function getFeatureConfigFromRef(featureName: string, featureRef:
2
2
  featureArgs?: any, repo?: string, owner?: string): Promise<any>;
3
3
  export declare function getFeatureConfig(featureName: string, version: string, featureOwner: any, // -> cr
4
4
  featureArgs?: any, repo?: string, owner?: string): Promise<any>;
5
- export declare function getFeatureClaimPatches(featureName: string, version: string, featureOwner: any, featureArgs?: any, repo?: string, owner?: string): Promise<any[]>;
6
- export declare function getFeatureClaimPatchesFromRef(featureName: string, featureRef: string, featureOwner: any, featureArgs?: any, repo?: string, owner?: string): Promise<any[]>;
5
+ export declare function resolveFeatureCommit(owner: string, repo: string, reference: string): Promise<{
6
+ sha: string;
7
+ tags: string[];
8
+ }>;
7
9
  export declare function prepareFeature(featureName: string, version: string, repo?: string, owner?: string): Promise<void>;
8
10
  export declare function downloadFeatureZip(repo: string, featureName: string, reference: string, owner?: string): Promise<string>;
@@ -1,4 +1,2 @@
1
1
  export declare function renderFeature(featureName: string, version: string, owner: any, repo: any, featureOwner: any, renderPath?: string, featureArgs?: any): any;
2
2
  export declare function renderFeatureFromPath(extractPath: string, renderedPath: string, featureOwner: any, featureArgs?: any): any;
3
- export declare function getFeatureClaimPatches(featureName: string, version: string, owner: any, repo: any, featureOwner: any, featureArgs?: any): any[];
4
- export declare function getFeatureClaimPatchesFromPath(extractPath: string, featureOwner: any, featureArgs?: any): any[];
@@ -1,8 +1,7 @@
1
1
  import validate from './src/validate';
2
- import render, { buildContext, renderContent, expandFiles, getClaimPatches } from './src/render';
2
+ import render, { buildContext, renderContent, expandFiles } from './src/render';
3
3
  import updateFileContent from './src/update_file';
4
4
  import { validateFeatureArgs } from './src/featureArgsValidation';
5
- export { getClaimPatches, buildContext, renderContent, expandFiles };
6
5
  declare const _default: {
7
6
  validate: typeof validate;
8
7
  render: typeof render;
@@ -13,12 +12,10 @@ declare const _default: {
13
12
  buildExpectedOutput: (config: import("./src/auxiliar").FeatureConfig, renderDir: string) => import("./src/auxiliar").ExpectedOutput;
14
13
  loadAndValidateRenderTests: (featurePath: string) => import("./src/auxiliar").RenderTestsFile;
15
14
  resolveCrPath: (featurePath: string, crRelPath: string) => string;
16
- resolveClaimPath: (featurePath: string, claimRelPath: string) => string;
17
15
  };
18
16
  buildContext: typeof buildContext;
19
17
  renderContent: typeof renderContent;
20
18
  expandFiles: typeof expandFiles;
21
19
  validateFeatureArgs: typeof validateFeatureArgs;
22
- getClaimPatches: typeof getClaimPatches;
23
20
  };
24
21
  export default _default;
@@ -11,7 +11,7 @@ export interface ConfigFile {
11
11
  }
12
12
  export interface FeatureConfig {
13
13
  files?: ConfigFile[];
14
- claimPatches?: unknown[];
14
+ patches?: unknown[];
15
15
  }
16
16
  export interface ExpectedFile {
17
17
  localPath: string;
@@ -19,14 +19,24 @@ export interface ExpectedFile {
19
19
  targetBranch: string;
20
20
  userManaged: boolean;
21
21
  }
22
+ export interface Traceability {
23
+ owner?: string;
24
+ repo?: string;
25
+ name?: string;
26
+ version?: string;
27
+ ref?: string;
28
+ url?: string;
29
+ sha?: string;
30
+ tags?: string[];
31
+ }
22
32
  export interface ExpectedOutput {
23
33
  files: ExpectedFile[];
24
- claimPatches: unknown[];
34
+ patches: unknown[];
35
+ traceability?: Traceability;
25
36
  }
26
37
  export interface RenderTest {
27
38
  name: string;
28
- cr?: string;
29
- claim?: string;
39
+ cr: string;
30
40
  args?: Record<string, unknown>;
31
41
  }
32
42
  export interface RenderTestsFile {
@@ -61,7 +71,6 @@ export interface RenderContext {
61
71
  export declare function formatAjvErrors(errors: ErrorObject[] | null | undefined): string;
62
72
  declare function loadAndValidateRenderTests(featurePath: string): RenderTestsFile;
63
73
  declare function resolveCrPath(featurePath: string, crRelPath: string): string;
64
- declare function resolveClaimPath(featurePath: string, claimRelPath: string): string;
65
74
  export declare function listYamlFiles(dir: string): string[];
66
75
  declare function loadYaml<T = unknown>(file: string): T;
67
76
  declare function mkNamedTmp(...names: string[]): Promise<string>;
@@ -74,6 +83,5 @@ declare const _default: {
74
83
  buildExpectedOutput: typeof buildExpectedOutput;
75
84
  loadAndValidateRenderTests: typeof loadAndValidateRenderTests;
76
85
  resolveCrPath: typeof resolveCrPath;
77
- resolveClaimPath: typeof resolveClaimPath;
78
86
  };
79
87
  export default _default;
@@ -1,6 +1,5 @@
1
1
  export default function render(featurePath: string, featureRenderPath: string, entity: any, firestartrConfig?: any, featureArgs?: any): any;
2
- export declare function getClaimPatches(featurePath: string, entity: any, firestartrConfig?: any, featureArgs?: any): any[];
3
- export declare function buildContext(stitchedClaim: any, args: any, firestartrConfig: any, featureArgs: any): any;
2
+ export declare function buildContext(entity: any, args: any, firestartrConfig: any, featureArgs: any): any;
4
3
  export declare function expandFiles(featurePath: string, configData: any, context: any): void;
5
4
  export declare function renderContent(template: string, ctx: any): any;
6
5
  export declare function assertNonEmptyString(value: unknown, what: string): asserts value is string;
@@ -18,12 +18,6 @@ declare const _default: {
18
18
  $ref: string;
19
19
  };
20
20
  };
21
- claimPatches: {
22
- type: string;
23
- items: {
24
- $ref: string;
25
- };
26
- };
27
21
  patches: {
28
22
  type: string;
29
23
  patternProperties: {
@@ -135,7 +129,7 @@ declare const _default: {
135
129
  type: string;
136
130
  };
137
131
  value: {
138
- type: string[];
132
+ type: string;
139
133
  };
140
134
  };
141
135
  required: string[];
@@ -4,6 +4,36 @@ export declare function setResourcesPath(path: string): void;
4
4
  export declare function getResourcesPath(): string;
5
5
  export declare function setConfigPath(path: string): void;
6
6
  export declare function getConfigPath(): string;
7
+ export declare function setClaimsDefaultsPath(path: string): void;
8
+ export declare function getClaimsDefaultsPath(): string;
9
+ /**
10
+ * Loads claims_defaults.yaml once and caches the default owner claim reference.
11
+ * Must be called after setClaimsDefaultsPath() and before any decanter runs.
12
+ */
13
+ export declare function loadClaimsDefaultsOnce(): void;
14
+ /**
15
+ * Returns the cached default owner claim reference (e.g., "group:group_a" or "user:user_a").
16
+ * Returns null if not loaded or not set in claims_defaults.yaml.
17
+ */
18
+ export declare function getDefaultOwnerClaimRef(): string | null;
19
+ /**
20
+ * Resolves the default owner claim reference to CODEOWNERS handle(s) using the
21
+ * same claim-to-external-name mapping used by CODEOWNERS generation.
22
+ * Must be called after the referenced claims have been seeded into the renderer
23
+ * (i.e., after setPreviousCRs) so resolveCodeownersRef can resolve them.
24
+ */
25
+ export declare function resolveDefaultOwnerHandles(org: string, crs?: any): void;
26
+ /**
27
+ * Returns the resolved default owner CODEOWNERS handles, if any.
28
+ */
29
+ export declare function getDefaultOwnerHandles(): {
30
+ team: string | null;
31
+ user: string | null;
32
+ };
33
+ /**
34
+ * Resets the cached default owner claim ref and handles (useful for testing).
35
+ */
36
+ export declare function resetClaimsDefaultsCache(): void;
7
37
  declare const _default: {
8
38
  setClaimsPath: typeof setClaimsPath;
9
39
  getClaimsPath: typeof getClaimsPath;
@@ -11,5 +41,12 @@ declare const _default: {
11
41
  getResourcesPath: typeof getResourcesPath;
12
42
  setConfigPath: typeof setConfigPath;
13
43
  getConfigPath: typeof getConfigPath;
44
+ setClaimsDefaultsPath: typeof setClaimsDefaultsPath;
45
+ getClaimsDefaultsPath: typeof getClaimsDefaultsPath;
46
+ loadClaimsDefaultsOnce: typeof loadClaimsDefaultsOnce;
47
+ getDefaultOwnerClaimRef: typeof getDefaultOwnerClaimRef;
48
+ resolveDefaultOwnerHandles: typeof resolveDefaultOwnerHandles;
49
+ getDefaultOwnerHandles: typeof getDefaultOwnerHandles;
50
+ resetClaimsDefaultsCache: typeof resetClaimsDefaultsCache;
14
51
  };
15
52
  export default _default;
@@ -11,7 +11,7 @@ export declare const collections: {
11
11
  RepoCollectionGithubDecanter: typeof RepoCollectionGithubDecanter;
12
12
  };
13
13
  export declare function isInPreviousCRs(kind: string, name: string): boolean;
14
- export declare function setPreviousCRs(resourcesPath: string): Promise<void>;
14
+ export declare function setPreviousCRs(resourcesPath: string, org?: string): Promise<void>;
15
15
  export declare function importGithubGitopsRepository(org: string, skipPlan: boolean, claimsPath: string, resourcesPath: string, configPath: string, filters: CollectionFilter[], needsReImport: boolean, force: boolean): Promise<void>;
16
16
  export declare function getPreviousCrs(crsPath: string): Promise<void>;
17
17
  declare const _default: {
@@ -0,0 +1,12 @@
1
+ export interface CrdMonitorOpts {
2
+ enabled?: boolean;
3
+ intervalSeconds?: number;
4
+ apiGroup?: string;
5
+ namespace?: string;
6
+ }
7
+ export declare function createCrdMonitor(plural: string, opts?: CrdMonitorOpts): {
8
+ start: () => void;
9
+ stop: () => void;
10
+ isStarted: () => boolean;
11
+ };
12
+ export default createCrdMonitor;
@@ -7,6 +7,7 @@ export declare function needsProvisioningOnCreateOrUpdate(cr: any): Promise<Need
7
7
  export declare function shouldForceReconcileByAnnotation(cr: any): boolean;
8
8
  export declare function updateSyncTransition(itemPath: string, reason: string, lastSyncTime: string, nextSyncTime: string, message: string, status: string): Promise<void>;
9
9
  export declare function updateRetryStatusInCR(pluralKind: string, namespace: string, name: string, retryCount: number, nextRetryTime?: string): Promise<void>;
10
+ export declare function isKubernetesNotFoundError(error: unknown): boolean;
10
11
  export declare function writePrioritizedStatus(kind: string, namespace: string, item: any): Promise<void>;
11
12
  export declare function updateTransition(itemPath: string, reason: string, type: string, statusValue: string, message?: string, updateStatusOnly?: boolean): Promise<void>;
12
13
  export declare function getConditionByType(conditionList: Array<any>, type: string): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firestartr/cli",
3
- "version": "2.11.0-snapshot-patch-claims-3",
3
+ "version": "2.11.0-snapshot-mco-3",
4
4
  "private": false,
5
5
  "description": "Commandline tool",
6
6
  "main": "build/main.js",
@@ -1,14 +0,0 @@
1
- export type StitchingViolationReason = 'protected-path' | 'overwrite-protected' | 'duplicate-path' | 'user-declared-path';
2
- export interface StitchingViolation {
3
- feature: string;
4
- op: string;
5
- path: string;
6
- reason: StitchingViolationReason;
7
- conflictingFeature?: string;
8
- message: string;
9
- }
10
- export declare class StitchingError extends Error {
11
- violations: StitchingViolation[];
12
- constructor(violations: StitchingViolation[]);
13
- }
14
- export declare function formatStitchingError(error: StitchingError): string;
@@ -1,3 +0,0 @@
1
- export declare const PROTECTED_CLAIM_PATHS: string[];
2
- export declare function isProtectedPath(patchPath: string): boolean;
3
- export declare function normalizePointer(pointer: string): string;
@@ -1,19 +0,0 @@
1
- export interface FeaturePatchEnvelope {
2
- feature: string;
3
- patches: Array<{
4
- op: string;
5
- path: string;
6
- value?: unknown;
7
- name?: string;
8
- }>;
9
- }
10
- export declare function MOCK_STITCHING_FEATURES(mock?: (claim: unknown) => Promise<FeaturePatchEnvelope[]>): void;
11
- export declare function stitchClaim(claimAfterDefaults: unknown, preCollectedEnvelopes?: FeaturePatchEnvelope[], originalClaim?: unknown): Promise<unknown>;
12
- export declare function extractClaimPatches(rendered: {
13
- claimPatches?: unknown;
14
- }): Array<{
15
- op: string;
16
- path: string;
17
- value?: unknown;
18
- name?: string;
19
- }>;