Skip to content

Commit

Permalink
formating
Browse files Browse the repository at this point in the history
  • Loading branch information
dekiel committed Oct 11, 2024
1 parent 84d5141 commit fc92858
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/image-syncer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,20 +230,25 @@ func (cfg *Config) newAuthenticator() (authn.Authenticator, error) {

if cfg.TargetKeyFile != "" {
log.WithField("targetKeyFile", cfg.TargetKeyFile).Debug("target key file path provided, reading the file")

authCfg, err = os.ReadFile(cfg.TargetKeyFile)
if err != nil {
return nil, fmt.Errorf("could not open target auth key JSON file, error: %w", err)
}
log.Debug("target key file read successfully, creating basic authenticator")

auth = &authn.Basic{Username: "_json_key", Password: string(authCfg)}
log.WithField("username", "_json_key").Debug("basic authenticator created successfully")

return auth, nil
}
if cfg.AccessToken != "" {
log.Debug("access token provided, creating bearer authenticator")
auth = &authn.Bearer{Token: cfg.AccessToken}

return auth, nil
}

return nil, fmt.Errorf("no target auth key file or access token provided")
}

Expand Down

0 comments on commit fc92858

Please sign in to comment.