MCPcopy
hub / github.com/opentofu/opentofu / Outputs

Method Outputs

internal/command/output.go:76–113  ·  view source on GitHub ↗
(ctx context.Context, statePath string, enc encryption.Encryption)

Source from the content-addressed store, hash-verified

74}
75
76func (c *OutputCommand) Outputs(ctx context.Context, statePath string, enc encryption.Encryption) (map[string]*states.OutputValue, tfdiags.Diagnostics) {
77 var diags tfdiags.Diagnostics
78
79 // Allow state path override
80 if statePath != "" {
81 c.Meta.statePath = statePath
82 }
83
84 // Load the backend
85 b, backendDiags := c.Backend(ctx, nil, enc.State())
86 diags = diags.Append(backendDiags)
87 if diags.HasErrors() {
88 return nil, diags
89 }
90
91 // This is a read-only command
92 c.ignoreRemoteVersionConflict(b)
93
94 env, err := c.Workspace(ctx)
95 if err != nil {
96 diags = diags.Append(fmt.Errorf("Error selecting workspace: %w", err))
97 return nil, diags
98 }
99
100 // Get the state
101 stateStore, err := b.StateMgr(ctx, env)
102 if err != nil {
103 diags = diags.Append(fmt.Errorf("Failed to load state: %w", err))
104 return nil, diags
105 }
106
107 output, err := stateStore.GetRootOutputValues(context.TODO())
108 if err != nil {
109 return nil, diags.Append(err)
110 }
111
112 return output, diags
113}
114
115func (c *OutputCommand) Help() string {
116 helpText := `

Callers 1

RunMethod · 0.95

Calls 8

AppendMethod · 0.95
HasErrorsMethod · 0.95
WorkspaceMethod · 0.80
BackendMethod · 0.65
StateMethod · 0.65
StateMgrMethod · 0.65
GetRootOutputValuesMethod · 0.65

Tested by

no test coverage detected