(ctx context.Context, statePath string, enc encryption.Encryption)
| 74 | } |
| 75 | |
| 76 | func (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 | |
| 115 | func (c *OutputCommand) Help() string { |
| 116 | helpText := ` |
no test coverage detected