Skip to content

Commit

Permalink
Look for Cluster in organization namespace in vintage MCs
Browse files Browse the repository at this point in the history
  • Loading branch information
anvddriesch committed Oct 24, 2023
1 parent f466bb4 commit 35cc11a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Look for Cluster in organization namespace in vintage MCs

### Added

- Add option to `setup` to use credentials as base64 encoded variables.
Expand Down
15 changes: 14 additions & 1 deletion pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package auth
import (
"context"
"fmt"
"strings"

"github.com/giantswarm/dex-operator/pkg/key"

Expand Down Expand Up @@ -166,12 +167,24 @@ func (s *Service) ReconcileDelete(ctx context.Context) error {
}

func (s *Service) getAPIServerPort(clusterID string, ctx context.Context) (int, error) {
var namespace string
{
if isOrgNamespace(s.app.Namespace) {
namespace = s.app.Namespace
} else {
namespace = "org-" + s.app.GetLabels()[label.Organization]
}
}
cluster := &capi.Cluster{}
if err := s.Get(ctx, types.NamespacedName{
Name: clusterID,
Namespace: s.app.Namespace},
Namespace: namespace},
cluster); err != nil {
return 0, err
}
return int(cluster.Spec.ControlPlaneEndpoint.Port), nil
}

func isOrgNamespace(namespace string) bool {
return strings.HasPrefix(namespace, "org-")
}

0 comments on commit 35cc11a

Please sign in to comment.