@@ -37,6 +37,8 @@ import (
37
37
internalapi "k8s.io/cri-api/pkg/apis"
38
38
pb "k8s.io/cri-api/pkg/apis/runtime/v1"
39
39
"k8s.io/kubelet/pkg/types"
40
+
41
+ "sigs.k8s.io/cri-tools/pkg/framework"
40
42
)
41
43
42
44
type containerByCreated []* pb.Container
@@ -580,7 +582,7 @@ var listContainersCommand = &cli.Command{
580
582
Name : "output" ,
581
583
Aliases : []string {"o" },
582
584
Usage : "Output format, One of: json|yaml|table" ,
583
- Value : "table" ,
585
+ Value : outputTypeTable ,
584
586
},
585
587
& cli.BoolFlag {
586
588
Name : "all" ,
@@ -889,7 +891,7 @@ func UpdateContainerResources(client internalapi.RuntimeService, id string, opts
889
891
request := & pb.UpdateContainerResourcesRequest {
890
892
ContainerId : id ,
891
893
}
892
- if goruntime .GOOS != "windows" {
894
+ if goruntime .GOOS != framework . OSWindows {
893
895
request .Linux = & pb.LinuxContainerResources {
894
896
CpuPeriod : opts .CPUPeriod ,
895
897
CpuQuota : opts .CPUQuota ,
@@ -1010,7 +1012,7 @@ func marshalContainerStatus(cs *pb.ContainerStatus) (string, error) {
1010
1012
func containerStatus (client internalapi.RuntimeService , ids []string , output , tmplStr string , quiet bool ) error {
1011
1013
verbose := ! (quiet )
1012
1014
if output == "" { // default to json output
1013
- output = "json"
1015
+ output = outputTypeJSON
1014
1016
}
1015
1017
if len (ids ) == 0 {
1016
1018
return errors .New ("ID cannot be empty" )
@@ -1036,7 +1038,7 @@ func containerStatus(client internalapi.RuntimeService, ids []string, output, tm
1036
1038
return fmt .Errorf ("marshal container status: %w" , err )
1037
1039
}
1038
1040
1039
- if output == "table" {
1041
+ if output == outputTypeTable {
1040
1042
outputContainerStatusTable (r , verbose )
1041
1043
} else {
1042
1044
statuses = append (statuses , statusData {json : statusJSON , info : r .Info })
@@ -1138,11 +1140,11 @@ func ListContainers(runtimeClient internalapi.RuntimeService, imageClient intern
1138
1140
r = getContainersList (r , opts )
1139
1141
1140
1142
switch opts .output {
1141
- case "json" :
1143
+ case outputTypeJSON :
1142
1144
return outputProtobufObjAsJSON (& pb.ListContainersResponse {Containers : r })
1143
- case "yaml" :
1145
+ case outputTypeYAML :
1144
1146
return outputProtobufObjAsYAML (& pb.ListContainersResponse {Containers : r })
1145
- case "table" :
1147
+ case outputTypeTable :
1146
1148
// continue; output will be generated after the switch block ends.
1147
1149
default :
1148
1150
return fmt .Errorf ("unsupported output format %q" , opts .output )
0 commit comments