Skip to content

Commit

Permalink
Merge branch 'main' into renovate/test-libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
erkanerol authored May 7, 2024
2 parents d3c16a4 + 09cb60f commit e5f28a6
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 8 deletions.
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]

### Added

- Added fields to ClusterBuilder structs to allow consumers to use custom kubeconfig contexts.

## [1.0.2] - 2024-04-29

### Added
Expand Down
3 changes: 2 additions & 1 deletion pkg/clusterbuilder/client_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package clusterbuilder

import (
"reflect"
"testing"

"github.com/giantswarm/cluster-standup-teardown/pkg/clusterbuilder/providers/capa"
Expand Down Expand Up @@ -70,7 +71,7 @@ func Test_GetClusterBuilderForContext(t *testing.T) {
t.Fatalf("unexpected error: %v", err)
}

if cb != tc.expected {
if !reflect.DeepEqual(cb, tc.expected) {
t.Fatalf("Actual value didn't match expected value\n\nexpected: %q\n\nactual: %q", tc.expected, cb)
}
})
Expand Down
9 changes: 8 additions & 1 deletion pkg/clusterbuilder/providers/capa/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ var (
)

// ClusterBuilder is the CAPA ClusterBuilder
type ClusterBuilder struct{}
type ClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new CAPA cluster App
func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand All @@ -43,5 +45,10 @@ func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clust

// KubeContext returns the known KubeConfig context that this builder expects
func (c *ClusterBuilder) KubeContext() string {

if c.CustomKubeContext != "" {
return c.CustomKubeContext
}

return "capa"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ var (
baseManagedDefaultAppsValues string
)

// ClusterBuilder is the CAPA EKS ClusterBuilder
type ManagedClusterBuilder struct{}
// ManagedClusterBuilder is the CAPA EKS ClusterBuilder
type ManagedClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new CAPA EKS cluster App
func (c *ManagedClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand All @@ -43,5 +45,8 @@ func (c *ManagedClusterBuilder) NewClusterApp(clusterName string, orgName string

// KubeContext returns the known KubeConfig context that this builder expects
func (c *ManagedClusterBuilder) KubeContext() string {
if c.CustomKubeContext != "" {
return c.CustomKubeContext
}
return "eks"
}
7 changes: 6 additions & 1 deletion pkg/clusterbuilder/providers/capa/private_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ var (
)

// PrivateClusterBuilder is the private CAPA ClusterBuilder
type PrivateClusterBuilder struct{}
type PrivateClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new private CAPA cluster App
func (c *PrivateClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand Down Expand Up @@ -56,5 +58,8 @@ func (c *PrivateClusterBuilder) NewClusterApp(clusterName string, orgName string

// KubeContext returns the known KubeConfig context that this builder expects
func (c *PrivateClusterBuilder) KubeContext() string {
if c.CustomKubeContext != "" {
return c.CustomKubeContext
}
return "capa-private-proxy"
}
7 changes: 6 additions & 1 deletion pkg/clusterbuilder/providers/capv/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ var (
)

// ClusterBuilder is the CAPV ClusterBuilder
type ClusterBuilder struct{}
type ClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new CAPV cluster App
func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand Down Expand Up @@ -65,5 +67,8 @@ func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clust

// KubeContext returns the known KubeConfig context that this builder expects
func (c *ClusterBuilder) KubeContext() string {
if c.CustomKubeContext != "" {
return c.CustomKubeContext
}
return "capv"
}
7 changes: 6 additions & 1 deletion pkg/clusterbuilder/providers/capvcd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ var (
)

// ClusterBuilder is the CAPVCD ClusterBuilder
type ClusterBuilder struct{}
type ClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new CAPVCD cluster App
func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand Down Expand Up @@ -57,5 +59,8 @@ func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clust

// KubeContext returns the known KubeConfig context that this builder expects
func (c *ClusterBuilder) KubeContext() string {
if c.CustomKubeContext != "" {
return c.CustomKubeContext
}
return "capvcd"
}
7 changes: 6 additions & 1 deletion pkg/clusterbuilder/providers/capz/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ var (
)

// ClusterBuilder is the CAPZ ClusterBuilder
type ClusterBuilder struct{}
type ClusterBuilder struct {
CustomKubeContext string
}

// NewClusterApp builds a new CAPZ cluster App
func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesOverrides []string, defaultAppsValuesOverrides []string) *application.Cluster {
Expand All @@ -43,5 +45,8 @@ func (c *ClusterBuilder) NewClusterApp(clusterName string, orgName string, clust

// KubeContext returns the known KubeConfig context that this builder expects
func (c *ClusterBuilder) KubeContext() string {
if c.CustomKubeContext != "" {
return c.CustomKubeContext
}
return "capz"
}

0 comments on commit e5f28a6

Please sign in to comment.