Skip to content

Commit d3282b3

Browse files
committed
boring refactors
1 parent 976b059 commit d3282b3

File tree

98 files changed

+526
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+526
-579
lines changed

docs/generated/oadm_by_example_content.adoc

-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ displays Merged kubeconfig settings or a specified kubeconfig file.
110110
// Show Merged kubeconfig settings.
111111
$ openshift admin config view
112112
113-
// Show only local kubeconfig settings
114-
$ openshift admin config view --local
115-
116113
// Get the password for the e2e user
117114
$ openshift admin config view -o template --template='{{range .users}}{{ if eq .name "e2e" }}{{ index .user.password }}{{end}}{{end}}'
118115
----

docs/generated/oc_by_example_content.adoc

+16-19
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ displays Merged kubeconfig settings or a specified kubeconfig file.
114114
// Show Merged kubeconfig settings.
115115
$ openshift cli config view
116116
117-
// Show only local kubeconfig settings
118-
$ openshift cli config view --local
119-
120117
// Get the password for the e2e user
121118
$ openshift cli config view -o template --template='{{range .users}}{{ if eq .name "e2e" }}{{ index .user.password }}{{end}}{{end}}'
122119
----
@@ -577,6 +574,22 @@ Run a proxy to the Kubernetes API server
577574
====
578575

579576

577+
== oc replace
578+
Replace a resource by filename or stdin.
579+
580+
====
581+
582+
[options="nowrap"]
583+
----
584+
// Update a pod using the data in pod.json.
585+
$ openshift cli update -f pod.json
586+
587+
// Update a pod based on the JSON passed into stdin.
588+
$ cat pod.json | openshift cli update -f -
589+
----
590+
====
591+
592+
580593
== oc rollback
581594
Revert part of an application back to a previous deployment
582595

@@ -727,22 +740,6 @@ An introduction to the concepts and types in OpenShift
727740
====
728741

729742

730-
== oc update
731-
Update a resource by filename or stdin.
732-
733-
====
734-
735-
[options="nowrap"]
736-
----
737-
// Update a pod using the data in pod.json.
738-
$ openshift cli update -f pod.json
739-
740-
// Update a pod based on the JSON passed into stdin.
741-
$ cat pod.json | openshift cli update -f -
742-
----
743-
====
744-
745-
746743
== oc volume
747744
Update volume on a resource with a pod template
748745

hack/test-cmd.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ echo "templates: ok"
320320
[ "$(openshift cli help update 2>&1 | grep 'openshift')" ]
321321

322322
# runnable commands with required flags must error consistently
323-
[ "$(oc get 2>&1 | grep 'you must provide one or more resources')" ]
324-
[ "$(openshift cli get 2>&1 | grep 'you must provide one or more resources')" ]
325-
[ "$(openshift kubectl get 2>&1 | grep 'you must provide one or more resources')" ]
323+
[ "$(oc get 2>&1 | grep 'Required resource not specified')" ]
324+
[ "$(openshift cli get 2>&1 | grep 'Required resource not specified')" ]
325+
[ "$(openshift kubectl get 2>&1 | grep 'Required resource not specified')" ]
326326

327327
# commands that expect file paths must validate and error out correctly
328328
[ "$(oc login --certificate-authority=/path/to/invalid 2>&1 | grep 'no such file or directory')" ]
@@ -659,7 +659,6 @@ sleep 2 && [ "$(oc get projects | grep 'ui-test-project')" ]
659659
echo "ui-project-commands: ok"
660660

661661
# Expose service as a route
662-
oc delete svc/frontend
663662
oc create -f test/integration/fixtures/test-service.json
664663
[ ! "$(oc expose service frontend --create-external-load-balancer)" ]
665664
[ ! "$(oc expose service frontend --port=40 --type=NodePort)" ]
@@ -704,10 +703,10 @@ oc status
704703
echo "complex-scenarios: ok"
705704

706705
[ "$(oc export svc --all -t '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' | wc -l)" -ne 0 ]
707-
[ "$(oc export svc --all | grep 'portalIP: ""')" ]
708706
[ "$(oc export svc --all --as-template=template | grep 'kind: Template')" ]
709-
[ ! "$(oc export svc --all --exact | grep 'portalIP: ""')" ]
710-
[ ! "$(oc export svc --all --raw | grep 'portalIP: ""')" ]
707+
[ ! "$(oc export svc --all | grep 'clusterIP')" ]
708+
[ ! "$(oc export svc --all --exact | grep 'clusterIP: ""')" ]
709+
[ ! "$(oc export svc --all --raw | grep 'clusterIP: ""')" ]
711710
[ ! "$(oc export svc --all --raw --exact)" ]
712711
[ ! "$(oc export svc -l a=b)" ] # return error if no items match selector
713712
[ "$(oc export svc -l a=b 2>&1 | grep 'no resources found')" ]

pkg/api/kubegraph/nodes/nodes_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestPodSpecNode(t *testing.T) {
1414
pod := &kapi.Pod{}
1515
pod.Namespace = "ns"
1616
pod.Name = "foo"
17-
pod.Spec.Host = "any-host"
17+
pod.Spec.NodeName = "any-host"
1818

1919
podNode := EnsurePodNode(g, pod)
2020

pkg/api/v1/conversion_generated.go

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func convert_api_ObjectMeta_To_v1_ObjectMeta(in *api.ObjectMeta, out *v1.ObjectM
4747
out.SelfLink = in.SelfLink
4848
out.UID = in.UID
4949
out.ResourceVersion = in.ResourceVersion
50+
out.Generation = in.Generation
5051
if err := s.Convert(&in.CreationTimestamp, &out.CreationTimestamp, 0); err != nil {
5152
return err
5253
}
@@ -118,6 +119,7 @@ func convert_v1_ObjectMeta_To_api_ObjectMeta(in *v1.ObjectMeta, out *api.ObjectM
118119
out.SelfLink = in.SelfLink
119120
out.UID = in.UID
120121
out.ResourceVersion = in.ResourceVersion
122+
out.Generation = in.Generation
121123
if err := s.Convert(&in.CreationTimestamp, &out.CreationTimestamp, 0); err != nil {
122124
return err
123125
}

pkg/api/v1/deep_copy_generated.go

-9
Original file line numberDiff line numberDiff line change
@@ -1235,15 +1235,6 @@ func deepCopy_v1_DeploymentConfigSpec(in deployapiv1.DeploymentConfigSpec, out *
12351235
} else {
12361236
out.Selector = nil
12371237
}
1238-
if in.TemplateRef != nil {
1239-
if newVal, err := c.DeepCopy(in.TemplateRef); err != nil {
1240-
return err
1241-
} else {
1242-
out.TemplateRef = newVal.(*v1.ObjectReference)
1243-
}
1244-
} else {
1245-
out.TemplateRef = nil
1246-
}
12471238
if in.Template != nil {
12481239
if newVal, err := c.DeepCopy(in.Template); err != nil {
12491240
return err

pkg/api/v1beta3/conversion_generated.go

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func convert_api_ObjectMeta_To_v1beta3_ObjectMeta(in *api.ObjectMeta, out *v1bet
4747
out.SelfLink = in.SelfLink
4848
out.UID = in.UID
4949
out.ResourceVersion = in.ResourceVersion
50+
out.Generation = in.Generation
5051
if err := s.Convert(&in.CreationTimestamp, &out.CreationTimestamp, 0); err != nil {
5152
return err
5253
}
@@ -118,6 +119,7 @@ func convert_v1beta3_ObjectMeta_To_api_ObjectMeta(in *v1beta3.ObjectMeta, out *a
118119
out.SelfLink = in.SelfLink
119120
out.UID = in.UID
120121
out.ResourceVersion = in.ResourceVersion
122+
out.Generation = in.Generation
121123
if err := s.Convert(&in.CreationTimestamp, &out.CreationTimestamp, 0); err != nil {
122124
return err
123125
}

pkg/api/v1beta3/deep_copy_generated.go

-9
Original file line numberDiff line numberDiff line change
@@ -1243,15 +1243,6 @@ func deepCopy_v1beta3_DeploymentConfigSpec(in deployapiv1beta3.DeploymentConfigS
12431243
} else {
12441244
out.Selector = nil
12451245
}
1246-
if in.TemplateRef != nil {
1247-
if newVal, err := c.DeepCopy(in.TemplateRef); err != nil {
1248-
return err
1249-
} else {
1250-
out.TemplateRef = newVal.(*v1beta3.ObjectReference)
1251-
}
1252-
} else {
1253-
out.TemplateRef = nil
1254-
}
12551246
if in.Template != nil {
12561247
if newVal, err := c.DeepCopy(in.Template); err != nil {
12571248
return err

pkg/authorization/registry/clusterpolicy/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func (strategy) AllowCreateOnUpdate() bool {
3131
return false
3232
}
3333

34+
func (strategy) AllowUnconditionalUpdate() bool {
35+
return false
36+
}
37+
3438
func (strategy) GenerateName(base string) string {
3539
return base
3640
}

pkg/authorization/registry/clusterpolicybinding/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func (strategy) AllowCreateOnUpdate() bool {
3131
return false
3232
}
3333

34+
func (strategy) AllowUnconditionalUpdate() bool {
35+
return false
36+
}
37+
3438
func (strategy) GenerateName(base string) string {
3539
return base
3640
}

pkg/authorization/registry/policy/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func (strategy) AllowCreateOnUpdate() bool {
3232
return false
3333
}
3434

35+
func (strategy) AllowUnconditionalUpdate() bool {
36+
return false
37+
}
38+
3539
func (strategy) GenerateName(base string) string {
3640
return base
3741
}

pkg/authorization/registry/policybinding/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func (strategy) AllowCreateOnUpdate() bool {
3232
return false
3333
}
3434

35+
func (strategy) AllowUnconditionalUpdate() bool {
36+
return false
37+
}
38+
3539
func (strategy) GenerateName(base string) string {
3640
return base
3741
}

pkg/authorization/registry/role/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ func (s strategy) AllowCreateOnUpdate() bool {
3434
return false
3535
}
3636

37+
func (strategy) AllowUnconditionalUpdate() bool {
38+
return false
39+
}
40+
3741
func (s strategy) GenerateName(base string) string {
3842
return base
3943
}

pkg/authorization/registry/rolebinding/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ func (s strategy) AllowCreateOnUpdate() bool {
3535
return false
3636
}
3737

38+
func (strategy) AllowUnconditionalUpdate() bool {
39+
return false
40+
}
41+
3842
func (s strategy) GenerateName(base string) string {
3943
return base
4044
}

pkg/build/admission/admission_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestBuildAdmission(t *testing.T) {
7676

7777
for _, test := range tests {
7878
c := NewBuildByStrategy(fakeClient(test.expectedResource, test.reviewResponse))
79-
attrs := admission.NewAttributesRecord(test.object, test.kind, "default", test.resource, admission.Create, fakeUser())
79+
attrs := admission.NewAttributesRecord(test.object, test.kind, "default", "name", test.resource, "" /*subresource*/, admission.Create, fakeUser())
8080
err := c.Admit(attrs)
8181
if err != nil && test.expectAccept {
8282
t.Errorf("%s: unexpected error: %v", test.name, err)

pkg/build/controller/controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (bc *BuildPodController) HandlePod(pod *kapi.Pod) error {
176176
// Check the exit codes of all the containers in the pod
177177
nextStatus = buildapi.BuildStatusComplete
178178
for _, info := range pod.Status.ContainerStatuses {
179-
if info.State.Termination != nil && info.State.Termination.ExitCode != 0 {
179+
if info.State.Terminated != nil && info.State.Terminated.ExitCode != 0 {
180180
nextStatus = buildapi.BuildStatusFailed
181181
break
182182
}

pkg/build/controller/controller_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func mockPod(status kapi.PodPhase, exitCode int) *kapi.Pod {
166166
ContainerStatuses: []kapi.ContainerStatus{
167167
{
168168
State: kapi.ContainerState{
169-
Termination: &kapi.ContainerStateTerminated{ExitCode: exitCode},
169+
Terminated: &kapi.ContainerStateTerminated{ExitCode: exitCode},
170170
},
171171
},
172172
},

pkg/build/controller/strategy/custom.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (bs *CustomBuildStrategy) CreateBuildPod(build *buildapi.Build) (*kapi.Pod,
5757
Labels: getPodLabels(build),
5858
},
5959
Spec: kapi.PodSpec{
60-
ServiceAccount: build.Parameters.ServiceAccount,
60+
ServiceAccountName: build.Parameters.ServiceAccount,
6161
Containers: []kapi.Container{
6262
{
6363
Name: "custom-build",

pkg/build/controller/strategy/docker.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (bs *DockerBuildStrategy) CreateBuildPod(build *buildapi.Build) (*kapi.Pod,
4747
Labels: getPodLabels(build),
4848
},
4949
Spec: kapi.PodSpec{
50-
ServiceAccount: build.Parameters.ServiceAccount,
50+
ServiceAccountName: build.Parameters.ServiceAccount,
5151
Containers: []kapi.Container{
5252
{
5353
Name: "docker-build",

pkg/build/controller/strategy/sti.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (bs *SourceBuildStrategy) CreateBuildPod(build *buildapi.Build) (*kapi.Pod,
6161
Labels: getPodLabels(build),
6262
},
6363
Spec: kapi.PodSpec{
64-
ServiceAccount: build.Parameters.ServiceAccount,
64+
ServiceAccountName: build.Parameters.ServiceAccount,
6565
Containers: []kapi.Container{
6666
{
6767
Name: "sti-build",

pkg/build/registry/build/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func (strategy) AllowCreateOnUpdate() bool {
5555
return false
5656
}
5757

58+
func (strategy) AllowUnconditionalUpdate() bool {
59+
return false
60+
}
61+
5862
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
5963
func (strategy) PrepareForCreate(obj runtime.Object) {
6064
build := obj.(*api.Build)

pkg/build/registry/buildconfig/strategy.go

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ func (strategy) AllowCreateOnUpdate() bool {
3232
return false
3333
}
3434

35+
func (strategy) AllowUnconditionalUpdate() bool {
36+
return false
37+
}
38+
3539
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
3640
func (strategy) PrepareForCreate(obj runtime.Object) {
3741
_ = obj.(*api.BuildConfig)

pkg/build/registry/buildlog/rest_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func resourceLocationHelper(buildStatus api.BuildStatus, podPhase string, ctx ka
200200
storage := REST{
201201
BuildRegistry: &buildRegistry,
202202
PodGetter: &testPodGetter{},
203-
ConnectionInfo: &kclient.HTTPKubeletClient{EnableHttps: true, Port: 12345, Client: &http.Client{}},
203+
ConnectionInfo: &kclient.HTTPKubeletClient{Config: &kclient.KubeletConfig{EnableHttps: true, Port: 12345}, Client: &http.Client{}},
204204
Timeout: defaultTimeout,
205205
}
206206
getter := rest.GetterWithOptions(&storage)
@@ -231,7 +231,7 @@ func mockPod(podPhase kapi.PodPhase) *kapi.Pod {
231231
Name: "foo-container",
232232
},
233233
},
234-
Host: "foo-host",
234+
NodeName: "foo-host",
235235
},
236236
Status: kapi.PodStatus{
237237
Phase: podPhase,

pkg/cmd/admin/node/node_options.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type NodeOptions struct {
3131
Mapper meta.RESTMapper
3232
Typer runtime.ObjectTyper
3333
RESTClientFactory func(mapping *meta.RESTMapping) (resource.RESTClient, error)
34-
Printer func(mapping *meta.RESTMapping, noHeaders, withNamespace bool) (kubectl.ResourcePrinter, error)
34+
Printer func(mapping *meta.RESTMapping, noHeaders, withNamespace bool, columnLabels []string) (kubectl.ResourcePrinter, error)
3535

3636
CmdPrinter kubectl.ResourcePrinter
3737
CmdPrinterOutput bool
@@ -173,11 +173,11 @@ func (n *NodeOptions) GetPrinters(kind, version string) (kubectl.ResourcePrinter
173173
return nil, nil, err
174174
}
175175

176-
printerWithHeaders, err := n.Printer(mapping, false, true)
176+
printerWithHeaders, err := n.Printer(mapping, false, true, []string{})
177177
if err != nil {
178178
return nil, nil, err
179179
}
180-
printerNoHeaders, err := n.Printer(mapping, true, true)
180+
printerNoHeaders, err := n.Printer(mapping, true, true, []string{})
181181
if err != nil {
182182
return nil, nil, err
183183
}

pkg/cmd/admin/registry/registry.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ func RunCmdRegistry(f *clientcmd.Factory, cmd *cobra.Command, out io.Writer, cfg
232232
podTemplate := &kapi.PodTemplateSpec{
233233
ObjectMeta: kapi.ObjectMeta{Labels: label},
234234
Spec: kapi.PodSpec{
235-
ServiceAccount: cfg.ServiceAccount,
236-
NodeSelector: nodeSelector,
235+
ServiceAccountName: cfg.ServiceAccount,
236+
NodeSelector: nodeSelector,
237237
Containers: []kapi.Container{
238238
{
239239
Name: "registry",

pkg/cmd/admin/router/router.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out io.Writer, cfg *
287287
Template: &kapi.PodTemplateSpec{
288288
ObjectMeta: kapi.ObjectMeta{Labels: label},
289289
Spec: kapi.PodSpec{
290-
ServiceAccount: cfg.ServiceAccount,
291-
NodeSelector: nodeSelector,
290+
ServiceAccountName: cfg.ServiceAccount,
291+
NodeSelector: nodeSelector,
292292
Containers: []kapi.Container{
293293
{
294294
Name: "router",

pkg/cmd/cli/cmd/edit.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func RunEdit(fullName string, f *clientcmd.Factory, out io.Writer, cmd *cobra.Co
218218
if err != nil {
219219
return err
220220
}
221-
updated, err := resource.NewHelper(info.Client, info.Mapping).Update(info.Namespace, info.Name, false, data)
221+
updated, err := resource.NewHelper(info.Client, info.Mapping).Replace(info.Namespace, info.Name, false, data)
222222
if err != nil {
223223
fmt.Fprintln(cmd.Out(), results.AddError(err, info))
224224
return nil
@@ -375,7 +375,7 @@ func applyPatch(delta *jsonmerge.Delta, info *resource.Info, version string) err
375375
if err != nil {
376376
return patchError{err}
377377
}
378-
updated, err := resource.NewHelper(info.Client, info.Mapping).Update(info.Namespace, info.Name, false, merged)
378+
updated, err := resource.NewHelper(info.Client, info.Mapping).Replace(info.Namespace, info.Name, false, merged)
379379
if err != nil {
380380
return err
381381
}

0 commit comments

Comments
 (0)