Skip to content

Commit

Permalink
Bump Kubernetes version to 1.14
Browse files Browse the repository at this point in the history
implement and test patch options
implement new metrics provider API
  • Loading branch information
adracus committed Apr 24, 2019
1 parent 856708d commit 090a42a
Show file tree
Hide file tree
Showing 339 changed files with 19,173 additions and 8,448 deletions.
100 changes: 47 additions & 53 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ required = ["sigs.k8s.io/testing_frameworks/integration",

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.13.4"
version = "kubernetes-1.14.1"

[[constraint]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.13.4"
version = "kubernetes-1.14.1"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.13.4"
version = "kubernetes-1.14.1"

[[constraint]]
name = "k8s.io/client-go"
version = "kubernetes-1.13.4"
version = "kubernetes-1.14.1"

[[constraint]]
name = "sigs.k8s.io/testing_frameworks"
Expand Down
28 changes: 26 additions & 2 deletions pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ var _ = Describe("Client", func() {
Expect(err).NotTo(HaveOccurred())

By("patching the Deployment with dry-run")
err = cl.Patch(context.TODO(), dep, client.ConstantPatch(types.MergePatchType, mergePatch), client.UpdatePatchWith(client.UpdateDryRunAll()))
err = cl.Patch(context.TODO(), dep, client.ConstantPatch(types.MergePatchType, mergePatch), client.PatchDryRunAll())
Expect(err).NotTo(HaveOccurred())

By("validating patched Deployment doesn't have the new annotation")
Expand Down Expand Up @@ -1183,7 +1183,7 @@ var _ = Describe("Client", func() {
Kind: "Deployment",
Version: "v1",
})
err = cl.Patch(context.TODO(), u, client.ConstantPatch(types.MergePatchType, mergePatch), client.UpdatePatchWith(client.UpdateDryRunAll()))
err = cl.Patch(context.TODO(), u, client.ConstantPatch(types.MergePatchType, mergePatch), client.PatchDryRunAll())
Expect(err).NotTo(HaveOccurred())

By("validating patched Deployment does not have the new annotation")
Expand Down Expand Up @@ -2153,6 +2153,30 @@ var _ = Describe("Client", func() {
Expect(co.AsUpdateOptions()).To(Equal(&metav1.UpdateOptions{}))
})
})

Describe("PatchOptions", func() {
It("should allow setting DryRun to 'all'", func() {
po := &client.PatchOptions{}
client.PatchDryRunAll()(po)
all := []string{metav1.DryRunAll}
Expect(po.AsPatchOptions().DryRun).To(Equal(all))
})

It("should allow setting Force to 'true'", func() {
po := &client.PatchOptions{}
client.PatchWithForce()(po)
mpo := po.AsPatchOptions()
Expect(mpo.Force).NotTo(BeNil())
Expect(*mpo.Force).To(BeTrue())
})

It("should produce empty metav1.PatchOptions if nil", func() {
var po *client.PatchOptions
Expect(po.AsPatchOptions()).To(Equal(&metav1.PatchOptions{}))
po = &client.PatchOptions{}
Expect(po.AsPatchOptions()).To(Equal(&metav1.PatchOptions{}))
})
})
})

var _ = Describe("DelegatingReader", func() {
Expand Down
9 changes: 9 additions & 0 deletions pkg/client/fake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ func (c *fakeClient) Update(ctx context.Context, obj runtime.Object, opts ...cli
}

func (c *fakeClient) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.PatchOptionFunc) error {
patchOptions := &client.PatchOptions{}
patchOptions.ApplyOptions(opts)

for _, dryRunOpt := range patchOptions.DryRun {
if dryRunOpt == metav1.DryRunAll {
return nil
}
}

gvr, err := getGVRFromObject(obj, c.scheme)
if err != nil {
return err
Expand Down
Loading

0 comments on commit 090a42a

Please sign in to comment.