github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/orbiter/kinds/providers/cs/current.go (about)

     1  package cs
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/orbiter/kinds/clusters/core/infra"
     5  	"github.com/caos/orbos/internal/operator/orbiter/kinds/providers/core"
     6  	"github.com/caos/orbos/pkg/tree"
     7  )
     8  
     9  var _ infra.ProviderCurrent = (*Current)(nil)
    10  
    11  type Current struct {
    12  	Common  *tree.Common `yaml:",inline"`
    13  	Current struct {
    14  		pools      map[string]infra.Pool `yaml:"-"`
    15  		Ingresses  map[string]*infra.Address
    16  		cleanupped <-chan error `yaml:"-"`
    17  	}
    18  }
    19  
    20  func (c *Current) Pools() map[string]infra.Pool {
    21  	return c.Current.pools
    22  }
    23  func (c *Current) Ingresses() map[string]*infra.Address {
    24  	return c.Current.Ingresses
    25  }
    26  func (c *Current) Cleanupped() <-chan error {
    27  	return c.Current.cleanupped
    28  }
    29  func (c *Current) PrivateInterface() string { return "eth1" }
    30  
    31  func (c *Current) Kubernetes() infra.Kubernetes {
    32  	return infra.Kubernetes{}
    33  }
    34  
    35  func addPools(current *Current, spec *Spec, machinesSvc core.MachinesService) error {
    36  	current.Current.pools = make(map[string]infra.Pool)
    37  	for pool := range spec.Pools {
    38  		current.Current.pools[pool] = newInfraPool(pool, machinesSvc)
    39  	}
    40  
    41  	unconfiguredPools, err := machinesSvc.ListPools()
    42  	if err != nil {
    43  		return nil
    44  	}
    45  	for idx := range unconfiguredPools {
    46  		unconfiguredPool := unconfiguredPools[idx]
    47  		if _, ok := current.Current.pools[unconfiguredPool]; !ok {
    48  			current.Current.pools[unconfiguredPool] = newInfraPool(unconfiguredPool, machinesSvc)
    49  		}
    50  	}
    51  	return nil
    52  }