Skip to content

Commit e13d67e

Browse files
1gtmhossainemruz
andauthored
Update to Kubernetes v1.18.3 (#1142)
* Update to Kubernetes v1.18.3 Signed-off-by: 1gtm <1gtm@appscode.com> * Fix ValidNameWithPrefix spelling Signed-off-by: hossainemruz <emruz@appscode.com> Co-authored-by: hossainemruz <emruz@appscode.com>
1 parent 26ee605 commit e13d67e

File tree

10 files changed

+51
-16
lines changed

10 files changed

+51
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require (
3434
k8s.io/client-go v12.0.0+incompatible
3535
k8s.io/kube-aggregator v0.18.3
3636
k8s.io/kubernetes v1.18.3
37-
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371
37+
kmodules.xyz/client-go v0.0.0-20200630053911-20d035822d35
3838
kmodules.xyz/constants v0.0.0-20200506032633-a21e58ceec72
3939
kmodules.xyz/custom-resources v0.0.0-20200604135349-9e9f5c4fdba9
4040
kmodules.xyz/objectstore-api v0.0.0-20200521103120-92080446e04d

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ kmodules.xyz/client-go v0.0.0-20200522120609-c6430d66212f/go.mod h1:sY/eoe4ktxZE
987987
kmodules.xyz/client-go v0.0.0-20200525012433-99c6914a1eca/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
988988
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371 h1:PPawDOMyDHGeDPN8j1epNozaIB/Z7MlJsXpwm/r4jgk=
989989
kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
990+
kmodules.xyz/client-go v0.0.0-20200630053911-20d035822d35 h1:gDzZWVvgAaEBzo4lxMGhPUWqySgFyFDkcqw3NskZiwQ=
991+
kmodules.xyz/client-go v0.0.0-20200630053911-20d035822d35/go.mod h1:sY/eoe4ktxZEoHpr5NpAQ5s22VSwTE8psJtKVeVgLRY=
990992
kmodules.xyz/constants v0.0.0-20200506032633-a21e58ceec72 h1:0sM6nE7aJon/PSdqZTj0bKJlPyzobXkG0wVYKpjcJJE=
991993
kmodules.xyz/constants v0.0.0-20200506032633-a21e58ceec72/go.mod h1:DbiFk1bJ1KEO94t1SlAn7tzc+Zz95rSXgyUKa2nzPmY=
992994
kmodules.xyz/crd-schema-fuzz v0.0.0-20200521005638-2433a187de95/go.mod h1:jpu8xFsDKd6kAWUAKk8oTu/GQGBWqhrcaDeOJdaCJnk=

pkg/cmds/create_backupsession.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (opt *options) createBackupSession() error {
9898

9999
bsMeta := metav1.ObjectMeta{
100100
// Name format: <invoker name>-<timestamp in unix format>
101-
Name: meta.ValidNameWithSuffix(opt.invokerName, fmt.Sprintf("%d", time.Now().Unix())),
101+
Name: meta.NameWithSuffix(opt.invokerName, fmt.Sprintf("%d", time.Now().Unix())),
102102
Namespace: opt.namespace,
103103
OwnerReferences: []metav1.OwnerReference{},
104104
}

pkg/controller/backup_session.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ func (c *StashController) handleBackupJobCreationFailure(invoker apis.Invoker, b
617617
}
618618

619619
func getBackupJobName(backupSession *api_v1beta1.BackupSession, index string) string {
620-
return meta.ValidNameWithPefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(backupSession.Name, ".", "-"), index)
620+
return meta.ValidNameWithPrefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(backupSession.Name, ".", "-"), index)
621621
}
622622

623623
func getBackupJobServiceAccountName(invokerName, index string) string {
624-
return meta.ValidNameWithPefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(invokerName, ".", "-"), index)
624+
return meta.ValidNameWithPrefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(invokerName, ".", "-"), index)
625625
}
626626

627627
func getVolumeSnapshotterJobName(targetRef api_v1beta1.TargetRef, name string) string {
@@ -631,7 +631,7 @@ func getVolumeSnapshotterJobName(targetRef api_v1beta1.TargetRef, name string) s
631631
}
632632

633633
func getVolumeSnapshotterServiceAccountName(invokerName, index string) string {
634-
return meta.ValidNameWithPefixNSuffix(apis.PrefixStashVolumeSnapshot, strings.ReplaceAll(invokerName, ".", "-"), index)
634+
return meta.ValidNameWithPrefixNSuffix(apis.PrefixStashVolumeSnapshot, strings.ReplaceAll(invokerName, ".", "-"), index)
635635
}
636636

637637
// cleanupBackupHistory deletes old BackupSessions and theirs associate resources according to BackupHistoryLimit

pkg/rbac/init_container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func ensureRestoreInitContainerRoleBinding(kc kubernetes.Interface, owner *metav
127127
}
128128

129129
func getRestoreInitContainerRoleBindingName(kind, name string) string {
130-
return meta_util.ValidNameWithPefixNSuffix(apis.StashRestoreInitContainerClusterRole, strings.ToLower(kind), name)
130+
return meta_util.ValidNameWithPrefixNSuffix(apis.StashRestoreInitContainerClusterRole, strings.ToLower(kind), name)
131131
}
132132

133133
func ensureRestoreInitContainerRoleBindingDeleted(kubeClient kubernetes.Interface, w *wapi.Workload) error {

pkg/rbac/sidecar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040
)
4141

4242
func getSidecarRoleBindingName(name string, kind string) string {
43-
return meta_util.ValidNameWithPefixNSuffix(apis.StashSidecarClusterRole, strings.ToLower(kind), name)
43+
return meta_util.ValidNameWithPrefixNSuffix(apis.StashSidecarClusterRole, strings.ToLower(kind), name)
4444
}
4545

4646
func EnsureSidecarClusterRole(kc kubernetes.Interface) error {

test/e2e/framework/backup_configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,5 @@ func getBackupCronJobName(objMeta metav1.ObjectMeta) string {
148148
}
149149

150150
func getBackupJobName(backupSessionName string, index string) string {
151-
return meta_util.ValidNameWithPefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(backupSessionName, ".", "-"), index)
151+
return meta_util.ValidNameWithPrefixNSuffix(apis.PrefixStashBackup, strings.ReplaceAll(backupSessionName, ".", "-"), index)
152152
}

vendor/kmodules.xyz/client-go/apiextensions/kubernetes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
5454
client,
5555
crd.V1.Name,
5656
func(in *crdv1.CustomResourceDefinition) *crdv1.CustomResourceDefinition {
57-
in.Labels = meta_util.MergeKeys(in.Labels, crd.V1.Labels)
58-
in.Annotations = meta_util.MergeKeys(in.Annotations, crd.V1.Annotations)
57+
in.Labels = meta_util.OverwriteKeys(in.Labels, crd.V1.Labels)
58+
in.Annotations = meta_util.OverwriteKeys(in.Annotations, crd.V1.Annotations)
5959

6060
in.Spec = crd.V1.Spec
6161
return in
@@ -86,8 +86,8 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
8686
client,
8787
crd.V1beta1.Name,
8888
func(in *crdv1beta1.CustomResourceDefinition) *crdv1beta1.CustomResourceDefinition {
89-
in.Labels = meta_util.MergeKeys(in.Labels, crd.V1beta1.Labels)
90-
in.Annotations = meta_util.MergeKeys(in.Annotations, crd.V1beta1.Annotations)
89+
in.Labels = meta_util.OverwriteKeys(in.Labels, crd.V1beta1.Labels)
90+
in.Annotations = meta_util.OverwriteKeys(in.Annotations, crd.V1beta1.Annotations)
9191

9292
in.Spec = crd.V1beta1.Spec
9393
return in

vendor/kmodules.xyz/client-go/meta/lib.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,32 @@ func MergeKeys(out, in map[string]string) map[string]string {
109109
out = make(map[string]string, len(in))
110110
}
111111

112+
for k, v := range in {
113+
if _, ok := out[k]; !ok {
114+
out[k] = v
115+
}
116+
}
117+
return out
118+
}
119+
120+
func OverwriteKeys(out, in map[string]string) map[string]string {
121+
if in == nil {
122+
return out
123+
}
124+
if out == nil {
125+
out = make(map[string]string, len(in))
126+
}
127+
112128
for k, v := range in {
113129
out[k] = v
114130
}
115131
return out
116132
}
117133

134+
func NameWithPrefix(prefix, name string, customLength ...int) string {
135+
return ValidNameWithPrefix(prefix, name, customLength...)
136+
}
137+
118138
func ValidNameWithPrefix(prefix, name string, customLength ...int) string {
119139
maxLength := validation.DNS1123LabelMaxLength
120140
if len(customLength) != 0 {
@@ -124,6 +144,19 @@ func ValidNameWithPrefix(prefix, name string, customLength ...int) string {
124144
return strings.Trim(out[:min(maxLength, len(out))], "-")
125145
}
126146

147+
func NameWithSuffix(name, suffix string, customLength ...int) string {
148+
maxLength := validation.DNS1123LabelMaxLength
149+
if len(customLength) != 0 {
150+
maxLength = customLength[0]
151+
}
152+
if len(suffix) >= maxLength {
153+
return strings.Trim(suffix[max(0, len(suffix)-maxLength):], "-")
154+
}
155+
out := fmt.Sprintf("%s-%s", name[:min(len(name), maxLength-len(suffix)-1)], suffix)
156+
return strings.Trim(out, "-")
157+
}
158+
159+
// Deprecated: Use NameWithSuffix in new code
127160
func ValidNameWithSuffix(name, suffix string, customLength ...int) string {
128161
maxLength := validation.DNS1123LabelMaxLength
129162
if len(customLength) != 0 {
@@ -133,7 +166,7 @@ func ValidNameWithSuffix(name, suffix string, customLength ...int) string {
133166
return strings.Trim(out[max(0, len(out)-maxLength):], "-")
134167
}
135168

136-
func ValidNameWithPefixNSuffix(prefix, name, suffix string, customLength ...int) string {
169+
func ValidNameWithPrefixNSuffix(prefix, name, suffix string, customLength ...int) string {
137170
maxLength := validation.DNS1123LabelMaxLength
138171
if len(customLength) != 0 {
139172
maxLength = customLength[0]
@@ -154,8 +187,8 @@ func ValidCronJobNameWithSuffix(name, suffix string) string {
154187
return ValidNameWithSuffix(name, suffix, MaxCronJobNameLength)
155188
}
156189

157-
func ValidCronJobNameWithPefixNSuffix(prefix, name, suffix string) string {
158-
return ValidNameWithPefixNSuffix(prefix, name, suffix, MaxCronJobNameLength)
190+
func ValidCronJobNameWithPrefixNSuffix(prefix, name, suffix string) string {
191+
return ValidNameWithPrefixNSuffix(prefix, name, suffix, MaxCronJobNameLength)
159192
}
160193

161194
func min(x, y int) int {

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ k8s.io/utils/net
10431043
k8s.io/utils/path
10441044
k8s.io/utils/pointer
10451045
k8s.io/utils/trace
1046-
# kmodules.xyz/client-go v0.0.0-20200525195850-2fd180961371
1046+
# kmodules.xyz/client-go v0.0.0-20200630053911-20d035822d35
10471047
kmodules.xyz/client-go
10481048
kmodules.xyz/client-go/admissionregistration/v1beta1
10491049
kmodules.xyz/client-go/api/v1

0 commit comments

Comments
 (0)