cli: add Terraform log support (#1620)

* add Terraform logging

* add TF logging to CLI

* fix path

* only create file if logging is enabled

* update bazel files

* register persistent flags manually

* clidocgen

* move logging code to separate file

* reword yes flag parsing error

* update bazel buildfile

* factor out log level setting
This commit is contained in:
Moritz Sanft 2023-04-14 14:15:07 +02:00 committed by GitHub
parent ca1400819d
commit 1d0ee796e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 688 additions and 238 deletions

View file

@ -13,9 +13,9 @@ import (
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
"github.com/edgelesssys/constellation/v2/cli/internal/clusterid"
"github.com/edgelesssys/constellation/v2/cli/internal/iamid"
"github.com/edgelesssys/constellation/v2/cli/internal/terraform"
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
"github.com/edgelesssys/constellation/v2/internal/cloud/gcpshared"
"github.com/edgelesssys/constellation/v2/internal/config"
"go.uber.org/goleak"
)
@ -34,13 +34,10 @@ type stubCloudCreator struct {
func (c *stubCloudCreator) Create(
_ context.Context,
provider cloudprovider.Provider,
_ *config.Config,
_ string,
_, _ int,
opts cloudcmd.CreateOptions,
) (clusterid.File, error) {
c.createCalled = true
c.id.CloudProvider = provider
c.id.CloudProvider = opts.Provider
return c.id, c.createErr
}
@ -49,7 +46,7 @@ type stubCloudTerminator struct {
terminateErr error
}
func (c *stubCloudTerminator) Terminate(context.Context) error {
func (c *stubCloudTerminator) Terminate(_ context.Context, _ terraform.LogLevel) error {
c.called = true
return c.terminateErr
}
@ -67,7 +64,7 @@ type stubIAMCreator struct {
func (c *stubIAMCreator) Create(
_ context.Context,
provider cloudprovider.Provider,
_ *cloudcmd.IAMConfig,
_ *cloudcmd.IAMConfigOptions,
) (iamid.File, error) {
c.createCalled = true
c.id.CloudProvider = provider
@ -82,7 +79,7 @@ type stubIAMDestroyer struct {
getTfstateKeyErr error
}
func (d *stubIAMDestroyer) DestroyIAMConfiguration(_ context.Context) error {
func (d *stubIAMDestroyer) DestroyIAMConfiguration(_ context.Context, _ terraform.LogLevel) error {
d.destroyCalled = true
return d.destroyErr
}