Ejemplo n.º 1
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
}
Ejemplo n.º 2
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)
}
Ejemplo n.º 3
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)
}