From 2e4d6200ceb7dd1c9f080f3e064e72542b740ae5 Mon Sep 17 00:00:00 2001 From: Ofer Bochan Date: Mon, 15 Jun 2026 21:10:40 +0300 Subject: [PATCH 1/2] OSAC-1533: Fix --network-attachment ignored with --catalog-item The buildSpecFromCatalogItem() function was missing the applyNetworkingFlags() call, causing --network-attachment flags to be silently dropped when creating compute instances via --catalog-item. The sibling buildSpec() function (used by --template) already includes this call. Signed-off-by: Ofer Bochan --- .../cli/create/computeinstance/create_compute_instance_cmd.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd.go b/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd.go index 36e576568..6d8a2bc16 100644 --- a/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd.go +++ b/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd.go @@ -869,6 +869,9 @@ func (c *runnerContext) buildSpecFromCatalogItem(catalogItemID string) (*publicv if c.args.userData != "" { spec.UserData = new(c.args.userData) } + if err := c.applyNetworkingFlags(&spec); err != nil { + return nil, err + } return spec.Build(), nil } From e55ffc9ca5c9c0efcf356b57bb4eae67431ceca7 Mon Sep 17 00:00:00 2001 From: Ofer Bochan Date: Mon, 15 Jun 2026 21:32:08 +0300 Subject: [PATCH 2/2] OSAC-1533: Add unit tests for buildSpecFromCatalogItem networking Verify that --network-attachment flags are correctly applied when using --catalog-item, matching the existing buildSpec test coverage. Signed-off-by: Ofer Bochan --- .../create_compute_instance_cmd_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd_test.go b/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd_test.go index cb8fa9f04..3aacfb06f 100644 --- a/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd_test.go +++ b/internal/cmd/cli/create/computeinstance/create_compute_instance_cmd_test.go @@ -73,6 +73,42 @@ var _ = Describe("buildSpec", func() { }) }) +var _ = Describe("buildSpecFromCatalogItem", func() { + It("should populate attachments when network-attachment flags are set", func() { + c := &runnerContext{} + c.args.networkAttachments = []string{"n1", "subnet=n2,security-groups=g1"} + spec, err := c.buildSpecFromCatalogItem("cat-001") + Expect(err).NotTo(HaveOccurred()) + + want := publicv1.ComputeInstanceSpec_builder{ + CatalogItem: "cat-001", + NetworkAttachments: []*publicv1.NetworkAttachment{ + publicv1.NetworkAttachment_builder{Subnet: "n1"}.Build(), + publicv1.NetworkAttachment_builder{Subnet: "n2", SecurityGroups: []string{"g1"}}.Build(), + }, + }.Build() + Expect(proto.Equal(spec, want)).To(BeTrue(), "spec should equal expected spec") + }) + + It("should return spec without attachments when no network flags are set", func() { + c := &runnerContext{} + spec, err := c.buildSpecFromCatalogItem("cat-002") + Expect(err).NotTo(HaveOccurred()) + + want := publicv1.ComputeInstanceSpec_builder{ + CatalogItem: "cat-002", + }.Build() + Expect(proto.Equal(spec, want)).To(BeTrue(), "spec should equal expected spec") + }) + + It("should return error when network-attachment value is invalid", func() { + c := &runnerContext{} + c.args.networkAttachments = []string{"subnet=a,foo=bar"} + _, err := c.buildSpecFromCatalogItem("cat-003") + Expect(err).To(HaveOccurred()) + }) +}) + var _ = Describe("Create computeinstance flag registration", func() { It("should register --catalog-item flag", func() { cmd := Cmd()