history method

Future<List<Map<String, dynamic>>> history({
  1. int? pageSize,
  2. int? page,
  3. bool showSecrets = false,
})

Returns stack update history.

Implementation

Future<List<Map<String, dynamic>>> history({
  int? pageSize,
  int? page,
  bool showSecrets = false,
}) async {
  final args = <String>['stack', 'history', '--json', '--stack', name];
  if (pageSize != null) {
    args.addAll(<String>['--page-size', '$pageSize']);
  }
  if (page != null) {
    args.addAll(<String>['--page', '$page']);
  }
  if (showSecrets) {
    args.add('--show-secrets');
  }

  final result = await workspace.runPulumiCommand(args);
  final decoded = jsonDecode(result.stdout);
  if (decoded is! List) {
    throw FormatException(
      'Expected array JSON from `pulumi stack history --json`',
    );
  }

  return decoded
      .whereType<Map>()
      .map((entry) => entry.map((key, value) => MapEntry('$key', value)))
      .toList(growable: false);
}