Skip to content

Commit bb96e42

Browse files
stainless-app[bot]yjp20
authored andcommitted
fix: fix for issue with nil responses
1 parent 010d5d2 commit bb96e42

File tree

6 files changed

+66
-33
lines changed

6 files changed

+66
-33
lines changed

pkg/cmd/build.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,12 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
451451
targetPaths := parseTargetPaths(cc.workspaceConfig)
452452
buildGroup := Info("Creating build...")
453453
params := stainless.BuildNewParams{}
454-
res, err := cc.client.Builds.New(
454+
var res []byte
455+
_, err := cc.client.Builds.New(
455456
context.TODO(),
456457
params,
457458
option.WithMiddleware(cc.AsMiddleware()),
459+
option.WithResponseBodyInto(&res),
458460
)
459461
if err != nil {
460462
return err
@@ -484,22 +486,24 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
484486
}
485487

486488
format := cmd.Root().String("format")
487-
return ShowJSON("builds create", res.RawJSON(), format)
489+
return ShowJSON("builds create", string(res), format)
488490
}
489491

490492
func handleBuildsRetrieve(ctx context.Context, cmd *cli.Command) error {
491493
cc := getAPICommandContext(cmd)
492-
res, err := cc.client.Builds.Get(
494+
var res []byte
495+
_, err := cc.client.Builds.Get(
493496
context.TODO(),
494497
cmd.Value("build-id").(string),
495498
option.WithMiddleware(cc.AsMiddleware()),
499+
option.WithResponseBodyInto(&res),
496500
)
497501
if err != nil {
498502
return err
499503
}
500504

501505
format := cmd.Root().String("format")
502-
return ShowJSON("builds retrieve", res.RawJSON(), format)
506+
return ShowJSON("builds retrieve", string(res), format)
503507
}
504508

505509
// pullBuildOutputs pulls the outputs for a completed build
@@ -774,31 +778,35 @@ func pullOutput(output, url, ref, targetDir string, targetGroup *Group) error {
774778
func handleBuildsList(ctx context.Context, cmd *cli.Command) error {
775779
cc := getAPICommandContext(cmd)
776780
params := stainless.BuildListParams{}
777-
res, err := cc.client.Builds.List(
781+
var res []byte
782+
_, err := cc.client.Builds.List(
778783
context.TODO(),
779784
params,
780785
option.WithMiddleware(cc.AsMiddleware()),
786+
option.WithResponseBodyInto(&res),
781787
)
782788
if err != nil {
783789
return err
784790
}
785791

786792
format := cmd.Root().String("format")
787-
return ShowJSON("builds list", res.RawJSON(), format)
793+
return ShowJSON("builds list", string(res), format)
788794
}
789795

790796
func handleBuildsCompare(ctx context.Context, cmd *cli.Command) error {
791797
cc := getAPICommandContext(cmd)
792798
params := stainless.BuildCompareParams{}
793-
res, err := cc.client.Builds.Compare(
799+
var res []byte
800+
_, err := cc.client.Builds.Compare(
794801
context.TODO(),
795802
params,
796803
option.WithMiddleware(cc.AsMiddleware()),
804+
option.WithResponseBodyInto(&res),
797805
)
798806
if err != nil {
799807
return err
800808
}
801809

802810
format := cmd.Root().String("format")
803-
return ShowJSON("builds compare", res.RawJSON(), format)
811+
return ShowJSON("builds compare", string(res), format)
804812
}

pkg/cmd/builddiagnostic.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,18 @@ var buildsDiagnosticsList = cli.Command{
6161
func handleBuildsDiagnosticsList(ctx context.Context, cmd *cli.Command) error {
6262
cc := getAPICommandContext(cmd)
6363
params := stainless.BuildDiagnosticListParams{}
64-
res, err := cc.client.Builds.Diagnostics.List(
64+
var res []byte
65+
_, err := cc.client.Builds.Diagnostics.List(
6566
context.TODO(),
6667
cmd.Value("build-id").(string),
6768
params,
6869
option.WithMiddleware(cc.AsMiddleware()),
70+
option.WithResponseBodyInto(&res),
6971
)
7072
if err != nil {
7173
return err
7274
}
7375

7476
format := cmd.Root().String("format")
75-
return ShowJSON("builds:diagnostics list", res.RawJSON(), format)
77+
return ShowJSON("builds:diagnostics list", string(res), format)
7678
}

pkg/cmd/org.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,33 @@ var orgsList = cli.Command{
3131

3232
func handleOrgsRetrieve(ctx context.Context, cmd *cli.Command) error {
3333
cc := getAPICommandContext(cmd)
34-
res, err := cc.client.Orgs.Get(
34+
var res []byte
35+
_, err := cc.client.Orgs.Get(
3536
context.TODO(),
3637
cmd.Value("org").(string),
3738
option.WithMiddleware(cc.AsMiddleware()),
39+
option.WithResponseBodyInto(&res),
3840
)
3941
if err != nil {
4042
return err
4143
}
4244

4345
format := cmd.Root().String("format")
44-
return ShowJSON("orgs retrieve", res.RawJSON(), format)
46+
return ShowJSON("orgs retrieve", string(res), format)
4547
}
4648

4749
func handleOrgsList(ctx context.Context, cmd *cli.Command) error {
4850
cc := getAPICommandContext(cmd)
49-
res, err := cc.client.Orgs.List(context.TODO(), option.WithMiddleware(cc.AsMiddleware()))
51+
var res []byte
52+
_, err := cc.client.Orgs.List(
53+
context.TODO(),
54+
option.WithMiddleware(cc.AsMiddleware()),
55+
option.WithResponseBodyInto(&res),
56+
)
5057
if err != nil {
5158
return err
5259
}
5360

5461
format := cmd.Root().String("format")
55-
return ShowJSON("orgs list", res.RawJSON(), format)
62+
return ShowJSON("orgs list", string(res), format)
5663
}

pkg/cmd/project.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,19 @@ var projectsList = cli.Command{
119119
func handleProjectsCreate(ctx context.Context, cmd *cli.Command) error {
120120
cc := getAPICommandContext(cmd)
121121
params := stainless.ProjectNewParams{}
122-
res, err := cc.client.Projects.New(
122+
var res []byte
123+
_, err := cc.client.Projects.New(
123124
context.TODO(),
124125
params,
125126
option.WithMiddleware(cc.AsMiddleware()),
127+
option.WithResponseBodyInto(&res),
126128
)
127129
if err != nil {
128130
return err
129131
}
130132

131133
format := cmd.Root().String("format")
132-
return ShowJSON("projects create", res.RawJSON(), format)
134+
return ShowJSON("projects create", string(res), format)
133135
}
134136

135137
func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error {
@@ -138,17 +140,19 @@ func handleProjectsRetrieve(ctx context.Context, cmd *cli.Command) error {
138140
if cmd.IsSet("project") {
139141
params.Project = stainless.String(cmd.Value("project").(string))
140142
}
141-
res, err := cc.client.Projects.Get(
143+
var res []byte
144+
_, err := cc.client.Projects.Get(
142145
context.TODO(),
143146
params,
144147
option.WithMiddleware(cc.AsMiddleware()),
148+
option.WithResponseBodyInto(&res),
145149
)
146150
if err != nil {
147151
return err
148152
}
149153

150154
format := cmd.Root().String("format")
151-
return ShowJSON("projects retrieve", res.RawJSON(), format)
155+
return ShowJSON("projects retrieve", string(res), format)
152156
}
153157

154158
func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error {
@@ -157,31 +161,35 @@ func handleProjectsUpdate(ctx context.Context, cmd *cli.Command) error {
157161
if cmd.IsSet("project") {
158162
params.Project = stainless.String(cmd.Value("project").(string))
159163
}
160-
res, err := cc.client.Projects.Update(
164+
var res []byte
165+
_, err := cc.client.Projects.Update(
161166
context.TODO(),
162167
params,
163168
option.WithMiddleware(cc.AsMiddleware()),
169+
option.WithResponseBodyInto(&res),
164170
)
165171
if err != nil {
166172
return err
167173
}
168174

169175
format := cmd.Root().String("format")
170-
return ShowJSON("projects update", res.RawJSON(), format)
176+
return ShowJSON("projects update", string(res), format)
171177
}
172178

173179
func handleProjectsList(ctx context.Context, cmd *cli.Command) error {
174180
cc := getAPICommandContext(cmd)
175181
params := stainless.ProjectListParams{}
176-
res, err := cc.client.Projects.List(
182+
var res []byte
183+
_, err := cc.client.Projects.List(
177184
context.TODO(),
178185
params,
179186
option.WithMiddleware(cc.AsMiddleware()),
187+
option.WithResponseBodyInto(&res),
180188
)
181189
if err != nil {
182190
return err
183191
}
184192

185193
format := cmd.Root().String("format")
186-
return ShowJSON("projects list", res.RawJSON(), format)
194+
return ShowJSON("projects list", string(res), format)
187195
}

pkg/cmd/projectbranch.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,19 @@ func handleProjectsBranchesCreate(ctx context.Context, cmd *cli.Command) error {
129129
if cmd.IsSet("project") {
130130
params.Project = stainless.String(cmd.Value("project").(string))
131131
}
132-
res, err := cc.client.Projects.Branches.New(
132+
var res []byte
133+
_, err := cc.client.Projects.Branches.New(
133134
context.TODO(),
134135
params,
135136
option.WithMiddleware(cc.AsMiddleware()),
137+
option.WithResponseBodyInto(&res),
136138
)
137139
if err != nil {
138140
return err
139141
}
140142

141143
format := cmd.Root().String("format")
142-
return ShowJSON("projects:branches create", res.RawJSON(), format)
144+
return ShowJSON("projects:branches create", string(res), format)
143145
}
144146

145147
func handleProjectsBranchesRetrieve(ctx context.Context, cmd *cli.Command) error {
@@ -148,18 +150,20 @@ func handleProjectsBranchesRetrieve(ctx context.Context, cmd *cli.Command) error
148150
if cmd.IsSet("project") {
149151
params.Project = stainless.String(cmd.Value("project").(string))
150152
}
151-
res, err := cc.client.Projects.Branches.Get(
153+
var res []byte
154+
_, err := cc.client.Projects.Branches.Get(
152155
context.TODO(),
153156
cmd.Value("branch").(string),
154157
params,
155158
option.WithMiddleware(cc.AsMiddleware()),
159+
option.WithResponseBodyInto(&res),
156160
)
157161
if err != nil {
158162
return err
159163
}
160164

161165
format := cmd.Root().String("format")
162-
return ShowJSON("projects:branches retrieve", res.RawJSON(), format)
166+
return ShowJSON("projects:branches retrieve", string(res), format)
163167
}
164168

165169
func handleProjectsBranchesList(ctx context.Context, cmd *cli.Command) error {
@@ -168,17 +172,19 @@ func handleProjectsBranchesList(ctx context.Context, cmd *cli.Command) error {
168172
if cmd.IsSet("project") {
169173
params.Project = stainless.String(cmd.Value("project").(string))
170174
}
171-
res, err := cc.client.Projects.Branches.List(
175+
var res []byte
176+
_, err := cc.client.Projects.Branches.List(
172177
context.TODO(),
173178
params,
174179
option.WithMiddleware(cc.AsMiddleware()),
180+
option.WithResponseBodyInto(&res),
175181
)
176182
if err != nil {
177183
return err
178184
}
179185

180186
format := cmd.Root().String("format")
181-
return ShowJSON("projects:branches list", res.RawJSON(), format)
187+
return ShowJSON("projects:branches list", string(res), format)
182188
}
183189

184190
func handleProjectsBranchesDelete(ctx context.Context, cmd *cli.Command) error {
@@ -187,7 +193,7 @@ func handleProjectsBranchesDelete(ctx context.Context, cmd *cli.Command) error {
187193
if cmd.IsSet("project") {
188194
params.Project = stainless.String(cmd.Value("project").(string))
189195
}
190-
res := []byte{}
196+
var res []byte
191197
_, err := cc.client.Projects.Branches.Delete(
192198
context.TODO(),
193199
cmd.Value("branch").(string),
@@ -209,16 +215,18 @@ func handleProjectsBranchesRebase(ctx context.Context, cmd *cli.Command) error {
209215
if cmd.IsSet("project") {
210216
params.Project = stainless.String(cmd.Value("project").(string))
211217
}
212-
res, err := cc.client.Projects.Branches.Rebase(
218+
var res []byte
219+
_, err := cc.client.Projects.Branches.Rebase(
213220
context.TODO(),
214221
cmd.Value("branch").(string),
215222
params,
216223
option.WithMiddleware(cc.AsMiddleware()),
224+
option.WithResponseBodyInto(&res),
217225
)
218226
if err != nil {
219227
return err
220228
}
221229

222230
format := cmd.Root().String("format")
223-
return ShowJSON("projects:branches rebase", res.RawJSON(), format)
231+
return ShowJSON("projects:branches rebase", string(res), format)
224232
}

pkg/cmd/projectconfig.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func handleProjectsConfigsRetrieve(ctx context.Context, cmd *cli.Command) error
6969
if cmd.IsSet("project") {
7070
params.Project = stainless.String(cmd.Value("project").(string))
7171
}
72-
res := []byte{}
72+
var res []byte
7373
_, err := cc.client.Projects.Configs.Get(
7474
context.TODO(),
7575
params,
@@ -90,7 +90,7 @@ func handleProjectsConfigsGuess(ctx context.Context, cmd *cli.Command) error {
9090
if cmd.IsSet("project") {
9191
params.Project = stainless.String(cmd.Value("project").(string))
9292
}
93-
res := []byte{}
93+
var res []byte
9494
_, err := cc.client.Projects.Configs.Guess(
9595
context.TODO(),
9696
params,

0 commit comments

Comments
 (0)