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
2 changes: 1 addition & 1 deletion pkg/configuration/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func SetFlag(flag string, enable bool) {
func GetFlagDefault(flag string) bool {
switch flag {
case models.FlagAnalytics:
return true
return false
case models.FlagEnvWarning:
return true
case models.FlagUpdateCheck:
Expand Down
3 changes: 1 addition & 2 deletions pkg/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ type VersionCheck struct {
}

type AnalyticsOptions struct {
// we use the key 'disable' rather than 'enable' because blank value are automatically parsed as 'false',
// and we want this feature to be enabled by default
// Deprecated: retained only for interop with CLI versions that predate the 'flags' property.
Disable bool `yaml:"disable"`
}

Expand Down
21 changes: 14 additions & 7 deletions tests/e2e/analytics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,31 @@ beforeAll

beforeEach

# analytics defaults to enabled
# analytics defaults to disabled
status="$("$DOPPLER_BINARY" analytics status --configuration=./temp-config --json)"
[[ "$status" == '{"enabled":true}' ]] || error "ERROR: analytics not enabled"
[[ "$status" == '{"enabled":false}' ]] || error "ERROR: analytics not disabled"

beforeEach

# analytics defaults to enabled after clearing config
# analytics defaults to disabled after clearing config
"$DOPPLER_BINARY" configure reset --configuration=./temp-config --yes
status="$("$DOPPLER_BINARY" analytics status --configuration=./temp-config --json)"
[[ "$status" == '{"enabled":true}' ]] || error "ERROR: analytics not enabled after reset"
[[ "$status" == '{"enabled":false}' ]] || error "ERROR: analytics not disabled after reset"

beforeEach

# analytics defaults to enabled after disabling and then clearing config
"$DOPPLER_BINARY" analytics disable --configuration=./temp-config >/dev/null 2>&1
# analytics defaults to disabled after enabling and then clearing config
"$DOPPLER_BINARY" analytics enable --configuration=./temp-config >/dev/null 2>&1
"$DOPPLER_BINARY" configure reset --configuration=./temp-config --yes
status="$("$DOPPLER_BINARY" analytics status --configuration=./temp-config --json)"
[[ "$status" == '{"enabled":true}' ]] || error "ERROR: analytics not enabled after diabling and resetting"
[[ "$status" == '{"enabled":false}' ]] || error "ERROR: analytics not disabled after enabling and resetting"

beforeEach

# analytics can be enabled
"$DOPPLER_BINARY" analytics enable --configuration=./temp-config >/dev/null 2>&1
status="$("$DOPPLER_BINARY" analytics status --configuration=./temp-config --json)"
[[ "$status" == '{"enabled":true}' ]] || error "ERROR: analytics not enabled"

beforeEach

Expand Down
30 changes: 24 additions & 6 deletions tests/e2e/flags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ error() {

flags=('analytics' 'env-warning' 'update-check')

# analytics is opt-in, all other flags are enabled by default
defaultValue() {
case "$1" in
analytics) echo 'false' ;;
*) echo 'true' ;;
esac
}

beforeAll

beforeEach

# verify defaults
for flag in "${flags[@]}"; do
[[ "$("$DOPPLER_BINARY" configure flags get "$flag" --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect default for $flag"
[[ "$("$DOPPLER_BINARY" configure flags get "$flag" --plain --config-dir=$TEST_CONFIG_DIR)" == "$(defaultValue "$flag")" ]] || error "ERROR: incorrect default for $flag"
done

beforeEach
Expand All @@ -63,17 +71,17 @@ done
for flag in "${flags[@]}"; do
"$DOPPLER_BINARY" configure flags disable "$flag" --config-dir=$TEST_CONFIG_DIR >/dev/null 2>/dev/null
"$DOPPLER_BINARY" configure flags reset -y "$flag" --config-dir=$TEST_CONFIG_DIR >/dev/null 2>/dev/null
[[ "$("$DOPPLER_BINARY" configure flags get "$flag" --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect value for $flag after reset"
[[ "$("$DOPPLER_BINARY" configure flags get "$flag" --plain --config-dir=$TEST_CONFIG_DIR)" == "$(defaultValue "$flag")" ]] || error "ERROR: incorrect value for $flag after reset"
done

beforeEach

# verify interoperability between 'flags' command and legacy 'analytics' command
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect initial value for analytics"
"$DOPPLER_BINARY" analytics disable --config-dir=$TEST_CONFIG_DIR >/dev/null 2>&1
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'false' ]] || error "ERROR: incorrect disabled value for analytics"
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'false' ]] || error "ERROR: incorrect initial value for analytics"
"$DOPPLER_BINARY" analytics enable --config-dir=$TEST_CONFIG_DIR >/dev/null 2>&1
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect enabled value for analytics"
"$DOPPLER_BINARY" analytics disable --config-dir=$TEST_CONFIG_DIR >/dev/null 2>&1
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'false' ]] || error "ERROR: incorrect disabled value for analytics"

beforeEach

Expand All @@ -86,11 +94,21 @@ EOF

[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'false' ]] || error "ERROR: incorrect value read when parsing legacy analytics field in config file"

# legacy 'disable: false' is not an opt-in; older binaries wrote it unconditionally,
# so it's indistinguishable from the field being unset
cat << EOF > ./temp-config-dir/.doppler.yaml
analytics:
disable: false
EOF

[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect value read when parsing legacy analytics field in config file"
[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'false' ]] || error "ERROR: legacy 'analytics.disable: false' field in config file treated as an opt-in"

# parse analytics flag from config file
cat << EOF > ./temp-config-dir/.doppler.yaml
flags:
analytics: true
EOF

[[ "$("$DOPPLER_BINARY" configure flags get analytics --plain --config-dir=$TEST_CONFIG_DIR)" == 'true' ]] || error "ERROR: incorrect value read when parsing analytics flag in config file"

afterAll
4 changes: 2 additions & 2 deletions tests/e2e/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ beforeEach

cat << EOF > doppler.yaml
flags:
analytics: false
analytics: true
env-warning: false
update-check: false
EOF
"$DOPPLER_BINARY" setup --config-dir=$TEST_CONFIG_DIR --no-interactive
[[ "$("$DOPPLER_BINARY" configure flags get analytics --config-dir=$TEST_CONFIG_DIR --plain)" == 'false' ]] || error "ERROR: setup not setting disabled value for analytics"
[[ "$("$DOPPLER_BINARY" configure flags get analytics --config-dir=$TEST_CONFIG_DIR --plain)" == 'true' ]] || error "ERROR: setup not setting enabled value for analytics"
[[ "$("$DOPPLER_BINARY" configure flags get env-warning --config-dir=$TEST_CONFIG_DIR --plain)" == 'false' ]] || error "ERROR: setup not setting disabled value for env-warning"
[[ "$("$DOPPLER_BINARY" configure flags get update-check --config-dir=$TEST_CONFIG_DIR --plain)" == 'false' ]] || error "ERROR: setup not setting disabled value for update-check"

Expand Down
Loading