Skip to content

Commit

Permalink
fix syncing repository visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
xrstf committed Jun 17, 2020
1 parent 660046f commit 34b9199
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pkg/quay/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ func (r *Repository) FullName() string {
return r.Namespace + "/" + r.Name
}

func (r *Repository) Visibility() RepositoryVisibility {
if r.IsPublic {
return Public
}

return Private
}

type getRepositoriesReponse struct {
Repositories []Repository `json:"repositories"`
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ func syncRepositories(ctx context.Context, config *config.Config, client *quay.C
}

func syncRepository(ctx context.Context, client *quay.Client, repo quay.Repository, repoConfig *config.RepositoryConfig) error {
// ensure repos are not public if they are configured to be private (phrase it like this
// just in case quay ever introduces a third visibility state)
if repo.IsPublic && repoConfig.Visibility != quay.Public {
if repo.Visibility() != repoConfig.Visibility {
log.Printf(" - set visibility to %s", repoConfig.Visibility)
if err := client.ChangeRepositoryVisibility(ctx, repo.FullName(), repoConfig.Visibility); err != nil {
return fmt.Errorf("failed to set visibility: %v", err)
Expand Down

0 comments on commit 34b9199

Please sign in to comment.