Skip to content

Commit

Permalink
Ensure spec.params and spec.systemParams are not empty (#5715)
Browse files Browse the repository at this point in the history
  • Loading branch information
joehan committed Apr 21, 2023
1 parent 7910bb2 commit f2592d5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Fixes an issue where Secret Manager secrets were tagged incorrectly (#5704).
- Fix bug where Custom Event channels weren't automatically crated on function deploys (#5700)
- Lift GCF 2nd gen naming restrictions (#5690)
- Fixes a bug where `ext:install` and `ext:configure` would error on extensions with no params.
3 changes: 1 addition & 2 deletions src/commands/ext-configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export const command = new Command("ext:configure <extensionInstanceId>")
instanceId,
projectDir: config.projectDir,
});

const [immutableParams, tbdParams] = partition(
spec.params.concat(spec.systemParams ?? []),
(spec.params ?? []).concat(spec.systemParams ?? []),
(param) => param.immutable ?? false
);
infoImmutableParams(immutableParams, oldParamValues);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ext-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ async function installToManifest(options: InstallExtensionOptions): Promise<void

const paramBindingOptions = await paramHelper.getParams({
projectId,
paramSpecs: spec.params.concat(spec.systemParams ?? []),
paramSpecs: (spec.params ?? []).concat(spec.systemParams ?? []),
nonInteractive,
paramsEnvPath,
instanceId,
Expand Down
15 changes: 9 additions & 6 deletions src/extensions/extensionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,20 @@ async function patchInstance(args: {
return pollRes;
}

function populateResourceProperties(spec: ExtensionSpec): void {
function populateSpec(spec: ExtensionSpec): void {
if (spec) {
spec.resources.forEach((r) => {
for (const r of spec.resources) {
try {
if (r.propertiesYaml) {
r.properties = yaml.safeLoad(r.propertiesYaml);
}
} catch (err: any) {
logger.debug(`[ext] failed to parse resource properties yaml: ${err}`);
}
});
}
// We need to populate empty repeated fields with empty arrays, since proto wire format removes them.
spec.params = spec.params ?? [];
spec.systemParams = spec.systemParams ?? [];
}
}

Expand Down Expand Up @@ -405,7 +408,7 @@ export async function createSource(
masterTimeout: 600000,
});
if (pollRes.spec) {
populateResourceProperties(pollRes.spec);
populateSpec(pollRes.spec);
}
return pollRes;
}
Expand All @@ -418,7 +421,7 @@ export async function createSource(
export async function getSource(sourceName: string): Promise<ExtensionSource> {
const res = await apiClient.get<ExtensionSource>(`/${sourceName}`);
if (res.body.spec) {
populateResourceProperties(res.body.spec);
populateSpec(res.body.spec);
}
return res.body;
}
Expand All @@ -434,7 +437,7 @@ export async function getExtensionVersion(extensionVersionRef: string): Promise<
try {
const res = await apiClient.get<ExtensionVersion>(`/${refs.toExtensionVersionName(ref)}`);
if (res.body.spec) {
populateResourceProperties(res.body.spec);
populateSpec(res.body.spec);
}
return res.body;
} catch (err: any) {
Expand Down

0 comments on commit f2592d5

Please sign in to comment.