diff --git a/internal/command/views/output.go b/internal/command/views/output.go index c7dbbe0fbf..acac6d4d61 100644 --- a/internal/command/views/output.go +++ b/internal/command/views/output.go @@ -234,8 +234,8 @@ func (v *OutputJSON) Output(name string, outputs map[string]*states.OutputValue) return diags } - v.output.Write(jsonOutput) - v.output.Write([]byte("\n")) + _, _ = v.output.Write(jsonOutput) + _, _ = v.output.Write([]byte("\n")) return nil } @@ -279,8 +279,8 @@ func (v *OutputJSON) Output(name string, outputs map[string]*states.OutputValue) return diags } - v.output.Write(jsonOutputs) - v.output.Write([]byte("\n")) + _, _ = v.output.Write(jsonOutputs) + _, _ = v.output.Write([]byte("\n")) return nil } diff --git a/internal/command/views/show.go b/internal/command/views/show.go index 4471662729..a16933e67e 100644 --- a/internal/command/views/show.go +++ b/internal/command/views/show.go @@ -237,7 +237,7 @@ func (v *ShowJSON) DisplayState(_ context.Context, stateFile *statefile.File, sc v.view.streams.Eprintf("Failed to marshal state to json: %s", err) return 1 } - v.output.Write(jsonState) + _, _ = v.output.Write(jsonState) return 0 } @@ -249,7 +249,7 @@ func (v *ShowJSON) DisplayPlan(_ context.Context, plan *plans.Plan, planJSON *cl v.view.streams.Eprintf("Didn't get external JSON plan format") return 1 } - v.output.Write(planJSON.JSONBytes) + _, _ = v.output.Write(planJSON.JSONBytes) } else if plan != nil { planJSON, err := jsonplan.Marshal(config, plan, priorStateFile, schemas) @@ -257,12 +257,12 @@ func (v *ShowJSON) DisplayPlan(_ context.Context, plan *plans.Plan, planJSON *cl v.view.streams.Eprintf("Failed to marshal plan to json: %s", err) return 1 } - v.output.Write(planJSON) + _, _ = v.output.Write(planJSON) } else { // Should not get here because at least one of the two plan arguments // should be present, but we'll tolerate this by just returning an // empty JSON object. - v.output.Write([]byte("{}")) + _, _ = v.output.Write([]byte("{}")) } return 0 } @@ -273,7 +273,7 @@ func (v *ShowJSON) DisplayConfig(config *configs.Config, schemas *tofu.Schemas) v.view.streams.Eprintf("Failed to marshal configuration to JSON: %s", err) return 1 } - v.output.Write(configJSON) + _, _ = v.output.Write(configJSON) return 0 } @@ -283,7 +283,7 @@ func (v *ShowJSON) DisplaySingleModule(module *configs.Module) int { v.view.streams.Eprintf("Failed to marshal module contents to JSON: %s", err) return 1 } - v.output.Write(moduleJSON) + _, _ = v.output.Write(moduleJSON) return 0 } diff --git a/internal/command/views/state_locker.go b/internal/command/views/state_locker.go index 7ac210f697..5ef2ff597c 100644 --- a/internal/command/views/state_locker.go +++ b/internal/command/views/state_locker.go @@ -92,7 +92,7 @@ func (v *StateLockerJSON) Locking() { lock_info_message, _ := json.Marshal(json_data) lock_info_message = append(lock_info_message, '\n') - v.output.Write(lock_info_message) + _, _ = v.output.Write(lock_info_message) } func (v *StateLockerJSON) Unlocking() { @@ -107,5 +107,5 @@ func (v *StateLockerJSON) Unlocking() { lock_info_message, _ := json.Marshal(json_data) lock_info_message = append(lock_info_message, '\n') - v.output.Write(lock_info_message) + _, _ = v.output.Write(lock_info_message) } diff --git a/internal/command/views/validate.go b/internal/command/views/validate.go index 411bbb6d9e..e4dad6c3d2 100644 --- a/internal/command/views/validate.go +++ b/internal/command/views/validate.go @@ -157,7 +157,7 @@ func (v *ValidateJSON) Results(diags tfdiags.Diagnostics) int { // Should never happen because we fully-control the input here panic(err) } - v.output.Write(j) + _, _ = v.output.Write(j) if diags.HasErrors() { return 1