Skip to content

Commit

Permalink
refactor(module) Move repository to github.com/goharbor/harbor-operator
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Péronnet <pierre.peronnet@ovhcloud.com>
  • Loading branch information
holyhope committed Mar 6, 2020
1 parent 693d7a4 commit 9f94c00
Show file tree
Hide file tree
Showing 63 changed files with 573 additions and 522 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ COPY go.sum go.sum

ENV CGO_ENABLED=0 \
GOOS="linux" \
GO_APP_PKG="github.com/ovh/harbor-operator" \
GO_APP_PKG="github.com/goharbor/harbor-operator" \
GO111MODULE=on

# Copy the go source
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
domain: ovhcloud.com
repo: github.com/ovh/harbor-operator
repo: github.com/goharbor/harbor-operator
resources:
- group: containerregistry
kind: Harbor
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ Follow the [Development guide](https://github.com/goharbor/harbor-operator/blob/

## Additional documentation

1. [Learn how reconciliation works](https://github.com/ovh/harbor-operator/blob/master/docs/reconciler.md)
2. [Custom Resource Definition](https://github.com/ovh/harbor-operator/blob/master/docs/custom-resource-definition.md)
1. [Learn how reconciliation works](https://github.com/goharbor/harbor-operator/blob/master/docs/reconciler.md)
2. [Custom Resource Definition](https://github.com/goharbor/harbor-operator/blob/master/docs/custom-resource-definition.md)

## Related links

Expand All @@ -97,4 +97,4 @@ Follow the [Development guide](https://github.com/goharbor/harbor-operator/blob/

## License

See <https://github.com/ovh/harbor-operator/blob/master/LICENSE>
See <https://github.com/goharbor/harbor-operator/blob/master/LICENSE>
50 changes: 50 additions & 0 deletions config/samples/goharbor_v1alpha1_harbor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: goharbor.io/v1alpha1
kind: Harbor
metadata:
name: harbor-sample
spec:
publicURL: 'https://{{ env.Getenv "LBAAS_DOMAIN" }}'
tlsSecretName: public-certificate
version: "1.10.0"
adminPasswordSecret: admin-password-secret
components:
core:
databaseSecret: core-database
image: "goharbor/harbor-core:v1.10.0"
registryCtl:
image: "goharbor/harbor-registryctl:v1.10.0"
registry:
storageSecret: registry-storage
cacheSecret: registry-cache
image: goharbor/registry-photon:v2.7.1-patch-2819-2553-v1.10.0
jobService:
redisSecret: jobservice-redis
image: goharbor/harbor-jobservice:v1.10.0
clair:
databaseSecret: clair-database
image: goharbor/clair-photon:v2.1.1-v1.10.0
vulnerabilitySources: # https://github.com/quay/clair/blob/master/config.yaml.sample#L62
- debian
- ubuntu
- rhel
- oracle
- alpine
- suse
adapter:
image: holyhope/clair-adapter-with-config:latest
redisSecret: clair-adapter-redis
portal:
image: goharbor/harbor-portal:v1.10.0
chartMuseum:
image: goharbor/chartmuseum-photon:v0.9.0-v1.10.0
notary:
publicURL: 'https://{{ env.Getenv "NOTARY_DOMAIN" }}'
notaryDBMigratorImage: jmonsinjon/notary-db-migrator:v0.6.1
server:
databaseSecret: notary-server-database
image: goharbor/notary-server-photon:v0.6.1-v1.10.0
signer:
databaseSecret: notary-signer-database
image: goharbor/notary-signer-photon:v0.6.1-v1.10.0
certificateIssuerRef:
name: harbor-sample
30 changes: 15 additions & 15 deletions controllers/harbor/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
"github.com/ovh/harbor-operator/controllers/harbor/components"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
"github.com/goharbor/harbor-operator/controllers/harbor/components"
)

func (r *Reconciler) ApplyMutationFunc(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resource components.Resource, result metav1.Object, mutate controllerutil.MutateFn) func() error {
func (r *Reconciler) ApplyMutationFunc(ctx context.Context, harbor *goharborv1alpha1.Harbor, resource components.Resource, result metav1.Object, mutate controllerutil.MutateFn) func() error {
return func() error {
// Immutable field
resourceVersion := result.GetResourceVersion()
Expand Down Expand Up @@ -69,7 +69,7 @@ func (r *Reconciler) ApplyMutationFunc(ctx context.Context, harbor *containerreg
}
}

func (r *Reconciler) ApplyResource(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resource components.Resource, objectFactory components.ResourceFactory, objectMutation components.ResourceMutationGetter) (components.Resource, error) {
func (r *Reconciler) ApplyResource(ctx context.Context, harbor *goharborv1alpha1.Harbor, resource components.Resource, objectFactory components.ResourceFactory, objectMutation components.ResourceMutationGetter) (components.Resource, error) {
kind, version := resource.GetObjectKind().GroupVersionKind().ToAPIVersionAndKind()

span, ctx := opentracing.StartSpanFromContext(ctx, "deployResource", opentracing.Tags{
Expand All @@ -93,7 +93,7 @@ func (r *Reconciler) ApplyResource(ctx context.Context, harbor *containerregistr
return result, nil
}

func (r *Reconciler) ApplyResources(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource, objectFactory func() components.Resource, objectMutation func(components.Resource, components.Resource) controllerutil.MutateFn) error {
func (r *Reconciler) ApplyResources(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource, objectFactory func() components.Resource, objectMutation func(components.Resource, components.Resource) controllerutil.MutateFn) error {
var g errgroup.Group

for _, resource := range resources {
Expand Down Expand Up @@ -254,30 +254,30 @@ func mutateConfigMap(configResource, result components.Resource) controllerutil.
// +kubebuilder:rbac:groups="networking.k8s.io",resources="ingresses",verbs=get;list;watch;update;patch;create
// +kubebuilder:rbac:groups="apps",resources="deployments",verbs=get;list;watch;update;patch;create

func (r *Reconciler) ApplyComponent(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, component *components.ComponentRunner) error {
service := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
func (r *Reconciler) ApplyComponent(ctx context.Context, harbor *goharborv1alpha1.Harbor, component *components.ComponentRunner) error {
service := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &corev1.Service{} }, mutateService)
}
configMap := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
configMap := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &corev1.ConfigMap{} }, mutateConfigMap)
}
ingress := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
ingress := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &netv1.Ingress{} }, mutateIngress)
}
secret := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
secret := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &corev1.Secret{} }, mutateSecret)
}
certificate := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
certificate := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &certv1.Certificate{} }, mutateCertificate)
}
deployment := func(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, resources []components.Resource) error {
deployment := func(ctx context.Context, harbor *goharborv1alpha1.Harbor, resources []components.Resource) error {
return r.ApplyResources(ctx, harbor, resources, func() components.Resource { return &appsv1.Deployment{} }, mutateDeployment)
}

return component.ParallelRun(ctx, harbor, service, configMap, ingress, secret, certificate, deployment, true)
}

func (r *Reconciler) Apply(ctx context.Context, harbor *containerregistryv1alpha1.Harbor) error {
func (r *Reconciler) Apply(ctx context.Context, harbor *goharborv1alpha1.Harbor) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "apply")
defer span.Finish()

Expand All @@ -290,14 +290,14 @@ func (r *Reconciler) Apply(ctx context.Context, harbor *containerregistryv1alpha

if harbor.Spec.Components.Clair == nil {
g.Go(func() error {
err := r.DeleteComponent(ctx, harbor, containerregistryv1alpha1.ClairName)
err := r.DeleteComponent(ctx, harbor, goharborv1alpha1.ClairName)
return errors.Wrap(err, "cannot delete clair")
})
}

if harbor.Spec.Components.Notary == nil {
g.Go(func() error {
err := r.DeleteComponent(ctx, harbor, containerregistryv1alpha1.NotaryName)
err := r.DeleteComponent(ctx, harbor, goharborv1alpha1.NotaryName)
return errors.Wrap(err, "cannot delete notary")
})
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/harbor/components/chartmuseum/chartmuseum.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package chartmuseum
import (
"context"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
)

type ChartMuseum struct {
harbor *containerregistryv1alpha1.Harbor
harbor *goharborv1alpha1.Harbor
Option Option
}

type Option interface {
GetPriority() *int32
}

func New(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, opt Option) (*ChartMuseum, error) {
func New(ctx context.Context, harbor *goharborv1alpha1.Harbor, opt Option) (*ChartMuseum, error) {
return &ChartMuseum{
harbor: harbor,
Option: opt,
Expand Down
8 changes: 4 additions & 4 deletions controllers/harbor/components/chartmuseum/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
"github.com/ovh/harbor-operator/pkg/factories/application"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
"github.com/goharbor/harbor-operator/pkg/factories/application"
)

const (
Expand Down Expand Up @@ -49,10 +49,10 @@ func (c *ChartMuseum) GetConfigMaps(ctx context.Context) []*corev1.ConfigMap {
return []*corev1.ConfigMap{
{
ObjectMeta: metav1.ObjectMeta{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
Namespace: c.harbor.Namespace,
Labels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand Down
22 changes: 11 additions & 11 deletions controllers/harbor/components/chartmuseum/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
"github.com/ovh/harbor-operator/pkg/factories/application"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
"github.com/goharbor/harbor-operator/pkg/factories/application"
)

var (
Expand Down Expand Up @@ -62,7 +62,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.Spec.Components.ChartMuseum.StorageSecret,
},
Key: containerregistryv1alpha1.HarborChartMuseumStorageKindKey,
Key: goharborv1alpha1.HarborChartMuseumStorageKindKey,
},
},
}}
Expand Down Expand Up @@ -96,7 +96,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.Spec.Components.ChartMuseum.CacheSecret,
},
Key: containerregistryv1alpha1.HarborChartMuseumCacheURLKey,
Key: goharborv1alpha1.HarborChartMuseumCacheURLKey,
Optional: &varTrue,
},
},
Expand All @@ -107,18 +107,18 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
return []*appsv1.Deployment{
{
ObjectMeta: metav1.ObjectMeta{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
Namespace: c.harbor.Namespace,
Labels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand All @@ -132,7 +132,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
"operator/version": application.GetVersion(ctx),
},
Labels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand All @@ -151,7 +151,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
},
},
},
Expand Down Expand Up @@ -205,7 +205,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
Key: "secret",
Optional: &varFalse,
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.CoreName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.CoreName),
},
},
},
Expand All @@ -216,7 +216,7 @@ func (c *ChartMuseum) GetDeployments(ctx context.Context) []*appsv1.Deployment {
ConfigMapRef: &corev1.ConfigMapEnvSource{
Optional: &varFalse,
LocalObjectReference: corev1.LocalObjectReference{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
},
},
}),
Expand Down
10 changes: 5 additions & 5 deletions controllers/harbor/components/chartmuseum/ingresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
"github.com/ovh/harbor-operator/pkg/factories/application"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
"github.com/goharbor/harbor-operator/pkg/factories/application"
)

func (c *ChartMuseum) GetIngresses(ctx context.Context) []*netv1.Ingress { // nolint:funlen
Expand All @@ -37,10 +37,10 @@ func (c *ChartMuseum) GetIngresses(ctx context.Context) []*netv1.Ingress { // no
return []*netv1.Ingress{
{
ObjectMeta: metav1.ObjectMeta{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
Namespace: c.harbor.Namespace,
Labels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand All @@ -56,7 +56,7 @@ func (c *ChartMuseum) GetIngresses(ctx context.Context) []*netv1.Ingress { // no
{
Path: "/chartrepo",
Backend: netv1.IngressBackend{
ServiceName: c.harbor.NormalizeComponentName(containerregistryv1alpha1.CoreName),
ServiceName: c.harbor.NormalizeComponentName(goharborv1alpha1.CoreName),
ServicePort: intstr.FromInt(PublicPort),
},
},
Expand Down
10 changes: 5 additions & 5 deletions controllers/harbor/components/chartmuseum/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
"github.com/ovh/harbor-operator/pkg/factories/application"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
"github.com/goharbor/harbor-operator/pkg/factories/application"
)

const (
Expand All @@ -22,10 +22,10 @@ func (c *ChartMuseum) GetServices(ctx context.Context) []*corev1.Service {
return []*corev1.Service{
{
ObjectMeta: metav1.ObjectMeta{
Name: c.harbor.NormalizeComponentName(containerregistryv1alpha1.ChartMuseumName),
Name: c.harbor.NormalizeComponentName(goharborv1alpha1.ChartMuseumName),
Namespace: c.harbor.Namespace,
Labels: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand All @@ -38,7 +38,7 @@ func (c *ChartMuseum) GetServices(ctx context.Context) []*corev1.Service {
},
},
Selector: map[string]string{
"app": containerregistryv1alpha1.ChartMuseumName,
"app": goharborv1alpha1.ChartMuseumName,
"harbor": harborName,
"operator": operatorName,
},
Expand Down
6 changes: 3 additions & 3 deletions controllers/harbor/components/clair/clair.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package clair
import (
"context"

containerregistryv1alpha1 "github.com/ovh/harbor-operator/api/v1alpha1"
goharborv1alpha1 "github.com/goharbor/harbor-operator/api/v1alpha1"
)

type Clair struct {
harbor *containerregistryv1alpha1.Harbor
harbor *goharborv1alpha1.Harbor
Option Option
}

type Option interface {
GetPriority() *int32
}

func New(ctx context.Context, harbor *containerregistryv1alpha1.Harbor, opt Option) (*Clair, error) {
func New(ctx context.Context, harbor *goharborv1alpha1.Harbor, opt Option) (*Clair, error) {
return &Clair{
harbor: harbor,
Option: opt,
Expand Down

0 comments on commit 9f94c00

Please sign in to comment.