Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
feat: remove deps properties
Browse files Browse the repository at this point in the history
Closes: #43
  • Loading branch information
eliobischof committed Jan 27, 2020
1 parent 63f7866 commit 0bcf0b2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
16 changes: 7 additions & 9 deletions internal/operator/orbiter/kinds/orb/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func AdaptFunc(
providerDestroyers := make([]orbiter.DestroyFunc, 0)
secrets = make(map[string]*orbiter.Secret)

for provID, providerTree := range desiredKind.Deps.Providers {
for provID, providerTree := range desiredKind.Providers {

providerCurrent := &orbiter.Tree{}
providerCurrents[provID] = providerCurrent
Expand All @@ -53,9 +53,9 @@ func AdaptFunc(
// "provider": provID,
// })

providerSecretsTree, ok := secretsKind.Deps.Providers[provID]
providerSecretsTree, ok := secretsKind.Providers[provID]
if !ok {
secretsKind.Deps.Providers[provID] = &orbiter.Tree{}
secretsKind.Providers[provID] = &orbiter.Tree{}
}

// providerID := id + provID
Expand Down Expand Up @@ -138,12 +138,12 @@ func AdaptFunc(
clusterCurrents := make(map[string]*orbiter.Tree)
clusterEnsurers := make([]orbiter.EnsureFunc, 0)
clusterDestroyers := make([]orbiter.DestroyFunc, 0)
for clusterID, clusterTree := range desiredKind.Deps.Clusters {
for clusterID, clusterTree := range desiredKind.Clusters {

clusterCurrent := &orbiter.Tree{}
clusterCurrents[clusterID] = clusterCurrent

clusterSecretsTree, ok := secretsKind.Deps.Clusters[clusterID]
clusterSecretsTree, ok := secretsKind.Clusters[clusterID]
if !ok {
return nil, nil, nil, errors.Errorf("no secrets found for cluster %s", clusterID)
}
Expand Down Expand Up @@ -171,10 +171,8 @@ func AdaptFunc(
Kind: "orbiter.caos.ch/Orb",
Version: "v0",
},
Deps: Deps{
Clusters: clusterCurrents,
Providers: providerCurrents,
},
Clusters: clusterCurrents,
Providers: providerCurrents,
}

return func(psf orbiter.PushSecretsFunc, nodeAgentsCurrent map[string]*common.NodeAgentCurrent, nodeAgentsDesired map[string]*common.NodeAgentSpec) (err error) {
Expand Down
18 changes: 8 additions & 10 deletions internal/operator/orbiter/kinds/orb/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@ package orb

import "github.com/caos/orbiter/internal/operator/orbiter"

type Deps struct {
Clusters map[string]*orbiter.Tree
Providers map[string]*orbiter.Tree
}

type DesiredV0 struct {
Common *orbiter.Common `yaml:",inline"`
Spec struct {
Verbose bool
}
Deps Deps
Clusters map[string]*orbiter.Tree
Providers map[string]*orbiter.Tree
}

type SecretsV0 struct {
Common *orbiter.Common `yaml:",inline"`
Deps Deps
Common *orbiter.Common `yaml:",inline"`
Clusters map[string]*orbiter.Tree
Providers map[string]*orbiter.Tree
}

type Current struct {
Common *orbiter.Common `yaml:",inline"`
Deps Deps
Common *orbiter.Common `yaml:",inline"`
Clusters map[string]*orbiter.Tree
Providers map[string]*orbiter.Tree
}
6 changes: 3 additions & 3 deletions internal/operator/orbiter/kinds/providers/static/adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ func AdaptFunc(logger logging.Logger, masterkey string, id string) orbiter.Adapt
secretsTree.Parsed = secretsKind

lbCurrent := &orbiter.Tree{}
switch desiredKind.Deps.Common.Kind {
switch desiredKind.Loadbalancing.Common.Kind {
// case "orbiter.caos.ch/ExternalLoadBalancer":
// return []orbiter.Assembler{external.New(depPath, generalOverwriteSpec, externallbadapter.New())}, nil
case "orbiter.caos.ch/DynamicLoadBalancer":
if _, _, _, err = dynamic.AdaptFunc(desiredKind.Spec.RemoteUser)(desiredKind.Deps, nil, lbCurrent); err != nil {
if _, _, _, err = dynamic.AdaptFunc(desiredKind.Spec.RemoteUser)(desiredKind.Loadbalancing, nil, lbCurrent); err != nil {
return nil, nil, nil, err
}
// return []orbiter.Assembler{dynamic.New(depPath, generalOverwriteSpec, dynamiclbadapter.New(kind.Spec.RemoteUser))}, nil
default:
return nil, nil, nil, errors.Errorf("unknown loadbalancing kind %s", desiredKind.Deps.Common.Kind)
return nil, nil, nil, errors.Errorf("unknown loadbalancing kind %s", desiredKind.Loadbalancing.Common.Kind)
}

current := &Current{
Expand Down
2 changes: 1 addition & 1 deletion internal/operator/orbiter/kinds/providers/static/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type DesiredV0 struct {
RemotePublicKeyPath string
Pools map[string][]*Compute
}
Deps *orbiter.Tree
Loadbalancing *orbiter.Tree
}

type Compute struct {
Expand Down

0 comments on commit 0bcf0b2

Please sign in to comment.