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
82 changes: 82 additions & 0 deletions .ai/checkpoints/topic-9-sp-resource-commands.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.25.5
require (
github.com/dcm-project/catalog-manager v0.0.0-20260313160905-1ff110850088
github.com/dcm-project/policy-manager v0.0.0-20260310132113-15bd45617e87
github.com/dcm-project/service-provider-manager v0.0.0-20260324094657-8aad860d86d2
github.com/onsi/ginkgo/v2 v2.28.1
github.com/onsi/gomega v1.39.1
github.com/spf13/cobra v1.10.2
Expand All @@ -16,22 +17,22 @@ require (
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/getkin/kin-openapi v0.133.0 // indirect
github.com/getkin/kin-openapi v0.134.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-openapi/jsonpointer v0.22.4 // indirect
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mailru/easyjson v0.9.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/oapi-codegen/runtime v1.2.0 // indirect
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
github.com/oapi-codegen/runtime v1.3.0 // indirect
github.com/oasdiff/yaml v0.0.0-20260313112342-a3ea61cb4d4c // indirect
github.com/oasdiff/yaml3 v0.0.0-20260224194419-61cd415a242b // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
Expand All @@ -40,12 +41,12 @@ require (
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect
github.com/woodsbury/decimal128 v1.4.0 // indirect
golang.org/x/mod v0.32.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/tools v0.41.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
47 changes: 27 additions & 20 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions internal/commands/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@ import (
"time"

catalogclient "github.com/dcm-project/catalog-manager/pkg/client"
sprmclient "github.com/dcm-project/service-provider-manager/pkg/client/resource_manager"

"github.com/dcm-project/cli/internal/config"
"github.com/dcm-project/cli/internal/output"
"github.com/spf13/cobra"
"go.yaml.in/yaml/v3"
)

func newSPResourceClient(cfg *config.Config) (*sprmclient.Client, error) {
httpClient, err := buildHTTPClient(cfg)
if err != nil {
return nil, err
}
return sprmclient.NewClient(apiBaseURL(cfg), sprmclient.WithHTTPClient(httpClient))
}

func newCatalogClient(cfg *config.Config) (*catalogclient.Client, error) {
httpClient, err := buildHTTPClient(cfg)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func NewRootCommand() *cobra.Command {
// Register subcommand groups
cmd.AddCommand(newPolicyCommand())
cmd.AddCommand(newCatalogCommand())
cmd.AddCommand(newSPCommand())
cmd.AddCommand(newVersionCommand())

return cmd
Expand Down
21 changes: 20 additions & 1 deletion internal/commands/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
var _ = Describe("Root Command", func() {
// TC-U019: Root command registers all subcommands
Describe("TC-U019: Subcommand registration", func() {
It("should list policy, catalog, and version subcommands in help output", func() {
It("should list policy, catalog, sp, and version subcommands in help output", func() {
cmd := commands.NewRootCommand()
out := new(bytes.Buffer)
cmd.SetOut(out)
Expand All @@ -27,6 +27,7 @@ var _ = Describe("Root Command", func() {
helpOutput := out.String()
Expect(helpOutput).To(ContainSubstring("policy"))
Expect(helpOutput).To(ContainSubstring("catalog"))
Expect(helpOutput).To(ContainSubstring("sp"))
Expect(helpOutput).To(ContainSubstring("version"))
})
})
Expand All @@ -50,6 +51,23 @@ var _ = Describe("Root Command", func() {
})
})

// TC-U129: SP command registers subcommand groups
Describe("TC-U129: SP subcommand registration", func() {
It("should list resource subcommand in sp help", func() {
cmd := commands.NewRootCommand()
out := new(bytes.Buffer)
cmd.SetOut(out)
cmd.SetErr(new(bytes.Buffer))
cmd.SetArgs([]string{"sp", "--help"})

err := cmd.Execute()
Expect(err).NotTo(HaveOccurred())

helpOutput := out.String()
Expect(helpOutput).To(ContainSubstring("resource"))
})
})

// TC-U021: Global flags are registered
Describe("TC-U021: Global flags", func() {
It("should list all global flags in help output", func() {
Expand Down Expand Up @@ -148,6 +166,7 @@ var _ = Describe("Root Command", func() {
Entry("catalog item delete without ID", []string{"catalog", "item", "delete"}),
Entry("catalog instance get without ID", []string{"catalog", "instance", "get"}),
Entry("catalog instance delete without ID", []string{"catalog", "instance", "delete"}),
Entry("sp resource get without ID", []string{"sp", "resource", "get"}),
)
})
})
16 changes: 16 additions & 0 deletions internal/commands/sp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package commands

import (
"github.com/spf13/cobra"
)

func newSPCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "sp",
Short: "Manage service provider resources",
}

cmd.AddCommand(newSPResourceCommand())

return cmd
}
Loading