diff --git a/cmd/monaco/download/download_configs.go b/cmd/monaco/download/download_configs.go index 82dbca83e..11a68ac9b 100644 --- a/cmd/monaco/download/download_configs.go +++ b/cmd/monaco/download/download_configs.go @@ -255,7 +255,7 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts if opts.auth.Token == nil { return nil, errors.New("classic client config requires token") } - classicCfgs, err := fn.classicDownload(clientSet.Config(), opts.projectName, prepareAPIs(apisToDownload, opts), classic.ApiContentFilters) + classicCfgs, err := fn.classicDownload(clientSet.ConfigClient, opts.projectName, prepareAPIs(apisToDownload, opts), classic.ApiContentFilters) if err != nil { return nil, err } @@ -264,7 +264,7 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts if shouldDownloadSettings(opts) { log.Info("Downloading settings objects") - settingCfgs, err := fn.settingsDownload(clientSet.Settings(), opts.projectName, settings.DefaultSettingsFilters, makeSettingTypes(opts.specificSchemas)...) + settingCfgs, err := fn.settingsDownload(clientSet.SettingsClient, opts.projectName, settings.DefaultSettingsFilters, makeSettingTypes(opts.specificSchemas)...) if err != nil { return nil, err } @@ -274,7 +274,7 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts if shouldDownloadAutomationResources(opts) { if opts.auth.OAuth != nil { log.Info("Downloading automation resources") - automationCfgs, err := fn.automationDownload(clientSet.Automation(), opts.projectName) + automationCfgs, err := fn.automationDownload(clientSet.AutClient, opts.projectName) if err != nil { return nil, err } @@ -286,7 +286,7 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts if shouldDownloadBuckets(opts) && opts.auth.OAuth != nil { log.Info("Downloading Grail buckets") - bucketCfgs, err := fn.bucketDownload(clientSet.Bucket(), opts.projectName) + bucketCfgs, err := fn.bucketDownload(clientSet.BucketClient, opts.projectName) if err != nil { return nil, err } @@ -297,7 +297,7 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts if shouldDownloadDocuments(opts) { if opts.auth.OAuth != nil { log.Info("Downloading documents") - documentCfgs, err := fn.documentDownload(clientSet.Document(), opts.projectName) + documentCfgs, err := fn.documentDownload(clientSet.DocumentClient, opts.projectName) if err != nil { return nil, err } diff --git a/cmd/monaco/integrationtest/assert.go b/cmd/monaco/integrationtest/assert.go index 057464e84..3ec7bc3c6 100644 --- a/cmd/monaco/integrationtest/assert.go +++ b/cmd/monaco/integrationtest/assert.go @@ -142,7 +142,7 @@ func AssertAllConfigsAvailability(t *testing.T, fs afero.Fs, manifestPath string var foundID string switch typ := theConfig.Type.(type) { case config.SettingsType: - foundID = AssertSetting(t, ctx, clients.Settings(), typ, env.Name, available, theConfig) + foundID = AssertSetting(t, ctx, clients.SettingsClient, typ, env.Name, available, theConfig) case config.ClassicApiType: assert.NotEmpty(t, configName, "classic API config %v is missing name, can not assert if it exists", theConfig.Coordinate) @@ -155,21 +155,21 @@ func AssertAllConfigsAvailability(t *testing.T, fs afero.Fs, manifestPath string theApi = theApi.ApplyParentObjectID(scope) } - foundID = AssertConfig(t, ctx, clients.Config(), theApi, env, available, theConfig, configName) + foundID = AssertConfig(t, ctx, clients.ConfigClient, theApi, env, available, theConfig, configName) case config.AutomationType: - if clients.Automation() == nil { + if clients.AutClient == nil { t.Errorf("can not assert existience of Automtation config %q (%s) because no AutomationClient exists - was the test env not configured as Platform?", theConfig.Coordinate, typ.Resource) return } - foundID = AssertAutomation(t, clients.Automation(), env, available, typ.Resource, theConfig) + foundID = AssertAutomation(t, clients.AutClient, env, available, typ.Resource, theConfig) case config.BucketType: - if clients.Bucket() == nil { + if clients.BucketClient == nil { t.Errorf("can not assert existience of Bucket config %q) because no BucketClient exists - was the test env not configured as Platform?", theConfig.Coordinate) return } - foundID = AssertBucket(t, clients.Bucket(), env, available, theConfig) + foundID = AssertBucket(t, clients.BucketClient, env, available, theConfig) case config.DocumentType: - if clients.Document() == nil { + if clients.DocumentClient == nil { t.Errorf("can not assert existience of Document config %q) because no DocumentClient exists - was the test env not configured as Platform?", theConfig.Coordinate) return } diff --git a/cmd/monaco/integrationtest/v1/integration_test_utils.go b/cmd/monaco/integrationtest/v1/integration_test_utils.go index ee951b536..7fdbce452 100644 --- a/cmd/monaco/integrationtest/v1/integration_test_utils.go +++ b/cmd/monaco/integrationtest/v1/integration_test_utils.go @@ -72,7 +72,7 @@ func AssertConfigAvailability(t *testing.T, fs afero.Fs, manifestFile string, co ctx := context.WithValue(context.TODO(), log.CtxKeyCoord{}, coord) ctx = context.WithValue(ctx, log.CtxKeyEnv{}, log.CtxValEnv{Name: conf.Environment, Group: conf.Group}) - assertConfigAvailable(t, ctx, clients.Config(), envDefinition, available, *conf) + assertConfigAvailable(t, ctx, clients.ConfigClient, envDefinition, available, *conf) } func getConfigsForEnv(t *testing.T, project project.Project, env manifest.EnvironmentDefinition) project.ConfigsPerType { diff --git a/cmd/monaco/integrationtest/v2/delete_integration_test.go b/cmd/monaco/integrationtest/v2/delete_integration_test.go index 947098032..26bc2cf8e 100644 --- a/cmd/monaco/integrationtest/v2/delete_integration_test.go +++ b/cmd/monaco/integrationtest/v2/delete_integration_test.go @@ -258,7 +258,7 @@ environmentGroups: clientSet := integrationtest.CreateDynatraceClients(t, env) // check the setting was deleted - integrationtest.AssertSetting(t, context.TODO(), clientSet.Settings(), config.SettingsType{SchemaId: "builtin:tags.auto-tagging"}, envName, false, config.Config{ + integrationtest.AssertSetting(t, context.TODO(), clientSet.SettingsClient, config.SettingsType{SchemaId: "builtin:tags.auto-tagging"}, envName, false, config.Config{ Coordinate: coordinate.Coordinate{ Project: "project", Type: "builtin:tags.auto-tagging", @@ -267,7 +267,7 @@ environmentGroups: }) // check the workflow still exists after deletion was skipped without error - integrationtest.AssertAutomation(t, clientSet.Automation(), env, true, config.Workflow, config.Config{ + integrationtest.AssertAutomation(t, clientSet.AutClient, env, true, config.Workflow, config.Config{ Coordinate: coordinate.Coordinate{ Project: "project", Type: "workflow", @@ -276,7 +276,7 @@ environmentGroups: }) // check the bucket still exists after deletion was skipped without error - integrationtest.AssertBucket(t, clientSet.Bucket(), env, true, config.Config{ + integrationtest.AssertBucket(t, clientSet.BucketClient, env, true, config.Config{ Coordinate: coordinate.Coordinate{ Project: "project", Type: "bucket", @@ -343,7 +343,7 @@ configs: integrationtest.AssertAllConfigsAvailability(t, fs, deployManifestPath, []string{}, "", true) // get application ID - v, err := clientSet.Config().List(context.TODO(), apis["application-mobile"]) + v, err := clientSet.ConfigClient.List(context.TODO(), apis["application-mobile"]) assert.NoError(t, err) var appID string @@ -370,7 +370,7 @@ configs: require.NoError(t, err) // Assert key-user-action is deleted - integrationtest.AssertConfig(t, context.TODO(), clientSet.Config(), apis["key-user-actions-mobile"].ApplyParentObjectID(appID), env, false, config.Config{ + integrationtest.AssertConfig(t, context.TODO(), clientSet.ConfigClient, apis["key-user-actions-mobile"].ApplyParentObjectID(appID), env, false, config.Config{ Coordinate: coordinate.Coordinate{ Project: "project", Type: "key-user-actions-mobile", diff --git a/cmd/monaco/integrationtest/v2/diff_project_diff_ext_id_test.go b/cmd/monaco/integrationtest/v2/diff_project_diff_ext_id_test.go index ead930999..a4069fd2c 100644 --- a/cmd/monaco/integrationtest/v2/diff_project_diff_ext_id_test.go +++ b/cmd/monaco/integrationtest/v2/diff_project_diff_ext_id_test.go @@ -57,7 +57,7 @@ func TestSettingsInDifferentProjectsGetDifferentExternalIDs(t *testing.T) { clientSet, err := client.CreateClientSet(context.TODO(), environment.URL.Value, environment.Auth, client.ClientOptions{SupportArchive: support.SupportArchive}) assert.NoError(t, err) - c := clientSet.Settings() + c := clientSet.SettingsClient settings, _ := c.List(context.TODO(), "builtin:anomaly-detection.metric-events", dtclient.ListSettingsOptions{DiscardValue: true, Filter: func(object dtclient.DownloadSettingsObject) bool { return object.ExternalId == extIDProject1 || object.ExternalId == extIDProject2 }}) diff --git a/cmd/monaco/integrationtest/v2/documents_integration_test.go b/cmd/monaco/integrationtest/v2/documents_integration_test.go index df810c7c6..30c86d7e2 100644 --- a/cmd/monaco/integrationtest/v2/documents_integration_test.go +++ b/cmd/monaco/integrationtest/v2/documents_integration_test.go @@ -21,15 +21,17 @@ package v2 import ( "context" "fmt" + "path/filepath" + "strings" + "testing" + + "github.com/spf13/afero" + "github.com/stretchr/testify/assert" + "github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest" "github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest/utils/monaco" "github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags" manifestloader "github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/manifest/loader" - "github.com/spf13/afero" - "github.com/stretchr/testify/assert" - "path/filepath" - "strings" - "testing" ) // TestDocuments verifies that the "private" field of a document config definition in the config.yaml file @@ -63,13 +65,13 @@ func TestDocuments(t *testing.T) { // check isPrivate == false clientSet := integrationtest.CreateDynatraceClients(t, man.Environments[environment]) - result, err := clientSet.Document().List(context.TODO(), fmt.Sprintf("name='my-notebook_%s'", testContext.suffix)) + result, err := clientSet.DocumentClient.List(context.TODO(), fmt.Sprintf("name='my-notebook_%s'", testContext.suffix)) assert.NoError(t, err) assert.Len(t, result.Responses, 1) assert.False(t, result.Responses[0].IsPrivate) // check isPrivate == true - result, err = clientSet.Document().List(context.TODO(), fmt.Sprintf("name='my-dashboard_%s'", testContext.suffix)) + result, err = clientSet.DocumentClient.List(context.TODO(), fmt.Sprintf("name='my-dashboard_%s'", testContext.suffix)) assert.NoError(t, err) assert.Len(t, result.Responses, 1) assert.True(t, result.Responses[0].IsPrivate) @@ -101,13 +103,13 @@ func TestDocuments(t *testing.T) { assert.NoError(t, err) // check if isPrivate was changed to true - result, err = clientSet.Document().List(context.TODO(), fmt.Sprintf("name='my-notebook_%s'", testContext.suffix)) + result, err = clientSet.DocumentClient.List(context.TODO(), fmt.Sprintf("name='my-notebook_%s'", testContext.suffix)) assert.NoError(t, err) assert.Len(t, result.Responses, 1) assert.True(t, result.Responses[0].IsPrivate) // check if isPrivate was changed to false - result, err = clientSet.Document().List(context.TODO(), fmt.Sprintf("name='my-dashboard_%s'", testContext.suffix)) + result, err = clientSet.DocumentClient.List(context.TODO(), fmt.Sprintf("name='my-dashboard_%s'", testContext.suffix)) assert.NoError(t, err) assert.Len(t, result.Responses, 1) assert.False(t, result.Responses[0].IsPrivate) diff --git a/cmd/monaco/integrationtest/v2/scoped_configs_test.go b/cmd/monaco/integrationtest/v2/scoped_configs_test.go index 6270a398d..a244b4dee 100644 --- a/cmd/monaco/integrationtest/v2/scoped_configs_test.go +++ b/cmd/monaco/integrationtest/v2/scoped_configs_test.go @@ -73,17 +73,17 @@ func assertOverallDashboardSharedState(t *testing.T, fs afero.Fs, testContext Te dashboardAPI := apis[api.Dashboard] dashboardName := integrationtest.AddSuffix("Application monitoring", testContext.suffix) - exists, dashboardID, err := clientSet.Config().ExistsWithName(context.TODO(), dashboardAPI, dashboardName) + exists, dashboardID, err := clientSet.ConfigClient.ExistsWithName(context.TODO(), dashboardAPI, dashboardName) require.NoError(t, err, "expect to be able to get dashboard by name") require.True(t, exists, "dashboard must exist") - dashboardJSONBytes, err := clientSet.Config().Get(context.TODO(), dashboardAPI, dashboardID) + dashboardJSONBytes, err := clientSet.ConfigClient.Get(context.TODO(), dashboardAPI, dashboardID) require.NoError(t, err, "expect to be able to get dashboard by ID") assertDashboardSharedState(t, dashboardJSONBytes, expectShared) dashboardShareSettingsAPI := apis[api.DashboardShareSettings].ApplyParentObjectID(dashboardID) - dashboardShareSettingsJSONBytes, err := clientSet.Config().Get(context.TODO(), dashboardShareSettingsAPI, "") + dashboardShareSettingsJSONBytes, err := clientSet.ConfigClient.Get(context.TODO(), dashboardShareSettingsAPI, "") require.NoError(t, err, "expect to be able to get dashboard shared settings by ID") assertDashboardShareSettingsEnabledState(t, dashboardShareSettingsJSONBytes, expectShared) } diff --git a/cmd/monaco/integrationtest/v2/skip_e2e_test.go b/cmd/monaco/integrationtest/v2/skip_e2e_test.go index 56ccb1d89..43ba33524 100644 --- a/cmd/monaco/integrationtest/v2/skip_e2e_test.go +++ b/cmd/monaco/integrationtest/v2/skip_e2e_test.go @@ -105,7 +105,7 @@ func TestSkip(t *testing.T) { for name, def := range loadedManifest.Environments { set := integrationtest.CreateDynatraceClients(t, def) - clients[name] = set.Settings() + clients[name] = set.SettingsClient } for _, tt := range tests { diff --git a/pkg/client/clientset.go b/pkg/client/clientset.go index bc7e8a017..44d6155f4 100644 --- a/pkg/client/clientset.go +++ b/pkg/client/clientset.go @@ -192,30 +192,6 @@ type ClientSet struct { OpenPipelineClient OpenPipelineClient } -func (s ClientSet) Config() ConfigClient { - return s.ConfigClient -} - -func (s ClientSet) Settings() SettingsClient { - return s.SettingsClient -} - -func (s ClientSet) Automation() AutomationClient { - return s.AutClient -} - -func (s ClientSet) Bucket() BucketClient { - return s.BucketClient -} - -func (s ClientSet) Document() DocumentClient { - return s.DocumentClient -} - -func (s ClientSet) OpenPipeline() OpenPipelineClient { - return s.OpenPipelineClient -} - type ClientOptions struct { CustomUserAgent string SupportArchive bool