mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	removed make-symlink flag and corresponding code in hyperkube
Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
		@@ -20,12 +20,9 @@ limitations under the License.
 | 
				
			|||||||
package main
 | 
					package main
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	goflag "flag"
 | 
						goflag "flag"
 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"math/rand"
 | 
						"math/rand"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path"
 | 
					 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -103,24 +100,17 @@ func NewHyperKubeCommand() (*cobra.Command, []func() *cobra.Command) {
 | 
				
			|||||||
		cloudController,
 | 
							cloudController,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	makeSymlinksFlag := false
 | 
					 | 
				
			||||||
	cmd := &cobra.Command{
 | 
						cmd := &cobra.Command{
 | 
				
			||||||
		Use:   "hyperkube",
 | 
							Use:   "hyperkube",
 | 
				
			||||||
		Short: "Request a new project",
 | 
							Short: "Request a new project",
 | 
				
			||||||
		Run: func(cmd *cobra.Command, args []string) {
 | 
							Run: func(cmd *cobra.Command, args []string) {
 | 
				
			||||||
			if len(args) != 0 || !makeSymlinksFlag {
 | 
								if len(args) != 0 {
 | 
				
			||||||
				cmd.Help()
 | 
									cmd.Help()
 | 
				
			||||||
				os.Exit(1)
 | 
									os.Exit(1)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if err := makeSymlinks(os.Args[0], commandFns); err != nil {
 | 
					 | 
				
			||||||
				fmt.Fprintf(os.Stderr, "%v\n", err.Error())
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	cmd.Flags().BoolVar(&makeSymlinksFlag, "make-symlinks", makeSymlinksFlag, "create a symlink for each server in current directory")
 | 
					 | 
				
			||||||
	cmd.Flags().MarkHidden("make-symlinks") // hide this flag from appearing in servers' usage output
 | 
					 | 
				
			||||||
	cmd.Flags().MarkDeprecated("make-symlinks", "This feature will be removed in a later release.")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i := range commandFns {
 | 
						for i := range commandFns {
 | 
				
			||||||
		cmd.AddCommand(commandFns[i]())
 | 
							cmd.AddCommand(commandFns[i]())
 | 
				
			||||||
@@ -128,28 +118,3 @@ func NewHyperKubeCommand() (*cobra.Command, []func() *cobra.Command) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return cmd, commandFns
 | 
						return cmd, commandFns
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// makeSymlinks will create a symlink for each command in the local directory.
 | 
					 | 
				
			||||||
func makeSymlinks(targetName string, commandFns []func() *cobra.Command) error {
 | 
					 | 
				
			||||||
	wd, err := os.Getwd()
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	var errs bool
 | 
					 | 
				
			||||||
	for _, commandFn := range commandFns {
 | 
					 | 
				
			||||||
		command := commandFn()
 | 
					 | 
				
			||||||
		link := path.Join(wd, command.Name())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		err := os.Symlink(targetName, link)
 | 
					 | 
				
			||||||
		if err != nil {
 | 
					 | 
				
			||||||
			errs = true
 | 
					 | 
				
			||||||
			fmt.Println(err)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if errs {
 | 
					 | 
				
			||||||
		return errors.New("Error creating one or more symlinks")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return nil
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user