Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all references to staging environment #1417

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
37 changes: 1 addition & 36 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ const (
// ProxiesURL is the URL for fetching the per user proxy config.
ProxiesURL = "http://config.getiantem.org/proxies.yaml.gz"

// ProxiesStagingURL is the URL for fetching the per user proxy config in a staging environment.
ProxiesStagingURL = "http://config-staging.getiantem.org/proxies.yaml.gz"

// Sentry Configurations
SentryTimeout = time.Second * 30
SentryMaxMessageChars = 8000
Expand All @@ -37,15 +34,6 @@ var (
// GlobalURL URL for fetching the global config.
GlobalURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz"

// GlobalStagingURL is the URL for fetching the global config in a staging environment.
GlobalStagingURL = "https://globalconfig.flashlightproxy.com/global.yaml.gz"

// StagingMode if true, run Lantern against our staging infrastructure.
// This is set by the linker using -ldflags
StagingMode = "false"

Staging = false

ProAPIHost = "api.getiantem.org"

log = golog.LoggerFor("flashlight.common")
Expand All @@ -58,31 +46,8 @@ var (
Environment = "production"
)

func init() {
initInternal()
}

// ForceStaging forces staging mode.
func ForceStaging() {
StagingMode = "true"
initInternal()
}

func initInternal() {
var err error
log.Debugf("****************************** stagingMode: %v", StagingMode)
Staging, err = strconv.ParseBool(StagingMode)
if err != nil {
log.Errorf("Error parsing boolean flag: %v", err)
return
}
if Staging {
ProAPIHost = "api-staging.getiantem.org"
}
forceAds, _ = strconv.ParseBool(os.Getenv("FORCEADS"))
}

// ForceAds indicates whether adswapping should be forced to 100%
func ForceAds() bool {
forceAds, _ = strconv.ParseBool(os.Getenv("FORCEADS"))
return forceAds
}
5 changes: 0 additions & 5 deletions config/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,4 @@ func TestStagingSetup(t *testing.T) {
fetch = newHttpFetcher(newTestUserConfig(), rt, url).(*fetcher)

assert.Equal(t, "http://config.getiantem.org/proxies.yaml.gz", fetch.originURL)

stagingURL := common.ProxiesStagingURL
flags["staging"] = true
fetch = newHttpFetcher(newTestUserConfig(), rt, stagingURL).(*fetcher)
assert.Equal(t, "http://config-staging.getiantem.org/proxies.yaml.gz", fetch.originURL)
}
31 changes: 2 additions & 29 deletions config/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ func Init(
origGlobalDispatch func(interface{}, Source), onGlobalSaveError func(error),
rt http.RoundTripper) (stop func()) {

staging := isStaging(flags)
proxyConfigURL := checkOverrides(flags, getProxyURL(staging), "proxies.yaml.gz")
globalConfigURL := checkOverrides(flags, getGlobalURL(staging), "global.yaml.gz")
proxyConfigURL := checkOverrides(flags, common.ProxiesURL, "proxies.yaml.gz")
globalConfigURL := checkOverrides(flags, common.GlobalURL, "global.yaml.gz")

return InitWithURLs(
configDir, flags, userConfig, proxiesDispatch, onProxiesSaveError,
Expand Down Expand Up @@ -192,10 +191,6 @@ func obfuscate(flags map[string]interface{}) bool {
return flags["readableconfig"] == nil || !flags["readableconfig"].(bool)
}

func isStaging(flags map[string]interface{}) bool {
return checkBool(flags, "staging")
}

func isSticky(flags map[string]interface{}) bool {
return checkBool(flags, "stickyconfig")
}
Expand All @@ -217,25 +212,3 @@ func checkOverrides(flags map[string]interface{},
}
return url
}

// getProxyURL returns the proxy URL to use depending on whether or not
// we're in staging.
func getProxyURL(staging bool) string {
if staging {
log.Debug("Will obtain proxies.yaml from staging service")
return common.ProxiesStagingURL
}
log.Debug("Will obtain proxies.yaml from production service")
return common.ProxiesURL
}

// getGlobalURL returns the global URL to use depending on whether or not
// we're in staging.
func getGlobalURL(staging bool) string {
if staging {
log.Debug("Will obtain global.yaml from staging service")
return common.GlobalStagingURL
}
log.Debugf("Will obtain global.yaml from production service at %v", common.GlobalURL)
return common.GlobalURL
}
12 changes: 0 additions & 12 deletions config/initializer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func TestInit(t *testing.T) {
defer deleteGlobalConfig()

flags := make(map[string]interface{})
flags["staging"] = true

gotProxies := eventual.NewValue()
gotGlobal := eventual.NewValue()
Expand Down Expand Up @@ -104,17 +103,6 @@ func TestInitWithURLs(t *testing.T) {
})
}

func TestStaging(t *testing.T) {
flags := make(map[string]interface{})
flags["staging"] = true

assert.True(t, isStaging(flags))

flags["staging"] = false

assert.False(t, isStaging(flags))
}

// TestOverrides tests url override flags
func TestOverrides(t *testing.T) {
url := "host"
Expand Down
1 change: 0 additions & 1 deletion flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type Flags struct {
Initialize bool `flag:"initialize" help:"silently initialize Lantern to a state of having working proxy and exit, typically during installation."`
Timeout time.Duration `flag:"timeout" help:"force stop Lantern with an exit status of -1 after the timeout."`
ReplicaRustUrl string `flag:"replica-rust-url" help:"use the replica-rust service at the provided endpoint"`
Staging bool `flag:"-"`
Experiments []string `flag:"enabled-experiments" help:"comma separated list of experiments to enable"`
}

Expand Down
4 changes: 0 additions & 4 deletions pro/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ func generateUser() *common.UserConfigData {
return common.NewUserConfigData(common.DefaultAppName, generateDeviceId(), int64(rand.Uint64()), fmt.Sprintf("aasfge%d", rand.Uint64()), nil, "en-US")
}

func init() {
common.ForceStaging()
}

func createClient(resp *http.Response) *Client {
mockedHTTPClient := createMockClient(resp)
return NewClient(mockedHTTPClient, func(req *http.Request, uc common.UserConfig) {
Expand Down
2 changes: 0 additions & 2 deletions pro/user_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import (
)

func TestUsers(t *testing.T) {
common.ForceStaging()

deviceID := "77777777"
userID := int64(1000)
token := uuid.NewString()
Expand Down
Loading