2018-05-22 19:43:36 +00:00
|
|
|
// Copyright 2016-2018, Pulumi Corporation.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2018-01-31 17:41:42 +00:00
|
|
|
|
2018-09-04 22:40:15 +00:00
|
|
|
package display
|
2018-01-31 17:41:42 +00:00
|
|
|
|
2020-12-10 19:39:01 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2022-10-31 15:40:22 +00:00
|
|
|
"github.com/pulumi/pulumi/pkg/v3/backend/display/internal/terminal"
|
2021-03-17 13:20:05 +00:00
|
|
|
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
|
2020-12-10 19:39:01 +00:00
|
|
|
)
|
2018-01-31 17:41:42 +00:00
|
|
|
|
2019-04-30 17:31:53 +00:00
|
|
|
// Type of output to display.
|
|
|
|
type Type int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// DisplayProgress displays an update as it progresses.
|
|
|
|
DisplayProgress Type = iota
|
|
|
|
// DisplayDiff displays a rich diff.
|
|
|
|
DisplayDiff
|
|
|
|
// DisplayQuery displays query output.
|
|
|
|
DisplayQuery
|
2021-09-20 16:42:29 +00:00
|
|
|
// DisplayWatch displays watch output.
|
2019-11-06 20:56:29 +00:00
|
|
|
DisplayWatch
|
2019-04-30 17:31:53 +00:00
|
|
|
)
|
|
|
|
|
2018-09-04 22:40:15 +00:00
|
|
|
// Options controls how the output of events are rendered
|
|
|
|
type Options struct {
|
2023-10-09 18:31:17 +00:00
|
|
|
Color colors.Colorization // colorization to apply to events.
|
|
|
|
ShowConfig bool // true if we should show configuration information.
|
|
|
|
ShowPolicyRemediations bool // true if we should show detailed policy remediations.
|
|
|
|
ShowReplacementSteps bool // true to show the replacement steps in the plan.
|
|
|
|
ShowSameResources bool // true to show the resources that aren't updated in addition to updates.
|
|
|
|
ShowReads bool // true to show resources that are being read in
|
|
|
|
TruncateOutput bool // true if we should truncate long outputs
|
|
|
|
SuppressOutputs bool // true to suppress output summarization, e.g. if contains sensitive info.
|
|
|
|
SuppressPermalink bool // true to suppress state permalink
|
|
|
|
SummaryDiff bool // true if diff display should be summarized.
|
|
|
|
IsInteractive bool // true if we should display things interactively.
|
|
|
|
Type Type // type of display (rich diff, progress, or query).
|
|
|
|
JSONDisplay bool // true if we should emit the entire diff as JSON.
|
|
|
|
EventLogPath string // the path to the file to use for logging events, if any.
|
|
|
|
Debug bool // true to enable debug output.
|
|
|
|
Stdin io.Reader // the reader to use for stdin. Defaults to os.Stdin if unset.
|
|
|
|
Stdout io.Writer // the writer to use for stdout. Defaults to os.Stdout if unset.
|
|
|
|
Stderr io.Writer // the writer to use for stderr. Defaults to os.Stderr if unset.
|
|
|
|
SuppressTimings bool // true to suppress displaying timings of resource actions
|
2024-02-05 11:48:10 +00:00
|
|
|
SuppressProgress bool // true to suppress displaying progress spinner.
|
2022-10-31 15:40:22 +00:00
|
|
|
|
|
|
|
// testing-only options
|
|
|
|
term terminal.Terminal
|
Add display to the engine tests (#16050)
We want to add more test coverage to the display code. The best way to
do that is to add it to the engine tests, that already cover most of the
pulumi functionality.
It's probably not really possible to review all of the output, but at
least it gives us a baseline, which we can work with.
There's a couple of tests that are flaky for reasons I don't quite
understand yet. I marked them as to skip and we can look at them later.
I'd rather get in the baseline tests sooner, rather than spending a
bunch of time looking at that. The output differences also seem very
minor, so not super concerning.
The biggest remaining issue is that this doesn't interact well with the
Chdir we're doing in the engine. We could either pass the CWD through,
or just try to get rid of that Chdir. So this should only be merged
after https://github.com/pulumi/pulumi/pull/15607.
I've tried to split this into a few commits, separating out adding the
testdata, so it's hopefully a little easier to review, even though the
PR is still quite large.
One other thing to note is that we're comparing that the output has all
the same lines, and not that it is exactly the same. Because of how the
engine is implemented, there's a bunch of race conditions otherwise,
that would make us have to skip a bunch of tests, just because e.g.
resource A is sometimes deleted before resource B and sometimes it's the
other way around.
The biggest downside of that is that running with `PULUMI_ACCEPT` will
produce a diff even when there are no changes. Hopefully we won't have
to run that way too often though, so it might not be a huge issue?
---------
Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-05-13 07:18:25 +00:00
|
|
|
DeterministicOutput bool
|
2018-01-31 17:41:42 +00:00
|
|
|
}
|
2023-10-20 15:43:29 +00:00
|
|
|
|
|
|
|
func (opts Options) WithIsInteractive(isInteractive bool) Options {
|
|
|
|
opts.IsInteractive = isInteractive
|
|
|
|
return opts
|
|
|
|
}
|