From 34b91997076978f57643a41f6f1aa88c226198e7 Mon Sep 17 00:00:00 2001 From: Christoph Mewes Date: Wed, 17 Jun 2020 14:57:40 +0200 Subject: [PATCH] fix syncing repository visibility --- pkg/quay/repository.go | 8 ++++++++ pkg/sync/sync.go | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/quay/repository.go b/pkg/quay/repository.go index d96b944..3222816 100644 --- a/pkg/quay/repository.go +++ b/pkg/quay/repository.go @@ -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"` } diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 639c1e1..22b6b0f 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -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)