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

Allow non-standard API endpoint for push #652

Merged
merged 1 commit into from
Feb 25, 2015
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
5 changes: 3 additions & 2 deletions src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,11 @@ type Dependencies(dependenciesFileName: string) =
PackageProcess.Pack(dependenciesFile, outputPath, buildConfig, version, releaseNotes)

// Push a nupkg file.
member this.Push(packageFileName, ?url, ?apiKey, ?maxTrials) =
member this.Push(packageFileName, ?url, ?apiKey, ?endPoint, ?maxTrials) =
let endPoint = defaultArg endPoint "/api/v2/package"
let apiKey = defaultArg apiKey (Environment.GetEnvironmentVariable("nugetkey"))
if String.IsNullOrEmpty apiKey then
failwithf "Could not push package %s. Please specify an NuGet API key via environment variable \"nugetkey\"." packageFileName
let url = defaultArg url "https://nuget.org"
let maxTrials = defaultArg maxTrials 5
RemoteUpload.Push maxTrials url apiKey packageFileName
RemoteUpload.Push maxTrials (url + endPoint) apiKey packageFileName
1 change: 0 additions & 1 deletion src/Paket.Core/RemoteUpload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ let Push maxTrials url apiKey packageFileName =
let rec push trial =
tracefn "Pushing package %s to %s - trial %d" packageFileName url trial
try
let url = if url.Contains("nuget.org") then url + "/api/v2/package" else url
let client = Utils.createWebClient(url, None)
client.Headers.Add("X-NuGet-ApiKey", apiKey)
client.UploadFileAsMultipart (new Uri(url)) packageFileName
Expand Down
2 changes: 2 additions & 0 deletions src/Paket/Commands.fs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ type PushArgs =
| [<CustomCommandLine("url")>][<Mandatory>] Url of string
| [<CustomCommandLine("file")>][<Mandatory>] FileName of string
| [<CustomCommandLine("apikey")>] ApiKey of string
| [<CustomCommandLine("endpoint")>] EndPoint of string
with
interface IArgParserTemplate with
member this.Usage =
match this with
| Url(_) -> "Url of the Nuget feed."
| FileName(_) -> "Path to the package."
| ApiKey(_) -> "Optionally specify your API key on the command line. Otherwise uses the value of the `nugetkey` environment variable."
| EndPoint(_) -> "Optionally specify a custom api endpoint to push to. Defaults to `/api/v2/package`"

let cmdLineSyntax (parser:UnionArgParser<_>) commandName =
"$ paket " + commandName + " " + parser.PrintCommandLineSyntax()
Expand Down
1 change: 1 addition & 0 deletions src/Paket/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ let push (results : ArgParseResults<_>) =
let fileName = results.GetResult <@ PushArgs.FileName @>
Dependencies.Locate()
.Push(fileName, ?url = results.TryGetResult <@ PushArgs.Url @>,
?endPoint = results.TryGetResult <@ PushArgs.EndPoint @>,
?apiKey = results.TryGetResult <@ PushArgs.ApiKey @>)

try
Expand Down