Debian Codegraph @

kubernetes/typed/apps/v1/deployment.go

raw symbols SCIP
1 /*
2 Copyright The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 // Code generated by client-gen. DO NOT EDIT.
18
19 package v1
20
21 import (
22 context "context"
23 fmt "fmt"
24
25 appsv1 "k8s.io/api/apps/v1"
26 autoscalingv1 "k8s.io/api/autoscaling/v1"
27 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28 types "k8s.io/apimachinery/pkg/types"
29 watch "k8s.io/apimachinery/pkg/watch"
30 applyconfigurationsappsv1 "k8s.io/client-go/applyconfigurations/apps/v1"
31 applyconfigurationsautoscalingv1 "k8s.io/client-go/applyconfigurations/autoscaling/v1"
32 gentype "k8s.io/client-go/gentype"
33 scheme "k8s.io/client-go/kubernetes/scheme"
34 apply "k8s.io/client-go/util/apply"
35 )
36
37 // DeploymentsGetter has a method to return a DeploymentInterface.
38 // A group's client should implement this interface.
39 type DeploymentsGetter interface {
40 Deployments(namespace string) DeploymentInterface
41 }
42
43 // DeploymentInterface has methods to work with Deployment resources.
44 type DeploymentInterface interface {
45 Create(ctx context.Context, deployment *appsv1.Deployment, opts metav1.CreateOptions) (*appsv1.Deployment, error)
46 Update(ctx context.Context, deployment *appsv1.Deployment, opts metav1.UpdateOptions) (*appsv1.Deployment, error)
47 // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus().
48 UpdateStatus(ctx context.Context, deployment *appsv1.Deployment, opts metav1.UpdateOptions) (*appsv1.Deployment, error)
49 Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
50 DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
51 Get(ctx context.Context, name string, opts metav1.GetOptions) (*appsv1.Deployment, error)
52 List(ctx context.Context, opts metav1.ListOptions) (*appsv1.DeploymentList, error)
53 Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
54 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *appsv1.Deployment, err error)
55 Apply(ctx context.Context, deployment *applyconfigurationsappsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (result *appsv1.Deployment, err error)
56 // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus().
57 ApplyStatus(ctx context.Context, deployment *applyconfigurationsappsv1.DeploymentApplyConfiguration, opts metav1.ApplyOptions) (result *appsv1.Deployment, err error)
58 GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (*autoscalingv1.Scale, error)
59 UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (*autoscalingv1.Scale, error)
60 ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (*autoscalingv1.Scale, error)
61
62 DeploymentExpansion
63 }
64
65 // deployments implements DeploymentInterface
66 type deployments struct {
67 *gentype.ClientWithListAndApply[*appsv1.Deployment, *appsv1.DeploymentList, *applyconfigurationsappsv1.DeploymentApplyConfiguration]
68 }
69
70 // newDeployments returns a Deployments
71 func newDeployments(c *AppsV1Client, namespace string) *deployments {
72 return &deployments{
73 gentype.NewClientWithListAndApply[*appsv1.Deployment, *appsv1.DeploymentList, *applyconfigurationsappsv1.DeploymentApplyConfiguration](
74 "deployments",
75 c.RESTClient(),
76 scheme.ParameterCodec,
77 namespace,
78 func() *appsv1.Deployment { return &appsv1.Deployment{} },
79 func() *appsv1.DeploymentList { return &appsv1.DeploymentList{} },
80 gentype.PrefersProtobuf[*appsv1.Deployment](),
81 ),
82 }
83 }
84
85 // GetScale takes name of the deployment, and returns the corresponding autoscalingv1.Scale object, and an error if there is any.
86 func (c *deployments) GetScale(ctx context.Context, deploymentName string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) {
87 result = &autoscalingv1.Scale{}
88 err = c.GetClient().Get().
89 UseProtobufAsDefault().
90 Namespace(c.GetNamespace()).
91 Resource("deployments").
92 Name(deploymentName).
93 SubResource("scale").
94 VersionedParams(&options, scheme.ParameterCodec).
95 Do(ctx).
96 Into(result)
97 return
98 }
99
100 // UpdateScale takes the top resource name and the representation of a scale and updates it. Returns the server's representation of the scale, and an error, if there is any.
101 func (c *deployments) UpdateScale(ctx context.Context, deploymentName string, scale *autoscalingv1.Scale, opts metav1.UpdateOptions) (result *autoscalingv1.Scale, err error) {
102 result = &autoscalingv1.Scale{}
103 err = c.GetClient().Put().
104 UseProtobufAsDefault().
105 Namespace(c.GetNamespace()).
106 Resource("deployments").
107 Name(deploymentName).
108 SubResource("scale").
109 VersionedParams(&opts, scheme.ParameterCodec).
110 Body(scale).
111 Do(ctx).
112 Into(result)
113 return
114 }
115
116 // ApplyScale takes top resource name and the apply declarative configuration for scale,
117 // applies it and returns the applied scale, and an error, if there is any.
118 func (c *deployments) ApplyScale(ctx context.Context, deploymentName string, scale *applyconfigurationsautoscalingv1.ScaleApplyConfiguration, opts metav1.ApplyOptions) (result *autoscalingv1.Scale, err error) {
119 if scale == nil {
120 return nil, fmt.Errorf("scale provided to ApplyScale must not be nil")
121 }
122 patchOpts := opts.ToPatchOptions()
123 request, err := apply.NewRequest(c.GetClient(), scale)
124 if err != nil {
125 return nil, err
126 }
127
128 result = &autoscalingv1.Scale{}
129 err = request.
130 UseProtobufAsDefault().
131 Namespace(c.GetNamespace()).
132 Resource("deployments").
133 Name(deploymentName).
134 SubResource("scale").
135 VersionedParams(&patchOpts, scheme.ParameterCodec).
136 Do(ctx).
137 Into(result)
138 return
139 }