Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detailed discussion and complete code for "Discover shared projects" #4153

Closed
wants to merge 6 commits into from
22 changes: 21 additions & 1 deletion apps/dashboard/app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,29 @@ def next_id
end

def all
lookup_table.map do |id, directory|
projects = lookup_table.map do |id, directory|
Project.new({ id: id, directory: directory })
end

# TODO: Move this out of here
Configuration.shared_projects_root.each do |path|
if path.exist?
CurrentUser.group_names.each do |group|
dir_path = path.join(group)
# {shared_projects_path}/<UNIX group ID>/<project>/.ondemand
if dir_path.exist? && dir_path.directory?
Dir.each_child(dir_path) do |child|
if File.directory?(File.join(dir_path, child, '.ondemand'))
projects << Project.new({ id: child, directory: File.join(dir_path, child) })
end
end
end

end
end
end

projects
end

def find(id)
Expand Down
16 changes: 16 additions & 0 deletions apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,22 @@ def rails_env_production?
rails_env == 'production'
end

def shared_projects_root
# This environment varible will support ':' colon separated paths
vendor_path = ENV['VENDOR_SHARED_FILESYSTEM'] || ''
path_list = vendor_path.split(":")

paths = []
path_list.each do |path|
temp_path = Pathname.new(path)
if temp_path.exists?
paths.append(temp_path)
end
end

return paths
end

private

def can_access_core_app?(name)
Expand Down