mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-05-17 01:03:30 -04:00
43 lines
957 B
Go
43 lines
957 B
Go
// Copyright (c) The OpenTofu Authors
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
// Copyright (c) 2023 HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package cloud
|
|
|
|
import (
|
|
"context"
|
|
|
|
tfe "github.com/hashicorp/go-tfe"
|
|
)
|
|
|
|
const (
|
|
changedPolicyEnforcementAction = "changed_policy_enforcements"
|
|
changedTaskEnforcementAction = "changed_task_enforcements"
|
|
ignoredPolicySetAction = "ignored_policy_sets"
|
|
)
|
|
|
|
func (b *Cloud) renderRunWarnings(ctx context.Context, client *tfe.Client, runId string) error {
|
|
if b.View == nil {
|
|
return nil
|
|
}
|
|
|
|
result, err := client.RunEvents.List(ctx, runId, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if result == nil {
|
|
return nil
|
|
}
|
|
|
|
// We don't have to worry about paging as the API doesn't support it yet
|
|
for _, re := range result.Items {
|
|
switch re.Action {
|
|
case changedPolicyEnforcementAction, changedTaskEnforcementAction, ignoredPolicySetAction:
|
|
b.View.RunWarning(re.Description)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|