Skip to content

Commit

Permalink
Update to client-go 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed May 19, 2020
1 parent 6c38527 commit 11a7de5
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 54 deletions.
10 changes: 5 additions & 5 deletions provider/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ require (
github.com/pulumi/pulumi/sdk/v2 v2.2.2-0.20200514204320-e677c7d6dca3
github.com/stretchr/testify v1.5.1
google.golang.org/grpc v1.28.0
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/client-go v0.18.0
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c
k8s.io/kubectl v0.17.0
sigs.k8s.io/yaml v1.1.0
sigs.k8s.io/yaml v1.2.0
)

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.1+incompatible
24 changes: 24 additions & 0 deletions provider/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
Expand Down Expand Up @@ -253,6 +254,8 @@ github.com/google/go-replayers/httpreplay v0.1.0/go.mod h1:YKZViNhiGgqdBlUbI2MwG
github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian v2.1.1-0.20190517191504-25dcb96d9e51+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
Expand All @@ -267,6 +270,7 @@ github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g=
github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/gophercloud/gophercloud v0.1.0 h1:P/nh25+rzXouhytV2pUHBb65fnds26Ghl8/391+sT5o=
Expand Down Expand Up @@ -405,6 +409,8 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
Expand Down Expand Up @@ -545,6 +551,7 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200317142112-1b76d66859c6 h1:TjszyFsQsyZNHwdVdZ5m7bjmreu0znc2kRYsEml9/Ww=
golang.org/x/crypto v0.0.0-20200317142112-1b76d66859c6/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -650,6 +657,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down Expand Up @@ -815,11 +823,17 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM=
k8s.io/api v0.17.0/go.mod h1:npsyOePkeP0CPwyGfXDHxvypiYMJxBWAMpQxCaJ4ZxI=
k8s.io/api v0.18.0 h1:lwYk8Vt7rsVTwjRU6pzEsa9YNhThbmbocQlKvNBB4EQ=
k8s.io/api v0.18.0/go.mod h1:q2HRQkfDzHMBZL9l/y9rH63PkQl4vae0xRT+8prbrK8=
k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo=
k8s.io/apimachinery v0.17.0/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg=
k8s.io/apimachinery v0.18.0 h1:fuPfYpk3cs1Okp/515pAf0dNhL66+8zk8RLbSX+EgAE=
k8s.io/apimachinery v0.18.0/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA=
k8s.io/cli-runtime v0.17.0/go.mod h1:1E5iQpMODZq2lMWLUJELwRu2MLWIzwvMgDBpn3Y81Qo=
k8s.io/client-go v0.17.0 h1:8QOGvUGdqDMFrm9sD6IUFl256BcffynGoe80sxgTEDg=
k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k=
k8s.io/client-go v0.18.0 h1:yqKw4cTUQraZK3fcVCMeSa+lqKwcjZ5wtcOIPnxQno4=
k8s.io/client-go v0.18.0/go.mod h1:uQSYDYs4WhVZ9i6AIoEZuwUggLVEF64HOD37boKAtF8=
k8s.io/code-generator v0.17.0/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s=
k8s.io/component-base v0.17.0/go.mod h1:rKuRAokNMY2nn2A6LP/MiwpoaMRHpfRnrPaUJJj1Yoc=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
Expand All @@ -830,11 +844,15 @@ k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU=
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c h1:/KUFqjjqAcY4Us6luF5RDNZ16KJtb49HfR3ZHB9qYXM=
k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E=
k8s.io/kubectl v0.17.0 h1:xD4EWlL+epc/JTO1gvSjmV9yiYF0Z2wiHK2DIek6URY=
k8s.io/kubectl v0.17.0/go.mod h1:jIPrUAW656Vzn9wZCCe0PC+oTcu56u2HgFD21Xbfk1s=
k8s.io/metrics v0.17.0/go.mod h1:EH1D3YAwN6d7bMelrElnLhLg72l/ERStyv2SIQVt6Do=
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f h1:GiPwtSzdP43eI1hpPCbROQCCIgCuiMMNF8YUVLF3vJo=
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU=
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
Expand All @@ -845,9 +863,15 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 h1:dOmIZBMfhcHS09XZkMyUgkq5trg3/jRyJYFZUiaOp8E=
sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
Expand Down
20 changes: 10 additions & 10 deletions provider/pkg/await/await.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func Creation(c CreateConfig) (*unstructured.Unstructured, error) {
}
}

outputs, err = client.Create(c.Inputs, metav1.CreateOptions{})
outputs, err = client.Create(context.TODO(), c.Inputs, metav1.CreateOptions{})
if err != nil {
_ = c.Host.LogStatus(c.Context, diag.Info, c.URN, fmt.Sprintf(
"Retry #%d; creation failed: %v", i, err))
Expand Down Expand Up @@ -201,7 +201,7 @@ func Creation(c CreateConfig) (*unstructured.Unstructured, error) {
// If the client fails to get the live object for some reason, DO NOT return the error. This
// will leak the fact that the object was successfully created. Instead, fall back to the
// last-seen live object.
live, err := client.Get(c.Inputs.GetName(), metav1.GetOptions{})
live, err := client.Get(context.TODO(), c.Inputs.GetName(), metav1.GetOptions{})
if err != nil {
return outputs, nil
}
Expand All @@ -216,7 +216,7 @@ func Read(c ReadConfig) (*unstructured.Unstructured, error) {
}

// Retrieve live version of the object from k8s.
outputs, err := client.Get(c.Name, metav1.GetOptions{})
outputs, err := client.Get(context.TODO(), c.Name, metav1.GetOptions{})
if err != nil {
return nil, err
} else if c.Inputs == nil || len(c.Inputs.Object) == 0 {
Expand Down Expand Up @@ -255,7 +255,7 @@ func Read(c ReadConfig) (*unstructured.Unstructured, error) {
// If the client fails to get the live object for some reason, DO NOT return the error. This
// will leak the fact that the object was successfully created. Instead, fall back to the
// last-seen live object.
live, err := client.Get(c.Name, metav1.GetOptions{})
live, err := client.Get(context.TODO(), c.Name, metav1.GetOptions{})
if err != nil {
return outputs, nil
}
Expand Down Expand Up @@ -324,7 +324,7 @@ func Update(c UpdateConfig) (*unstructured.Unstructured, error) {

// Get the "live" version of the last submitted object. This is necessary because the server may
// have populated some fields automatically, updated status fields, and so on.
liveOldObj, err := client.Get(c.Previous.GetName(), metav1.GetOptions{})
liveOldObj, err := client.Get(context.TODO(), c.Previous.GetName(), metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand All @@ -338,7 +338,7 @@ func Update(c UpdateConfig) (*unstructured.Unstructured, error) {
// Issue patch request.
// NOTE: We can use the same client because if the `kind` changes, this will cause
// a replace (i.e., destroy and create).
currentOutputs, err := client.Patch(c.Inputs.GetName(), patchType, patch, metav1.PatchOptions{})
currentOutputs, err := client.Patch(context.TODO(), c.Inputs.GetName(), patchType, patch, metav1.PatchOptions{})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -384,7 +384,7 @@ func Update(c UpdateConfig) (*unstructured.Unstructured, error) {
// If the client fails to get the live object for some reason, DO NOT return the error. This
// will leak the fact that the object was successfully created. Instead, fall back to the
// last-seen live object.
live, err := client.Get(c.Inputs.GetName(), metav1.GetOptions{})
live, err := client.Get(context.TODO(), c.Inputs.GetName(), metav1.GetOptions{})
if err != nil {
return currentOutputs, nil
}
Expand Down Expand Up @@ -427,7 +427,7 @@ func Deletion(c DeleteConfig) error {
}

// Set up a watcher for the selected resource.
watcher, err := client.Watch(listOpts)
watcher, err := client.Watch(context.TODO(), listOpts)
if err != nil {
return nilIfGVKDeleted(err)
}
Expand Down Expand Up @@ -538,13 +538,13 @@ func deleteResource(name string, client dynamic.ResourceInterface, version clust
}

// Issue deletion request.
return client.Delete(name, &deleteOpts)
return client.Delete(context.TODO(), name, *&deleteOpts)
}

// checkIfResourceDeleted attempts to get a k8s resource, and returns true if the resource is not found (was deleted).
// Return the resource if it still exists.
func checkIfResourceDeleted(name string, client dynamic.ResourceInterface) (bool, *unstructured.Unstructured) {
obj, err := client.Get(name, metav1.GetOptions{})
obj, err := client.Get(context.TODO(), name, metav1.GetOptions{})
if err != nil && is404(err) { // In case of 404, the resource no longer exists, so return success.
return true, nil
}
Expand Down
18 changes: 10 additions & 8 deletions provider/pkg/await/deployment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package await

import (
"context"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -150,15 +151,15 @@ func (dia *deploymentInitAwaiter) Await() error {
}

// Create Deployment watcher.
deploymentWatcher, err := deploymentClient.Watch(metav1.ListOptions{})
deploymentWatcher, err := deploymentClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err, "could not set up watch for Deployment object %q",
dia.config.currentInputs.GetName())
}
defer deploymentWatcher.Stop()

// Create ReplicaSet watcher.
replicaSetWatcher, err := replicaSetClient.Watch(metav1.ListOptions{})
replicaSetWatcher, err := replicaSetClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err,
"Could not create watcher for ReplicaSet objects associated with Deployment %q",
Expand All @@ -167,7 +168,7 @@ func (dia *deploymentInitAwaiter) Await() error {
defer replicaSetWatcher.Stop()

// Create Pod watcher.
podWatcher, err := podClient.Watch(metav1.ListOptions{})
podWatcher, err := podClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err,
"Could not create watcher for Pods objects associated with Deployment %q",
Expand All @@ -176,7 +177,7 @@ func (dia *deploymentInitAwaiter) Await() error {
defer podWatcher.Stop()

// Create PersistentVolumeClaims watcher.
pvcWatcher, err := pvcClient.Watch(metav1.ListOptions{})
pvcWatcher, err := pvcClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err,
"Could not create watcher for PersistentVolumeClaims objects associated with Deployment %q",
Expand All @@ -200,7 +201,8 @@ func (dia *deploymentInitAwaiter) Read() error {
}

// Get live versions of Deployment, ReplicaSets, and Pods.
deployment, err := deploymentClient.Get(dia.config.currentInputs.GetName(),
deployment, err := deploymentClient.Get(context.TODO(),
dia.config.currentInputs.GetName(),
metav1.GetOptions{})
if err != nil {
// IMPORTANT: Do not wrap this error! If this is a 404, the provider need to know so that it
Expand All @@ -214,21 +216,21 @@ func (dia *deploymentInitAwaiter) Read() error {
// in a way that is useful to the user.
//

rsList, err := replicaSetClient.List(metav1.ListOptions{})
rsList, err := replicaSetClient.List(context.TODO(), metav1.ListOptions{})
if err != nil {
logger.V(3).Infof("Error retrieving ReplicaSet list for Deployment %q: %v",
deployment.GetName(), err)
rsList = &unstructured.UnstructuredList{Items: []unstructured.Unstructured{}}
}

podList, err := podClient.List(metav1.ListOptions{})
podList, err := podClient.List(context.TODO(), metav1.ListOptions{})
if err != nil {
logger.V(3).Infof("Error retrieving Pod list for Deployment %q: %v",
deployment.GetName(), err)
podList = &unstructured.UnstructuredList{Items: []unstructured.Unstructured{}}
}

pvcList, err := pvcClient.List(metav1.ListOptions{})
pvcList, err := pvcClient.List(context.TODO(), metav1.ListOptions{})
if err != nil {
logger.V(3).Infof("Error retrieving PersistentVolumeClaims list for Deployment %q: %v",
deployment.GetName(), err)
Expand Down
13 changes: 7 additions & 6 deletions provider/pkg/await/ingress.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package await

import (
"context"
"encoding/json"
"fmt"
"reflect"
Expand Down Expand Up @@ -101,22 +102,22 @@ func (iia *ingressInitAwaiter) Await() error {
}

// Create ingress watcher.
ingressWatcher, err := ingressClient.Watch(metav1.ListOptions{})
ingressWatcher, err := ingressClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err, "Could not set up watch for Ingress object %q",
iia.config.currentInputs.GetName())
}
defer ingressWatcher.Stop()

endpointWatcher, err := endpointsClient.Watch(metav1.ListOptions{})
endpointWatcher, err := endpointsClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err,
"Could not create watcher for Endpoint objects associated with Ingress %q",
iia.config.currentInputs.GetName())
}
defer endpointWatcher.Stop()

serviceWatcher, err := servicesClient.Watch(metav1.ListOptions{})
serviceWatcher, err := servicesClient.Watch(context.TODO(), metav1.ListOptions{})
if err != nil {
return errors.Wrapf(err,
"Could not create watcher for Service objects associated with Ingress %q",
Expand All @@ -134,21 +135,21 @@ func (iia *ingressInitAwaiter) Read() error {
}

// Get live versions of Ingress.
ingress, err := ingressClient.Get(iia.config.currentInputs.GetName(), metav1.GetOptions{})
ingress, err := ingressClient.Get(context.TODO(), iia.config.currentInputs.GetName(), metav1.GetOptions{})
if err != nil {
// IMPORTANT: Do not wrap this error! If this is a 404, the provider need to know so that it
// can mark the deployment as having been deleted.
return err
}

// Get live version of Endpoints.
endpointList, err := endpointsClient.List(metav1.ListOptions{})
endpointList, err := endpointsClient.List(context.TODO(), metav1.ListOptions{})
if err != nil {
logger.V(3).Infof("Failed to list endpoints needed for Ingress awaiter: %v", err)
endpointList = &unstructured.UnstructuredList{Items: []unstructured.Unstructured{}}
}

serviceList, err := servicesClient.List(metav1.ListOptions{})
serviceList, err := servicesClient.List(context.TODO(), metav1.ListOptions{})
if err != nil {
logger.V(3).Infof("Failed to list services needed for Ingress awaiter: %v", err)
serviceList = &unstructured.UnstructuredList{Items: []unstructured.Unstructured{}}
Expand Down
Loading

0 comments on commit 11a7de5

Please sign in to comment.