Skip to content

Commit

Permalink
feat(docker): Adding ghcr token for authorization
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Oct 5, 2023
1 parent d5b6f3b commit bd23c65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ KETCHUP_DB_NAME=postgres
KETCHUP_DB_PASS=<secret>
KETCHUP_REDIS_ADDRESS=localhost:6379
KETCHUP_REDIS_PASSWORD=
KETCHUP_GITHUB_TOKEN=
2 changes: 1 addition & 1 deletion cmd/ketchup/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmd/notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 8 additions & 6 deletions pkg/provider/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ type authResponse struct {
}

type Service struct {
username string
password string
username string
password string
githubToken string
}

type Config struct {
Expand All @@ -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,
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd23c65

Please sign in to comment.