func (r authAppRolePlugin) Create(cfg *vaultAuthOptions) (string, error) {
	if cfg.RoleID == "" {
		cfg.RoleID = os.Getenv("VAULT_SIDEKICK_ROLE_ID")
	}
	if cfg.SecretID == "" {
		cfg.SecretID = os.Getenv("VAULT_SIDEKICK_SECRET_ID")
	}

	// step: create the token request
	request := r.client.NewRequest("POST", "/v1/auth/approle/login")
	login := appRoleLogin{SecretID: cfg.SecretID, RoleID: cfg.RoleID}
	if err := request.SetJSONBody(login); err != nil {
		return "", err
	}
	// step: make the request
	resp, err := r.client.RawRequest(request)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()

	// step: parse and return auth
	secret, err := api.ParseSecret(resp.Body)
	if err != nil {
		return "", err
	}

	return secret.Auth.ClientToken, nil
}
// Create a approle plugin with the secret id and role id provided in the file
Create a approle plugin with the secret id and role id provided in the file
// Create a approle plugin with the secret id and role id provided in the file
func (r authAppRolePlugin) Create(cfg *vaultAuthOptions) (string, error) {
	if cfg.RoleID == "" {
		cfg.RoleID = os.Getenv("VAULT_SIDEKICK_ROLE_ID")
	}
	if cfg.SecretID == "" {
		cfg.SecretID = os.Getenv("VAULT_SIDEKICK_SECRET_ID")
	}
	request := r.client.NewRequest("POST", "/v1/auth/approle/login")
	login := appRoleLogin{SecretID: cfg.SecretID, RoleID: cfg.RoleID}
	if err := request.SetJSONBody(login); err != nil {
		return "", err
	}
	resp, err := r.client.RawRequest(request)
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	secret, err := api.ParseSecret(resp.Body)
	if err != nil {
		return "", err
	}
	return secret.Auth.ClientToken, nil
}
func ( r authAppRolePlugin ) Create ( cfg * vaultAuthOptions ) ( string , error ) { if cfg . RoleID == " " { cfg . RoleID = os . Getenv ( " " ) } if cfg . SecretID == " " { cfg . SecretID = os . Getenv ( " " ) } request := r . client . NewRequest ( " " , " " ) login := appRoleLogin { SecretID : cfg . SecretID , RoleID : cfg . RoleID } if err := request . SetJSONBody ( login ) ; err != nil { return " " , err } resp , err := r . client . RawRequest ( request ) if err != nil { return " " , err } defer resp . Body . Close ( ) secret , err := api . ParseSecret ( resp . Body ) if err != nil { return " " , err } return secret . Auth . ClientToken , nil }
Create a approle plugin with the secret id and role id provided in the file
Create a approle plugin with the secret id and role id provided in the file
// step: create the token request // step: make the request // step: parse and return auth