Skip to content

Commit

Permalink
Fix htpasswd issues (#1786)
Browse files Browse the repository at this point in the history
## Description

This fixes issues with generating an htpasswd for external registries
(when it is not needed).

## Related Issue

Fixes #1781 

## Type of change

- [X] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed
  • Loading branch information
Racer159 authored Jun 5, 2023
1 parent 5e709a7 commit f0328e5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/internal/packager/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ func Generate(cfg *types.PackagerConfig) (*Values, error) {

regInfo := cfg.State.RegistryInfo

pushUser, err := utils.GetHtpasswdString(regInfo.PushUsername, regInfo.PushPassword)
if err != nil {
return nil, fmt.Errorf("error generating htpasswd string: %w", err)
}
// Only calculate this for internal registries to allow longer external passwords
if regInfo.InternalRegistry {
pushUser, err := utils.GetHtpasswdString(regInfo.PushUsername, regInfo.PushPassword)
if err != nil {
return nil, fmt.Errorf("error generating htpasswd string: %w", err)
}

pullUser, err := utils.GetHtpasswdString(regInfo.PullUsername, regInfo.PullPassword)
if err != nil {
return nil, fmt.Errorf("error generating htpasswd string: %w", err)
}
pullUser, err := utils.GetHtpasswdString(regInfo.PullUsername, regInfo.PullPassword)
if err != nil {
return nil, fmt.Errorf("error generating htpasswd string: %w", err)
}

generated.htpasswd = fmt.Sprintf("%s\\n%s", pushUser, pullUser)
generated.htpasswd = fmt.Sprintf("%s\\n%s", pushUser, pullUser)
}

generated.registry = regInfo.Address

Expand Down

0 comments on commit f0328e5

Please sign in to comment.