Add a --json flag to the preview command

This change adds a --json flag to the preview command, enabling
basic JSON serialization of preview plans. This effectively flattens
the engine event stream into a preview structure that contains a list
of steps, diagnostics, and summary information. Each step contains
the deep serialization of resource state, in addition to metadata about
the step, such as what kind of operation it entails.

This is a partial implementation of pulumi/pulumi#2390. In particular,
we only support --json on the `preview` command itself, and not `up`,
meaning that it isn't possible to serialize the result of an actual
deployment yet (thereby limiting what you can do with outputs, etc).
This commit is contained in:
joeduffy 2019-04-20 13:34:58 -07:00
parent 23f905a468
commit 234c3dfec9

View file

@ -478,10 +478,11 @@ func (b *localBackend) apply(
}
}
fmt.Printf(
_, err := fmt.Fprintf(os.Stderr,
op.Opts.Display.Color.Colorize(
colors.SpecHeadline+"Permalink: "+
colors.Underline+colors.BrightBlue+"%s"+colors.Reset+"\n"), link)
contract.IgnoreError(err)
}
return changes, nil