runWithConfig method

  1. @override
Future<void> runWithConfig(
  1. Configuration<SetSecretCommandConfig> commandConfig
)
override

Runs this command with prepared configuration (options). Subclasses should override this method.

Implementation

@override
Future<void> runWithConfig(
  final Configuration<SetSecretCommandConfig> commandConfig,
) async {
  final projectId = commandConfig.value(SetSecretCommandConfig.projectId);
  final name = commandConfig.value(SetSecretCommandConfig.name);
  final valueToSet = commandConfig.valueOrFileContent(
    value: SetSecretCommandConfig.value,
    valueFile: SetSecretCommandConfig.valueFile,
  );

  final apiCloudClient = runner.serviceProvider.cloudApiClient;

  try {
    await apiCloudClient.secrets.upsert(
      secrets: {name: valueToSet},
      cloudCapsuleId: projectId,
    );
  } on Exception catch (e, s) {
    throw FailureException.nested(e, s, 'Failed to set secret');
  }

  logger.success('Successfully set secret: $name.');
}