diff --git a/config/config_test.go b/config/config_test.go index 4cbcb1bd..f144def0 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -319,19 +319,4 @@ func Test_Misc(t *testing.T) { t.Setenv("RELEASE_NAME", "value") require.Equal(t, "value", GetReleaseName()) - - t.Setenv("INSTANCE_ID", "allbirds-v0-rudderstack-gw-ha-0-85d66f748f-8w4td") - require.Equal(t, "0", GetInstanceID()) - - t.Setenv("INSTANCE_ID", "prousmtusmt-v0-rs-gw-0") - require.Equal(t, "0", GetInstanceID()) - - t.Setenv("INSTANCE_ID", "prousmtusmt-v0-rs") - require.Equal(t, "", GetInstanceID()) - - t.Setenv("INSTANCE_ID", "prousmtusmt-v0-rs-gw-10") - require.Equal(t, "10", GetInstanceID()) - - t.Setenv("INSTANCE_ID", "prousmtusmt-v0-rs-gw-ha-12-234234-10") - require.Equal(t, "12", GetInstanceID()) } diff --git a/config/misc.go b/config/misc.go index e1935d84..c926fe6c 100644 --- a/config/misc.go +++ b/config/misc.go @@ -2,13 +2,6 @@ package config import ( "os" - "regexp" - "strings" -) - -var ( - regexGwHa = regexp.MustCompile(`^.*-gw-ha-\d+-\w+-\w+$`) - regexGwNonHaOrProcessor = regexp.MustCompile(`^.*-\d+$`) ) // GetWorkspaceToken returns the workspace token provided in the environment variables @@ -36,21 +29,6 @@ func GetKubeNamespace() string { return os.Getenv("KUBE_NAMESPACE") } -func GetInstanceID() string { - instance := GetString("INSTANCE_ID", "") - instanceArr := strings.Split(instance, "-") - length := len(instanceArr) - // This handles 2 kinds of server instances - // a) Processor OR Gateway running in non HA mod where the instance name ends with the index - // b) Gateway running in HA mode, where the instance name is of the form *-gw-ha--- - if (regexGwHa.MatchString(instance)) && (length > 3) { - return instanceArr[length-3] - } else if (regexGwNonHaOrProcessor.MatchString(instance)) && (length > 1) { - return instanceArr[length-1] - } - return "" -} - func GetReleaseName() string { return os.Getenv("RELEASE_NAME") }