...

Source file src/k8s.io/kubernetes/test/images/agnhost/entrypoint-tester/ep.go

Documentation: k8s.io/kubernetes/test/images/agnhost/entrypoint-tester

     1  /*
     2  Copyright 2015 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  package entrypoint
    18  
    19  import (
    20  	"fmt"
    21  	"os"
    22  
    23  	"github.com/spf13/cobra"
    24  )
    25  
    26  // CmdEntrypointTester is used by agnhost Cobra.
    27  var CmdEntrypointTester = &cobra.Command{
    28  	Use:   "entrypoint-tester",
    29  	Short: "Prints the args it's passed and exits",
    30  	Long:  "Prints the args it's passed and exits.",
    31  	Run:   main,
    32  }
    33  
    34  // This program prints all the executable's arguments and exits.
    35  func main(cmd *cobra.Command, args []string) {
    36  	// Some of the entrypoint-tester related tests overrides agnhost's default entrypoint
    37  	// with agnhost-2, and this function's args will only contain the subcommand's
    38  	// args (./agnhost entrypoint-tester these args), but we need to print *all* the
    39  	// args, which is why os.Args should be printed instead.
    40  	fmt.Printf("%v\n", os.Args)
    41  	os.Exit(0)
    42  }
    43  

View as plain text