Skip to content

Commit

Permalink
make createkustomizations use createkustomization function
Browse files Browse the repository at this point in the history
  • Loading branch information
zjaco13 committed Aug 2, 2023
1 parent 341ec40 commit 79c43b7
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions lib/addons/fluxcd/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class FluxCDAddOn extends HelmAddOn {
this.options.workloadApplications.forEach(app => {
const gitRepoConstruct = createGitRepository(clusterInfo, app, this.options);
gitRepoConstruct.node.addDependency(chart);
const kustomizationConstruct = createKustomization(clusterInfo, app, this.options);
const kustomizationConstruct = createKustomization(clusterInfo, app, this.options, app.repository?.path!);

Check failure on line 147 in lib/addons/fluxcd/index.ts

View workflow job for this annotation

GitHub Actions / build (18.12.1)

Optional chain expressions can return undefined by design - using a non-null assertion is unsafe and wrong
kustomizationConstruct.node.addDependency(gitRepoConstruct);
});
}
Expand All @@ -165,9 +165,10 @@ function createGitRepository(clusterInfo: ClusterInfo, bootstrapRepo: spi.GitOps
/**
* create Kustomizations calls the FluxKustomization().generate to create Kustomization resource.
*/
function createKustomization(clusterInfo: ClusterInfo, bootstrapRepo: spi.GitOpsApplicationDeployment, fluxcdAddonProps: FluxCDAddOnProps): KubernetesManifest {
const manifest = new FluxKustomization(bootstrapRepo).generate(bootstrapRepo.name, fluxcdAddonProps.namespace!, fluxcdAddonProps.fluxSyncInterval!, bootstrapRepo.namespace ?? fluxcdAddonProps.fluxTargetNamespace!, fluxcdAddonProps.fluxPrune!, fluxcdAddonProps.fluxTimeout!, fluxcdAddonProps.bootstrapValues!, bootstrapRepo.repository?.path!);
let manifestName: string | undefined = fluxcdAddonProps.name + '-kustomization-' + bootstrapRepo.name;
function createKustomization(clusterInfo: ClusterInfo, bootstrapRepo: spi.GitOpsApplicationDeployment, fluxcdAddonProps: FluxCDAddOnProps, fluxKustomizationPath: string, manifestNameAddOns?: string, fluxKustomization?: FluxKustomization): KubernetesManifest {
fluxKustomization = fluxKustomization ?? new FluxKustomization(bootstrapRepo)

Check warning on line 169 in lib/addons/fluxcd/index.ts

View workflow job for this annotation

GitHub Actions / build (18.12.1)

Missing semicolon
const manifest = fluxKustomization.generate(bootstrapRepo.name, fluxcdAddonProps.namespace!, fluxcdAddonProps.fluxSyncInterval!, bootstrapRepo.namespace ?? fluxcdAddonProps.fluxTargetNamespace!, fluxcdAddonProps.fluxPrune!, fluxcdAddonProps.fluxTimeout!, bootstrapRepo.values, fluxKustomizationPath);
let manifestName: string | undefined = fluxcdAddonProps.name + '-kustomization-' + bootstrapRepo.name + (manifestNameAddOns ? "-"+manifestNameAddOns: "") ;
const construct = clusterInfo.cluster.addManifest(manifestName!, manifest);
return construct;
}
Expand All @@ -185,17 +186,7 @@ function createKustomizations(clusterInfo: ClusterInfo, bootstrapRepo: spi.GitOp
const constructs: KubernetesManifest[] = [];
const fluxKustomization = new FluxKustomization(bootstrapRepo);
fluxKustomizationPaths.map((fluxKustomizationPath, index) => {
const manifest =fluxKustomization.generate(
fluxcdAddonProps.bootstrapRepo!.name! + "-" + index,
fluxcdAddonProps.namespace!,
fluxcdAddonProps.fluxSyncInterval!,
fluxcdAddonProps.fluxTargetNamespace!,
fluxcdAddonProps.fluxPrune!,
fluxcdAddonProps.fluxTimeout!,
fluxcdAddonProps.bootstrapValues!,
fluxKustomizationPath);
let manifestName: string | undefined = fluxcdAddonProps.name + 'kustomization' + index;
constructs.push(clusterInfo.cluster.addManifest(manifestName!, manifest));
constructs.push(createKustomization(clusterInfo, bootstrapRepo, fluxcdAddonProps, fluxKustomizationPath, "" + index, fluxKustomization))

Check warning on line 189 in lib/addons/fluxcd/index.ts

View workflow job for this annotation

GitHub Actions / build (18.12.1)

Missing semicolon
});

return constructs;
Expand Down

0 comments on commit 79c43b7

Please sign in to comment.