Skip to content

Commit d76ee16

Browse files
authored
Merge pull request #9397 from jandubois/cherry-pick-1.20.1
Cherry pick 1.20.1
2 parents 181db3a + 91478a5 commit d76ee16

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "rancher-desktop",
33
"productName": "Rancher Desktop",
44
"license": "Apache-2.0",
5-
"version": "1.20.0",
5+
"version": "1.20.1",
66
"author": {
77
"name": "SUSE",
88
"email": "containers@suse.com"

pkg/rancher-desktop/assets/dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ kuberlr: 0.6.1
99
helm: 3.18.6
1010
dockerCLI: 28.3.3
1111
dockerBuildx: 0.26.1
12-
dockerCompose: 2.39.2
12+
dockerCompose: 2.40.3
1313
golangci-lint: 2.4.0
1414
trivy: 0.65.0
1515
steve: 0.1.0-beta9

scripts/dependencies/moby-openapi.ts

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from 'fs';
22
import path from 'path';
33

4+
import _ from 'lodash';
45
import yaml from 'yaml';
56

67
import { download } from '../lib/download';
@@ -37,11 +38,46 @@ export class MobyOpenAPISpec extends GlobalDependency(VersionedDependency) {
3738
for (const key of Object.keys(contents.definitions ?? {}).filter(k => /^Plugin./.test(k))) {
3839
delete contents.definitions[key]?.['x-go-name'];
3940
}
40-
// This forces a go type that isn't defined; delete the override and just
41-
// use strings instead.
42-
if (contents.definitions?.Plugin?.properties?.Config?.properties?.Interface?.properties?.Types?.items?.['x-go-type']?.type === 'CapabilityID') {
43-
delete contents.definitions.Plugin.properties.Config.properties.Interface.properties.Types.items['x-go-type'];
44-
}
41+
42+
// Some type overrides end up with errors, override them here:
43+
// noTypeOverride: This type does not actually exist in go, delete the override.
44+
// noValidate: This does not implement the .Validate() method; add a 'noValidation' hint.
45+
const perTypeActions: Record<string, 'noTypeOverride' | 'noValidate'> = {
46+
'net/netip.Addr': 'noValidate',
47+
'net/netip.Prefix': 'noValidate',
48+
'time.Time': 'noValidate',
49+
'undefined.int': 'noValidate',
50+
'undefined.CapabilityID': 'noTypeOverride', // This type is not defined anywhere.
51+
'undefined.SubnetStatuses': 'noTypeOverride', // This type is not defined anywhere.
52+
};
53+
54+
(function checkTypes(obj: object, prefix = '') {
55+
for (const [k, v] of Object.entries(obj)) {
56+
if (k === 'x-go-type') {
57+
const typeName = `${ v.import?.package }.${ v.type }`;
58+
if (typeName in perTypeActions) {
59+
switch (perTypeActions[typeName]) {
60+
case 'noTypeOverride':
61+
console.log(`\x1B[34m${ prefix } has invalid type ${ typeName }, removing.\x1B[0m`);
62+
delete (obj as any)[k];
63+
break;
64+
case 'noValidate':
65+
console.log(`\x1B[34m${ prefix } has type ${ typeName }, disabling validation.\x1B[0m`);
66+
_.set(v, 'hints.noValidation', true);
67+
break;
68+
}
69+
} else {
70+
console.log(`\x1B[34m${ prefix } has unknown type ${ typeName }, ignoring.\x1B[0m`);
71+
}
72+
} else if (_.isPlainObject(v)) {
73+
checkTypes(v, `${ prefix }.${ k }`.replace(/^\./, ''));
74+
} else if (Array.isArray(v)) {
75+
for (const [i, element] of Object.entries(v)) {
76+
checkTypes(element, `${ prefix }[${ i }]`);
77+
}
78+
}
79+
}
80+
})(contents);
4581

4682
await fs.promises.writeFile(modifiedPath, yaml.stringify(contents), 'utf-8');
4783

0 commit comments

Comments
 (0)