Exemple #1
0
func (dp *doProvider) DeleteInstance(info providers.ClusterInstanceInfo, dnsProvider providers.DnsProvider) error {
	fullName := info.String()
	droplets, err := dp.getInstances(info.ClusterInfo)
	if err != nil {
		return err
	}
	client := NewDOClient(dp.token)
	for _, d := range droplets {
		if d.Name == fullName {
			// Delete DNS instance records
			instance := dp.clusterInstance(d)
			if err := providers.UnRegisterInstance(dp.Logger, dnsProvider, instance, info.Domain); err != nil {
				return maskAny(err)
			}

			// Delete droplet
			_, err := client.Droplets.Delete(d.ID)
			if err != nil {
				return err
			}
			return nil
		}
	}

	return maskAny(NotFoundError)
}
Exemple #2
0
func (vp *vultrProvider) DeleteInstance(info providers.ClusterInstanceInfo, dnsProvider providers.DnsProvider) error {
	fullName := info.String()
	servers, err := vp.getInstances(info.ClusterInfo)
	if err != nil {
		return err
	}
	for _, s := range servers {
		if s.Name == fullName {
			// Delete DNS instance records
			instance := vp.clusterInstance(s)
			if err := providers.UnRegisterInstance(vp.Logger, dnsProvider, instance, info.Domain); err != nil {
				return maskAny(err)
			}

			// Delete droplet
			err := vp.client.DeleteServer(s.ID)
			if err != nil {
				return err
			}
			return nil
		}
	}

	return maskAny(NotFoundError)
}
Exemple #3
0
func (vp *scalewayProvider) DeleteInstance(info providers.ClusterInstanceInfo, dnsProvider providers.DnsProvider) error {
	fullName := info.String()
	servers, err := vp.getServers(info.ClusterInfo)
	if err != nil {
		return maskAny(err)
	}

	found := false
	for _, s := range servers {
		if s.Name == fullName {
			if err := vp.deleteServer(s, dnsProvider, info.Domain); err != nil {
				return maskAny(err)
			}
			found = true
			break
		}
	}

	if !found {
		return maskAny(NotFoundError)
	}

	// Reconfigure tinc
	instanceList, err := vp.GetInstances(info.ClusterInfo)
	if err != nil {
		return maskAny(err)
	}
	// Create tinc network config
	newInstances := providers.ClusterInstanceList{}
	if instanceList.ReconfigureTincCluster(vp.Logger, newInstances); err != nil {
		return maskAny(err)
	}

	return nil
}
Exemple #4
0
// clusterInstanceInfoFromArgs fills the given cluster info from a command line argument
func clusterInstanceInfoFromArgs(info *providers.ClusterInstanceInfo, args []string) {
	if len(args) == 1 && info.Prefix == "" && info.Name == "" {
		parts := strings.SplitN(args[0], ".", 3)
		info.Prefix = parts[0]
		info.Name = parts[1]
		info.Domain = parts[2]
	}
}