Skip to content

Commit

Permalink
Remove map of subdomains to environments (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinag08 authored Jun 6, 2024
1 parent df98be4 commit 0eaec59
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions pkg/cmdutil/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@ import (
"strings"
)

// SubdomainToEnvironmentMap is a map of subdomains to environments
var SubdomainToEnvironmentMap = map[string]string{
"test": "test",
"dev": "test",
"awsd": "test",
"azd": "test",
"production": "production",
"awsp": "production",
"azp": "production",
}

const boxerURL = "https://boxer.%s.sneaksanddata.com"

// AuthServiceFactory is responsible for creating instances of AuthService.
Expand Down Expand Up @@ -52,10 +41,6 @@ func (f *AuthServiceFactory) CreateAuthService(env, provider string) (*auth.Serv
// InitializeAuthService initializes the AuthService based on a URL and an AuthProvider.
// It checks the URL for a known subdomain to determine the environment.
func InitializeAuthService(url, env, authProvider string, authServiceFactory AuthServiceFactory) (*auth.Service, error) {
matchedUrl, matchedEnv := containsSubdomain(url, SubdomainToEnvironmentMap)
if matchedUrl != "" {
env = matchedEnv
}
return authServiceFactory.CreateAuthService(env, authProvider)
}

Expand Down Expand Up @@ -165,16 +150,6 @@ func processURL(url, env string) string {
return url
}

// containsSubdomain checks if the given URL contains any subdomain as defined in the subdomainMap.
func containsSubdomain(url string, subdomainMap map[string]string) (string, string) {
for key, value := range subdomainMap {
if strings.Contains(url, key) {
return url, value // Found a match, return the url and environment
}
}
return "", "" // No match found
}

// createTokenProvider initializes a token.Provider with the given environment and AuthService.
func createTokenProvider(env string, authService token.AuthService) (*token.Provider, error) {
tp, err := token.NewProvider(authService, env)
Expand Down

0 comments on commit 0eaec59

Please sign in to comment.