Dependency: update storageClass-accessor (#5271)
Dependency: update storageClass-accessor to v0.2.2, deleting storage source no longer requires validation now. Signed-off-by: f10atin9 <f10atin9@kubesphere.io> Signed-off-by: f10atin9 <f10atin9@kubesphere.io>
This commit is contained in:
4
go.mod
4
go.mod
@@ -49,7 +49,7 @@ require (
|
||||
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
|
||||
github.com/kubesphere/pvc-autoresizer v0.1.1
|
||||
github.com/kubesphere/sonargo v0.0.2
|
||||
github.com/kubesphere/storageclass-accessor v0.2.0
|
||||
github.com/kubesphere/storageclass-accessor v0.2.2
|
||||
github.com/mitchellh/mapstructure v1.2.2
|
||||
github.com/onsi/ginkgo v1.16.4
|
||||
github.com/onsi/gomega v1.15.0
|
||||
@@ -665,7 +665,7 @@ replace (
|
||||
github.com/kubernetes-csi/external-snapshotter/client/v4 => github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
|
||||
github.com/kubesphere/pvc-autoresizer => github.com/kubesphere/pvc-autoresizer v0.1.1
|
||||
github.com/kubesphere/sonargo => github.com/kubesphere/sonargo v0.0.2
|
||||
github.com/kubesphere/storageclass-accessor => github.com/kubesphere/storageclass-accessor v0.2.0
|
||||
github.com/kubesphere/storageclass-accessor => github.com/kubesphere/storageclass-accessor v0.2.2
|
||||
github.com/kylelemons/go-gypsy => github.com/kylelemons/go-gypsy v0.0.0-20160905020020-08cad365cd28
|
||||
github.com/kylelemons/godebug => github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb
|
||||
github.com/lann/builder => github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
|
||||
|
||||
4
go.sum
4
go.sum
@@ -531,8 +531,8 @@ github.com/kubesphere/pvc-autoresizer v0.1.1 h1:Q0VrvLfTiE1f38EvmFpJdBevwN21X7Br
|
||||
github.com/kubesphere/pvc-autoresizer v0.1.1/go.mod h1:88qz9L1Ov2bvw7L/i5mUT8g5DvBwRCZ60JA2d1WLgB0=
|
||||
github.com/kubesphere/sonargo v0.0.2 h1:hsSRE3sv3mkPcUAeSABdp7rtfcNW2zzeHXzFa01CTkU=
|
||||
github.com/kubesphere/sonargo v0.0.2/go.mod h1:ww8n9ANlDXhX5PBZ18iaRnCgEkXN0GMml3/KZXOZ11w=
|
||||
github.com/kubesphere/storageclass-accessor v0.2.0 h1:rnzKafhneo8160dh6REm3z1yAEaQWz1x/Lwi3QFVLWE=
|
||||
github.com/kubesphere/storageclass-accessor v0.2.0/go.mod h1:jqZ3tCiw09yOiPkZ3rDmf6QIpbZJx55McnyRaS0ayCY=
|
||||
github.com/kubesphere/storageclass-accessor v0.2.2 h1:FzKRQwwOYYwccZyG6z3ENFiONWAQ03d6SGs7H9N6gfI=
|
||||
github.com/kubesphere/storageclass-accessor v0.2.2/go.mod h1:jqZ3tCiw09yOiPkZ3rDmf6QIpbZJx55McnyRaS0ayCY=
|
||||
github.com/kylelemons/go-gypsy v0.0.0-20160905020020-08cad365cd28/go.mod h1:T/T7jsxVqf9k/zYOqbgNAsANsjxTd1Yq3htjDhQ1H0c=
|
||||
github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
|
||||
|
||||
49
vendor/github.com/kubesphere/storageclass-accessor/webhook/pvc.go
generated
vendored
49
vendor/github.com/kubesphere/storageclass-accessor/webhook/pvc.go
generated
vendored
@@ -1,14 +1,10 @@
|
||||
package webhook
|
||||
|
||||
import (
|
||||
"context"
|
||||
admissionv1 "k8s.io/api/admission/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/config"
|
||||
)
|
||||
|
||||
type ReqInfo struct {
|
||||
@@ -27,7 +23,7 @@ var reviewResponse = &admissionv1.AdmissionResponse{
|
||||
func AdmitPVC(ar admissionv1.AdmissionReview) *admissionv1.AdmissionResponse {
|
||||
klog.Info("admitting pvc")
|
||||
|
||||
if !(ar.Request.Operation == admissionv1.Delete || ar.Request.Operation == admissionv1.Create) {
|
||||
if ar.Request.Operation != admissionv1.Create {
|
||||
return reviewResponse
|
||||
}
|
||||
|
||||
@@ -35,37 +31,18 @@ func AdmitPVC(ar admissionv1.AdmissionReview) *admissionv1.AdmissionResponse {
|
||||
|
||||
var newPVC *corev1.PersistentVolumeClaim
|
||||
|
||||
switch ar.Request.Operation {
|
||||
case admissionv1.Create:
|
||||
deserializer := codecs.UniversalDeserializer()
|
||||
pvc := &corev1.PersistentVolumeClaim{}
|
||||
obj, _, err := deserializer.Decode(raw, nil, pvc)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
var ok bool
|
||||
newPVC, ok = obj.(*corev1.PersistentVolumeClaim)
|
||||
if !ok {
|
||||
klog.Error("obj can't exchange to pvc object")
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
case admissionv1.Delete:
|
||||
pvcInfo := types.NamespacedName{
|
||||
Namespace: ar.Request.Namespace,
|
||||
Name: ar.Request.Name,
|
||||
}
|
||||
cli, err := client.New(config.GetConfigOrDie(), client.Options{})
|
||||
if err != nil {
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
targetPVC := &corev1.PersistentVolumeClaim{}
|
||||
err = cli.Get(context.Background(), pvcInfo, targetPVC)
|
||||
if err != nil {
|
||||
klog.Error("get target Delete PVC from client failed, err:", err)
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
newPVC = targetPVC
|
||||
deserializer := codecs.UniversalDeserializer()
|
||||
pvc := &corev1.PersistentVolumeClaim{}
|
||||
obj, _, err := deserializer.Decode(raw, nil, pvc)
|
||||
if err != nil {
|
||||
klog.Error(err)
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
var ok bool
|
||||
newPVC, ok = obj.(*corev1.PersistentVolumeClaim)
|
||||
if !ok {
|
||||
klog.Error("obj can't exchange to pvc object")
|
||||
return toV1AdmissionResponse(err)
|
||||
}
|
||||
|
||||
reqPVC := ReqInfo{
|
||||
|
||||
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -582,7 +582,7 @@ github.com/kubesphere/pvc-autoresizer/runners
|
||||
# github.com/kubesphere/sonargo v0.0.2 => github.com/kubesphere/sonargo v0.0.2
|
||||
## explicit
|
||||
github.com/kubesphere/sonargo/sonar
|
||||
# github.com/kubesphere/storageclass-accessor v0.2.0 => github.com/kubesphere/storageclass-accessor v0.2.0
|
||||
# github.com/kubesphere/storageclass-accessor v0.2.2 => github.com/kubesphere/storageclass-accessor v0.2.2
|
||||
## explicit; go 1.16
|
||||
github.com/kubesphere/storageclass-accessor/client/apis/accessor/v1alpha1
|
||||
github.com/kubesphere/storageclass-accessor/webhook
|
||||
@@ -2726,7 +2726,7 @@ sigs.k8s.io/yaml
|
||||
# github.com/kubernetes-csi/external-snapshotter/client/v4 => github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
|
||||
# github.com/kubesphere/pvc-autoresizer => github.com/kubesphere/pvc-autoresizer v0.1.1
|
||||
# github.com/kubesphere/sonargo => github.com/kubesphere/sonargo v0.0.2
|
||||
# github.com/kubesphere/storageclass-accessor => github.com/kubesphere/storageclass-accessor v0.2.0
|
||||
# github.com/kubesphere/storageclass-accessor => github.com/kubesphere/storageclass-accessor v0.2.2
|
||||
# github.com/kylelemons/go-gypsy => github.com/kylelemons/go-gypsy v0.0.0-20160905020020-08cad365cd28
|
||||
# github.com/kylelemons/godebug => github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb
|
||||
# github.com/lann/builder => github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
|
||||
|
||||
Reference in New Issue
Block a user