mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
client-go: add context/options to expansions methods
This commit is contained in:
parent
f52cbea102
commit
4c034278f4
@ -20,20 +20,23 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
certificates "k8s.io/api/certificates/v1beta1"
|
certificates "k8s.io/api/certificates/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CertificateSigningRequestExpansion interface {
|
type CertificateSigningRequestExpansion interface {
|
||||||
UpdateApproval(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error)
|
UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *certificateSigningRequests) UpdateApproval(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) {
|
func (c *certificateSigningRequests) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) {
|
||||||
result = &certificates.CertificateSigningRequest{}
|
result = &certificates.CertificateSigningRequest{}
|
||||||
err = c.client.Put().
|
err = c.client.Put().
|
||||||
Resource("certificatesigningrequests").
|
Resource("certificatesigningrequests").
|
||||||
Name(certificateSigningRequest.Name).
|
Name(certificateSigningRequest.Name).
|
||||||
|
VersionedParams(&opts, scheme.ParameterCodec).
|
||||||
Body(certificateSigningRequest).
|
Body(certificateSigningRequest).
|
||||||
SubResource("approval").
|
SubResource("approval").
|
||||||
Do(context.TODO()).
|
Do(ctx).
|
||||||
Into(result)
|
Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,14 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
certificates "k8s.io/api/certificates/v1beta1"
|
certificates "k8s.io/api/certificates/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeCertificateSigningRequests) UpdateApproval(certificateSigningRequest *certificates.CertificateSigningRequest) (result *certificates.CertificateSigningRequest, err error) {
|
func (c *FakeCertificateSigningRequests) UpdateApproval(ctx context.Context, certificateSigningRequest *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) {
|
||||||
obj, err := c.Fake.
|
obj, err := c.Fake.
|
||||||
Invokes(core.NewRootUpdateSubresourceAction(certificatesigningrequestsResource, "approval", certificateSigningRequest), &certificates.CertificateSigningRequest{})
|
Invokes(core.NewRootUpdateSubresourceAction(certificatesigningrequestsResource, "approval", certificateSigningRequest), &certificates.CertificateSigningRequest{})
|
||||||
if obj == nil {
|
if obj == nil {
|
||||||
|
@ -17,11 +17,14 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeNamespaces) Finalize(namespace *v1.Namespace) (*v1.Namespace, error) {
|
func (c *FakeNamespaces) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error) {
|
||||||
action := core.CreateActionImpl{}
|
action := core.CreateActionImpl{}
|
||||||
action.Verb = "create"
|
action.Verb = "create"
|
||||||
action.Resource = namespacesResource
|
action.Resource = namespacesResource
|
||||||
|
@ -17,13 +17,16 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakePods) Bind(binding *v1.Binding) error {
|
func (c *FakePods) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error {
|
||||||
action := core.CreateActionImpl{}
|
action := core.CreateActionImpl{}
|
||||||
action.Verb = "create"
|
action.Verb = "create"
|
||||||
action.Namespace = binding.Namespace
|
action.Namespace = binding.Namespace
|
||||||
@ -57,7 +60,7 @@ func (c *FakePods) GetLogs(name string, opts *v1.PodLogOptions) *restclient.Requ
|
|||||||
return &restclient.Request{}
|
return &restclient.Request{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FakePods) Evict(eviction *policy.Eviction) error {
|
func (c *FakePods) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||||
action := core.CreateActionImpl{}
|
action := core.CreateActionImpl{}
|
||||||
action.Verb = "create"
|
action.Verb = "create"
|
||||||
action.Namespace = c.ns
|
action.Namespace = c.ns
|
||||||
|
@ -20,16 +20,18 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
// The NamespaceExpansion interface allows manually adding extra methods to the NamespaceInterface.
|
||||||
type NamespaceExpansion interface {
|
type NamespaceExpansion interface {
|
||||||
Finalize(item *v1.Namespace) (*v1.Namespace, error)
|
Finalize(ctx context.Context, item *v1.Namespace, opts metav1.UpdateOptions) (*v1.Namespace, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
// Finalize takes the representation of a namespace to update. Returns the server's representation of the namespace, and an error, if it occurs.
|
||||||
func (c *namespaces) Finalize(namespace *v1.Namespace) (result *v1.Namespace, err error) {
|
func (c *namespaces) Finalize(ctx context.Context, namespace *v1.Namespace, opts metav1.UpdateOptions) (result *v1.Namespace, err error) {
|
||||||
result = &v1.Namespace{}
|
result = &v1.Namespace{}
|
||||||
err = c.client.Put().Resource("namespaces").Name(namespace.Name).SubResource("finalize").Body(namespace).Do(context.TODO()).Into(result)
|
err = c.client.Put().Resource("namespaces").Name(namespace.Name).VersionedParams(&opts, scheme.ParameterCodec).SubResource("finalize").Body(namespace).Do(ctx).Into(result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,24 +21,25 @@ import (
|
|||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
restclient "k8s.io/client-go/rest"
|
restclient "k8s.io/client-go/rest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The PodExpansion interface allows manually adding extra methods to the PodInterface.
|
// The PodExpansion interface allows manually adding extra methods to the PodInterface.
|
||||||
type PodExpansion interface {
|
type PodExpansion interface {
|
||||||
Bind(binding *v1.Binding) error
|
Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error
|
||||||
Evict(eviction *policy.Eviction) error
|
Evict(ctx context.Context, eviction *policy.Eviction) error
|
||||||
GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request
|
GetLogs(name string, opts *v1.PodLogOptions) *restclient.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
// Bind applies the provided binding to the named pod in the current namespace (binding.Namespace is ignored).
|
||||||
func (c *pods) Bind(binding *v1.Binding) error {
|
func (c *pods) Bind(ctx context.Context, binding *v1.Binding, opts metav1.CreateOptions) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).SubResource("binding").Body(binding).Do(context.TODO()).Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(binding.Name).VersionedParams(&opts, scheme.ParameterCodec).SubResource("binding").Body(binding).Do(ctx).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *pods) Evict(eviction *policy.Eviction) error {
|
func (c *pods) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do(context.TODO()).Error()
|
return c.client.Post().Namespace(c.ns).Resource("pods").Name(eviction.Name).SubResource("eviction").Body(eviction).Do(ctx).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get constructs a request for getting the logs for a pod
|
// Get constructs a request for getting the logs for a pod
|
||||||
|
@ -20,14 +20,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"k8s.io/api/extensions/v1beta1"
|
"k8s.io/api/extensions/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
// The DeploymentExpansion interface allows manually adding extra methods to the DeploymentInterface.
|
||||||
type DeploymentExpansion interface {
|
type DeploymentExpansion interface {
|
||||||
Rollback(*v1beta1.DeploymentRollback) error
|
Rollback(context.Context, *v1beta1.DeploymentRollback, metav1.CreateOptions) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
// Rollback applied the provided DeploymentRollback to the named deployment in the current namespace.
|
||||||
func (c *deployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
func (c *deployments) Rollback(ctx context.Context, deploymentRollback *v1beta1.DeploymentRollback, opts metav1.CreateOptions) error {
|
||||||
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).SubResource("rollback").Body(deploymentRollback).Do(context.TODO()).Error()
|
return c.client.Post().Namespace(c.ns).Resource("deployments").Name(deploymentRollback.Name).VersionedParams(&opts, scheme.ParameterCodec).SubResource("rollback").Body(deploymentRollback).Do(ctx).Error()
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,14 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"k8s.io/api/extensions/v1beta1"
|
"k8s.io/api/extensions/v1beta1"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeDeployments) Rollback(deploymentRollback *v1beta1.DeploymentRollback) error {
|
func (c *FakeDeployments) Rollback(ctx context.Context, deploymentRollback *v1beta1.DeploymentRollback, opts metav1.CreateOptions) error {
|
||||||
action := core.CreateActionImpl{}
|
action := core.CreateActionImpl{}
|
||||||
action.Verb = "create"
|
action.Verb = "create"
|
||||||
action.Resource = deploymentsResource
|
action.Resource = deploymentsResource
|
||||||
|
@ -24,10 +24,10 @@ import (
|
|||||||
|
|
||||||
// The EvictionExpansion interface allows manually adding extra methods to the ScaleInterface.
|
// The EvictionExpansion interface allows manually adding extra methods to the ScaleInterface.
|
||||||
type EvictionExpansion interface {
|
type EvictionExpansion interface {
|
||||||
Evict(eviction *policy.Eviction) error
|
Evict(ctx context.Context, eviction *policy.Eviction) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *evictions) Evict(eviction *policy.Eviction) error {
|
func (c *evictions) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||||
return c.client.Post().
|
return c.client.Post().
|
||||||
AbsPath("/api/v1").
|
AbsPath("/api/v1").
|
||||||
Namespace(eviction.Namespace).
|
Namespace(eviction.Namespace).
|
||||||
@ -35,6 +35,6 @@ func (c *evictions) Evict(eviction *policy.Eviction) error {
|
|||||||
Name(eviction.Name).
|
Name(eviction.Name).
|
||||||
SubResource("eviction").
|
SubResource("eviction").
|
||||||
Body(eviction).
|
Body(eviction).
|
||||||
Do(context.TODO()).
|
Do(ctx).
|
||||||
Error()
|
Error()
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,14 @@ limitations under the License.
|
|||||||
package fake
|
package fake
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
policy "k8s.io/api/policy/v1beta1"
|
policy "k8s.io/api/policy/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
core "k8s.io/client-go/testing"
|
core "k8s.io/client-go/testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *FakeEvictions) Evict(eviction *policy.Eviction) error {
|
func (c *FakeEvictions) Evict(ctx context.Context, eviction *policy.Eviction) error {
|
||||||
action := core.CreateActionImpl{}
|
action := core.CreateActionImpl{}
|
||||||
action.Verb = "create"
|
action.Verb = "create"
|
||||||
action.Namespace = c.ns
|
action.Namespace = c.ns
|
||||||
|
Loading…
Reference in New Issue
Block a user