From 91b8f79018718c8256faa29ddc43aed87191e053 Mon Sep 17 00:00:00 2001 From: Alex Suraci Date: Wed, 3 Feb 2016 11:02:11 -0800 Subject: [PATCH] configure upload URL when `github_api_url` is set [#99533974] Signed-off-by: Corbin Halliwill --- README.md | 4 ++++ github.go | 13 +++++++++++++ resources.go | 7 ++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3ca5464..3f444c1 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ Fetches and creates versioned GitHub resources. * `github_api_url`: *Optional.* If you use a non-public GitHub deployment then you can set your API URL here. +* `github_uploads_url`: *Optional.* Some GitHub instances have a separate URL + for uploading. If `github_api_url` is set, this value defaults to the same + value, but if you have your own endpoint, this field will override it. + * `drafts`: *Optional. Default `false`.* When set to `true`, `put` produces drafts and `check` only detects drafts. If `false`, only non-draft releases will be detected and published. Note that releases must have semver compliant diff --git a/github.go b/github.go index b3ac1d6..d87a513 100644 --- a/github.go +++ b/github.go @@ -55,6 +55,19 @@ func NewGitHubClient(source Source) (*GitHubClient, error) { if err != nil { return nil, err } + + client.UploadURL, err = url.Parse(source.GitHubAPIURL) + if err != nil { + return nil, err + } + } + + if source.GitHubUploadsURL != "" { + var err error + client.UploadURL, err = url.Parse(source.GitHubUploadsURL) + if err != nil { + return nil, err + } } return &GitHubClient{ diff --git a/resources.go b/resources.go index 30167b4..761fbfb 100644 --- a/resources.go +++ b/resources.go @@ -4,9 +4,10 @@ type Source struct { User string `json:"user"` Repository string `json:"repository"` - GitHubAPIURL string `json:"github_api_url"` - AccessToken string `json:"access_token"` - Drafts bool `json:"drafts"` + GitHubAPIURL string `json:"github_api_url"` + GitHubUploadsURL string `json:"github_uploads_url"` + AccessToken string `json:"access_token"` + Drafts bool `json:"drafts"` } type CheckRequest struct {