diff --git a/pkg/customresource/customresource.go b/pkg/customresource/customresource.go index 37793589db..86c9d5ea2a 100644 --- a/pkg/customresource/customresource.go +++ b/pkg/customresource/customresource.go @@ -65,7 +65,7 @@ type Context struct { APIExtensionClientset apiextensionsclient.Interface Interval time.Duration Timeout time.Duration - ParentContext contextpkg.Context + Context contextpkg.Context } // CreateCustomResources creates the given custom resources and waits for them to initialize @@ -125,7 +125,7 @@ func createCRD(context Context, resource CustomResource) error { return errors.Wrap(err, "Getting CRD object from CRD bytes") } - _, err = context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Create(context.ParentContext, crd, metav1.CreateOptions{}) + _, err = context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Create(context.Context, crd, metav1.CreateOptions{}) if err != nil { if !apierrors.IsAlreadyExists(err) { return errors.Errorf("Failed to create %s CRD. %+v", resource.Name, err) @@ -133,13 +133,13 @@ func createCRD(context Context, resource CustomResource) error { err := retry.RetryOnConflict(retry.DefaultRetry, func() error { // if CRD already exists, get the resource version and create the CRD with that resource version - c, err := context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.ParentContext, crd.Name, metav1.GetOptions{}) + c, err := context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.Context, crd.Name, metav1.GetOptions{}) if err != nil { return err } crd.ResourceVersion = c.ResourceVersion - _, err = context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Update(context.ParentContext, crd, metav1.UpdateOptions{}) + _, err = context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Update(context.Context, crd, metav1.UpdateOptions{}) if err != nil { return err } @@ -159,8 +159,8 @@ func rawCRDFromFile(path string) ([]byte, error) { func waitForCRDInit(context Context, resource CustomResource) error { crdName := fmt.Sprintf("%s.%s", resource.Plural, resource.Group) - return wait.PollUntilContextTimeout(context.ParentContext, context.Interval, context.Timeout, false, func(contextpkg.Context) (bool, error) { - crd, err := context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.ParentContext, crdName, metav1.GetOptions{}) + return wait.PollUntilContextTimeout(context.Context, context.Interval, context.Timeout, false, func(contextpkg.Context) (bool, error) { + crd, err := context.APIExtensionClientset.ApiextensionsV1().CustomResourceDefinitions().Get(context.Context, crdName, metav1.GetOptions{}) if err != nil { return false, err } diff --git a/pkg/resource/resource.go b/pkg/resource/resource.go index 223af2675d..4c4a109aa9 100644 --- a/pkg/resource/resource.go +++ b/pkg/resource/resource.go @@ -64,7 +64,7 @@ func newOpKitContext(config *rest.Config, ctx context.Context) (*customresource. APIExtensionClientset: apiExtClientset, Interval: 500 * time.Millisecond, Timeout: 60 * time.Second, - ParentContext: ctx, + Context: ctx, }, nil }