Пример #1
0
func (vt *Vultr) ImportPublicKey(key *compute.PublicKey) (*compute.PublicKey, error) {
	return common.ImportPublicKeyWrapper(key, func(label string, key string) (string, error) {
		vtKey, err := vt.client.CreateSSHKey(label, key)
		if err != nil {
			return "", err
		} else {
			return vtKey.ID, nil
		}
	})
}
Пример #2
0
func (lobster *Lobster) ImportPublicKey(key *compute.PublicKey) (*compute.PublicKey, error) {
	return common.ImportPublicKeyWrapper(key, func(label string, key string) (string, error) {
		id, err := lobster.client.KeyAdd(label, key)
		if err != nil {
			return "", err
		} else {
			return strconv.Itoa(id), nil
		}
	})
}
Пример #3
0
func (do *DigitalOcean) ImportPublicKey(key *compute.PublicKey) (*compute.PublicKey, error) {
	return common.ImportPublicKeyWrapper(key, func(label string, key string) (string, error) {
		doKey, _, err := do.client.Keys.Create(&godo.KeyCreateRequest{
			Name:      label,
			PublicKey: key,
		})
		if err != nil {
			return "", err
		} else {
			return strconv.Itoa(doKey.ID), nil
		}
	})
}