Skip to content

Commit

Permalink
support azure blob storage
Browse files Browse the repository at this point in the history
Signed-off-by: soulseen <zhuxiaoyang1996@gmail.com>
  • Loading branch information
soulseen authored and bitsf committed Nov 8, 2021
1 parent 3553e9c commit 63a8292
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 0 deletions.
22 changes: 22 additions & 0 deletions apis/goharbor.io/v1beta1/chartmuseum_types.go
Expand Up @@ -155,6 +155,28 @@ type ChartMuseumChartStorageDriverSpec struct {

// +kubebuilder:validation:Optional
FileSystem *ChartMuseumChartStorageDriverFilesystemSpec `json:"filesystem,omitempty"`

// +kubebuilder:validation:Optional
Azure *ChartMuseumChartStorageDriverAzureSpec `json:"azure,omitempty"`
}

type ChartMuseumChartStorageDriverAzureSpec struct {
// +kubebuilder:validation:Optional
AccountName string `json:"accountname,omitempty"`

// +kubebuilder:validation:Optional
AccountKeyRef string `json:"accountkeyRef,omitempty"`

// +kubebuilder:validation:Optional
Container string `json:"container,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=core.windows.net
BaseURL string `json:"baseURL,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=/azure/harbor/charts
PathPrefix string `json:"pathPrefix,omitempty"`
}

type ChartMuseumChartStorageDriverAmazonSpec struct {
Expand Down
18 changes: 18 additions & 0 deletions apis/goharbor.io/v1beta1/harbor_types.go
Expand Up @@ -564,6 +564,24 @@ type HarborStorageRegistryPersistentVolumeSpec struct {
MaxThreads int32 `json:"maxthreads,omitempty"`
}

type HarborStorageImageChartStorageAzureSpec struct {
RegistryStorageDriverAzureSpec `json:",inline"`
}

func (r *HarborStorageImageChartStorageAzureSpec) ChartMuseum() *ChartMuseumChartStorageDriverAzureSpec {
return &ChartMuseumChartStorageDriverAzureSpec{
AccountName: r.AccountName,
AccountKeyRef: r.AccountKeyRef,
Container: r.Container,
BaseURL: r.BaseURL,
PathPrefix: r.PathPrefix,
}
}

func (r *HarborStorageImageChartStorageAzureSpec) Registry() *RegistryStorageDriverAzureSpec {
return &r.RegistryStorageDriverAzureSpec
}

type HarborStorageImageChartStorageS3Spec struct {
RegistryStorageDriverS3Spec `json:",inline"`
}
Expand Down
6 changes: 6 additions & 0 deletions apis/goharbor.io/v1beta1/harborcluster_types.go
Expand Up @@ -228,6 +228,8 @@ type StorageSpec struct {
S3 *S3Spec `json:"s3,omitempty"`
// +kubebuilder:validation:Optional
Swift *SwiftSpec `json:"swift,omitempty"`
// +kubebuilder:validation:Optional
Azure *AzureSpec `json:"azure,omitempty"`
}

// StorageRedirectSpec defines if the redirection is disabled.
Expand All @@ -247,6 +249,10 @@ type S3Spec struct {
HarborStorageImageChartStorageS3Spec `json:",inline"`
}

type AzureSpec struct {
HarborStorageImageChartStorageAzureSpec `json:",inline"`
}

type SwiftSpec struct {
HarborStorageImageChartStorageSwiftSpec `json:",inline"`
}
Expand Down
15 changes: 15 additions & 0 deletions apis/goharbor.io/v1beta1/registry_types.go
Expand Up @@ -650,6 +650,21 @@ type RegistryStorageDriverFilesystemSpec struct {
Prefix string `json:"prefix,omitempty"`
}

type RegistryStorageDriverAzureSpec struct {
// +kubebuilder:validation:Optional
AccountName string `json:"accountname,omitempty"`
// +kubebuilder:validation:Optional
AccountKeyRef string `json:"accountkeyRef,omitempty"`
// +kubebuilder:validation:Optional
Container string `json:"container,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=core.windows.net
BaseURL string `json:"baseURL,omitempty"`
// +kubebuilder:validation:Optional
// +kubebuilder:default=/azure/harbor/charts
PathPrefix string `json:"pathPrefix,omitempty"`
}

type RegistryStorageDriverS3Spec struct {
// +kubebuilder:validation:Optional
// The AWS Access Key.
Expand Down
72 changes: 72 additions & 0 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.

33 changes: 33 additions & 0 deletions controllers/goharbor/chartmuseum/deployments.go
Expand Up @@ -123,6 +123,39 @@ func (r *Reconciler) GetDeployment(ctx context.Context, chartMuseum *goharborv1.
})
}

if chartMuseum.Spec.Chart.Storage.Azure != nil {
envs = append(envs, corev1.EnvVar{
Name: "STORAGE",
Value: "microsoft",
}, corev1.EnvVar{
Name: "STORAGE_MICROSOFT_CONTAINER",
Value: chartMuseum.Spec.Chart.Storage.Azure.Container,
}, corev1.EnvVar{
Name: "AZURE_STORAGE_ACCOUNT",
Value: chartMuseum.Spec.Chart.Storage.Azure.AccountName,
}, corev1.EnvVar{
Name: "AZURE_BASE_URL",
Value: chartMuseum.Spec.Chart.Storage.Azure.BaseURL,
}, corev1.EnvVar{
Name: "STORAGE_MICROSOFT_PREFIX",
Value: chartMuseum.Spec.Chart.Storage.Azure.PathPrefix,
})

if chartMuseum.Spec.Chart.Storage.Azure.AccountKeyRef != "" {
envs = append(envs, corev1.EnvVar{
Name: "AZURE_STORAGE_ACCESS_KEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: chartMuseum.Spec.Chart.Storage.Azure.AccountKeyRef,
},
Key: harbormetav1.SharedSecretKey,
},
},
})
}
}

if chartMuseum.Spec.Chart.Storage.Amazon != nil {
envs = append(envs, corev1.EnvVar{
Name: "STORAGE",
Expand Down

0 comments on commit 63a8292

Please sign in to comment.