mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Address comments, fix tests.
This commit is contained in:
		@@ -930,7 +930,6 @@ Usage:
 | 
				
			|||||||
      --output-version="": Output the formatted object with the given version (default api-version)
 | 
					      --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.
 | 
					      --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.
 | 
					      --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
 | 
					  -r, --replicas=1: Number of replicas to create for this container. Default 1
 | 
				
			||||||
  -s, --server="": The address of the Kubernetes API server
 | 
					  -s, --server="": The address of the Kubernetes API server
 | 
				
			||||||
      --stderrthreshold=2: logs at or above this threshold go to stderr
 | 
					      --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().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().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().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().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().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.")
 | 
						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{
 | 
							controller.Spec.Template.Spec.Containers[0].Ports = []api.Port{
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				ContainerPort: 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{
 | 
								params: map[string]string{
 | 
				
			||||||
				"name":     "foo",
 | 
									"name":     "foo",
 | 
				
			||||||
@@ -97,8 +133,8 @@ func TestGenerate(t *testing.T) {
 | 
				
			|||||||
		if !test.expectErr && err != nil {
 | 
							if !test.expectErr && err != nil {
 | 
				
			||||||
			t.Errorf("unexpected error: %v", err)
 | 
								t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if !reflect.DeepEqual(obj, test.expected) {
 | 
							if !reflect.DeepEqual(obj.(*api.ReplicationController).Spec.Template, test.expected.Spec.Template) {
 | 
				
			||||||
			t.Errorf("\nexpected:\n%v\nsaw:\n%v", test.expected, obj)
 | 
								t.Errorf("\nexpected:\n%#v\nsaw:\n%#v", test.expected.Spec.Template, obj.(*api.ReplicationController).Spec.Template)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user