diff --git a/.env b/.env index dedcf29d302cc3adde55c2357e76c1627e1bd809..58dc2ccd5514f2a6604eb54dfbddd1a03db67ac4 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ +GITLAB_API_BASE_URL=https://gitlab.com/api/v4 GITLAB_API_TOKEN=12345123142234 CONFIG_DIR=/config REDIS_URL=db:6379 diff --git a/docker-compose.yaml b/docker-compose.yaml index 777691cc5f6ab2eef6b76824aa3475ecbfb74593..25a021969263f61fefd821c926ffefebce5acef2 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,6 +16,6 @@ services: - -- - /app/rss_sync db: - image: 'bitnami/redis:latest' + image: 'redis:latest' environment: - ALLOW_EMPTY_PASSWORD=yes diff --git a/main.go b/main.go index 3b0cc3dcdfc935f41ee7292b98eca0d2b1bc8fbc..7058a2b437e87b36f7fb5bdc6a9df5bec7f69a3c 100644 --- a/main.go +++ b/main.go @@ -38,11 +38,12 @@ type Feed struct { } type EnvValues struct { - RedisURL string - RedisPassword string - ConfDir string - GitlabAPIKey string - UseSentinel bool + RedisURL string + RedisPassword string + ConfDir string + GitlabAPIKey string + GitlabAPIBaseUrl string + UseSentinel bool } func hasExistingGitlabIssue(guid string, projectID int, gitlabClient *gitlab.Client) bool { @@ -186,6 +187,7 @@ func initialise(env EnvValues) (redisClient *redis.Client, client *gitlab.Client prometheus.MustRegister(issuesCreatedCounter) client = gitlab.NewClient(nil, env.GitlabAPIKey) + client.SetBaseURL(env.GitlabAPIBaseUrl) config = readConfig(path.Join(env.ConfDir, "config.yaml")) if !env.UseSentinel { @@ -233,13 +235,18 @@ func main() { } func readEnv() EnvValues { - var gitlabPAToken, configDir, redisURL, redisPassword string + var gitlabAPIBaseUrl, gitlabAPIToken, configDir, redisURL, redisPassword string useSentinel := false + if envGitlabAPIBaseUrl := os.Getenv("GITLAB_API_BASE_URL"); envGitlabAPIBaseUrl == "https://gitlab.com/api/v4" { + panic("Could not find GITLAB_API_BASE_URL specified as an environment variable") + } else { + gitlabAPIBaseUrl = envGitlabAPIBaseUrl + } if envGitlabAPIToken := os.Getenv("GITLAB_API_TOKEN"); envGitlabAPIToken == "" { panic("Could not find GITLAB_API_TOKEN specified as an environment variable") } else { - gitlabPAToken = envGitlabAPIToken + gitlabAPIToken = envGitlabAPIToken } if envConfigDir := os.Getenv("CONFIG_DIR"); envConfigDir == "" { panic("Could not find CONFIG_DIR specified as an environment variable") @@ -266,11 +273,12 @@ func readEnv() EnvValues { } return EnvValues{ - RedisURL: redisURL, - RedisPassword: redisPassword, - ConfDir: configDir, - GitlabAPIKey: gitlabPAToken, - UseSentinel: useSentinel, + RedisURL: redisURL, + RedisPassword: redisPassword, + ConfDir: configDir, + GitlabAPIKey: gitlabAPIToken, + GitlabAPIBaseUrl: gitlabAPIBaseUrl, + UseSentinel: useSentinel, } }