-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marcus Noble <[email protected]>
- Loading branch information
1 parent
70d7693
commit ca00840
Showing
6 changed files
with
63 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package capa | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"math/rand" | ||
|
||
"github.com/giantswarm/cluster-standup-teardown/pkg/values" | ||
"github.com/giantswarm/clustertest/pkg/application" | ||
"github.com/giantswarm/clustertest/pkg/organization" | ||
"github.com/giantswarm/clustertest/pkg/utils" | ||
) | ||
|
||
var ( | ||
//go:embed values/private-cluster_values.yaml | ||
basePrivateClusterValues string | ||
//go:embed values/private-default-apps_values.yaml | ||
basePrivateDefaultAppsValues string | ||
) | ||
|
||
// PrivateClusterBuilder is the private CAPA ClusterBuilder | ||
type PrivateClusterBuilder struct{} | ||
|
||
// NewClusterApp builds a new private CAPA cluster App | ||
func (c *PrivateClusterBuilder) NewClusterApp(clusterName string, orgName string, clusterValuesFile string, defaultAppsValuesFile string) *application.Cluster { | ||
if clusterName == "" { | ||
clusterName = utils.GenerateRandomName("t") | ||
} | ||
if orgName == "" { | ||
orgName = utils.GenerateRandomName("t") | ||
} | ||
|
||
// WC CIDRs have to not overlap and be in the 10.225. - 10.255. range, so | ||
// we select a random number in that range and set it as the second octet. | ||
//nolint:gosec | ||
randomOctet := rand.Intn(30) + 225 | ||
cidrOctet := fmt.Sprintf("%d", randomOctet) | ||
templateValues := &application.TemplateValues{ | ||
ClusterName: clusterName, | ||
Organization: orgName, | ||
ExtraValues: map[string]string{ | ||
"CIDRSecondOctet": cidrOctet, | ||
}, | ||
} | ||
|
||
return application.NewClusterApp(clusterName, application.ProviderAWS). | ||
WithOrg(organization.New(orgName)). | ||
WithAppValues( | ||
values.MustOverlayValues(basePrivateClusterValues, clusterValuesFile), | ||
values.MustOverlayValues(basePrivateDefaultAppsValues, defaultAppsValuesFile), | ||
templateValues, | ||
) | ||
} |
File renamed without changes.
File renamed without changes.