Commit 27ad82d6 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'fix-public-url-for-object-store' into 'master'

Fix url for object store artifacts

Closes #3172

See merge request !2705
parents e24d715b 69eaf332
......@@ -20,6 +20,14 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
def object_store_enabled?
object_store_options&.enabled
end
def object_store_credentials
@object_store_credentials ||= object_store_options&.connection&.to_hash&.deep_symbolize_keys
end
def object_store_directory
object_store_options&.remote_directory
end
end
attr_reader :subject, :field
......@@ -98,11 +106,11 @@ class ObjectStoreUploader < CarrierWave::Uploader::Base
end
def fog_directory
self.class.object_store_options.remote_directory
self.class.object_store_directory
end
def fog_credentials
self.class.object_store_options.connection
self.class.object_store_credentials
end
def fog_public
......
---
title: Fix url for object store artifacts
merge_request:
author:
type: fixed
......@@ -729,6 +729,18 @@ test:
enabled: true
lfs:
enabled: false
artifacts:
enabled: true
# The location where build artifacts are stored (default: shared/artifacts).
# path: shared/artifacts
object_store:
enabled: false
remote_directory: artifacts # The bucket name
connection:
provider: AWS # Only AWS supported at the moment
aws_access_key_id: AWS_ACCESS_KEY_ID
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
region: eu-central-1
gitlab:
host: localhost
port: 80
......
......@@ -336,8 +336,8 @@ Settings.artifacts['max_size'] ||= 100 # in megabytes
Settings.artifacts['object_store'] ||= Settingslogic.new({})
Settings.artifacts['object_store']['enabled'] = false if Settings.artifacts['object_store']['enabled'].nil?
Settings.artifacts['object_store']['remote_directory'] ||= nil
# Convert upload connection settings to use symbol keys, to make Fog happy
Settings.artifacts['object_store']['connection']&.deep_symbolize_keys!
# Convert upload connection settings to use string keys, to make Fog happy
Settings.artifacts['object_store']['connection']&.deep_stringify_keys!
#
# Registry
......
module StubConfiguration
def stub_artifacts_object_storage(enabled: true)
Fog.mock!
allow(Gitlab.config.artifacts.object_store).to receive_messages(
enabled: enabled,
remote_directory: 'artifacts',
connection: {
provider: 'AWS',
aws_access_key_id: 'AWS_ACCESS_KEY_ID',
aws_secret_access_key: 'AWS_SECRET_ACCESS_KEY',
region: 'eu-central-1'
}
)
allow(Gitlab.config.artifacts.object_store).to receive(:enabled) { enabled }
allow_any_instance_of(ArtifactUploader).to receive(:verify_license!) { true }
return unless enabled
::Fog::Storage.new(Gitlab.config.artifacts.object_store.connection).tap do |connection|
::Fog::Storage.new(ArtifactUploader.object_store_credentials).tap do |connection|
begin
connection.directories.create(key: 'artifacts')
rescue Excon::Error::Conflict
......
......@@ -239,7 +239,7 @@ describe ObjectStoreUploader do
end
describe '#fog_credentials' do
let(:connection) { 'connection' }
let(:connection) { Settingslogic.new("provider" => "AWS") }
before do
uploader_class.storage_options double(
......@@ -248,7 +248,7 @@ describe ObjectStoreUploader do
subject { uploader.fog_credentials }
it { is_expected.to eq(connection) }
it { is_expected.to eq(provider: 'AWS') }
end
describe '#fog_public' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment