Skip to content

Commit

Permalink
fix gcs config (#830)
Browse files Browse the repository at this point in the history
* fix chartmuseum gcs path

Signed-off-by: soulseen <zhuxiaoyang1996@gmail.com>
  • Loading branch information
soulseen committed Jan 19, 2022
1 parent d65f275 commit c17f9cc
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apis/goharbor.io/v1beta1/chartmuseum_types.go
Expand Up @@ -170,7 +170,7 @@ type ChartMuseumChartStorageDriverGcsSpec struct {

// +kubebuilder:validation:Required
// The base64 encoded json file which contains the key
KetDataSecretRef string `json:"ketDataSecretRef"`
KeyDataSecretRef string `json:"keyDataSecretRef"`

// +kubebuilder:validation:Optional
PathPrefix string `json:"pathPrefix,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion apis/goharbor.io/v1beta1/harbor_types.go
Expand Up @@ -606,7 +606,7 @@ type HarborStorageImageChartStorageGcsSpec struct {

func (r *HarborStorageImageChartStorageGcsSpec) ChartMuseum() *ChartMuseumChartStorageDriverGcsSpec {
return &ChartMuseumChartStorageDriverGcsSpec{
KetDataSecretRef: r.KetDataRef,
KeyDataSecretRef: r.KeyDataRef,
Bucket: r.Bucket,
PathPrefix: r.PathPrefix,
ChunkSize: r.ChunkSize,
Expand Down
2 changes: 1 addition & 1 deletion apis/goharbor.io/v1beta1/registry_types.go
Expand Up @@ -689,7 +689,7 @@ type RegistryStorageDriverAzureSpec struct {
type RegistryStorageDriverGcsSpec struct {
// +kubebuilder:validation:Required
// The base64 encoded json file which contains the key
KetDataRef string `json:"keyDataRef,omitempty"`
KeyDataRef string `json:"keyDataRef,omitempty"`

// +kubebuilder:validation:Required
// bucket to store charts for Gcs storage
Expand Down
4 changes: 2 additions & 2 deletions charts/harbor-operator/templates/crds.yaml
Expand Up @@ -2485,14 +2485,14 @@ spec:
type: string
chunksize:
type: string
ketDataSecretRef:
keyDataSecretRef:
description: The base64 encoded json file which contains the key
type: string
pathPrefix:
type: string
required:
- bucket
- ketDataSecretRef
- keyDataSecretRef
type: object
maxStorageObject:
description: Maximum number of objects allowed in storage (per tenant)
Expand Down
6 changes: 5 additions & 1 deletion config/config/assets/registry-config.yaml.tmpl
Expand Up @@ -148,9 +148,13 @@ storage:
{{- if .Spec.Storage.Driver.Gcs }}
gcs:
bucket: {{ .Spec.Storage.Driver.Gcs.Bucket | quote }}
keyfile: {{ .Spec.Storage.Driver.Gcs.Container | quote }}
keyfile: /etc/gcs/gcs-key.json
{{- if .Spec.Storage.Driver.Gcs.PathPrefix }}
rootdirectory: {{ .Spec.Storage.Driver.Gcs.PathPrefix | quote }}
{{- end }}
{{- if .Spec.Storage.Driver.Gcs.ChunkSize }}
chunksize: {{ .Spec.Storage.Driver.Gcs.ChunkSize | quote }}
{{- end }}
{{- end }}

{{- if .Spec.Storage.Driver.Swift }}
Expand Down
8 changes: 4 additions & 4 deletions controllers/goharbor/chartmuseum/deployments.go
Expand Up @@ -28,7 +28,7 @@ const (
LocalStorageVolume = "storage"
DefaultLocalStoragePath = "/mnt/chartstorage"
StorageTimestampTolerance = 1 * time.Second
DefautJSONKeyFilePath = ConfigPath + "/gcs-key.json"
GcsJSONKeyFilePath = "/etc/gcs/gcs-key.json"
)

var (
Expand Down Expand Up @@ -133,7 +133,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.
Value: chartMuseum.Spec.Chart.Storage.Gcs.Bucket,
}, corev1.EnvVar{
Name: "GOOGLE_APPLICATION_CREDENTIALS",
Value: DefautJSONKeyFilePath,
Value: GcsJSONKeyFilePath,
}, corev1.EnvVar{
Name: "STORAGE_GOOGLE_PREFIX",
Value: chartMuseum.Spec.Chart.Storage.Gcs.PathPrefix,
Expand All @@ -143,7 +143,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.
Name: "gcs-key",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: chartMuseum.Spec.Chart.Storage.Gcs.KetDataSecretRef,
SecretName: chartMuseum.Spec.Chart.Storage.Gcs.KeyDataSecretRef,
Items: []corev1.KeyToPath{
{
Key: "GCS_KEY_DATA",
Expand All @@ -156,7 +156,7 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.

volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: "gcs-key",
MountPath: DefautJSONKeyFilePath,
MountPath: GcsJSONKeyFilePath,
SubPath: "gcs-key.json",
})
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/goharbor/registry/deployments.go
Expand Up @@ -39,7 +39,7 @@ const (
CtlHealthPath = "/api/health"
StorageServiceCAName = "storage-service-ca"
StorageServiceCAMountPath = "/harbor_cust_cert/custom-ca-bundle.crt"
GcsJSONKeyFilePath = ConfigPath + "/gcs-key.json"
GcsJSONKeyFilePath = "/etc/gcs/gcs-key.json"
)

var (
Expand Down Expand Up @@ -192,12 +192,12 @@ func (r *Reconciler) GetDeployment(ctx context.Context, registry *goharborv1.Reg
})
}

if registry.Spec.Storage.Driver.Gcs != nil && registry.Spec.Storage.Driver.Gcs.KetDataRef != "" {
if registry.Spec.Storage.Driver.Gcs != nil && registry.Spec.Storage.Driver.Gcs.KeyDataRef != "" {
volumes = append(volumes, corev1.Volume{
Name: "gcs-key",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: registry.Spec.Storage.Driver.Gcs.KetDataRef,
SecretName: registry.Spec.Storage.Driver.Gcs.KeyDataRef,
Items: []corev1.KeyToPath{
{
Key: "GCS_KEY_DATA",
Expand Down Expand Up @@ -540,9 +540,9 @@ func (r *Reconciler) ApplyGcsStorageEnvs(ctx context.Context, registry *goharbor
Name: "GCS_KEY_DATA",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: harbormetav1.SharedSecretKey,
Key: "GCS_KEY_DATA",
LocalObjectReference: corev1.LocalObjectReference{
Name: registry.Spec.Storage.Driver.Gcs.KetDataRef,
Name: registry.Spec.Storage.Driver.Gcs.KeyDataRef,
},
},
},
Expand Down

0 comments on commit c17f9cc

Please sign in to comment.