Skip to content

Commit

Permalink
add initial inst-fs integration
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
xandroxygen committed Aug 18, 2017
1 parent 9dd3ec1 commit 92a4f9e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/views/plugins/_inst_fs_settings.html.erb
@@ -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 %>
6 changes: 6 additions & 0 deletions config/consul.yml.example
Expand Up @@ -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
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions lib/canvas/plugins/default_plugins.rb
Expand Up @@ -425,4 +425,13 @@
: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 changes: 41 additions & 0 deletions lib/inst_fs.rb
@@ -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

0 comments on commit 92a4f9e

Please sign in to comment.