mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Address comments, fix tests.
This commit is contained in:
parent
250b9ccd74
commit
7e48b26ff5
@ -930,7 +930,6 @@ Usage:
|
||||
--output-version="": Output the formatted object with the given version (default api-version)
|
||||
--overrides="": An inline JSON override for the generated object. If this is non-empty, it is parsed used to override the generated object. Requires that the object supply a valid apiVersion field.
|
||||
--port=-1: The port that this container exposes.
|
||||
--public-ip="": A public IP address to use for this service.
|
||||
-r, --replicas=1: Number of replicas to create for this container. Default 1
|
||||
-s, --server="": The address of the Kubernetes API server
|
||||
--stderrthreshold=2: logs at or above this threshold go to stderr
|
||||
|
@ -90,7 +90,6 @@ Examples:
|
||||
cmd.Flags().String("image", "", "The image for the container you wish to run.")
|
||||
cmd.Flags().IntP("replicas", "r", 1, "Number of replicas to create for this container. Default 1")
|
||||
cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, don't actually do anything")
|
||||
cmd.Flags().String("public-ip", "", "A public IP address to use for this service.")
|
||||
cmd.Flags().String("overrides", "", "An inline JSON override for the generated object. If this is non-empty, it is parsed used to override the generated object. Requires that the object supply a valid apiVersion field.")
|
||||
cmd.Flags().Int("port", -1, "The port that this container exposes.")
|
||||
cmd.Flags().StringP("labels", "l", "", "Labels to apply to the pod(s) created by this call to run-container.")
|
||||
|
@ -73,8 +73,12 @@ func (BasicReplicationController) Generate(params map[string]string) (runtime.Ob
|
||||
},
|
||||
},
|
||||
}
|
||||
port, err := strconv.Atoi(params["port"])
|
||||
if err != nil {
|
||||
|
||||
if len(params["port"]) > 0 {
|
||||
port, err := strconv.Atoi(params["port"])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{
|
||||
{
|
||||
ContainerPort: port,
|
||||
|
@ -59,6 +59,42 @@ func TestGenerate(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
params: map[string]string{
|
||||
"name": "foo",
|
||||
"image": "someimage",
|
||||
"replicas": "1",
|
||||
"port": "80",
|
||||
},
|
||||
expected: &api.ReplicationController{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Labels: map[string]string{"run-container": "foo"},
|
||||
},
|
||||
Spec: api.ReplicationControllerSpec{
|
||||
Replicas: 1,
|
||||
Selector: map[string]string{"run-container": "foo"},
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Labels: map[string]string{"run-container": "foo"},
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "foo",
|
||||
Image: "someimage",
|
||||
Ports: []api.Port{
|
||||
{
|
||||
ContainerPort: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
params: map[string]string{
|
||||
"name": "foo",
|
||||
@ -97,8 +133,8 @@ func TestGenerate(t *testing.T) {
|
||||
if !test.expectErr && err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !reflect.DeepEqual(obj, test.expected) {
|
||||
t.Errorf("\nexpected:\n%v\nsaw:\n%v", test.expected, obj)
|
||||
if !reflect.DeepEqual(obj.(*api.ReplicationController).Spec.Template, test.expected.Spec.Template) {
|
||||
t.Errorf("\nexpected:\n%#v\nsaw:\n%#v", test.expected.Spec.Template, obj.(*api.ReplicationController).Spec.Template)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user