Skip to content

Commit

Permalink
feat(Portal) Make the deployment of Portal optional. Fix #645. (#761)
Browse files Browse the repository at this point in the history
* chore(controller-runtime) bump to stable version

Signed-off-by: Simon Guyennet <simon.guyennet@corp.ovh.com>

* feat(Portal) enable/disable Portal deployment

Signed-off-by: Simon Guyennet <simon.guyennet@corp.ovh.com>
  • Loading branch information
sguyennet committed Sep 7, 2021
1 parent eb5f440 commit 23729c5
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 42 deletions.
10 changes: 7 additions & 3 deletions apis/goharbor.io/v1alpha3/harbor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (h *Harbor) deepCopyComponentSpecInto(_ context.Context, component harborme
h.Spec.Notary.Signer.DeepCopyInto(spec)
}
case harbormetav1.PortalComponent:
h.Spec.Portal.DeepCopyInto(spec)
h.Spec.Portal.ComponentSpec.DeepCopyInto(spec)
case harbormetav1.RegistryComponent:
h.Spec.Registry.ComponentSpec.DeepCopyInto(spec)
case harbormetav1.RegistryControllerComponent:
Expand Down Expand Up @@ -254,8 +254,8 @@ func (spec *HarborSpec) ValidateRegistryController() *field.Error {
}

type HarborComponentsSpec struct {
// +kubebuilder:validation:Required
Portal harbormetav1.ComponentSpec `json:"portal,omitempty"`
// +kubebuilder:validation:Optional
Portal *PortalComponentSpec `json:"portal,omitempty"`

// +kubebuilder:validation:Required
Core CoreComponentSpec `json:"core,omitempty"`
Expand Down Expand Up @@ -378,6 +378,10 @@ func (r *HarborComponentsSpec) RedisConnection(component harbormetav1.ComponentW
}
}

type PortalComponentSpec struct {
harbormetav1.ComponentSpec `json:",inline"`
}

type CoreComponentSpec struct {
harbormetav1.ComponentSpec `json:",inline"`

Expand Down
22 changes: 21 additions & 1 deletion apis/goharbor.io/v1alpha3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions apis/goharbor.io/v1beta1/harbor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (h *Harbor) deepCopyComponentSpecInto(_ context.Context, component harborme
h.Spec.Notary.Signer.DeepCopyInto(spec)
}
case harbormetav1.PortalComponent:
h.Spec.Portal.DeepCopyInto(spec)
h.Spec.Portal.ComponentSpec.DeepCopyInto(spec)
case harbormetav1.RegistryComponent:
h.Spec.Registry.ComponentSpec.DeepCopyInto(spec)
case harbormetav1.RegistryControllerComponent:
Expand Down Expand Up @@ -237,8 +237,8 @@ func (spec *HarborSpec) ValidateRegistryController() *field.Error {
}

type HarborComponentsSpec struct {
// +kubebuilder:validation:Required
Portal harbormetav1.ComponentSpec `json:"portal,omitempty"`
// +kubebuilder:validation:Optional
Portal *PortalComponentSpec `json:"portal,omitempty"`

// +kubebuilder:validation:Required
Core CoreComponentSpec `json:"core,omitempty"`
Expand Down Expand Up @@ -356,6 +356,10 @@ func (r *HarborComponentsSpec) RedisConnection(component harbormetav1.ComponentW
}
}

type PortalComponentSpec struct {
harbormetav1.ComponentSpec `json:",inline"`
}

type CoreComponentSpec struct {
harbormetav1.ComponentSpec `json:",inline"`

Expand Down
4 changes: 2 additions & 2 deletions apis/goharbor.io/v1beta1/harborcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ type EmbeddedHarborSpec struct {
}

type EmbeddedHarborComponentsSpec struct {
// +kubebuilder:validation:Required
Portal harbormetav1.ComponentSpec `json:"portal,omitempty"`
// +kubebuilder:validation:Optional
Portal *PortalComponentSpec `json:"portal,omitempty"`

// +kubebuilder:validation:Required
Core CoreComponentSpec `json:"core,omitempty"`
Expand Down
28 changes: 26 additions & 2 deletions apis/goharbor.io/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ spec:
certificateRef: sample-public-certificate
internalTLS:
enabled: true
portal: {}
registry: {}
core:
tokenIssuer:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: goharbor.io/v1alpha3
kind: HarborCluster
metadata:
name: sample
spec:
portal: {}
1 change: 1 addition & 0 deletions config/samples/harborcluster-standard/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ bases:
patchesStrategicMerge:
- harbor_chartmuseum_patch.yaml
- harbor_notary_patch.yaml
- harbor_portal_patch.yaml
- harbor_trivy_patch.yaml
4 changes: 4 additions & 0 deletions controllers/goharbor/harbor/portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
type Portal graph.Resource

func (r *Reconciler) AddPortal(ctx context.Context, harbor *goharborv1.Harbor, tlsIssuer InternalTLSIssuer) (PortalInternalCertificate, Portal, error) {
if harbor.Spec.Portal == nil {
return nil, nil, nil
}

cert, err := r.AddPortalInternalCertificate(ctx, harbor, tlsIssuer)
if err != nil {
return nil, nil, errors.Wrap(err, "certificate")
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ require (
github.com/markbates/pkger v0.15.1
github.com/minio/minio-go/v6 v6.0.57
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.12.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/opentracing-contrib/go-stdlib v1.0.0
github.com/opentracing/opentracing-go v1.2.0
github.com/ovh/configstore v0.3.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.10.0
github.com/prometheus/client_golang v1.11.0
github.com/sethvargo/go-password v0.1.3
github.com/sirupsen/logrus v1.7.0
github.com/spotahome/redis-operator v1.0.0
github.com/theupdateframework/notary v0.6.1
github.com/uber/jaeger-client-go v2.24.0+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible
github.com/zalando/postgres-operator v1.6.1
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0
go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/tools v0.1.2 // indirect
Expand All @@ -41,7 +40,7 @@ require (
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
k8s.io/klog v1.0.0
sigs.k8s.io/controller-runtime v0.9.0-beta.6
sigs.k8s.io/controller-runtime v0.9.0
sigs.k8s.io/kustomize/kstatus v0.0.2
sigs.k8s.io/yaml v1.2.0
)

0 comments on commit 23729c5

Please sign in to comment.