add initial inst-fs integration

* register instfs plugin
* add instfs data to consul

closes CNVS-38588

test plan: none

Change-Id: Iaabcea702b001be75532b24ced3e8eeee574e424
Reviewed-on: https://gerrit.instructure.com/123199
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
Product-Review: Xander Moffatt <xmoffatt@instructure.com>
QA-Review: Xander Moffatt <xmoffatt@instructure.com>
This commit is contained in:
Xander Moffatt 2017-08-17 14:54:21 -06:00
parent 9dd3ec155c
commit 92a4f9ea88
4 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<%
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>
<%= fields_for :settings, OpenObject.new(settings) do |f| %>
<% end %>

View File

@ -19,6 +19,9 @@ test:
address-book:
app-host: http://address-book.docker
secret: opensesame
inst-fs:
app-host: http://api.instfs.docker
secret: supersecretyup
live-events-subscription-service:
app-host: http://les.docker
sad-panda: null
@ -36,6 +39,9 @@ development:
address-book:
app-host: http://address-book.docker
secret: opensesame
inst-fs:
app-host: http://api.instfs.docker
secret: supersecretyup
live-events-subscription-service:
app-host: http://les.docker
live-events:

View File

@ -425,4 +425,13 @@ Canvas::Plugin.register('live_events', nil, {
:settings_partial => 'plugins/live_events_settings',
:validator => 'LiveEventsValidator'
})
Canvas::Plugin.register('inst_fs', nil, {
:name =>lambda{ t :name, 'Inst-FS' },
:description => lambda{ t :description, 'File service that proxies for S3.' },
:author => 'Instructure',
:author_website => 'http://www.instructure.com',
:version => '0.0.1',
:settings => nil,
:settings_partial => 'plugins/inst_fs_settings'
})
require_dependency 'canvas/plugins/address_book'

41
lib/inst_fs.rb Normal file
View File

@ -0,0 +1,41 @@
#
# Copyright (C) 2016 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
module InstFS
class << self
def enabled?
Canvas::Plugin.find('inst_fs').enabled?
end
def app_host
setting("app-host")
end
def jwt_secret
setting("secret")
end
private
def setting(key)
settings = Canvas::DynamicSettings.from_cache("inst-fs", expires_in: 5.minutes, use_env: false)
settings[key]
rescue Imperium::TimeoutError => e
Canvas::Errors.capture_exception(:inst_fs, e)
nil
end
end
end