Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
)

const (
// Change both values when Cluster direct central create is customer-released.
centralEnrichmentDefault = false
centralEnrichmentHidden = true
// Cloud monitoring configs are created with central enrichment unless the
// caller opts out. Reverting to the hidden, backend-chosen mode is a matter
// of flipping both values back.
centralEnrichmentDefault = true
centralEnrichmentHidden = false
)

// createCmd represents the create command
Expand Down Expand Up @@ -54,11 +56,10 @@ Supported resources:
// schema, so nil ("let the backend choose") must stay distinguishable from an
// explicit false ("keep legacy enrichment").
//
// While the flag is hidden and defaults to false, an untouched flag means the
// caller has no opinion and the field is omitted. Once centralEnrichmentDefault
// flips to true at customer release the value is always sent explicitly, so
// --central-enrichment=false remains a working opt-out instead of silently
// falling back to the backend default.
// With centralEnrichmentDefault set to true the value is always sent
// explicitly, so --central-enrichment=false remains a working opt-out instead
// of silently falling back to the backend default. Only with the default off
// does an untouched flag mean "no opinion" and omit the field.
func centralEnrichmentIntent(cmd *cobra.Command, enabled bool) *bool {
if !centralEnrichmentDefault && !cmd.Flags().Changed("central-enrichment") {
return nil
Expand All @@ -67,7 +68,7 @@ func centralEnrichmentIntent(cmd *cobra.Command, enabled bool) *bool {
}

func addCentralEnrichmentFlag(command *cobra.Command, target *bool) {
command.Flags().BoolVar(target, "central-enrichment", centralEnrichmentDefault, "Use central enrichment configuration")
command.Flags().BoolVar(target, "central-enrichment", centralEnrichmentDefault, "Use central enrichment configuration (--central-enrichment=false keeps legacy enrichment)")
if centralEnrichmentHidden {
_ = command.Flags().MarkHidden("central-enrichment")
}
Expand Down
22 changes: 11 additions & 11 deletions cmd/create_cloud_monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/Dynatrace/dtctl/pkg/resources/gcpmonitoringconfig"
)

func TestCloudMonitoringCentralEnrichmentFlagsAreHiddenAndDisabledByDefault(t *testing.T) {
func TestCloudMonitoringCentralEnrichmentFlagsAreVisibleAndEnabledByDefault(t *testing.T) {
commands := []struct {
name string
cmd *cobra.Command
Expand All @@ -28,11 +28,11 @@ func TestCloudMonitoringCentralEnrichmentFlagsAreHiddenAndDisabledByDefault(t *t
if flag == nil {
t.Fatal("central-enrichment flag is not registered")
}
if !flag.Hidden {
t.Error("central-enrichment flag must remain hidden before customer release")
if flag.Hidden {
t.Error("central-enrichment flag must be visible so the legacy opt-out is discoverable")
}
if flag.DefValue != "false" {
t.Errorf("central-enrichment default = %q, want false", flag.DefValue)
if flag.DefValue != "true" {
t.Errorf("central-enrichment default = %q, want true", flag.DefValue)
}
})
}
Expand All @@ -46,9 +46,10 @@ func TestCentralEnrichmentIntent(t *testing.T) {
return cmd
}

t.Run("untouched flag is omitted", func(t *testing.T) {
if intent := centralEnrichmentIntent(newCmd(), centralEnrichmentDefault); intent != nil {
t.Errorf("intent = %v, want nil so the backend keeps its own default", *intent)
t.Run("untouched flag sends central", func(t *testing.T) {
intent := centralEnrichmentIntent(newCmd(), centralEnrichmentDefault)
if intent == nil || !*intent {
t.Errorf("intent = %v, want true", intent)
}
})

Expand All @@ -63,9 +64,8 @@ func TestCentralEnrichmentIntent(t *testing.T) {
}
})

// The rollout switch documented in create.go flips the default to true. An
// explicit --central-enrichment=false has to stay a working opt-out at that
// point, which it only does if "false" is distinguishable from "unset".
// With the default on, an explicit --central-enrichment=false is the only
// way to ask for legacy enrichment, so it must be sent rather than omitted.
t.Run("explicit false is sent", func(t *testing.T) {
cmd := newCmd()
if err := cmd.Flags().Set("central-enrichment", "false"); err != nil {
Expand Down
6 changes: 5 additions & 1 deletion docs/resources/cloud-integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ There is no dedicated `aws`/`azure`/`gcp` resource type in the command catalog.

## Flags

Resource commands take dtctl's **global flags** (`-o/--output`, `--context`, `--jq`, `-v`, ...). Cloud-integration commands add their own noun-specific flags, such as `--name` (sets the name on `create`), `--regions`, `--feature-sets`, `--credentials`, `--role-arn` (AWS), `--type`, `--directory-id`, `--application-id`, `--client-secret`, `--locations` (Azure), and `--service-account-id` (GCP connections), plus `--credentials`, `--locations`, and `--feature-sets` (GCP monitoring). See the examples below for their usage in context.
Resource commands take dtctl's **global flags** (`-o/--output`, `--context`, `--jq`, `-v`, ...). Cloud-integration commands add their own noun-specific flags, such as `--name` (sets the name on `create`), `--regions`, `--feature-sets`, `--credentials`, `--role-arn` (AWS), `--type`, `--directory-id`, `--application-id`, `--client-secret`, `--locations` (Azure), and `--service-account-id` (GCP connections), plus `--credentials`, `--locations`, and `--feature-sets` (GCP monitoring). `create aws|azure|gcp monitoring` also takes `--central-enrichment` (see [Central enrichment](#central-enrichment)). See the examples below for their usage in context.

**Renamed in 0.48.0 (before 1.0).** From 0.48.0 the camelCase flags and their spelling aliases no longer exist; the old names are not accepted. An old name fails with `unknown flag: --roleArn (renamed to --role-arn)`.

Expand Down Expand Up @@ -248,6 +248,10 @@ dtctl delete gcp connection my-gcp-connection

## Notes

### Central enrichment

`dtctl create aws|azure|gcp monitoring` creates the configuration with central enrichment (`useIngestEnrichmentConfig: true`). Pass `--central-enrichment=false` to keep legacy enrichment. Some environments enforce central enrichment on every write, and there the stored configuration is central regardless of the flag. `update` and `enable` resend the stored value, and `apply` sends `useIngestEnrichmentConfig` only if the file sets it.

### AWS: IAM role deployment script

The connection command prints a ready-to-run snippet, but the underlying script is worth knowing if you need to adapt it (for example, to change the stack name or region). It downloads Dynatrace's least-privilege role template and deploys it as a CloudFormation stack, then reads the role ARN back out of the stack outputs:
Expand Down
Loading