コード例 #1
0
ファイル: client_test.go プロジェクト: giantswarm/mayu
func newClientAndServer(t *testing.T, handler http.Handler) (*client.Client, *httptest.Server) {
	ts := httptest.NewServer(handler)

	host, port := urlToHostPort(t, ts.URL)
	ui, err := strconv.ParseUint(port, 10, 16)
	if err != nil {
		t.Fatalf("strconv.ParseUint returned error: %#v", err)
	}

	client, err := client.New("http", host, uint16(ui))
	if err != nil {
		t.Fatalf("client.New returned error: %#v", err)
	}

	return client, ts
}
コード例 #2
0
ファイル: main.go プロジェクト: sysbot/mayu
	mayu *client.Client

	mainCmd = &cobra.Command{
		Use:   "mayuctl",
		Short: "Manage a mayu cluster",
		Long:  "Manage a mayu cluster",
		Run:   mainRun,
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			scheme := "https"
			if globalFlags.NoSecure {
				scheme = "http"
			}

			var err error
			mayu, err = client.New(scheme, globalFlags.Host, globalFlags.Port)
			assert(err)
		},
	}

	projectVersion string
	projectBuild   string
)

func init() {
	mainCmd.PersistentFlags().StringVar(&globalFlags.Host, "host", defaultHost, "hostname to connect to mayu service")
	mainCmd.PersistentFlags().Uint16Var(&globalFlags.Port, "port", defaultPort, "port to connect to mayu service")
	mainCmd.PersistentFlags().BoolVar(&globalFlags.NoSecure, "no-secure", false, "do not use secure communication channels like https")
	mainCmd.PersistentFlags().BoolVarP(&globalFlags.Debug, "debug", "d", false, "print debug output")
	mainCmd.PersistentFlags().BoolVarP(&globalFlags.Verbose, "verbose", "v", false, "print verbose output")
}