[automation] - Add diff to up and preview in automation API (#6413)
Co-authored-by: Mike Chen <mikechen@ip-192-168-1-8.ec2.internal>
This commit is contained in:
parent
8b665f7131
commit
256e8284d0
|
@ -3,6 +3,7 @@
|
|||
|
||||
### Enhancements
|
||||
|
||||
- [#6410](https://github.com/pulumi/pulumi/pull/6410) Add `diff` option to Automation API's `preview` and `up`
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ You can easily get all required dependencies with brew and npm
|
|||
|
||||
```bash
|
||||
brew install node pipenv python@3 typescript yarn go@1.13 golangci/tap/golangci-lint pulumi/tap/pulumictl
|
||||
brew cask install dotnet dotnet-sdk
|
||||
curl https://raw.githubusercontent.com/Homebrew/homebrew-cask/0272f0d33f/Casks/dotnet-sdk.rb > dotnet-sdk.rb # v3.1.0
|
||||
brew install --HEAD -s dotnet-sdk.rb
|
||||
rm dotnet-sdk.rb
|
||||
```
|
||||
|
||||
## Make build system
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Pulumi.Automation
|
|||
{
|
||||
public bool? ExpectNoChanges { get; set; }
|
||||
|
||||
public bool? Diff { get; set; }
|
||||
|
||||
public List<string>? Replace { get; set; }
|
||||
|
||||
public bool? TargetDependents { get; set; }
|
||||
|
|
|
@ -71,6 +71,8 @@ Pulumi.Automation.PluginKind.Resource = 2 -> Pulumi.Automation.PluginKind
|
|||
Pulumi.Automation.PreviewOptions
|
||||
Pulumi.Automation.PreviewOptions.ExpectNoChanges.get -> bool?
|
||||
Pulumi.Automation.PreviewOptions.ExpectNoChanges.set -> void
|
||||
Pulumi.Automation.PreviewOptions.Diff.get -> bool?
|
||||
Pulumi.Automation.PreviewOptions.Diff.set -> void
|
||||
Pulumi.Automation.PreviewOptions.PreviewOptions() -> void
|
||||
Pulumi.Automation.PreviewOptions.Program.get -> Pulumi.Automation.PulumiFn
|
||||
Pulumi.Automation.PreviewOptions.Program.set -> void
|
||||
|
@ -176,6 +178,8 @@ Pulumi.Automation.StackSummary.Url.get -> string
|
|||
Pulumi.Automation.UpOptions
|
||||
Pulumi.Automation.UpOptions.ExpectNoChanges.get -> bool?
|
||||
Pulumi.Automation.UpOptions.ExpectNoChanges.set -> void
|
||||
Pulumi.Automation.UpOptions.Diff.get -> bool?
|
||||
Pulumi.Automation.UpOptions.Diff.set -> void
|
||||
Pulumi.Automation.UpOptions.OnOutput.get -> System.Action<string>
|
||||
Pulumi.Automation.UpOptions.OnOutput.set -> void
|
||||
Pulumi.Automation.UpOptions.Program.get -> Pulumi.Automation.PulumiFn
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace Pulumi.Automation
|
|||
public sealed class UpOptions : UpdateOptions
|
||||
{
|
||||
public bool? ExpectNoChanges { get; set; }
|
||||
|
||||
public bool? Diff { get; set; }
|
||||
|
||||
public List<string>? Replace { get; set; }
|
||||
|
||||
|
|
|
@ -229,6 +229,9 @@ namespace Pulumi.Automation
|
|||
if (options.ExpectNoChanges is true)
|
||||
args.Add("--expect-no-changes");
|
||||
|
||||
if (options.Diff is true)
|
||||
args.Add("--diff");
|
||||
|
||||
if (options.Replace?.Any() == true)
|
||||
{
|
||||
foreach (var item in options.Replace)
|
||||
|
@ -323,6 +326,9 @@ namespace Pulumi.Automation
|
|||
if (options.ExpectNoChanges is true)
|
||||
args.Add("--expect-no-changes");
|
||||
|
||||
if (options.Diff is true)
|
||||
args.Add("--diff");
|
||||
|
||||
if (options.Replace?.Any() == true)
|
||||
{
|
||||
foreach (var item in options.Replace)
|
||||
|
|
|
@ -42,6 +42,13 @@ func ExpectNoChanges() Option {
|
|||
})
|
||||
}
|
||||
|
||||
// Diff displays operation as a rich diff showing the overall change
|
||||
func Diff() Option {
|
||||
return optionFunc(func(opts *Options) {
|
||||
opts.Diff = true
|
||||
})
|
||||
}
|
||||
|
||||
// Replace specifies an array of resource URNs to explicitly replace during the preview
|
||||
func Replace(urns []string) Option {
|
||||
return optionFunc(func(opts *Options) {
|
||||
|
@ -85,6 +92,8 @@ type Options struct {
|
|||
Message string
|
||||
// Return an error if any changes occur during this preview
|
||||
ExpectNoChanges bool
|
||||
// Diff displays operation as a rich diff showing the overall change
|
||||
Diff bool
|
||||
// Specify resources to replace
|
||||
Replace []string
|
||||
// Specify an exclusive list of resource URNs to update
|
||||
|
|
|
@ -43,6 +43,13 @@ func ExpectNoChanges() Option {
|
|||
})
|
||||
}
|
||||
|
||||
// Diff displays operation as a rich diff showing the overall change
|
||||
func Diff() Option {
|
||||
return optionFunc(func(opts *Options) {
|
||||
opts.Diff = true
|
||||
})
|
||||
}
|
||||
|
||||
// Replace specifies an array of resource URNs to explicitly replace during the update
|
||||
func Replace(urns []string) Option {
|
||||
return optionFunc(func(opts *Options) {
|
||||
|
@ -93,6 +100,8 @@ type Options struct {
|
|||
Message string
|
||||
// Return an error if any changes occur during this update
|
||||
ExpectNoChanges bool
|
||||
// Diff displays operation as a rich diff showing the overall change
|
||||
Diff bool
|
||||
// Specify resources to replace
|
||||
Replace []string
|
||||
// Specify an exclusive list of resource URNs to update
|
||||
|
|
|
@ -226,6 +226,9 @@ func (s *Stack) Preview(ctx context.Context, opts ...optpreview.Option) (Preview
|
|||
if preOpts.ExpectNoChanges {
|
||||
sharedArgs = append(sharedArgs, "--expect-no-changes")
|
||||
}
|
||||
if preOpts.Diff {
|
||||
sharedArgs = append(sharedArgs, "--diff")
|
||||
}
|
||||
for _, rURN := range preOpts.Replace {
|
||||
sharedArgs = append(sharedArgs, "--replace %s", rURN)
|
||||
}
|
||||
|
@ -288,6 +291,9 @@ func (s *Stack) Up(ctx context.Context, opts ...optup.Option) (UpResult, error)
|
|||
if upOpts.ExpectNoChanges {
|
||||
sharedArgs = append(sharedArgs, "--expect-no-changes")
|
||||
}
|
||||
if upOpts.Diff {
|
||||
sharedArgs = append(sharedArgs, "--diff")
|
||||
}
|
||||
for _, rURN := range upOpts.Replace {
|
||||
sharedArgs = append(sharedArgs, "--replace %s", rURN)
|
||||
}
|
||||
|
|
|
@ -126,6 +126,9 @@ export class Stack {
|
|||
if (opts.expectNoChanges) {
|
||||
args.push("--expect-no-changes");
|
||||
}
|
||||
if (opts.diff) {
|
||||
args.push("--diff");
|
||||
}
|
||||
if (opts.replace) {
|
||||
for (const rURN of opts.replace) {
|
||||
args.push("--replace", rURN);
|
||||
|
@ -211,6 +214,9 @@ export class Stack {
|
|||
if (opts.expectNoChanges) {
|
||||
args.push("--expect-no-changes");
|
||||
}
|
||||
if (opts.diff) {
|
||||
args.push("--diff");
|
||||
}
|
||||
if (opts.replace) {
|
||||
for (const rURN of opts.replace) {
|
||||
args.push("--replace", rURN);
|
||||
|
@ -589,6 +595,7 @@ export interface UpOptions {
|
|||
parallel?: number;
|
||||
message?: string;
|
||||
expectNoChanges?: boolean;
|
||||
diff?: boolean;
|
||||
replace?: string[];
|
||||
target?: string[];
|
||||
targetDependents?: boolean;
|
||||
|
@ -603,6 +610,7 @@ export interface PreviewOptions {
|
|||
parallel?: number;
|
||||
message?: string;
|
||||
expectNoChanges?: boolean;
|
||||
diff?: boolean;
|
||||
replace?: string[];
|
||||
target?: string[];
|
||||
targetDependents?: boolean;
|
||||
|
|
|
@ -298,6 +298,7 @@ class Stack:
|
|||
message: Optional[str] = None,
|
||||
target: Optional[List[str]] = None,
|
||||
expect_no_changes: Optional[bool] = None,
|
||||
diff: Optional[bool] = None,
|
||||
target_dependents: Optional[bool] = None,
|
||||
replace: Optional[List[str]] = None,
|
||||
program: Optional[PulumiFn] = None) -> PreviewResult:
|
||||
|
@ -310,6 +311,7 @@ class Stack:
|
|||
:param message: Message to associate with the preview operation.
|
||||
:param target: Specify an exclusive list of resource URNs to update.
|
||||
:param expect_no_changes: Return an error if any changes occur during this update.
|
||||
:param diff: Display operation as a rich diff showing the overall change
|
||||
:param target_dependents: Allows updating of dependent targets discovered but not specified in the Target list.
|
||||
:param replace: Specify resources to replace.
|
||||
:param program: The inline program.
|
||||
|
@ -570,6 +572,8 @@ def _parse_extra_args(**kwargs) -> List[str]:
|
|||
extra_args.extend(["--message", kwargs["message"]])
|
||||
if "expect_no_changes" in kwargs and kwargs["expect_no_changes"] is not None:
|
||||
extra_args.append("--expect-no-changes")
|
||||
if "diff" in kwargs and kwargs["diff"] is not None:
|
||||
extra_args.append("--diff")
|
||||
if "replace" in kwargs and kwargs["replace"] is not None:
|
||||
for r in kwargs["replace"]:
|
||||
extra_args.extend(["--replace", r])
|
||||
|
|
Loading…
Reference in a new issue