Skip to content

Commit

Permalink
feat(kind) let users specify a KIND config file (#222)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Utt <shaneutt@linux.com>
  • Loading branch information
rainest and shaneutt authored Feb 17, 2022
1 parent c477528 commit 8fd7331
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/clusters/types/kind/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Builder struct {

addons clusters.Addons
clusterVersion *semver.Version
configPath *string
}

// NewBuilder provides a new *Builder object.
Expand All @@ -42,13 +43,24 @@ func (b *Builder) WithClusterVersion(version semver.Version) *Builder {
return b
}

// WithConfig sets a filename containing a KIND config
// See: https://kind.sigs.k8s.io/docs/user/configuration/
func (b *Builder) WithConfig(filename string) *Builder {
b.configPath = &filename
return b
}

// Build creates and configures clients for a Kind-based Kubernetes clusters.Cluster.
func (b *Builder) Build(ctx context.Context) (*Cluster, error) {
deployArgs := make([]string, 0)
if b.clusterVersion != nil {
deployArgs = append(deployArgs, "--image", "kindest/node:v"+b.clusterVersion.String())
}

if b.configPath != nil {
deployArgs = append(deployArgs, "--config", *b.configPath)
}

if err := createCluster(ctx, b.Name, deployArgs...); err != nil {
return nil, fmt.Errorf("failed to create cluster %s: %w", b.Name, err)
}
Expand Down

0 comments on commit 8fd7331

Please sign in to comment.