2021-08-13 20:31:04 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-08-30 10:51:31 +01:00
|
|
|
"context"
|
2021-08-13 20:31:04 +01:00
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
|
2022-01-06 19:55:46 +00:00
|
|
|
"storj.io/storj/cmd/uplink/ulext"
|
2021-08-13 20:31:04 +01:00
|
|
|
)
|
|
|
|
|
2023-01-17 02:16:10 +00:00
|
|
|
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
|
|
|
|
}
|
2021-08-13 20:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
values := make(map[string]string)
|
2023-01-17 02:16:10 +00:00
|
|
|
|
|
|
|
if analyticsEnabled {
|
|
|
|
values["analytics.enabled"] = "true"
|
|
|
|
} else {
|
2021-08-13 20:31:04 +01:00
|
|
|
values["metrics.addr"] = ""
|
2022-09-27 21:32:07 +01:00
|
|
|
values["analytics.enabled"] = "false"
|
2021-08-13 20:31:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ex.SaveConfig(values)
|
|
|
|
}
|