Skip to content

Commit d75850b

Browse files
committed
update kubectl to 1.18.10
1 parent 39c5605 commit d75850b

File tree

7 files changed

+88
-125
lines changed

7 files changed

+88
-125
lines changed

cmd/diff/cmddiff.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
"github.com/spf13/cobra"
1111
"k8s.io/cli-runtime/pkg/genericclioptions"
12+
"k8s.io/cli-runtime/pkg/resource"
1213
"k8s.io/klog"
13-
"k8s.io/kubectl/pkg/cmd/apply"
1414
"k8s.io/kubectl/pkg/cmd/diff"
1515
"k8s.io/kubectl/pkg/cmd/util"
1616
"k8s.io/kubectl/pkg/util/i18n"
@@ -90,10 +90,7 @@ func Initialize(o *diff.DiffOptions, f util.Factory, args []string) (func(), err
9090
return cleanupFunc, err
9191
}
9292

93-
o.DryRunVerifier = &apply.DryRunVerifier{
94-
Finder: util.NewCRDFinder(util.CRDFromDynamic(o.DynamicClient)),
95-
OpenAPIGetter: o.DiscoveryClient,
96-
}
93+
o.DryRunVerifier = resource.NewDryRunVerifier(o.DynamicClient, o.DiscoveryClient)
9794

9895
o.CmdNamespace, o.EnforceNamespace, err = f.ToRawKubeConfigLoader().Namespace()
9996
if err != nil {

go.mod

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ require (
2020
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
2121
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
2222
gotest.tools v2.2.0+incompatible
23-
k8s.io/api v0.17.2
24-
k8s.io/apiextensions-apiserver v0.17.2
25-
k8s.io/apimachinery v0.17.2
26-
k8s.io/cli-runtime v0.17.2
27-
k8s.io/client-go v0.17.2
23+
k8s.io/api v0.18.10
24+
k8s.io/apiextensions-apiserver v0.18.10
25+
k8s.io/apimachinery v0.18.10
26+
k8s.io/cli-runtime v0.18.10
27+
k8s.io/client-go v0.18.10
2828
k8s.io/klog v1.0.0
29-
k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd
30-
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f
31-
sigs.k8s.io/controller-runtime v0.4.0
29+
k8s.io/kubectl v0.18.10
30+
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89
31+
sigs.k8s.io/controller-runtime v0.6.0
3232
sigs.k8s.io/kustomize/kyaml v0.9.3
3333
sigs.k8s.io/yaml v1.2.0
3434
)

go.sum

Lines changed: 56 additions & 104 deletions
Large diffs are not rendered by default.

pkg/apply/prune/prune.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package prune
1313

1414
import (
15+
"context"
1516
"sort"
1617
"strings"
1718

@@ -107,7 +108,7 @@ func (po *PruneOptions) Prune(localInv *unstructured.Unstructured, localObjs []*
107108
return err
108109
}
109110
namespacedClient := po.client.Resource(mapping.Resource).Namespace(clusterObj.Namespace)
110-
obj, err := namespacedClient.Get(clusterObj.Name, metav1.GetOptions{})
111+
obj, err := namespacedClient.Get(context.TODO(), clusterObj.Name, metav1.GetOptions{})
111112
if err != nil {
112113
// Object not found in cluster, so no need to delete it; skip to next object.
113114
if apierrors.IsNotFound(err) {
@@ -146,7 +147,7 @@ func (po *PruneOptions) Prune(localInv *unstructured.Unstructured, localObjs []*
146147
}
147148
if !o.DryRunStrategy.ClientOrServerDryRun() {
148149
klog.V(4).Infof("prune object delete: %s/%s", clusterObj.Namespace, clusterObj.Name)
149-
err = namespacedClient.Delete(clusterObj.Name, &metav1.DeleteOptions{})
150+
err = namespacedClient.Delete(context.TODO(), clusterObj.Name, metav1.DeleteOptions{})
150151
if err != nil {
151152
return err
152153
}

pkg/apply/task/apply_task.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,12 @@ func newApplyOptions(eventChannel chan event.Event, serverSideOptions common.Ser
178178
ServerSideApply: strategy.ServerDryRun() || serverSideOptions.ServerSideApply,
179179
ForceConflicts: serverSideOptions.ForceConflicts,
180180
FieldManager: serverSideOptions.FieldManager,
181-
DryRun: strategy.ClientOrServerDryRun(),
182-
ServerDryRun: strategy.ServerDryRun(),
181+
DryRunStrategy: strategy.Strategy(),
183182
ToPrinter: (&KubectlPrinterAdapter{
184183
ch: eventChannel,
185184
}).toPrinterFunc(),
186-
DiscoveryClient: discovery,
187-
DynamicClient: dynamic,
185+
DynamicClient: dynamic,
186+
DryRunVerifier: resource.NewDryRunVerifier(dynamic, discovery),
188187
}, nil
189188
}
190189

pkg/common/common.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package common
66
import (
77
"fmt"
88
"math/rand"
9+
10+
cmdutil "k8s.io/kubectl/pkg/cmd/util"
911
)
1012

1113
const (
@@ -102,6 +104,18 @@ func (drs DryRunStrategy) ClientOrServerDryRun() bool {
102104
return drs == DryRunClient || drs == DryRunServer
103105
}
104106

107+
// Strategy returns the
108+
func (drs DryRunStrategy) Strategy() cmdutil.DryRunStrategy {
109+
switch drs {
110+
case DryRunClient:
111+
return cmdutil.DryRunClient
112+
case DryRunServer:
113+
return cmdutil.DryRunServer
114+
default:
115+
return cmdutil.DryRunNone
116+
}
117+
}
118+
105119
// ServerSideOptions encapsulates the fields to implement server-side apply.
106120
type ServerSideOptions struct {
107121
// ServerSideApply means the merge patch is calculated on the API server instead of the client.

pkg/inventory/inventory-client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func (cic *ClusterInventoryClient) createInventoryObj(obj *unstructured.Unstruct
351351
}
352352
klog.V(4).Infof("creating inventory object: %s/%s", invInfo.Namespace, invInfo.Name)
353353
var clearResourceVersion = false
354-
createdObj, err := helper.Create(invInfo.Namespace, clearResourceVersion, invInfo.Object, nil)
354+
createdObj, err := helper.Create(invInfo.Namespace, clearResourceVersion, invInfo.Object)
355355
if err != nil {
356356
return err
357357
}
@@ -408,7 +408,7 @@ func (cic *ClusterInventoryClient) ApplyInventoryNamespace(obj *unstructured.Uns
408408
return err
409409
}
410410
var clearResourceVersion = false
411-
createdObj, err := helper.Create(invInfo.Namespace, clearResourceVersion, invInfo.Object, nil)
411+
createdObj, err := helper.Create(invInfo.Namespace, clearResourceVersion, invInfo.Object)
412412
if err != nil {
413413
if !apierrors.IsAlreadyExists(err) {
414414
return err

0 commit comments

Comments
 (0)