Skip to content

Commit

Permalink
Merge branch 'release/128' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
korczis committed Jan 15, 2017
2 parents 9057a6d + e6d0194 commit 723fa42
Show file tree
Hide file tree
Showing 36 changed files with 179 additions and 241 deletions.
4 changes: 0 additions & 4 deletions CLI.md
Expand Up @@ -223,10 +223,6 @@ tomaskorcak@kx-mac:~/$ gooddata -p tk6192gsnav58crp6o1ahsmtuniq8khb project invi
Inviting tomas.korcak@gooddata.com, role: /gdc/projects/tk6192gsnav58crp6o1ahsmtuniq8khb/roles/2
```

### project jack_in

If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project

### project list_users

List users
Expand Down
8 changes: 0 additions & 8 deletions DEPENDENCIES.md
Expand Up @@ -524,14 +524,6 @@ Add parallel methods into Enumerable: pmap and peach

A few useful extensions to core Ruby classes.

<a name="pry"></a>
### <a href="http://pryrepl.org">pry</a> v0.10.3
#### An IRB alternative and runtime developer console

<a href="http://opensource.org/licenses/mit-license">MIT</a> whitelisted

An IRB alternative and runtime developer console

<a name="rainbow"></a>
### <a href="https://github.com/sickill/rainbow">rainbow</a> v2.0.0
#### Colorize printed text on ANSI terminals
Expand Down
49 changes: 24 additions & 25 deletions gooddata.gemspec
Expand Up @@ -27,37 +27,36 @@ Gem::Specification.new do |s|
s.homepage = 'http://github.com/gooddata/gooddata-ruby'
s.require_paths = ['lib']

s.add_development_dependency 'bundler', "~> 1.13", '>= 1.13.6'
s.add_development_dependency 'debase', '~> 0.1', '>= 0.1.7' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
s.add_development_dependency 'license_finder', '~> 2.0', '>= 2.0.4'
s.add_development_dependency 'rake', '~> 11.1', '>= 11.1.1'
s.add_development_dependency 'rake-notes', '~> 0.2', '>= 0.2.0'
s.add_development_dependency 'redcarpet', '~> 3.1', '>= 3.1.1' if RUBY_PLATFORM != 'java'
s.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
s.add_development_dependency 'rspec-expectations', '~> 3.4', '>= 3.4.0'
s.add_development_dependency 'rubocop', '~> 0.45', '>= 0.45.0'
s.add_development_dependency 'bundler', "~> 1.13.0"
s.add_development_dependency 'debase', '~> 0.1.0' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
s.add_development_dependency 'license_finder', '~> 2.0.0'
s.add_development_dependency 'rake', '~> 11.1.0'
s.add_development_dependency 'rake-notes', '~> 0.2.0'
s.add_development_dependency 'redcarpet', '~> 3.1.0' if RUBY_PLATFORM != 'java'
s.add_development_dependency 'rspec', '~> 3.5.0'
s.add_development_dependency 'rspec-expectations', '~> 3.5.0'
s.add_development_dependency 'rubocop', '~> 0.45.0'
s.add_development_dependency 'ruby-debug-ide', '~> 0.4' if !ENV['TRAVIS_BUILD'] && RUBY_VERSION >= '2.0.0'
s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10.0'
s.add_development_dependency 'webmock', '~> 1.21', '>= 1.21.0'
s.add_development_dependency 'simplecov', '~> 0.12.0'
s.add_development_dependency 'webmock', '~> 1.21.0'
s.add_development_dependency 'yard', '~> 0.8.7.6'
s.add_development_dependency 'yard-rspec', '~> 0.1'
s.add_development_dependency 'ZenTest', '~> 4.10', '>= 4.11.0'
s.add_development_dependency 'ZenTest', '~> 4.11.0'

s.add_dependency 'nokogiri', '~> 1.6.8'
s.add_dependency 'aws-sdk-v1', '~> 1.45'
s.add_dependency 'docile', '~> 1.1', '>= 1.1.5'
s.add_dependency 'erubis', '~> 2.7', '>= 2.7.0'
s.add_dependency 'gli', '~> 2.13', '>= 2.13.2'
s.add_dependency 'highline', '~> 1.7', '>= 1.7.3'
s.add_dependency 'json_pure', '~> 1.8', '>= 1.8.2'
s.add_dependency 'multi_json', '~> 1.11', '>= 1.11.2'
s.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.6'
s.add_dependency 'pmap', '~> 1.0', '>= 1.0.2'
s.add_dependency 'pry', '~> 0.10', '>= 0.10.3'
s.add_dependency 'docile', '~> 1.1.0'
s.add_dependency 'erubis', '~> 2.7.0'
s.add_dependency 'gli', '~> 2.13.0'
s.add_dependency 'highline', '~> 1.7.0'
s.add_dependency 'json_pure', '~> 1.8.0'
s.add_dependency 'multi_json', '~> 1.11.0'
s.add_dependency 'parseconfig', '~> 1.0.0'
s.add_dependency 'pmap', '~> 1.0.0'
s.add_dependency 'restforce', '~> 2.4.0'
s.add_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
s.add_dependency 'rubyzip', '~> 1.1', '>= 1.1.7'
s.add_dependency 'salesforce_bulk_query', '~> 0.2', '>= 0.2.0'
s.add_dependency 'terminal-table', '~> 1.5', '>= 1.5.2'
s.add_dependency 'rest-client', '~> 1.8.0'
s.add_dependency 'rubyzip', '~> 1.1.0'
s.add_dependency 'salesforce_bulk_query', '~> 0.2.0'
s.add_dependency 'terminal-table', '~> 1.5.0'
s.add_dependency 'thread_safe'
end
17 changes: 0 additions & 17 deletions lib/gooddata/cli/commands/project_cmd.rb
Expand Up @@ -16,15 +16,6 @@ module CLI
arg_name 'project_command'

command :project do |c|
c.desc 'If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project'
c.command :jack_in do |jack|
jack.action do |global_options, options, _args|
warn '[DEPRECATION] `gooddata project jack_in` is deprecated. Please use `gooddata jack_in` instead.'
opts = options.merge(global_options)
GoodData::Command::Project.jack_in(opts)
end
end

c.desc 'Shows users in project'
c.command :users do |users|
users.action do |global_options, options, _args|
Expand All @@ -33,13 +24,5 @@ module CLI
end
end
end

desc 'If you are in a gooddata project blueprint or if you provide a project id it will start an interactive session inside that project'
command :jack_in do |jack|
jack.action do |global_options, options, _args|
opts = options.merge(global_options)
GoodData::Command::Project.jack_in(opts)
end
end
end
end
1 change: 0 additions & 1 deletion lib/gooddata/cli/hooks.rb
Expand Up @@ -49,7 +49,6 @@
on_error do |_exception|
# Error logic here
# return false to skip default error handling
# binding.pry
# pp exception.backtrace
# pp exception
true
Expand Down
30 changes: 0 additions & 30 deletions lib/gooddata/commands/project.rb
Expand Up @@ -103,36 +103,6 @@ def validate(project_id, options = { client: GoodData.connection })
client.with_project(project_id, &:validate)
end

def jack_in(options)
goodfile_path = GoodData::Helpers.find_goodfile(Pathname('.'))

spin_session = proc do |goodfile|
project_id = options[:project_id] || goodfile[:project_id]

begin
require 'gooddata'
client = GoodData.connect(options)
project = client.projects(project_id) if project_id
puts "Use 'exit' to quit the live session. Use 'q' to jump out of displaying a large output."
binding.pry(:quiet => true, # rubocop:disable Lint/Debugger
:prompt => [proc do |_target_self, _nest_level, _pry|
'project_live_session: '
end])
rescue GoodData::ProjectNotFound
puts "Project with id \"#{project_id}\" could not be found. Make sure that the id you provided is correct."
end
end

if goodfile_path
goodfile = MultiJson.load(File.read(goodfile_path), :symbolize_keys => true)
FileUtils.cd(goodfile_path.dirname) do
spin_session.call(goodfile)
end
else
spin_session.call({}, nil)
end
end

# Lists roles in a project
#
# @param project_id [String | GoodData::Project] Project id or project instance to list the users in
Expand Down
11 changes: 11 additions & 0 deletions lib/gooddata/extensions/hash.rb
Expand Up @@ -35,4 +35,15 @@ def slice(*keys)
def compact
select { |_, value| !value.nil? }
end

def deep_merge(hash)
hash = hash.to_hash
merge(hash) do |_key, old_val, new_val|
if old_val.is_a?(Hash) && new_val.is_a?(Hash)
old_val.deep_merge(new_val)
else
new_val
end
end
end
end
24 changes: 23 additions & 1 deletion lib/gooddata/helpers/global_helpers_params.rb
Expand Up @@ -55,6 +55,26 @@ def encode_hidden_params(params)
# Decodes params as they came from the platform
# The "data" key is supposed to be json and it's parsed - if this
def decode_params(params)
convert_secure_params = lambda do |args|
args = args.select { |k, _| k.include? "|" }
lines = args.keys.map do |key|
hash = {}
last_a = nil
last_e = nil
key.split("|").reduce(hash) do |a, e|
last_a = a
last_e = e
a[e] = {}
end
last_a[last_e] = args[key]
hash
end

lines.reduce({}) do |a, e|
a.deep_merge(e)
end
end

key = ENCODED_PARAMS_KEY.to_s
hidden_key = ENCODED_HIDDEN_PARAMS_KEY.to_s
data_params = params[key] || '{}'
Expand All @@ -76,9 +96,11 @@ def decode_params(params)
# Add the nil on ENCODED_HIDDEN_PARAMS_KEY
# if the data was retrieved from API You will not have the actual values so encode -> decode is not losless. The nil on the key prevents the server from deleting the key
parsed_hidden_data_params[ENCODED_HIDDEN_PARAMS_KEY] = nil unless parsed_hidden_data_params.empty?
secure_params = convert_secure_params.call(params)
params.delete_if { |k, _| k.include? "|" }
params.delete(key)
params.delete(hidden_key)
params.merge(parsed_data_params).merge(parsed_hidden_data_params)
params.deep_merge(parsed_data_params).deep_merge(parsed_hidden_data_params).deep_merge(secure_params)
end

# A helper which allows you to diff two lists of objects. The objects
Expand Down
23 changes: 13 additions & 10 deletions lib/gooddata/lcm/lcm.rb
Expand Up @@ -27,7 +27,9 @@ def ensure_users(domain, migration_spec, filter_on_segment = [])
messages
end

def transfer_everything(client, domain, migration_spec, filter_on_segment = [], opts = {})
def transfer_everything(client, domain, migration_spec, opts = {})
filter_on_segment = migration_spec['segments'] || []

puts 'Ensuring Users - warning: works across whole domain not just provided segment(s)'
ensure_users(domain, migration_spec, filter_on_segment)

Expand All @@ -38,8 +40,6 @@ def transfer_everything(client, domain, migration_spec, filter_on_segment = [],
maql_replacements: opts[:maql_replacements] || opts['maql_replacements']
}

tags = opts[:production_tag] || opts['production_tag']

domain.segments.peach do |segment|
next if !filter_on_segment.empty? && !(filter_on_segment.include?(segment.id))
bp = segment.master_project.blueprint
Expand Down Expand Up @@ -76,15 +76,18 @@ def transfer_everything(client, domain, migration_spec, filter_on_segment = [],
s.update_hidden_params(migration_spec[:additional_hidden_params] || {})
s.save
end

GoodData::Project.transfer_tagged_stuff(segment_master, project, tags) if tags
end

puts 'Migrating Dashboards'
if filter_on_segment.empty?
domain.synchronize_clients
else
filter_on_segment.map { |s| domain.segments(s).synchronize_clients }
do_not_synchronize_clients = migration_spec[:do_not_synchronize_clients]
if do_not_synchronize_clients.nil? || !do_not_synchronize_clients
puts 'Migrating Dashboards'
if filter_on_segment.empty?
domain.synchronize_clients
else
filter_on_segment.map do |s|
domain.segments(s).synchronize_clients
end
end
end
end

Expand Down
19 changes: 16 additions & 3 deletions lib/gooddata/models/domain.rb
Expand Up @@ -94,7 +94,12 @@ def add_user(user_data, name = nil, opts = { :client => GoodData.connection })
error_type = GoodData::Helpers.get_path(error, %w(error errorClass))
case error_type
when 'com.gooddata.webapp.service.userprovisioning.LoginNameAlreadyRegisteredException'
raise GoodData::UserInDifferentDomainError, "User #{data[:login]} is already in different domain"
u = Domain.find_user_by_login(domain_name, data[:login])
if u
response = { 'uri' => u.uri }
else
raise GoodData::UserInDifferentDomainError, "User #{data[:login]} is already in different domain"
end
when 'com.gooddata.json.validator.exception.MalformedMessageException'
raise GoodData::MalformedUserError, "User #{data[:login]} is malformed. The message from API is #{GoodData::Helpers.interpolate_error_message(error)}"
else
Expand Down Expand Up @@ -386,8 +391,16 @@ def synchronize_clients
# Runs async process that walks through segments and provisions projects if necessary.
#
# @return [Enumerator] Returns Enumerator of results
def provision_client_projects
res = client.post(segments_uri + '/provisionClientProjects', nil)
def provision_client_projects(segments = nil)
body = if segments
{
provisionClientProjects: {
segments: segments.is_a?(Array) ? segments : [segments]
}
}
end

res = client.post(segments_uri + '/provisionClientProjects', body)
res = client.poll_on_code(res['asyncTask']['links']['poll'])
failed_count = GoodData::Helpers.get_path(res, %w(clientProjectProvisioningResult failed count), 0)
created_count = GoodData::Helpers.get_path(res, %w(clientProjectProvisioningResult created count), 0)
Expand Down
1 change: 0 additions & 1 deletion lib/gooddata/models/process.rb
Expand Up @@ -4,7 +4,6 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require 'pry'
require 'zip'
require 'uri'

Expand Down
9 changes: 6 additions & 3 deletions lib/gooddata/models/project.rb
Expand Up @@ -126,15 +126,18 @@ def create_object(data = {})
# - :summary
# - :template (default /projects/blank)
#
def create(opts = { :client => GoodData.connection }, &block)
def create(opts = { client: GoodData.connection }, &block)
GoodData.logger.info "Creating project #{opts[:title]}"

c = client(opts)
fail ArgumentError, 'No :client specified' if c.nil?

opts = { :auth_token => Helpers::AuthHelper.read_token }.merge(opts)
auth_token = opts[:auth_token] || opts[:token]
fail ArgumentError, 'You have to provide your token for creating projects as :auth_token parameter' if auth_token.nil? || auth_token.empty?
if auth_token.nil? || auth_token.empty?
opts = { auth_token: Helpers::AuthHelper.read_token }.merge(opts)
auth_token = opts[:auth_token]
end
fail ArgumentError, 'You have to provide your token for creating projects as :auth_token or :token parameter' if auth_token.nil? || auth_token.empty?

project = create_object(opts)
project.save
Expand Down
8 changes: 4 additions & 4 deletions lib/gooddata/rest/connection.rb
Expand Up @@ -272,8 +272,8 @@ def download(what, where, options = {})

staging_uri = options[:staging_url].to_s

base_url = dir.empty? ? staging_uri : URI.join(staging_uri, "#{dir}/").to_s
url = URI.join(base_url, CGI.escape(what)).to_s
base_url = dir.empty? ? staging_uri : URI.join("#{server}", staging_uri, "#{dir}/").to_s
url = URI.join("#{server}", base_url, CGI.escape(what)).to_s

b = proc do |f|
raw = {
Expand Down Expand Up @@ -460,12 +460,12 @@ def tt_token
def upload(file, options = {})
dir = options[:directory] || ''
staging_uri = options[:staging_url].to_s
url = dir.empty? ? staging_uri : URI.join(staging_uri, "#{dir}/").to_s
url = dir.empty? ? staging_uri : URI.join("#{server}", staging_uri, "#{dir}/").to_s
# Make a directory, if needed
create_webdav_dir_if_needed url unless dir.empty?

webdav_filename = options[:filename] || File.basename(file)
do_stream_file URI.join(url, CGI.escape(webdav_filename)), file
do_stream_file URI.join("#{server}", url, CGI.escape(webdav_filename)), file
end

def generate_request_id
Expand Down
2 changes: 1 addition & 1 deletion lib/gooddata/version.rb
Expand Up @@ -6,7 +6,7 @@

# GoodData Module
module GoodData
VERSION = '0.6.49'
VERSION = '0.6.50'

class << self
# Version
Expand Down
1 change: 0 additions & 1 deletion spec/bricks/bricks_spec.rb
Expand Up @@ -7,7 +7,6 @@
require 'gooddata/bricks/brick'
require 'gooddata/bricks/bricks'
require 'gooddata/bricks/middleware/base_middleware'
require 'pry'

describe GoodData::Bricks do
it "Has GoodData::Bricks::Brick class" do
Expand Down

0 comments on commit 723fa42

Please sign in to comment.