Skip to content

Commit

Permalink
refact: set const to common file
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <[email protected]>
  • Loading branch information
zwwhdls committed Sep 13, 2024
1 parent 04c540b commit df77b79
Show file tree
Hide file tree
Showing 44 changed files with 397 additions and 358 deletions.
5 changes: 3 additions & 2 deletions cmd/app/mount_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"

"github.com/juicedata/juicefs-csi-driver/pkg/common"
"github.com/juicedata/juicefs-csi-driver/pkg/config"
mountctrl "github.com/juicedata/juicefs-csi-driver/pkg/controller"
"github.com/juicedata/juicefs-csi-driver/pkg/k8sclient"
Expand Down Expand Up @@ -71,10 +72,10 @@ func NewMountManager(
Scheme: scheme,
SelectorsByObject: cache.SelectorsByObject{
&corev1.Pod{}: {
Label: labels.SelectorFromSet(labels.Set{config.PodTypeKey: config.PodTypeValue}),
Label: labels.SelectorFromSet(labels.Set{common.PodTypeKey: common.PodTypeValue}),
},
&batchv1.Job{}: {
Label: labels.SelectorFromSet(labels.Set{config.PodTypeKey: config.JobTypeValue}),
Label: labels.SelectorFromSet(labels.Set{common.PodTypeKey: common.JobTypeValue}),
},
},
}),
Expand Down
4 changes: 2 additions & 2 deletions cmd/app/pod_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"

"github.com/juicedata/juicefs-csi-driver/pkg/config"
"github.com/juicedata/juicefs-csi-driver/pkg/common"
mountctrl "github.com/juicedata/juicefs-csi-driver/pkg/controller"
"github.com/juicedata/juicefs-csi-driver/pkg/k8sclient"
)
Expand Down Expand Up @@ -55,7 +55,7 @@ func NewPodManager() (*PodManager, error) {
Scheme: scheme,
SelectorsByObject: cache.SelectorsByObject{
&corev1.Pod{}: {
Label: labels.SelectorFromSet(labels.Set{config.PodTypeKey: config.PodTypeValue}),
Label: labels.SelectorFromSet(labels.Set{common.PodTypeKey: common.PodTypeValue}),
},
},
}),
Expand Down
3 changes: 2 additions & 1 deletion cmd/app/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"

"github.com/juicedata/juicefs-csi-driver/pkg/common"
"github.com/juicedata/juicefs-csi-driver/pkg/config"
mountctrl "github.com/juicedata/juicefs-csi-driver/pkg/controller"
"github.com/juicedata/juicefs-csi-driver/pkg/k8sclient"
Expand Down Expand Up @@ -60,7 +61,7 @@ func NewWebhookManager(certDir string, webhookPort int, leaderElection bool,
Scheme: scheme,
SelectorsByObject: cache.SelectorsByObject{
&corev1.Pod{}: {
Label: labels.SelectorFromSet(labels.Set{config.InjectSidecarDone: config.True}),
Label: labels.SelectorFromSet(labels.Set{common.InjectSidecarDone: common.True}),
},
},
}),
Expand Down
83 changes: 83 additions & 0 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
Copyright 2024 Juicedata Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package common

const (
// DriverName to be registered
CSINodeLabelKey = "app"
CSINodeLabelValue = "juicefs-csi-node"
PodTypeKey = "app.kubernetes.io/name"
PodTypeValue = "juicefs-mount"
PodUniqueIdLabelKey = "volume-id"
PodJuiceHashLabelKey = "juicefs-hash"
Finalizer = "juicefs.com/finalizer"
JuiceFSUUID = "juicefs-uuid"
UniqueId = "juicefs-uniqueid"
CleanCache = "juicefs-clean-cache"
MountContainerName = "jfs-mount"
JobTypeValue = "juicefs-job"
JfsInsideContainer = "JFS_INSIDE_CONTAINER"

// CSI Secret
ProvisionerSecretName = "csi.storage.k8s.io/provisioner-secret-name"
ProvisionerSecretNamespace = "csi.storage.k8s.io/provisioner-secret-namespace"
PublishSecretName = "csi.storage.k8s.io/node-publish-secret-name"
PublishSecretNamespace = "csi.storage.k8s.io/node-publish-secret-namespace"
ControllerExpandSecretName = "csi.storage.k8s.io/controller-expand-secret-name"
ControllerExpandSecretNamespace = "csi.storage.k8s.io/controller-expand-secret-namespace"

// webhook
WebhookName = "juicefs-admission-webhook"
True = "true"
False = "false"
inject = ".juicefs.com/inject"
injectSidecar = ".sidecar" + inject
InjectSidecarDone = "done" + injectSidecar
InjectSidecarDisable = "disable" + injectSidecar

// config in pv
MountPodCpuLimitKey = "juicefs/mount-cpu-limit"
MountPodMemLimitKey = "juicefs/mount-memory-limit"
MountPodCpuRequestKey = "juicefs/mount-cpu-request"
MountPodMemRequestKey = "juicefs/mount-memory-request"
MountPodLabelKey = "juicefs/mount-labels"
MountPodAnnotationKey = "juicefs/mount-annotations"
MountPodServiceAccount = "juicefs/mount-service-account"
MountPodImageKey = "juicefs/mount-image"
DeleteDelay = "juicefs/mount-delete-delay"
CleanCacheKey = "juicefs/clean-cache"
CachePVC = "juicefs/mount-cache-pvc"
CacheEmptyDir = "juicefs/mount-cache-emptydir"
CacheInlineVolume = "juicefs/mount-cache-inline-volume"
MountPodHostPath = "juicefs/host-path"

// DeleteDelayTimeKey mount pod annotation
DeleteDelayTimeKey = "juicefs-delete-delay"
DeleteDelayAtKey = "juicefs-delete-at"

// default value
DefaultMountPodCpuLimit = "2000m"
DefaultMountPodMemLimit = "5Gi"
DefaultMountPodCpuRequest = "1000m"
DefaultMountPodMemRequest = "1Gi"

// secret labels
JuicefsSecretLabelKey = "juicefs/secret"

PodInfoName = "csi.storage.k8s.io/pod.name"
PodInfoNamespace = "csi.storage.k8s.io/pod.namespace"
)
66 changes: 0 additions & 66 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,72 +80,6 @@ var (
DefaultEEMountImage = "juicedata/mount:ee-nightly" // mount pod ee image, override by ENV
)

const (
// DriverName to be registered
CSINodeLabelKey = "app"
CSINodeLabelValue = "juicefs-csi-node"
PodTypeKey = "app.kubernetes.io/name"
PodTypeValue = "juicefs-mount"
PodUniqueIdLabelKey = "volume-id"
PodJuiceHashLabelKey = "juicefs-hash"
Finalizer = "juicefs.com/finalizer"
JuiceFSUUID = "juicefs-uuid"
UniqueId = "juicefs-uniqueid"
CleanCache = "juicefs-clean-cache"
MountContainerName = "jfs-mount"
JobTypeValue = "juicefs-job"
JfsInsideContainer = "JFS_INSIDE_CONTAINER"

// CSI Secret
ProvisionerSecretName = "csi.storage.k8s.io/provisioner-secret-name"
ProvisionerSecretNamespace = "csi.storage.k8s.io/provisioner-secret-namespace"
PublishSecretName = "csi.storage.k8s.io/node-publish-secret-name"
PublishSecretNamespace = "csi.storage.k8s.io/node-publish-secret-namespace"
ControllerExpandSecretName = "csi.storage.k8s.io/controller-expand-secret-name"
ControllerExpandSecretNamespace = "csi.storage.k8s.io/controller-expand-secret-namespace"

// webhook
WebhookName = "juicefs-admission-webhook"
True = "true"
False = "false"
inject = ".juicefs.com/inject"
injectSidecar = ".sidecar" + inject
InjectSidecarDone = "done" + injectSidecar
InjectSidecarDisable = "disable" + injectSidecar

// config in pv
MountPodCpuLimitKey = "juicefs/mount-cpu-limit"
MountPodMemLimitKey = "juicefs/mount-memory-limit"
MountPodCpuRequestKey = "juicefs/mount-cpu-request"
MountPodMemRequestKey = "juicefs/mount-memory-request"
mountPodLabelKey = "juicefs/mount-labels"
mountPodAnnotationKey = "juicefs/mount-annotations"
mountPodServiceAccount = "juicefs/mount-service-account"
mountPodImageKey = "juicefs/mount-image"
deleteDelay = "juicefs/mount-delete-delay"
cleanCache = "juicefs/clean-cache"
cachePVC = "juicefs/mount-cache-pvc"
cacheEmptyDir = "juicefs/mount-cache-emptydir"
cacheInlineVolume = "juicefs/mount-cache-inline-volume"
mountPodHostPath = "juicefs/host-path"

// DeleteDelayTimeKey mount pod annotation
DeleteDelayTimeKey = "juicefs-delete-delay"
DeleteDelayAtKey = "juicefs-delete-at"

// default value
DefaultMountPodCpuLimit = "2000m"
DefaultMountPodMemLimit = "5Gi"
DefaultMountPodCpuRequest = "1000m"
DefaultMountPodMemRequest = "1Gi"

// secret labels
JuicefsSecretLabelKey = "juicefs/secret"

PodInfoName = "csi.storage.k8s.io/pod.name"
PodInfoNamespace = "csi.storage.k8s.io/pod.namespace"
)

var interVolumesPrefix = []string{
"rsa-key",
"init-config",
Expand Down
Loading

0 comments on commit df77b79

Please sign in to comment.