Skip to content

Commit

Permalink
Account for namespaced configuration for common PVC size.
Browse files Browse the repository at this point in the history
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Jul 15, 2021
1 parent 89e51d3 commit 4fcfb59
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/provision/storage/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import (
"github.com/devfile/devworkspace-operator/pkg/constants"
devfileConstants "github.com/devfile/devworkspace-operator/pkg/library/constants"
containerlib "github.com/devfile/devworkspace-operator/pkg/library/container"
nsconfig "github.com/devfile/devworkspace-operator/pkg/provision/config"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func getCommonPVCSpec(namespace string) (*corev1.PersistentVolumeClaim, error) {
pvcStorageQuantity, err := resource.ParseQuantity(constants.PVCStorageSize)
func getCommonPVCSpec(namespace string, size string) (*corev1.PersistentVolumeClaim, error) {
pvcStorageQuantity, err := resource.ParseQuantity(size)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -79,7 +80,16 @@ func needsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool {
}

func syncCommonPVC(namespace string, clusterAPI provision.ClusterAPI) (*corev1.PersistentVolumeClaim, error) {
pvc, err := getCommonPVCSpec(namespace)
namespacedConfig, err := nsconfig.ReadNamespacedConfig(namespace, clusterAPI)
if err != nil {
return nil, fmt.Errorf("failed to read namespace-specific configuration: %w", err)
}
pvcSize := constants.PVCStorageSize
if namespacedConfig != nil && namespacedConfig.CommonPVCSize != "" {
pvcSize = namespacedConfig.CommonPVCSize
}

pvc, err := getCommonPVCSpec(namespace, pvcSize)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4fcfb59

Please sign in to comment.