Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 689c618

Browse files
committedMar 17, 2025·
fix(workers_for_platforms): remove cyclic import due to model (#4039)
1 parent 3f496ad commit 689c618

File tree

5 files changed

+54
-51
lines changed

5 files changed

+54
-51
lines changed
 

‎api.md

-4
Original file line numberDiff line numberDiff line change
@@ -4570,10 +4570,6 @@ Methods:
45704570

45714571
##### Secrets
45724572

4573-
Params Types:
4574-
4575-
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/workers_for_platforms#WorkersSecretModelParam">WorkersSecretModelParam</a>
4576-
45774573
Response Types:
45784574

45794575
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/workers_for_platforms">workers_for_platforms</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v4/workers_for_platforms#DispatchNamespaceScriptSecretUpdateResponse">DispatchNamespaceScriptSecretUpdateResponse</a>

‎workers/scriptsecret.go

+24-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/cloudflare/cloudflare-go/v4/option"
1515
"github.com/cloudflare/cloudflare-go/v4/packages/pagination"
1616
"github.com/cloudflare/cloudflare-go/v4/shared"
17-
"github.com/cloudflare/cloudflare-go/v4/workers_for_platforms"
1817
)
1918

2019
// ScriptSecretService contains methods and other services that help with
@@ -265,12 +264,33 @@ func (r ScriptSecretGetResponseType) IsKnown() bool {
265264

266265
type ScriptSecretUpdateParams struct {
267266
// Identifier
268-
AccountID param.Field[string] `path:"account_id,required"`
269-
WorkersSecretModel workers_for_platforms.WorkersSecretModelParam `json:"workers_secret_model,required"`
267+
AccountID param.Field[string] `path:"account_id,required"`
268+
// The name of this secret, this is what will be used to access it inside the
269+
// Worker.
270+
Name param.Field[string] `json:"name"`
271+
// The value of the secret.
272+
Text param.Field[string] `json:"text"`
273+
// The type of secret to put.
274+
Type param.Field[ScriptSecretUpdateParamsType] `json:"type"`
270275
}
271276

272277
func (r ScriptSecretUpdateParams) MarshalJSON() (data []byte, err error) {
273-
return apijson.MarshalRoot(r.WorkersSecretModel)
278+
return apijson.MarshalRoot(r)
279+
}
280+
281+
// The type of secret to put.
282+
type ScriptSecretUpdateParamsType string
283+
284+
const (
285+
ScriptSecretUpdateParamsTypeSecretText ScriptSecretUpdateParamsType = "secret_text"
286+
)
287+
288+
func (r ScriptSecretUpdateParamsType) IsKnown() bool {
289+
switch r {
290+
case ScriptSecretUpdateParamsTypeSecretText:
291+
return true
292+
}
293+
return false
274294
}
275295

276296
type ScriptSecretUpdateResponseEnvelope struct {

‎workers/scriptsecret_test.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/cloudflare/cloudflare-go/v4/internal/testutil"
1313
"github.com/cloudflare/cloudflare-go/v4/option"
1414
"github.com/cloudflare/cloudflare-go/v4/workers"
15-
"github.com/cloudflare/cloudflare-go/v4/workers_for_platforms"
1615
)
1716

1817
func TestScriptSecretUpdateWithOptionalParams(t *testing.T) {
@@ -33,11 +32,9 @@ func TestScriptSecretUpdateWithOptionalParams(t *testing.T) {
3332
"this-is_my_script-01",
3433
workers.ScriptSecretUpdateParams{
3534
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
36-
WorkersSecretModel: workers_for_platforms.WorkersSecretModelParam{
37-
Name: cloudflare.F("MY_SECRET"),
38-
Text: cloudflare.F("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"),
39-
Type: cloudflare.F(workers_for_platforms.WorkersSecretModelTypeSecretText),
40-
},
35+
Name: cloudflare.F("MY_SECRET"),
36+
Text: cloudflare.F("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"),
37+
Type: cloudflare.F(workers.ScriptSecretUpdateParamsTypeSecretText),
4138
},
4239
)
4340
if err != nil {

‎workers_for_platforms/dispatchnamespacescriptsecret.go

+24-32
Original file line numberDiff line numberDiff line change
@@ -154,35 +154,6 @@ func (r *DispatchNamespaceScriptSecretService) Get(ctx context.Context, dispatch
154154
return
155155
}
156156

157-
type WorkersSecretModelParam struct {
158-
// The name of this secret, this is what will be used to access it inside the
159-
// Worker.
160-
Name param.Field[string] `json:"name"`
161-
// The value of the secret.
162-
Text param.Field[string] `json:"text"`
163-
// The type of secret to put.
164-
Type param.Field[WorkersSecretModelType] `json:"type"`
165-
}
166-
167-
func (r WorkersSecretModelParam) MarshalJSON() (data []byte, err error) {
168-
return apijson.MarshalRoot(r)
169-
}
170-
171-
// The type of secret to put.
172-
type WorkersSecretModelType string
173-
174-
const (
175-
WorkersSecretModelTypeSecretText WorkersSecretModelType = "secret_text"
176-
)
177-
178-
func (r WorkersSecretModelType) IsKnown() bool {
179-
switch r {
180-
case WorkersSecretModelTypeSecretText:
181-
return true
182-
}
183-
return false
184-
}
185-
186157
type DispatchNamespaceScriptSecretUpdateResponse struct {
187158
// The name of this secret, this is what will be used to access it inside the
188159
// Worker.
@@ -310,12 +281,33 @@ func (r DispatchNamespaceScriptSecretGetResponseType) IsKnown() bool {
310281

311282
type DispatchNamespaceScriptSecretUpdateParams struct {
312283
// Identifier
313-
AccountID param.Field[string] `path:"account_id,required"`
314-
WorkersSecretModel WorkersSecretModelParam `json:"workers_secret_model,required"`
284+
AccountID param.Field[string] `path:"account_id,required"`
285+
// The name of this secret, this is what will be used to access it inside the
286+
// Worker.
287+
Name param.Field[string] `json:"name"`
288+
// The value of the secret.
289+
Text param.Field[string] `json:"text"`
290+
// The type of secret to put.
291+
Type param.Field[DispatchNamespaceScriptSecretUpdateParamsType] `json:"type"`
315292
}
316293

317294
func (r DispatchNamespaceScriptSecretUpdateParams) MarshalJSON() (data []byte, err error) {
318-
return apijson.MarshalRoot(r.WorkersSecretModel)
295+
return apijson.MarshalRoot(r)
296+
}
297+
298+
// The type of secret to put.
299+
type DispatchNamespaceScriptSecretUpdateParamsType string
300+
301+
const (
302+
DispatchNamespaceScriptSecretUpdateParamsTypeSecretText DispatchNamespaceScriptSecretUpdateParamsType = "secret_text"
303+
)
304+
305+
func (r DispatchNamespaceScriptSecretUpdateParamsType) IsKnown() bool {
306+
switch r {
307+
case DispatchNamespaceScriptSecretUpdateParamsTypeSecretText:
308+
return true
309+
}
310+
return false
319311
}
320312

321313
type DispatchNamespaceScriptSecretUpdateResponseEnvelope struct {

‎workers_for_platforms/dispatchnamespacescriptsecret_test.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ func TestDispatchNamespaceScriptSecretUpdateWithOptionalParams(t *testing.T) {
3333
"this-is_my_script-01",
3434
workers_for_platforms.DispatchNamespaceScriptSecretUpdateParams{
3535
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
36-
WorkersSecretModel: workers_for_platforms.WorkersSecretModelParam{
37-
Name: cloudflare.F("MY_SECRET"),
38-
Text: cloudflare.F("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"),
39-
Type: cloudflare.F(workers_for_platforms.WorkersSecretModelTypeSecretText),
40-
},
36+
Name: cloudflare.F("MY_SECRET"),
37+
Text: cloudflare.F("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"),
38+
Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptSecretUpdateParamsTypeSecretText),
4139
},
4240
)
4341
if err != nil {

0 commit comments

Comments
 (0)
Please sign in to comment.