Skip to content

Commit

Permalink
Merge pull request #2 from curalate/DEV-31835
Browse files Browse the repository at this point in the history
DEV-31835 Allow override of Maven URL from where artifacts are fetched
  • Loading branch information
richid authored Nov 21, 2017
2 parents 5ffbb4e + d356752 commit f2b8149
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export ZIPKIN_UI_ENVIRONMENT="qa"
General attributes:

* `node['zipkin']['version']`: Version to install.
* `node['zipkin']['maven_base_url']`: Maven repository to fetch artifacts from.
Defaults to `https://repo1.maven.org/maven2`
* `node['zipkin']['install_dir']`: Where to install the application. Defaults
to `/opt/zipkin`.
* `node['zipkin']['manage_user']`: Should we create the user and group?
Expand Down
3 changes: 2 additions & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

# Base configuration
default['zipkin']['install_dir'] = '/opt/zipkin'
default['zipkin']['version'] = '2.0.0'
default['zipkin']['version'] = '2.3.0'
default['zipkin']['maven_base_url'] = 'https://repo1.maven.org/maven2'
default['zipkin']['user'] = 'zipkin'
default['zipkin']['group'] = 'zipkin'
default['zipkin']['uid'] = nil
Expand Down
38 changes: 38 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ def zipkin_jar_file
'zipkin.jar'
end

def zipkin_maven_group
'io.zipkin.java'
end

def zipkin_maven_artifact
'zipkin-server'
end

def zipkin_maven_artifact_file
[zipkin_maven_artifact, node['zipkin']['version'], 'exec.jar'].join('-')
end

def zipkin_kafka_maven_artifact
'zipkin-autoconfigure-collector-kafka10'
end

def zipkin_kafka_maven_artifact_file
[zipkin_kafka_maven_artifact, node['zipkin']['version'], 'module.jar'].join('-')
end

def zipkin_kafka_jar_file
'zipkin-collector-kafka.jar'
end
Expand All @@ -20,6 +40,24 @@ def zipkin_kafka_jar_path
::File.join(zipkin_version_dir, zipkin_kafka_jar_file)
end

def zipkin_jar_remote_url
zipkin_remote_url(zipkin_maven_artifact, zipkin_maven_artifact_file)
end

def zipkin_kafka_jar_remote_url
zipkin_remote_url(zipkin_kafka_maven_artifact, zipkin_kafka_maven_artifact_file)
end

def zipkin_remote_url(artifact, artifact_file)
::File.join(
node['zipkin']['maven_base_url'],
zipkin_maven_group.tr('.', '/'),
artifact,
node['zipkin']['version'],
artifact_file
)
end

def zipkin_version_dir
"#{node['zipkin']['install_dir']}-#{node['zipkin']['version']}"
end
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'MIT'
description 'Installs and configures Zipkin, a distributed tracing system.'
long_description 'Installs and configures Zipkin, a distributed tracing system.'
version '0.3.0'
version '0.4.0'
source_url 'https://github.com/curalate/chef-zipkin' if respond_to?(:source_url)
issues_url 'https://github.com/curalate/chef-zipkin/issues' if respond_to?(:issues_url)

Expand Down
5 changes: 2 additions & 3 deletions recipes/_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

install_dir = node['zipkin']['install_dir']
zipkin_user = node['zipkin']['user']
zipkin_version = node['zipkin']['version']

directory zipkin_version_dir do
owner zipkin_user
Expand All @@ -22,15 +21,15 @@
end

remote_file zipkin_jar_path do
source "https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=#{zipkin_version}&c=exec"
source zipkin_jar_remote_url
owner zipkin_user
group zipkin_user
mode '0755'
action :create
end

remote_file zipkin_kafka_jar_path do
source "https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-autoconfigure-collector-kafka10&v=#{zipkin_version}&c=module"
source zipkin_kafka_jar_remote_url
owner zipkin_user
group zipkin_user
mode '0755'
Expand Down

0 comments on commit f2b8149

Please sign in to comment.