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


Golang Config.Username方法代碼示例

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


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

示例1: Dial

func (*AppDialer) Dial(appName string, instanceIndex int, config *config_package.Config) (Client, error) {
	diegoSSHUser := fmt.Sprintf("diego:%s/%d", appName, instanceIndex)
	address := fmt.Sprintf("%s:2222", config.Target())

	client, err := sshapi.New(diegoSSHUser, config.Username(), config.Password(), address)
	if err != nil {
		return nil, err
	}

	return client, nil
}
開發者ID:davidwadden,項目名稱:lattice-release,代碼行數:11,代碼來源:dialer.go

示例2: ConnectToShell

func (ss *SecureShell) ConnectToShell(appName string, instanceIndex int, command string, config *config_package.Config) error {
	diegoSSHUser := fmt.Sprintf("diego:%s/%d", appName, instanceIndex)
	address := fmt.Sprintf("%s:2222", config.Target())

	session, err := ss.Dialer.Dial(diegoSSHUser, config.Username(), config.Password(), address)
	if err != nil {
		return err
	}
	defer session.Close()

	sessionIn, err := session.StdinPipe()
	if err != nil {
		return err
	}

	sessionOut, err := session.StdoutPipe()
	if err != nil {
		return err
	}

	sessionErr, err := session.StderrPipe()
	if err != nil {
		return err
	}

	modes := ssh.TerminalModes{
		ssh.ECHO:          1,
		ssh.TTY_OP_ISPEED: 115200,
		ssh.TTY_OP_OSPEED: 115200,
	}

	width, height := ss.Term.GetWinsize(os.Stdout.Fd())

	terminalType := os.Getenv("TERM")
	if terminalType == "" {
		terminalType = "xterm"
	}

	if err := session.RequestPty(terminalType, height, width, modes); err != nil {
		return err
	}

	if state, err := ss.Term.SetRawTerminal(os.Stdin.Fd()); err == nil {
		defer ss.Term.RestoreTerminal(os.Stdin.Fd(), state)
	}

	go copyAndClose(nil, sessionIn, os.Stdin)
	go io.Copy(os.Stdout, sessionOut)
	go io.Copy(os.Stderr, sessionErr)

	resized := make(chan os.Signal, 16)
	signal.Notify(resized, syscall.SIGWINCH)
	defer func() {
		signal.Stop(resized)
		close(resized)
	}()
	go ss.resize(resized, session, os.Stdout.Fd(), width, height)

	keepaliveStopCh := make(chan struct{})
	defer close(keepaliveStopCh)

	go ss.keepalive(session, keepaliveStopCh)

	if command == "" {
		session.Shell()
		session.Wait()
	} else {
		session.Run(command)
	}

	return nil
}
開發者ID:Klaudit,項目名稱:lattice,代碼行數:72,代碼來源:secure_shell.go

示例3:

		testConfig = config.New(testPersister)
	})

	Describe("Target", func() {
		It("sets the target", func() {
			testConfig.SetTarget("mynewapi.com")

			Expect(testConfig.Target()).To(Equal("mynewapi.com"))
		})
	})

	Describe("Username", func() {
		It("sets the target", func() {
			testConfig.SetLogin("ausername", "apassword")

			Expect(testConfig.Username()).To(Equal("ausername"))
		})
	})

	Describe("Receptor", func() {
		It("returns the Receptor with a username and password", func() {
			testConfig.SetTarget("mynewapi.com")
			testConfig.SetLogin("testusername", "testpassword")

			Expect(testConfig.Receptor()).To(Equal("http://testusername:[email protected]"))
		})

		It("returns a Receptor without a username and password", func() {
			testConfig.SetTarget("mynewapi.com")
			testConfig.SetLogin("", "")
開發者ID:shanetreacy,項目名稱:lattice,代碼行數:30,代碼來源:config_test.go


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