Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ func Cmd() *cobra.Command {
nil,
networkAttachmentFlagHelp,
)
flags.BoolVar(
&runner.args.windows,
"windows",
false,
windowsFlagHelp,
)

result.MarkFlagsMutuallyExclusive("catalog-item", "template")
result.MarkFlagsOneRequired("catalog-item", "template")
Expand All @@ -173,6 +179,7 @@ type runnerContext struct {
runStrategy string
userData string
networkAttachments []string
windows bool
}
logger *slog.Logger
console *terminal.Console
Expand Down Expand Up @@ -723,6 +730,9 @@ func (c *runnerContext) buildSpec(templateID string,
if c.args.userData != "" {
spec.UserData = new(c.args.userData)
}
if c.args.windows {
spec.IsWindows = new(true)
}
if err := c.applyNetworkingFlags(&spec); err != nil {
return nil, err
}
Expand Down Expand Up @@ -869,6 +879,9 @@ func (c *runnerContext) buildSpecFromCatalogItem(catalogItemID string) (*publicv
if c.args.userData != "" {
spec.UserData = new(c.args.userData)
}
if c.args.windows {
spec.IsWindows = new(true)
}
if err := c.applyNetworkingFlags(&spec); err != nil {
return nil, err
}
Expand Down Expand Up @@ -1022,3 +1035,7 @@ comma-separated specification in the format
{{ bt }}subnet=ID[,security-groups=ID,ID...]{{ bt }}. Can be
specified multiple times to attach multiple NICs.
`

const windowsFlagHelp = `
_[BOOLEAN]_ - Create a Windows VM. Defaults to {{ bt }}false{{ bt }} (Linux VM).
`
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ var _ = Describe("buildSpec", func() {
}.Build()
Expect(proto.Equal(spec, want)).To(BeTrue(), "spec should equal expected spec")
})

It("should set IsWindows when windows flag is true", func() {
c := &runnerContext{}
c.args.windows = true
spec, err := c.buildSpec("tmpl", nil)
Expect(err).NotTo(HaveOccurred())

Expect(spec.IsWindows).NotTo(BeNil())
Expect(*spec.IsWindows).To(BeTrue())
})

It("should leave IsWindows nil when windows flag is false", func() {
c := &runnerContext{}
c.args.windows = false
spec, err := c.buildSpec("tmpl", nil)
Expect(err).NotTo(HaveOccurred())

Expect(spec.IsWindows).To(BeNil())
})
})

var _ = Describe("buildSpecFromCatalogItem", func() {
Expand Down Expand Up @@ -107,6 +126,25 @@ var _ = Describe("buildSpecFromCatalogItem", func() {
_, err := c.buildSpecFromCatalogItem("cat-003")
Expect(err).To(HaveOccurred())
})

It("should set IsWindows when windows flag is true", func() {
c := &runnerContext{}
c.args.windows = true
spec, err := c.buildSpecFromCatalogItem("cat-004")
Expect(err).NotTo(HaveOccurred())

Expect(spec.IsWindows).NotTo(BeNil())
Expect(*spec.IsWindows).To(BeTrue())
})

It("should leave IsWindows nil when windows flag is false", func() {
c := &runnerContext{}
c.args.windows = false
spec, err := c.buildSpecFromCatalogItem("cat-005")
Expect(err).NotTo(HaveOccurred())

Expect(spec.IsWindows).To(BeNil())
})
})

var _ = Describe("Create computeinstance flag registration", func() {
Expand Down Expand Up @@ -144,6 +182,15 @@ var _ = Describe("Create computeinstance flag registration", func() {
Expect(flag).NotTo(BeNil())
Expect(flag.Shorthand).To(Equal("t"))
})

It("should register --windows flag with default value false", func() {
cmd := Cmd()
cmd.SetOut(GinkgoWriter)
cmd.SetErr(GinkgoWriter)
flag := cmd.Flags().Lookup("windows")
Expect(flag).NotTo(BeNil())
Expect(flag.DefValue).To(Equal("false"))
})
})

var _ = Describe("Create computeinstance flag validation", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ columns:
type: osac.private.v1.ComputeInstanceTemplate
lookup: true

- header: OS
value: "has(this.spec.is_windows) && this.spec.is_windows ? 'windows' : 'linux'"

- header: STATE
value: this.status.state
type: osac.private.v1.ComputeInstanceState
Expand Down
3 changes: 3 additions & 0 deletions internal/rendering/tables/osac.public.v1.ComputeInstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ columns:
type: osac.public.v1.ComputeInstanceTemplate
lookup: true

- header: OS
value: "has(this.spec.is_windows) && this.spec.is_windows ? 'windows' : 'linux'"

- header: STATE
value: this.status.state
type: osac.public.v1.ComputeInstanceState
Expand Down
Loading