Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/cluster/core/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func BindOptions(opts *RawCreateOptions, flags *pflag.FlagSet) {
func bindCoreOptions(opts *RawCreateOptions, flags *pflag.FlagSet) {
flags.StringVar(&opts.Namespace, "namespace", opts.Namespace, "A namespace to contain the generated resources")
flags.StringVar(&opts.Name, "name", opts.Name, "A name for the cluster")
flags.StringVar(&opts.BaseDomain, "base-domain", opts.BaseDomain, "The ingress base domain for the cluster")
flags.StringVar(&opts.BaseDomain, "base-domain", opts.BaseDomain, "The ingress base domain for the cluster. If omitted for an HCP KubeVirt cluster, this defaults to the management cluster's apps domain.")
flags.StringVar(&opts.BaseDomainPrefix, "base-domain-prefix", opts.BaseDomainPrefix, "The ingress base domain prefix for the cluster, defaults to cluster name. Use 'none' for an empty prefix")
flags.StringVar(&opts.ExternalDNSDomain, "external-dns-domain", opts.ExternalDNSDomain, "Sets hostname to opinionated values in the specified domain for services with publishing type LoadBalancer or Route.")
flags.StringVar(&opts.NetworkType, "network-type", opts.NetworkType, "Enum specifying the cluster SDN provider. Supports either Calico, OVNKubernetes, OpenShiftSDN or Other.")
Expand Down
34 changes: 34 additions & 0 deletions cmd/cluster/core/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,42 @@ import (

crclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

"github.com/spf13/pflag"
)

func TestBindOptions(t *testing.T) {
t.Run("When flags are parsed it should populate the options struct", func(t *testing.T) {
g := NewWithT(t)
opts := DefaultOptions()
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
BindOptions(opts, flags)

err := flags.Parse([]string{
"--base-domain=example.com",
"--name=my-cluster",
"--namespace=my-ns",
})

g.Expect(err).ToNot(HaveOccurred())
g.Expect(opts.BaseDomain).To(Equal("example.com"))
g.Expect(opts.Name).To(Equal("my-cluster"))
g.Expect(opts.Namespace).To(Equal("my-ns"))
})

t.Run("When base-domain flag is omitted the pflag default should be empty", func(t *testing.T) {
g := NewWithT(t)
opts := DefaultOptions()
flags := pflag.NewFlagSet("test", pflag.ContinueOnError)
BindOptions(opts, flags)

err := flags.Parse([]string{})

g.Expect(err).ToNot(HaveOccurred())
g.Expect(opts.BaseDomain).To(BeEmpty())
})
}

func TestValidateMgmtClusterAndNodePoolCPUArchitectures(t *testing.T) {
ctx := t.Context()

Expand Down