Skip to content

Commit

Permalink
Add support for 1.49 and 1.50
Browse files Browse the repository at this point in the history
  • Loading branch information
schrodit committed Jul 11, 2022
1 parent 70c2a6b commit 353cc6b
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 13 deletions.
5 changes: 1 addition & 4 deletions default.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

version: v1.48.6
version: v1.50.1

landscapeName: gardener-installation

Expand All @@ -10,9 +10,6 @@ gardener:
shootDomainPrefix: shoot
seedCandidateDeterminationStrategy: SameRegion

featureGates:
UseDNSRecords: true

soil:
shootDefaultNetworks:
pods: 100.96.0.0/11
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"files": [
"lib/**/*",
"src/charts/**/*",
"src/ts/versions/**/extensions.yaml",
"src/ts/versions/**/default.yaml",
"default.yaml"
]
}
30 changes: 22 additions & 8 deletions src/ts/Landscape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,18 @@ const setUp = async (config: LandscapeInstallationConfig) => {
);
}

const defaultValues = await readValueFiles([internalFile(defaultValuesFile)]);
const defaultValues = await readValueFiles(internalFile(defaultValuesFile));
let values = mergeObjects(
defaultValues,
config.values ?? {},
await readValueFiles(config.valueFiles ?? []),
config.valueFiles ? await readValueFiles(...config.valueFiles) : {},
) as VersionedValues;
required(values, 'version');
values = deepMergeObject(
await readValueFiles([extensionsDefaultsFile(values.version)]),
values = mergeObjects(
await readVersionedDefaults(values.version),
await readValueFiles(extensionsDefaultsFile(values.version)),
values,
);
) as VersionedValues;

return {
kubeClient,
Expand Down Expand Up @@ -182,11 +183,24 @@ const getCurrentState = async (newState: KeyValueState, kubeClient: KubeClient,

const extensionsDefaultsFile = (version: string): string => {
const v = new SemVer(version);
const f = internalFile(path.join('src/ts/versions', `v${v.major}.${v.minor}`, extensionsValuesFile));
return f;
return internalFile(path.join('src/ts/versions', `v${v.major}.${v.minor}`, extensionsValuesFile));
};

const readVersionedDefaults = async (version: string): Promise<any> => {
const v = new SemVer(version);
const f = internalFile(path.join('src/ts/versions', `v${v.major}.${v.minor}`, defaultValuesFile));
try {
return await readFile(f, 'utf-8');
} catch (e: any) {
if (e.code !== 'ENOENT') {
throw e;
}
log.info(`No version specific default file found: ${f}`);
return {};
}
};

const readValueFiles = async(valueFiles: string[]): Promise<any> => {
const readValueFiles = async(...valueFiles: string[]): Promise<any> => {
const allValues = await Promise.all(
valueFiles.map(path => readValues(path))
);
Expand Down
3 changes: 3 additions & 0 deletions src/ts/versions/installations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Flow, VersionedValues} from '../flow/Flow';
import {KubeClient} from '../utils/KubeClient';
import {Installation as Installation_1_46} from './v1.46/installation';
import {Installation as Installation_1_47} from './v1.47/installation';
import {Installation as Installation_1_50} from './v1.50/installation';

export type InstallationConfig = {
genDir: string,
Expand Down Expand Up @@ -36,6 +37,8 @@ const versions: Record<string, InstallationConstructor> = {
'v1.46.x': Installation_1_46,
'v1.47.x': Installation_1_47,
'v1.48.x': Installation_1_47,
'v1.49.x': Installation_1_47,
'v1.50.x': Installation_1_50,
};

export class VersionNotFound extends Exception {
Expand Down
1 change: 0 additions & 1 deletion src/ts/versions/v1.46/components/gardener/Controlplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export class Controlplane extends Task {
'leaderElect': true,
'leaseDuration': '15s',
'renewDeadline': '10s',
'resourceLock': 'configmaps',
'retryPeriod': '2s',
},
server: {
Expand Down
5 changes: 5 additions & 0 deletions src/ts/versions/v1.46/default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

gardener:

featureGates:
UseDNSRecords: true
1 change: 1 addition & 0 deletions src/ts/versions/v1.49/extensions.yaml
1 change: 1 addition & 0 deletions src/ts/versions/v1.50/extensions.yaml
31 changes: 31 additions & 0 deletions src/ts/versions/v1.50/installation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {has} from '@0cfg/utils-common/lib/has';
import {Flow, VersionedValues} from '../../flow/Flow';
import {VersionedState} from '../../Landscape';
import {createLogger} from '../../log/Logger';
import {Installation as Installation_1_47} from '../v1.46/installation';
import {emptyState, GeneralValues, isStateValues} from '../v1.46/Values';

export const VERSION = '1.50';

const log = createLogger('');

export class Installation extends Installation_1_47 {

public async install(flow: Flow, stateValues: null | VersionedState, inputValues: VersionedValues): Promise<void> {
if (stateValues === null) {
stateValues = emptyState(inputValues.version);
} else {
// with gardener version 1.50 the UseDNSRecords feature gate got dropped,
// so we need to remove it from the state.
if (!isStateValues(stateValues)) {
throw new Error('State values invalid');
}
const v = stateValues as GeneralValues;
if (has(v.gardener?.featureGates?.['UseDNSRecords'])) {
delete v.gardener?.featureGates?.['UseDNSRecords'];
}
}

await super.install(flow, stateValues, inputValues);
}
}

0 comments on commit 353cc6b

Please sign in to comment.