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
19 changes: 9 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: "3"

x-s3-client-env: &s3-client-env
AWS_REGION: ${AWS_REGION:-"us-east-1"}
Expand All @@ -7,7 +7,6 @@ x-s3-client-env: &s3-client-env
AWS_S3_ENDPOINT: ${AWS_S3_ENDPOINT:-"http://minio:9000"}
AWS_S3_BUCKET: ${AWS_S3_BUCKET:-"placeos-drivers-build-service"}


services:
test:
build:
Expand All @@ -24,14 +23,14 @@ services:
- minio
- testbucket
environment:
<< : *s3-client-env
<<: *s3-client-env
# Environment
GITHUB_ACTION: ${GITHUB_ACTION:-}
SG_ENV: ${SG_ENV:-development}
SPEC_ARGUMENTS: ''
SPEC_ARGUMENTS: ""
TIMEOUT: 200
OTEL_CRYSTAL_DISABLE_INSTRUMENTATION_HTTP_CLIENT: 'false'
OTEL_CRYSTAL_DISABLE_INSTRUMENTATION_HTTP_CLIENT: "false"

minio:
image: minio/minio:latest
volumes:
Expand All @@ -40,7 +39,7 @@ services:
- 9000:9000
- 9090:9090
environment:
<< : *s3-client-env
<<: *s3-client-env
MINIO_ACCESS_KEY: $AWS_KEY
MINIO_SECRET_KEY: $AWS_SECRET
command: server /data --console-address ":9090"
Expand All @@ -50,15 +49,15 @@ services:
depends_on:
- minio
environment:
<< : *s3-client-env
<<: *s3-client-env
entrypoint: >
sh -c '
sleep 3 &&
mc config host add s3 $AWS_S3_ENDPOINT $AWS_KEY $AWS_SECRET &&
mc alias set s3 $AWS_S3_ENDPOINT $AWS_KEY $AWS_SECRET &&
mc mb -p s3/$AWS_S3_BUCKET &&
exit 0
'

volumes:
s3:
driver: local
driver: local
1 change: 1 addition & 0 deletions spec/api_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ module PlaceOS::Api
json.has_key?(k).should be_true
end

json["url"].as_s.starts_with?(PlaceOS::Api::AWS_S3_ENDPOINT.not_nil!).should be_true
# compiled driver should return metadata
resp = client.get("#{namespace}/metadata/#{uri}?#{params}")
resp.status_code.should eq 200
Expand Down
11 changes: 8 additions & 3 deletions src/placeos-build-api/s3.cr
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ module PlaceOS::Api
end

def url : String
scheme = "https://"
scheme = "https"
host = nil
force_path_style = false
if h = hostname
force_path_style = true
scheme, host = h
end

options = Awscr::S3::Presigned::Url::Options.new(
aws_access_key: AWS_KEY,
aws_secret_key: AWS_SECRET,
Expand All @@ -127,7 +130,9 @@ module PlaceOS::Api
expires: AWS_S3_LINK_EXPIRY.to_i.to_i32,
additional_options: {
"Content-Type" => "binary/octet-stream",
})
},
force_path_style: force_path_style,
)
url = Awscr::S3::Presigned::Url.new(options)
Log.debug { "Generating signed URL}" }
url.for(:get)
Expand Down Expand Up @@ -173,7 +178,7 @@ module PlaceOS::Api
private def hostname
if h = AWS_S3_ENDPOINT
uri = URI.parse(h)
{"#{uri.scheme}://", "#{uri.hostname}:#{uri.port}"}
{"#{uri.scheme}", "#{uri.hostname}:#{uri.port}"}
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ set -e
function trap_ctrlc ()
{
echo "░░░ Cleaning up..."
docker-compose down
docker compose down
exit 2
}

# initialise trap to call trap_ctrlc function
# when signal 2 (SIGINT) is received
trap "trap_ctrlc" 2

docker-compose pull
docker compose pull

docker-compose build
docker compose build

exit_code="0"

docker-compose run --rm test $@ || exit_code="$?"
docker compose run --rm test $@ || exit_code="$?"

docker-compose down
docker compose down

exit ${exit_code}