Skip to content
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
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ shards:

awscr-s3:
git: https://github.com/taylorfinnell/awscr-s3.git
version: 0.9.0
version: 0.10.0

awscr-signer:
git: https://github.com/taylorfinnell/awscr-signer.git
Expand Down
5 changes: 2 additions & 3 deletions spec/api_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module PlaceOS::Api
task = TaskStatus.from_json(resp.body)
break if task.completed?
resp.status_code.should eq 200
sleep 5
sleep 5.seconds
end
resp.status_code.should eq 200
task.state.to_s.should eq("error")
Expand Down Expand Up @@ -97,7 +97,7 @@ module PlaceOS::Api
task = TaskStatus.from_json(resp.body)
break if task.completed?
resp.status_code.should eq 200
sleep 5
sleep 5.seconds
end
resp.status_code.should eq 303
task.state.to_s.should eq("done")
Expand Down Expand Up @@ -196,7 +196,6 @@ module PlaceOS::Api

resp = client.post("#{namespace}/#{Api.arch}/#{uri}?#{prms}")
resp.status_code.should eq 202

task = TaskStatus.from_json(resp.body)

code = TOTP.generate_number_string(Api::TOTP_SECRET)
Expand Down
25 changes: 0 additions & 25 deletions src/ext/url.cr

This file was deleted.

10 changes: 5 additions & 5 deletions src/placeos-build-api/controllers/driver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module PlaceOS::Api
@[AC::Param::Info(description: "Branch to return driver binary for, defaults to master", example: "main")]
branch : String?,
@[AC::Param::Info(description: "the commit hash of the driver to check is compiled", example: "e901494")]
commit : String
commit : String,
) : S3::LinkData?
Log.context.set(driver: file_name, arch: arch, repository: url, branch: branch, commit: commit)
if ret = Api.with_s3 &.compiled?(file_name, arch, url, commit, branch)
Expand All @@ -57,7 +57,7 @@ module PlaceOS::Api
@[AC::Param::Info(description: "Branch to return driver binary for, defaults to master", example: "main")]
branch : String?,
@[AC::Param::Info(description: "the commit hash of the driver to check is compiled, defaults to latest commit on branch", example: "e901494362f6859100b8f3")]
commit : String
commit : String,
) : String?
Log.context.set(driver: file_name, repository: url, branch: branch, commit: commit)
if ret = Api.with_s3 &.compiled?(file_name, "meta", url, commit, branch)
Expand All @@ -78,7 +78,7 @@ module PlaceOS::Api
@[AC::Param::Info(description: "Branch to return driver binary for, defaults to master", example: "main")]
branch : String?,
@[AC::Param::Info(description: "the commit hash of the driver to check is compiled, defaults to latest commit on branch", example: "e901494362f6859100b8f3")]
commit : String
commit : String,
) : String?
Log.context.set(driver: file_name, repository: url, branch: branch, commit: commit)
if ret = Api.with_s3 &.compiled?(file_name, "meta", url, commit, branch)
Expand All @@ -104,7 +104,7 @@ module PlaceOS::Api
@[AC::Param::Info(description: "the commit hash of the driver to check is compiled", example: "e901494")]
commit : String,
@[AC::Param::Info(description: "Whether to re-compile driver using the latest shards? default is false", example: "true")]
force : Bool = false
force : Bool = false,
) : TaskStatus
Log.context.set(driver: file_name, arch: arch, repository: url, branch: branch, commit: commit, force: force)
Log.info { "Processing compile driver request" }
Expand All @@ -124,7 +124,7 @@ module PlaceOS::Api
@[AC::Param::Info(description: "the system architecture, defaults to architecutre of system where this service is running", example: "amd64 | arm64")]
arch : String,
@[AC::Param::Info(description: "Submitted Job ID returned by POST request")]
id : String
id : String,
) : TaskStatus?
if task = Api.task_status(id)
if task.success?
Expand Down
4 changes: 2 additions & 2 deletions src/placeos-build-api/controllers/monitor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ module PlaceOS::Api
@[AC::Route::GET("/monitor")]
def monitor(
@[AC::Param::Info(name: "state", description: "state of job to return. One of [pending,running,cancelled error,done]. Defaults to 'pending'", example: "pending")]
state : Api::State = Api::State::Pending
state : Api::State = Api::State::Pending,
) : Array(TaskStatus)
render json: Api.get_job_queue(state)
end

@[AC::Route::DELETE("/cancel/:job")]
def cancel(
@[AC::Param::Info(name: "job", description: "ID of previously submitted compilation job")]
job : String
job : String,
) : String?
if Api.cancel_task(job)
render json: {status: "success", message: "Job with id #{job} cancelled successfully"}.to_json
Expand Down
4 changes: 2 additions & 2 deletions src/placeos-build-api/s3.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "awscr-s3"
require "http/headers"
require "./utils"
require "../ext/url"

module PlaceOS::Api
def self.with_s3(&)
Expand Down Expand Up @@ -124,13 +123,14 @@ module PlaceOS::Api
object: "/#{@name}",
bucket: AWS_S3_BUCKET,
host_name: host,
scheme: scheme,
expires: AWS_S3_LINK_EXPIRY.to_i.to_i32,
additional_options: {
"Content-Type" => "binary/octet-stream",
})
url = Awscr::S3::Presigned::Url.new(options)
Log.debug { "Generating signed URL}" }
url.for(:get, scheme)
url.for(:get)
end

def get_resp
Expand Down