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

Commit

Permalink
fix(networking): separate logic for zitadel from defined logic in net…
Browse files Browse the repository at this point in the history
…working-operator
  • Loading branch information
stebenz committed Mar 17, 2021
1 parent 744ecfd commit e538851
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 51 deletions.
4 changes: 0 additions & 4 deletions internal/operator/networking/kinds/networking/core/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ const queriedName = "networking"
type NetworkingCurrent interface {
GetTlsCertName() string
GetDomain() string
GetIssuerSubDomain() string
GetConsoleSubDomain() string
GetAPISubDomain() string
GetAccountsSubDomain() string
GetReadyCertificate() core.EnsureFunc
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
core2 "github.com/caos/orbos/internal/operator/core"
"github.com/caos/orbos/internal/operator/networking/kinds/networking/core"
"github.com/caos/orbos/pkg/labels"

"github.com/caos/orbos/internal/operator/orbiter"
)

type ExternalConfig struct {
Verbose bool
Domain string
IP orbiter.IPAddress
Rules []*Rule
Groups []*Group `yaml:"groups"`
Credentials *Credentials `yaml:"credentials"`
Expand All @@ -25,7 +22,6 @@ func (i *ExternalConfig) IsZero() bool {
if (i.Credentials == nil || i.Credentials.IsZero()) &&
!i.Verbose &&
i.Domain == "" &&
i.IP == "" &&
i.Groups == nil &&
i.Prefix == "" &&
i.Rules == nil &&
Expand Down Expand Up @@ -55,18 +51,13 @@ func (e *ExternalConfig) Validate() error {
if e.Domain == "" {
return errors.New("No domain configured")
}
return e.IP.Validate()

return nil
}

func (e *ExternalConfig) internalDomain() (*InternalDomain, *current) {

// TODO: Remove
subdomains := []*Subdomain{
subdomain("accounts", e.IP),
subdomain("api", e.IP),
subdomain("console", e.IP),
subdomain("issuer", e.IP),
}
subdomains := make([]*Subdomain, 0)
for _, sd := range e.AdditionalDNS {
subdomains = append(subdomains, sd)
}
Expand All @@ -77,52 +68,22 @@ func (e *ExternalConfig) internalDomain() (*InternalDomain, *current) {
Rules: e.Rules,
},
&current{
domain: e.Domain,
issureSubdomain: "issuer",
consoleSubdomain: "console",
apiSubdomain: "api",
accountsSubdomain: "accounts",
tlsCertName: "tls-cert-wildcard",
domain: e.Domain,
tlsCertName: "tls-cert-wildcard",
}
}

func subdomain(subdomain string, ip orbiter.IPAddress) *Subdomain {
return &Subdomain{
Subdomain: subdomain,
IP: string(ip),
Proxied: true,
TTL: 0,
Type: "A",
}
}

var _ core.NetworkingCurrent = (*current)(nil)

type current struct {
domain string `yaml:"-"`
issureSubdomain string `yaml:"-"`
consoleSubdomain string `yaml:"-"`
apiSubdomain string `yaml:"-"`
accountsSubdomain string `yaml:"-"`
tlsCertName string `yaml:"-"`
ReadyCertificate core2.EnsureFunc
domain string `yaml:"-"`
tlsCertName string `yaml:"-"`
ReadyCertificate core2.EnsureFunc
}

func (c *current) GetDomain() string {
return c.domain
}
func (c *current) GetIssuerSubDomain() string {
return c.issureSubdomain
}
func (c *current) GetConsoleSubDomain() string {
return c.consoleSubdomain
}
func (c *current) GetAPISubDomain() string {
return c.apiSubdomain
}
func (c *current) GetAccountsSubDomain() string {
return c.accountsSubdomain
}
func (c *current) GetReadyCertificate() core2.EnsureFunc {
return c.ReadyCertificate
}
Expand Down

0 comments on commit e538851

Please # to comment.