classic

package
v2.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package downloader is responsible for downloading configurations from Dynatrace.

The process looks like this:

result = array[api, templates]

for each api in apis:
	to_download = array[api, list]
	if api.isSingletonApi:
		to_download += (api, mock_download_value(api)) # Since we don't need a list-call, we can simply add this value to the array.
	else
		list <- dynatrace.ListAll(api) # List query for all configs of api
		list <- filter(list) # Remove unwanted values we already know we don't want to download
		to_download += (api, list)
	fi

	templates = array[]
	for each value in 'to_download':
		config <- dynatrace.Get(value)
		if skip(config) next # skip configs like presets

		template <- extract_and_sanitize(config)

		templates += template
	end_for

	results += (api, templates)
end_for

return result

```

Index

Constants

This section is empty.

Variables

View Source
var ApiContentFilters = map[string]ContentFilter{
	api.Dashboard: {
		ShouldBeSkippedPreDownload: func(value dtclient.Value) bool {
			return value.Owner != nil && *value.Owner == "Dynatrace"
		},
		ShouldConfigBePersisted: func(json map[string]interface{}) bool {
			if json["dashboardMetadata"] != nil {
				metadata := json["dashboardMetadata"].(map[string]interface{})

				if metadata["preset"] != nil && metadata["preset"] == true && metadata["owner"] == "Dynatrace" {
					return false
				}
			}

			return true
		},
	},
	api.SyntheticLocation: {
		ShouldConfigBePersisted: func(json map[string]interface{}) bool {
			return json["type"] == "PRIVATE"
		},
	},
	api.HostsAutoUpdate: {

		ShouldConfigBePersisted: func(json map[string]interface{}) bool {
			autoUpdates, ok := json["updateWindows"]
			if !ok {
				return true
			}

			windows, ok := autoUpdates.(map[string]interface{})["windows"].([]interface{})
			if !ok {
				return true
			}

			return len(windows) > 0
		},
	},
	api.AnomalyDetectionMetrics: {
		ShouldBeSkippedPreDownload: func(value dtclient.Value) bool {
			return strings.HasPrefix(value.Id, "dynatrace.") || strings.HasPrefix(value.Id, "ruxit.")
		},
	},
	api.NetworkZone: {
		ShouldBeSkippedPreDownload: func(value dtclient.Value) bool {
			return value.Id == "default"
		},
	},
}

ApiContentFilters defines default ContentFilter rules per API identifier

Functions

func Download added in v2.10.1

func Download(client client.ConfigClient, projectName string, apisToDownload api.APIs, filters ContentFilters) (projectv2.ConfigsPerType, error)

Types

type ContentFilter added in v2.5.0

type ContentFilter struct {
	// ShouldBeSkippedPreDownload is an optional callback indicating that a config should not be downloaded after the list of the configs
	ShouldBeSkippedPreDownload func(value dtclient.Value) bool

	// ShouldConfigBePersisted is an optional callback to check whether a config should be persisted after being downloaded
	ShouldConfigBePersisted func(json map[string]interface{}) bool
}

ContentFilter defines whether a given API value should be skipped - either already PreDownload or based on it's full json content

type ContentFilters added in v2.10.1

type ContentFilters map[string]ContentFilter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL