Skip to content

Commit

Permalink
Merge pull request #94 from mittwald/fix/projects-without-proxy-cache
Browse files Browse the repository at this point in the history
Fix/projects without proxy cache
  • Loading branch information
elenz97 authored Dec 15, 2021
2 parents 8ca7c5f + f0d1b10 commit 1bc81ad
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions controllers/registries/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
if err != nil {
return ctrl.Result{}, err
}
chartSpec.Wait = true

err = r.installOrUpgradeHelmChart(ctx, chartSpec)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions controllers/registries/project_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ func (r *ProjectReconciler) assertExistingProject(ctx context.Context, harborCli
heldRepo, err := harborClient.GetProject(ctx, project.Spec.Name)

var registry v1alpha2.Registry
var registryID int64
var registryID *int64
if project.Spec.ProxyCache != nil {
if err := r.Client.Get(ctx, client.ObjectKey{
Namespace: project.Namespace,
Name: project.Spec.ProxyCache.Registry.Name,
}, &registry); err != nil {
return err
}
registryID = registry.Status.ID
registryID = &registry.Status.ID
}

if errors.Is(err, &clienterrors.ErrProjectNotFound{}) {
Expand All @@ -293,7 +293,7 @@ func (r *ProjectReconciler) assertExistingProject(ctx context.Context, harborCli
Metadata: nil,
ProjectName: project.Spec.Name,
Public: nil,
RegistryID: &registryID,
RegistryID: registryID,
StorageLimit: &storageLimit,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ spec:
storageLimit: {{ $project.storageLimit }}
{{- else }}
storageLimit: -1
{{- end }}
{{- if $project.proxyCacheRegistryName }}
proxyCache:
registry:
name: {{ $project.proxyCacheRegistryName }}
{{- end }}
metadata:
{{- with $project.metadata }}
Expand Down
5 changes: 3 additions & 2 deletions deploy/helm-chart/harbor-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ fullnameOverride: {}
installHarborChartRepo: true

instances: ~
# - name: test-registry
# - name: test-harbor
# type: manual
# version: v1.5.3
# version: v1.8.0
# wait: true
# garbageCollection:
# cron: "0 * * * *"
Expand All @@ -47,6 +47,7 @@ instances: ~
# projects:
# - name: projects
# storageLimit: 10
# proxyCacheRegistryName: test-harbor-test-registry # <instanceName>-<registry-name>
# metadata:
# enableContentTrust: false
# autoScan: true
Expand Down

0 comments on commit 1bc81ad

Please sign in to comment.