diff --git a/.env.example b/.env.example index c2efded5..fe10f0a4 100644 --- a/.env.example +++ b/.env.example @@ -5,3 +5,4 @@ KETCHUP_DB_NAME=postgres KETCHUP_DB_PASS= KETCHUP_REDIS_ADDRESS=localhost:6379 KETCHUP_REDIS_PASSWORD= +KETCHUP_GITHUB_TOKEN= diff --git a/cmd/ketchup/api.go b/cmd/ketchup/api.go index 003a5f66..51c6ce07 100644 --- a/cmd/ketchup/api.go +++ b/cmd/ketchup/api.go @@ -134,7 +134,7 @@ func main() { userServiceService := userService.New(userStore.New(ketchupDb), &authServiceService) githubService := github.New(githubConfig, redisClient, telemetryService.MeterProvider(), telemetryService.TracerProvider()) - dockerService := docker.New(dockerConfig) + dockerService := docker.New(dockerConfig, githubConfig.Token) helmService := helm.New() npmService := npm.New() pypiService := pypi.New() diff --git a/cmd/notifier/notifier.go b/cmd/notifier/notifier.go index 6d15db01..14d6dd72 100644 --- a/cmd/notifier/notifier.go +++ b/cmd/notifier/notifier.go @@ -79,7 +79,7 @@ func main() { helmService := helm.New() npmService := npm.New() pypiService := pypi.New() - repositoryServiceService := repositoryService.New(repositoryStore.New(ketchupDb), github.New(githubConfig, nil, nil, telemetryService.TracerProvider()), helmService, docker.New(dockerConfig), npmService, pypiService) + repositoryServiceService := repositoryService.New(repositoryStore.New(ketchupDb), github.New(githubConfig, nil, nil, telemetryService.TracerProvider()), helmService, docker.New(dockerConfig, githubConfig.Token), npmService, pypiService) ketchupServiceService := ketchupService.New(ketchupStore.New(ketchupDb), repositoryServiceService) userServiceService := userService.New(userStore.New(ketchupDb), nil) diff --git a/pkg/provider/docker/docker.go b/pkg/provider/docker/docker.go index 796b7daf..6f8332c3 100644 --- a/pkg/provider/docker/docker.go +++ b/pkg/provider/docker/docker.go @@ -29,8 +29,9 @@ type authResponse struct { } type Service struct { - username string - password string + username string + password string + githubToken string } type Config struct { @@ -47,10 +48,11 @@ func Flags(fs *flag.FlagSet, prefix string, overrides ...flags.Override) *Config return &config } -func New(config *Config) Service { +func New(config *Config, githubToken string) Service { return Service{ - username: config.Username, - password: config.Password, + username: config.Username, + password: config.Password, + githubToken: githubToken, } } @@ -95,7 +97,7 @@ func (s Service) getImageDetails(ctx context.Context, repository string) (string var token string if parts[0] == "ghcr.io" { - token = "token" + token = "token " + s.githubToken } return fmt.Sprintf("https://%s", parts[0]), strings.Join(parts[1:], "/"), token, nil