storj/cmd/uplink/initial_setup.go
dlamarmorgan d53a56cef6 cmd/uplink/initial_setup.go: fix logic on analytics prompt
Correct the logic for the analytics prompt on a new setup of uplink.

Change-Id: I86755711dd2f3c8418609bd7072ae5d55927b841
2023-04-18 03:02:12 +00:00

47 lines
1.1 KiB
Go

// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"context"
"strings"
"github.com/zeebo/errs"
"storj.io/storj/cmd/uplink/ulext"
)
func saveInitialConfig(ctx context.Context, ex ulext.External, interactiveFlag bool, analyticsFlag *bool) error {
var analyticsEnabled bool
if analyticsFlag != nil {
analyticsEnabled = *analyticsFlag
} else {
if interactiveFlag {
answer, err := ex.PromptInput(ctx, `With your permission, Storj can `+
`automatically collect analytics information from your uplink CLI to `+
`help improve the quality and performance of our products. This `+
`information is sent only with your consent and is submitted `+
`anonymously to Storj Labs: (y/n)`)
if err != nil {
return errs.Wrap(err)
}
answer = strings.ToLower(answer)
analyticsEnabled = answer == "y" || answer == "yes"
} else {
analyticsEnabled = false
}
}
values := make(map[string]string)
if analyticsEnabled {
values["analytics.enabled"] = "true"
} else {
values["metrics.addr"] = ""
values["analytics.enabled"] = "false"
}
return ex.SaveConfig(values)
}