Exemplo n.º 1
0
// annotationsToParam parses annotations stored by paramToAnnotations
func (d *glusterfsVolumeDeleter) annotationsToParam(pv *api.PersistentVolume) error {
	annKeys := []string{
		annGlusterSecretName,
		annGlusterSecretNamespace,
		annGlusterURL,
		annGlusterUser,
		annGlusterUserKey,
	}
	params, err := volutil.ParseVolumeAnnotations(pv, annKeys)
	if err != nil {
		return err
	}

	d.url = params[annGlusterURL]
	d.user = params[annGlusterUser]
	d.userKey = params[annGlusterUserKey]
	d.secretName = params[annGlusterSecretName]
	d.secretNamespace = params[annGlusterSecretNamespace]
	return nil
}
Exemplo n.º 2
0
func (deleter *quobyteVolumeDeleter) Delete() error {
	var quobyteUser, quobytePassword string
	annotations, err := util.ParseVolumeAnnotations(deleter.pv, []string{
		annotationQuobyteAPISecret,
		annotationQuobyteAPISecretNamespace,
		annotationQuobyteAPIServer})

	if err != nil {
		return err
	}

	secretMap, err := util.GetSecretForPV(
		annotations[annotationQuobyteAPISecretNamespace],
		annotations[annotationQuobyteAPISecret],
		quobytePluginName,
		deleter.plugin.host.GetKubeClient())

	if err != nil {
		return err
	}

	var ok bool
	if quobyteUser, ok = secretMap["user"]; !ok {
		return fmt.Errorf("Missing \"user\" in secret")
	}

	if quobytePassword, ok = secretMap["password"]; !ok {
		return fmt.Errorf("Missing \"password\" in secret")
	}

	manager := &quobyteVolumeManager{
		config: &quobyteAPIConfig{
			quobyteUser:      quobyteUser,
			quobytePassword:  quobytePassword,
			quobyteAPIServer: annotations[annotationQuobyteAPIServer],
		},
	}
	return manager.deleteVolume(deleter)
}