github.com/kubernetes-incubator/kube-aws@v0.16.4/cmd/status.go (about)

     1  package cmd
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/kubernetes-incubator/kube-aws/core/root"
     7  	"github.com/kubernetes-incubator/kube-aws/logger"
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  var (
    12  	cmdStatus = &cobra.Command{
    13  		Use:          "status",
    14  		Short:        "Describe an existing Kubernetes cluster",
    15  		Long:         ``,
    16  		RunE:         runCmdStatus,
    17  		SilenceUsage: true,
    18  	}
    19  
    20  	statusOpts = struct {
    21  		profile string
    22  	}{}
    23  )
    24  
    25  func init() {
    26  	RootCmd.AddCommand(cmdStatus)
    27  	cmdStatus.Flags().StringVar(&statusOpts.profile, "profile", "", "The AWS profile to use from credentials file")
    28  }
    29  
    30  func runCmdStatus(_ *cobra.Command, _ []string) error {
    31  	opts := root.NewOptions(false, false, statusOpts.profile)
    32  	describer, err := root.ClusterDescriberFromFile(configPath, opts)
    33  	if err != nil {
    34  		return fmt.Errorf("failed to read cluster config: %v", err)
    35  	}
    36  
    37  	info, err := describer.Info()
    38  	if err != nil {
    39  		return fmt.Errorf("failed fetching cluster info: %v", err)
    40  	}
    41  
    42  	logger.Info(info)
    43  	return nil
    44  }