Skip to content

Commit 902cbe3

Browse files
fix: restore support for void endpoints
1 parent c0fbb51 commit 902cbe3

13 files changed

Lines changed: 280 additions & 0 deletions

pkg/cmd/build.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,31 @@ func handleBuild(ctx context.Context, cmd *cli.Command) error {
138138
return nil
139139
}
140140

141+
func handleBuildsCancel(ctx context.Context, cmd *cli.Command) error {
142+
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
143+
unusedArgs := cmd.Args().Slice()
144+
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
145+
cmd.Set("id", unusedArgs[0])
146+
unusedArgs = unusedArgs[1:]
147+
}
148+
if len(unusedArgs) > 0 {
149+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
150+
}
151+
152+
options, err := flagOptions(
153+
cmd,
154+
apiquery.NestedQueryFormatBrackets,
155+
apiquery.ArrayQueryFormatComma,
156+
EmptyBody,
157+
false,
158+
)
159+
if err != nil {
160+
return err
161+
}
162+
163+
return client.Builds.Cancel(ctx, cmd.Value("id").(string), options...)
164+
}
165+
141166
// streamBuildEventsSDK streams build events using the SDK
142167
func streamBuildEventsSDK(ctx context.Context, client hypeman.Client, buildID string, opts []option.RequestOption) error {
143168
stream := client.Builds.EventsStreaming(

pkg/cmd/build_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ func TestBuildsList(t *testing.T) {
3232
)
3333
}
3434

35+
func TestBuildsCancel(t *testing.T) {
36+
t.Skip("Prism tests are disabled")
37+
mocktest.TestRunMockTestWithFlags(
38+
t,
39+
"builds", "cancel",
40+
"--id", "id",
41+
)
42+
}
43+
3544
func TestBuildsEvents(t *testing.T) {
3645
t.Skip("Prism doesn't support text/event-stream responses")
3746
mocktest.TestRunMockTestWithFlags(

pkg/cmd/cmd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func init() {
9999
Commands: []*cli.Command{
100100
&imagesCreate,
101101
&imagesList,
102+
&imagesDelete,
102103
&imagesGet,
103104
},
104105
},
@@ -109,6 +110,7 @@ func init() {
109110
Commands: []*cli.Command{
110111
&instancesCreate,
111112
&instancesList,
113+
&instancesDelete,
112114
&instancesGet,
113115
&instancesLogs,
114116
&instancesRestore,
@@ -136,6 +138,7 @@ func init() {
136138
Commands: []*cli.Command{
137139
&volumesCreate,
138140
&volumesList,
141+
&volumesDelete,
139142
&volumesGet,
140143
},
141144
},
@@ -147,6 +150,7 @@ func init() {
147150
&devicesCreate,
148151
&devicesRetrieve,
149152
&devicesList,
153+
&devicesDelete,
150154
&devicesListAvailable,
151155
},
152156
},
@@ -157,6 +161,7 @@ func init() {
157161
Commands: []*cli.Command{
158162
&ingressesCreate,
159163
&ingressesList,
164+
&ingressesDelete,
160165
&ingressesGet,
161166
},
162167
},
@@ -175,6 +180,7 @@ func init() {
175180
Commands: []*cli.Command{
176181
&buildsCreate,
177182
&buildsList,
183+
&buildsCancel,
178184
&buildsEvents,
179185
&buildsGet,
180186
},

pkg/cmd/device.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ var devicesList = cli.Command{
5959
HideHelpCommand: true,
6060
}
6161

62+
var devicesDelete = cli.Command{
63+
Name: "delete",
64+
Usage: "Unregister device",
65+
Suggest: true,
66+
Flags: []cli.Flag{
67+
&requestflag.Flag[string]{
68+
Name: "id",
69+
Required: true,
70+
},
71+
},
72+
Action: handleDevicesDelete,
73+
HideHelpCommand: true,
74+
}
75+
6276
var devicesListAvailable = cli.Command{
6377
Name: "list-available",
6478
Usage: "Discover passthrough-capable devices on host",
@@ -169,6 +183,31 @@ func handleDevicesList(ctx context.Context, cmd *cli.Command) error {
169183
return ShowJSON(os.Stdout, "devices list", obj, format, transform)
170184
}
171185

186+
func handleDevicesDelete(ctx context.Context, cmd *cli.Command) error {
187+
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
188+
unusedArgs := cmd.Args().Slice()
189+
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
190+
cmd.Set("id", unusedArgs[0])
191+
unusedArgs = unusedArgs[1:]
192+
}
193+
if len(unusedArgs) > 0 {
194+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
195+
}
196+
197+
options, err := flagOptions(
198+
cmd,
199+
apiquery.NestedQueryFormatBrackets,
200+
apiquery.ArrayQueryFormatComma,
201+
EmptyBody,
202+
false,
203+
)
204+
if err != nil {
205+
return err
206+
}
207+
208+
return client.Devices.Delete(ctx, cmd.Value("id").(string), options...)
209+
}
210+
172211
func handleDevicesListAvailable(ctx context.Context, cmd *cli.Command) error {
173212
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
174213
unusedArgs := cmd.Args().Slice()

pkg/cmd/device_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ func TestDevicesList(t *testing.T) {
3535
)
3636
}
3737

38+
func TestDevicesDelete(t *testing.T) {
39+
t.Skip("Prism tests are disabled")
40+
mocktest.TestRunMockTestWithFlags(
41+
t,
42+
"devices", "delete",
43+
"--id", "id",
44+
)
45+
}
46+
3847
func TestDevicesListAvailable(t *testing.T) {
3948
t.Skip("Prism tests are disabled")
4049
mocktest.TestRunMockTestWithFlags(

pkg/cmd/image.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ var imagesList = cli.Command{
4141
HideHelpCommand: true,
4242
}
4343

44+
var imagesDelete = cli.Command{
45+
Name: "delete",
46+
Usage: "Delete image",
47+
Suggest: true,
48+
Flags: []cli.Flag{
49+
&requestflag.Flag[string]{
50+
Name: "name",
51+
Required: true,
52+
},
53+
},
54+
Action: handleImagesDelete,
55+
HideHelpCommand: true,
56+
}
57+
4458
var imagesGet = cli.Command{
4559
Name: "get",
4660
Usage: "Get image details",
@@ -121,6 +135,31 @@ func handleImagesList(ctx context.Context, cmd *cli.Command) error {
121135
return ShowJSON(os.Stdout, "images list", obj, format, transform)
122136
}
123137

138+
func handleImagesDelete(ctx context.Context, cmd *cli.Command) error {
139+
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
140+
unusedArgs := cmd.Args().Slice()
141+
if !cmd.IsSet("name") && len(unusedArgs) > 0 {
142+
cmd.Set("name", unusedArgs[0])
143+
unusedArgs = unusedArgs[1:]
144+
}
145+
if len(unusedArgs) > 0 {
146+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
147+
}
148+
149+
options, err := flagOptions(
150+
cmd,
151+
apiquery.NestedQueryFormatBrackets,
152+
apiquery.ArrayQueryFormatComma,
153+
EmptyBody,
154+
false,
155+
)
156+
if err != nil {
157+
return err
158+
}
159+
160+
return client.Images.Delete(ctx, cmd.Value("name").(string), options...)
161+
}
162+
124163
func handleImagesDelete(ctx context.Context, cmd *cli.Command) error {
125164
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
126165
unusedArgs := cmd.Args().Slice()

pkg/cmd/image_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ func TestImagesList(t *testing.T) {
2525
)
2626
}
2727

28+
func TestImagesDelete(t *testing.T) {
29+
t.Skip("Prism tests are disabled")
30+
mocktest.TestRunMockTestWithFlags(
31+
t,
32+
"images", "delete",
33+
"--name", "name",
34+
)
35+
}
36+
2837
func TestImagesGet(t *testing.T) {
2938
t.Skip("Prism tests are disabled")
3039
mocktest.TestRunMockTestWithFlags(

pkg/cmd/ingress.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ var ingressesList = cli.Command{
6767
HideHelpCommand: true,
6868
}
6969

70+
var ingressesDelete = cli.Command{
71+
Name: "delete",
72+
Usage: "Delete ingress",
73+
Suggest: true,
74+
Flags: []cli.Flag{
75+
&requestflag.Flag[string]{
76+
Name: "id",
77+
Required: true,
78+
},
79+
},
80+
Action: handleIngressesDelete,
81+
HideHelpCommand: true,
82+
}
83+
7084
var ingressesGet = cli.Command{
7185
Name: "get",
7286
Usage: "Get ingress details",
@@ -147,6 +161,31 @@ func handleIngressesList(ctx context.Context, cmd *cli.Command) error {
147161
return ShowJSON(os.Stdout, "ingresses list", obj, format, transform)
148162
}
149163

164+
func handleIngressesDelete(ctx context.Context, cmd *cli.Command) error {
165+
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
166+
unusedArgs := cmd.Args().Slice()
167+
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
168+
cmd.Set("id", unusedArgs[0])
169+
unusedArgs = unusedArgs[1:]
170+
}
171+
if len(unusedArgs) > 0 {
172+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
173+
}
174+
175+
options, err := flagOptions(
176+
cmd,
177+
apiquery.NestedQueryFormatBrackets,
178+
apiquery.ArrayQueryFormatComma,
179+
EmptyBody,
180+
false,
181+
)
182+
if err != nil {
183+
return err
184+
}
185+
186+
return client.Ingresses.Delete(ctx, cmd.Value("id").(string), options...)
187+
}
188+
150189
func handleIngressesGet(ctx context.Context, cmd *cli.Command) error {
151190
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
152191
unusedArgs := cmd.Args().Slice()

pkg/cmd/ingress_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ func TestIngressesList(t *testing.T) {
4141
)
4242
}
4343

44+
func TestIngressesDelete(t *testing.T) {
45+
t.Skip("Prism tests are disabled")
46+
mocktest.TestRunMockTestWithFlags(
47+
t,
48+
"ingresses", "delete",
49+
"--id", "id",
50+
)
51+
}
52+
4453
func TestIngressesGet(t *testing.T) {
4554
t.Skip("Prism tests are disabled")
4655
mocktest.TestRunMockTestWithFlags(

pkg/cmd/instance.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ var instancesList = cli.Command{
169169
HideHelpCommand: true,
170170
}
171171

172+
var instancesDelete = cli.Command{
173+
Name: "delete",
174+
Usage: "Stop and delete instance",
175+
Suggest: true,
176+
Flags: []cli.Flag{
177+
&requestflag.Flag[string]{
178+
Name: "id",
179+
Required: true,
180+
},
181+
},
182+
Action: handleInstancesDelete,
183+
HideHelpCommand: true,
184+
}
185+
172186
var instancesGet = cli.Command{
173187
Name: "get",
174188
Usage: "Get instance details",
@@ -363,6 +377,31 @@ func handleInstancesList(ctx context.Context, cmd *cli.Command) error {
363377
return ShowJSON(os.Stdout, "instances list", obj, format, transform)
364378
}
365379

380+
func handleInstancesDelete(ctx context.Context, cmd *cli.Command) error {
381+
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
382+
unusedArgs := cmd.Args().Slice()
383+
if !cmd.IsSet("id") && len(unusedArgs) > 0 {
384+
cmd.Set("id", unusedArgs[0])
385+
unusedArgs = unusedArgs[1:]
386+
}
387+
if len(unusedArgs) > 0 {
388+
return fmt.Errorf("Unexpected extra arguments: %v", unusedArgs)
389+
}
390+
391+
options, err := flagOptions(
392+
cmd,
393+
apiquery.NestedQueryFormatBrackets,
394+
apiquery.ArrayQueryFormatComma,
395+
EmptyBody,
396+
false,
397+
)
398+
if err != nil {
399+
return err
400+
}
401+
402+
return client.Instances.Delete(ctx, cmd.Value("id").(string), options...)
403+
}
404+
366405
func handleInstancesGet(ctx context.Context, cmd *cli.Command) error {
367406
client := hypeman.NewClient(getDefaultRequestOptions(cmd)...)
368407
unusedArgs := cmd.Args().Slice()

0 commit comments

Comments
 (0)