當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CliConnection.IsSSLDisabled方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/cli/plugin.CliConnection.IsSSLDisabled方法的典型用法代碼示例。如果您正苦於以下問題:Golang CliConnection.IsSSLDisabled方法的具體用法?Golang CliConnection.IsSSLDisabled怎麽用?Golang CliConnection.IsSSLDisabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/cli/plugin.CliConnection的用法示例。


在下文中一共展示了CliConnection.IsSSLDisabled方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Run

func (c *Test1) Run(cliConnection plugin.CliConnection, args []string) {
	if args[0] == "new-api" {
		token, _ := cliConnection.AccessToken()
		fmt.Println("Access Token:", token)
		fmt.Println("")

		app, err := cliConnection.GetApp("test_app")
		fmt.Println("err for test_app", err)
		fmt.Println("test_app is: ", app)

		hasOrg, _ := cliConnection.HasOrganization()
		fmt.Println("Has Organization Targeted:", hasOrg)
		currentOrg, _ := cliConnection.GetCurrentOrg()
		fmt.Println("Current Org:", currentOrg)
		org, _ := cliConnection.GetOrg(currentOrg.Name)
		fmt.Println(currentOrg.Name, " Org:", org)
		orgs, _ := cliConnection.GetOrgs()
		fmt.Println("Orgs:", orgs)
		hasSpace, _ := cliConnection.HasSpace()
		fmt.Println("Has Space Targeted:", hasSpace)
		currentSpace, _ := cliConnection.GetCurrentSpace()
		fmt.Println("Current space:", currentSpace)
		space, _ := cliConnection.GetSpace(currentSpace.Name)
		fmt.Println("Space:", space)
		spaces, _ := cliConnection.GetSpaces()
		fmt.Println("Spaces:", spaces)
		loggregator, _ := cliConnection.LoggregatorEndpoint()
		fmt.Println("Loggregator Endpoint:", loggregator)
		dopplerEndpoint, _ := cliConnection.DopplerEndpoint()
		fmt.Println("Doppler Endpoint:", dopplerEndpoint)

		user, _ := cliConnection.Username()
		fmt.Println("Current user:", user)
		userGUID, _ := cliConnection.UserGuid()
		fmt.Println("Current user guid:", userGUID)
		email, _ := cliConnection.UserEmail()
		fmt.Println("Current user email:", email)

		hasAPI, _ := cliConnection.HasAPIEndpoint()
		fmt.Println("Has API Endpoint:", hasAPI)
		api, _ := cliConnection.ApiEndpoint()
		fmt.Println("Current api:", api)
		version, _ := cliConnection.ApiVersion()
		fmt.Println("Current api version:", version)

		loggedIn, _ := cliConnection.IsLoggedIn()
		fmt.Println("Is Logged In:", loggedIn)
		isSSLDisabled, _ := cliConnection.IsSSLDisabled()
		fmt.Println("Is SSL Disabled:", isSSLDisabled)
	} else if args[0] == "test_1_cmd1" {
		theFirstCmd()
	} else if args[0] == "test_1_cmd2" {
		theSecondCmd()
	} else if args[0] == "CLI-MESSAGE-UNINSTALL" {
		uninstalling()
	}
}
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:57,代碼來源:test_1.go

示例2: Logs

func Logs(cliConnection plugin.CliConnection, args []string) {
	appName := args[1]
	rawOutput, _ := cliConnection.CliCommandWithoutTerminalOutput("curl", fmt.Sprintf("/v3/apps?names=%s", appName))
	apps := V3AppsModel{}
	output := strings.Join(rawOutput, "")
	json.Unmarshal([]byte(output), &apps)

	if len(apps.Apps) == 0 {
		fmt.Printf("App %s not found\n", appName)
		return
	}
	app := apps.Apps[0]

	messageQueue := logs.NewNoaaMessageQueue()

	bufferTime := 25 * time.Millisecond
	ticker := time.NewTicker(bufferTime)

	logChan := make(chan logs.Loggable)
	errChan := make(chan error)

	dopplerEndpoint, err := cliConnection.DopplerEndpoint()
	FreakOut(err)

	ssl, err := cliConnection.IsSSLDisabled()
	FreakOut(err)
	tlsConfig := net.NewTLSConfig([]tls.Certificate{}, ssl)

	noaaConsumer := consumer.New(dopplerEndpoint, tlsConfig, http.ProxyFromEnvironment)
	defer func() {
		noaaConsumer.Close()
		flushMessages(logChan, messageQueue)
	}()

	onConnect := func() {
		fmt.Printf("Tailing logs for app %s...\r\n\r\n", appName)
	}
	noaaConsumer.SetOnConnectCallback(onConnect)

	accessToken, err := cliConnection.AccessToken()
	FreakOut(err)

	c, e := noaaConsumer.TailingLogs(app.Guid, accessToken)

	go func() {
		for {
			select {
			case msg, ok := <-c:
				if !ok {
					ticker.Stop()
					flushMessages(logChan, messageQueue)
					close(logChan)
					close(errChan)
					return
				}

				messageQueue.PushMessage(msg)
			case err := <-e:
				if err != nil {
					errChan <- err

					ticker.Stop()
					close(logChan)
					close(errChan)
					return
				}
			}
		}
	}()

	go func() {
		for range ticker.C {
			flushMessages(logChan, messageQueue)
		}
	}()

	for {
		select {
		case msg := <-logChan:
			fmt.Printf("%s\r\n", logMessageOutput(msg, time.Local))
		case err, ok := <-errChan:
			if !ok {
				FreakOut(err)
			}
		}
	}
}
開發者ID:cloudfoundry,項目名稱:v3-cli-plugin,代碼行數:87,代碼來源:logs.go


注:本文中的code/cloudfoundry/org/cli/plugin.CliConnection.IsSSLDisabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。