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


Golang Client.Sys方法代碼示例

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


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

示例1: rekeyStatus

// rekeyStatus is used just to fetch and dump the status
func (c *RekeyCommand) rekeyStatus(client *api.Client) int {
	// Check the status
	status, err := client.Sys().RekeyStatus()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error reading rekey status: %s", err))
		return 1
	}

	// Dump the status
	statString := fmt.Sprintf(
		"Nonce: %s\n"+
			"Started: %v\n"+
			"Key Shares: %d\n"+
			"Key Threshold: %d\n"+
			"Rekey Progress: %d\n"+
			"Required Keys: %d",
		status.Nonce,
		status.Started,
		status.N,
		status.T,
		status.Progress,
		status.Required,
	)
	if len(status.PGPFingerprints) != 0 {
		statString = fmt.Sprintf("\nPGP Key Fingerprints: %s", status.PGPFingerprints)
		statString = fmt.Sprintf("\nBackup Storage: %t", status.Backup)
	}
	c.Ui.Output(statString)
	return 0
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:31,代碼來源:rekey.go

示例2: cancelRekey

// cancelRekey is used to abort the rekey process
func (c *RekeyCommand) cancelRekey(client *api.Client) int {
	err := client.Sys().RekeyCancel()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Failed to cancel rekey: %s", err))
		return 1
	}
	c.Ui.Output("Rekey canceled.")
	return 0
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:10,代碼來源:rekey.go

示例3: cancelGenerateRoot

// cancelGenerateRoot is used to abort the generation process
func (c *GenerateRootCommand) cancelGenerateRoot(client *api.Client) int {
	err := client.Sys().GenerateRootCancel()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Failed to cancel root generation: %s", err))
		return 1
	}
	c.Ui.Output("Root generation canceled.")
	return 0
}
開發者ID:thomaso-mirodin,項目名稱:vault,代碼行數:10,代碼來源:generate-root.go

示例4: rekeyDeleteStored

func (c *RekeyCommand) rekeyDeleteStored(client *api.Client) int {
	err := client.Sys().RekeyDeleteStored()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Failed to delete stored keys: %s", err))
		return 1
	}
	c.Ui.Output("Stored keys deleted.")
	return 0
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:9,代碼來源:rekey.go

示例5: rekeyStatus

// rekeyStatus is used just to fetch and dump the status
func (c *RekeyCommand) rekeyStatus(client *api.Client) int {
	// Check the status
	status, err := client.Sys().RekeyStatus()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error reading rekey status: %s", err))
		return 1
	}

	return c.dumpRekeyStatus(status)
}
開發者ID:sepiroth887,項目名稱:vault,代碼行數:11,代碼來源:rekey.go

示例6: initGenerateRoot

// initGenerateRoot is used to start the generation process
func (c *GenerateRootCommand) initGenerateRoot(client *api.Client, otp string, pgpKey string) int {
	// Start the rekey
	err := client.Sys().GenerateRootInit(otp, pgpKey)
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error initializing root generation: %s", err))
		return 1
	}

	// Provide the current status
	return c.rootGenerationStatus(client)
}
開發者ID:thomaso-mirodin,項目名稱:vault,代碼行數:12,代碼來源:generate-root.go

示例7: rootGenerationStatus

// rootGenerationStatus is used just to fetch and dump the status
func (c *GenerateRootCommand) rootGenerationStatus(client *api.Client) int {
	// Check the status
	status, err := client.Sys().GenerateRootStatus()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error reading root generation status: %s", err))
		return 1
	}

	c.dumpStatus(status)

	return 0
}
開發者ID:thomaso-mirodin,項目名稱:vault,代碼行數:13,代碼來源:generate-root.go

示例8: initGenerateRoot

// initGenerateRoot is used to start the generation process
func (c *GenerateRootCommand) initGenerateRoot(client *api.Client, otp string, pgpKey string) int {
	// Start the rekey
	status, err := client.Sys().GenerateRootInit(otp, pgpKey)
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error initializing root generation: %s", err))
		return 1
	}

	c.dumpStatus(status)

	return 0
}
開發者ID:GauntletWizard,項目名稱:vault,代碼行數:13,代碼來源:generate-root.go

示例9: initializeNewVault

func initializeNewVault(vc *vault.Client) *vault.InitResponse {
	log.Info("Initialize fresh vault")
	vaultInit := &vault.InitRequest{
		SecretShares:    1,
		SecretThreshold: 1,
	}
	initResponse, err := vc.Sys().Init(vaultInit)
	fatal(err)

	return initResponse

}
開發者ID:xtraclabs,項目名稱:roll,代碼行數:12,代碼來源:runvaultmachine.go

示例10: rekeyRetrieveStored

func (c *RekeyCommand) rekeyRetrieveStored(client *api.Client) int {
	storedKeys, err := client.Sys().RekeyRetrieveStored()
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error retrieving stored keys: %s", err))
		return 1
	}

	secret := &api.Secret{
		Data: structs.New(storedKeys).Map(),
	}

	return OutputSecret(c.Ui, "table", secret)
}
開發者ID:vincentaubert,項目名稱:vault,代碼行數:13,代碼來源:rekey.go

示例11: cancelRekey

// cancelRekey is used to abort the rekey process
func (c *RekeyCommand) cancelRekey(client *api.Client, recovery bool) int {
	var err error
	if recovery {
		err = client.Sys().RekeyRecoveryKeyCancel()
	} else {
		err = client.Sys().RekeyCancel()
	}
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Failed to cancel rekey: %s", err))
		return 1
	}
	c.Ui.Output("Rekey canceled.")
	return 0
}
開發者ID:citywander,項目名稱:vault,代碼行數:15,代碼來源:rekey.go

示例12: initRekey

// initRekey is used to start the rekey process
func (c *RekeyCommand) initRekey(client *api.Client, shares, threshold int) int {
	// Start the rekey
	err := client.Sys().RekeyInit(&api.RekeyInitRequest{
		SecretShares:    shares,
		SecretThreshold: threshold,
	})
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error initializing rekey: %s", err))
		return 1
	}

	// Provide the current status
	return c.rekeyStatus(client)
}
開發者ID:worldspawn,項目名稱:vault,代碼行數:15,代碼來源:rekey.go

示例13: rekeyDeleteStored

func (c *RekeyCommand) rekeyDeleteStored(client *api.Client, recovery bool) int {
	var err error
	if recovery {
		err = client.Sys().RekeyDeleteRecoveryBackup()
	} else {
		err = client.Sys().RekeyDeleteBackup()
	}
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Failed to delete stored keys: %s", err))
		return 1
	}
	c.Ui.Output("Stored keys deleted.")
	return 0
}
開發者ID:citywander,項目名稱:vault,代碼行數:14,代碼來源:rekey.go

示例14: checkStatus

func (c *InitCommand) checkStatus(client *api.Client) int {
	inited, err := client.Sys().InitStatus()
	switch {
	case err != nil:
		c.Ui.Error(fmt.Sprintf(
			"Error checking initialization status: %s", err))
		return 1
	case inited:
		c.Ui.Output("Vault has been initialized")
		return 0
	default:
		c.Ui.Output("Vault is not initialized")
		return 2
	}
}
開發者ID:mhurne,項目名稱:vault,代碼行數:15,代碼來源:init.go

示例15: rekeyStatus

// rekeyStatus is used just to fetch and dump the status
func (c *RekeyCommand) rekeyStatus(client *api.Client, recovery bool) int {
	// Check the status
	var status *api.RekeyStatusResponse
	var err error
	if recovery {
		status, err = client.Sys().RekeyRecoveryKeyStatus()
	} else {
		status, err = client.Sys().RekeyStatus()
	}
	if err != nil {
		c.Ui.Error(fmt.Sprintf("Error reading rekey status: %s", err))
		return 1
	}

	return c.dumpRekeyStatus(status)
}
開發者ID:citywander,項目名稱:vault,代碼行數:17,代碼來源:rekey.go


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