Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ScriptName to UploadWorker #11

Merged
merged 1 commit into from
Dec 12, 2018
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
10 changes: 7 additions & 3 deletions cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ func ListWorkerRoutes(api *cloudflare.API, ZoneId string) (resp interface{}, err
return
}

func UploadWorker(api *cloudflare.API, ZoneId string, Script string) (resp interface{}, err error) {
func UploadWorker(api *cloudflare.API, ZoneId, Script, ScriptName string) (resp interface{}, err error) {
s := Script
if len(Script) != 0 {
if Script[0] == '@' {
Expand All @@ -1177,9 +1177,13 @@ func UploadWorker(api *cloudflare.API, ZoneId string, Script string) (resp inter
s = string(fileScript)
}
}
resp, err = api.UploadWorker(&cloudflare.WorkerRequestParams{
wrp := &cloudflare.WorkerRequestParams{
ZoneID: ZoneId,
}, s)
}
if ScriptName != "" {
wrp.ScriptName = ScriptName
}
resp, err = api.UploadWorker(wrp, s)
return
}

Expand Down
5 changes: 4 additions & 1 deletion cmd/autogenerated.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (
Disable bool
RouteId string
Script string
ScriptName string
ActorIp string
ActorEmail string
Id string
Expand Down Expand Up @@ -1973,6 +1974,8 @@ func init() {
UploadWorker.Flags().StringVar(&Script, "script", "", "The raw worker code to run at the edge. @ to read code from a file. - to read from stdin")
UploadWorker.MarkFlagRequired("script")

UploadWorker.Flags().StringVar(&ScriptName, "script-name", "", "The worker script name associated with the worker")

var UploadOrganizationWorker = &cobra.Command{
Use: "upload-organization-worker",
Short: "Upload a Cloudflare Worker associated with your Organization",
Expand Down Expand Up @@ -2545,7 +2548,7 @@ func Run(cmd *cobra.Command, args []string, name string, api *cloudflare.API) (r
case "ListWorkerRoutes":
resp, err = ListWorkerRoutes(api, ZoneId)
case "UploadWorker":
resp, err = UploadWorker(api, ZoneId, Script)
resp, err = UploadWorker(api, ZoneId, Script, ScriptName)
case "UploadOrganizationWorker":
resp, err = UploadOrganizationWorker(api, ZoneId, OrganizationId, Name, Script)
case "DeleteWorker":
Expand Down
5 changes: 5 additions & 0 deletions definitions/definitions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2464,6 +2464,11 @@
type = "string"
description = "The raw worker code to run at the edge. @ to read code from a file. - to read from stdin"
required = true
[[command.option]]
name = "script-name"
type = "string"
description = "The worker script name associated with the worker"
required = false

[[command]]
name = "upload-organization-worker"
Expand Down