unsetVariable static method
Implementation
static Future<Map<String, Object?>> unsetVariable(
final Client cloudApiClient, {
required final String baseCommand,
required final String projectId,
required final String name,
}) async {
final existing = await findVariable(
cloudApiClient,
baseCommand: baseCommand,
projectId: projectId,
name: name,
);
final isSecret = existing['secret'] == true;
try {
if (isSecret) {
await cloudApiClient.secrets.delete(
key: name,
cloudCapsuleId: projectId,
);
} else {
await cloudApiClient.environmentVariables.delete(
name: name,
cloudCapsuleId: projectId,
);
}
} on Exception catch (e, s) {
throw FailureException.nested(
e,
s,
'Failed to remove the environment variable',
);
}
return existing;
}