-
Notifications
You must be signed in to change notification settings - Fork 18
Windows Support #26
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
Open
ArtemPopenkov
wants to merge
4
commits into
evenup:master
Choose a base branch
from
ArtemPopenkov:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Windows Support #26
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,38 +58,34 @@ | |
| $version, | ||
| $install_path, | ||
| $format, | ||
| $path = undef, | ||
| $path = '', | ||
| $server = 'http://artifactory', | ||
| $repo = 'libs-release-local', | ||
| $filename = undef, | ||
| $source_file = undef, | ||
| $filename = '', | ||
| $source_file = '' | ||
| ){ | ||
|
|
||
| if $source_file { | ||
| $sourcefile_real = $source_file | ||
| } else { | ||
| $sourcefile_real = "${project}-${version}.${format}" | ||
| if ( $source_file == '' and $format == '' ) { | ||
| fail('source_file or format is required') | ||
| } | ||
|
|
||
| if $filename { | ||
| $filename_real = $filename | ||
| } else { | ||
| $filename_real = "${project}-${version}.${format}" | ||
| $sourcefile_real = $source_file ? { | ||
| '' => "${project}-${version}.${format}", | ||
| default => $source_file | ||
| } | ||
|
|
||
| if ( $path ) { | ||
| $fetch_url = "${server}/artifactory/${repo}/${path}/${project}/${version}/${sourcefile_real}" | ||
| } else { | ||
| $fetch_url = "${server}/artifactory/${repo}/${project}/${version}/${sourcefile_real}" | ||
| $filename_real = $filename ? { | ||
| '' => "${project}-${version}.${format}", | ||
| default => $filename | ||
| } | ||
|
|
||
| $full_path = "${install_path}/${filename_real}" | ||
|
|
||
| exec { "artifactory_fetch_${name}": | ||
| command => "curl -o ${full_path} ${fetch_url}", | ||
| cwd => $install_path, | ||
| creates => $full_path, | ||
| path => '/usr/bin:/bin', | ||
| logoutput => on_failure; | ||
| artifactory::fetch_artifact_generic {"fetch_artifact_generic_${name}": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is fetch_artifact_generic intended to be used as a standalone in some cases? Trying to understand why you broke it out into it's own directive. |
||
| install_path => $install_path, | ||
| base_path => "${server}/artifactory", | ||
| repo => $repo, | ||
| filename => $filename_real, | ||
| source_file => $sourcefile_real, | ||
| layout => "${path}/${project}/${version}" | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # == Definition: artifactory::fetch_artifact_generic | ||
| # | ||
| # This define fetches a specific artifact from artifactory | ||
| # | ||
| # === Parameters | ||
| # | ||
| # [*install_path*] | ||
| # String. Where should the fetched file be installed at | ||
| # | ||
| # [*base_path*] | ||
| # String. Full path to artifactory repository | ||
| # Default: 'http://artifactory/artifactory' | ||
| # | ||
| # [*repo*] | ||
| # String. Name of the repository that holds this artifact | ||
| # Default: libs-release-local | ||
| # | ||
| # [*filename*] | ||
| # String. Filename that should be used for the fetched file | ||
| # Default: $project-$version.$format | ||
| # | ||
| # [*source_file*] | ||
| # String. Source file name in project | ||
| # Default: '' | ||
| # | ||
| # [*layout] | ||
| # Path to fetch file inside arifactory | ||
| # | ||
| # === Examples | ||
| # | ||
| # artifactory::fetch_artifact { 'mywar': | ||
| # install_path => '/data/tomcat/site', | ||
| # base_path => 'http://myhost/myartifactory', | ||
| # repo => 'mysimplerepo', | ||
| # filename => 'myproject-1.2.3.war', | ||
| # source_file => 'myproject.war', | ||
| # layout => 'myteam/myproject/1.2.3/foo' | ||
| # } | ||
| # | ||
| # | ||
| # === Authors | ||
| # | ||
| # * Artem Popenkov <mailto:artem.popenkov@concur.com> | ||
| # | ||
| define artifactory::fetch_artifact_generic( | ||
| $install_path, | ||
| $base_path = 'http://artifactory/artifactory', | ||
| $repo = 'libs-release-local', | ||
| $filename = '', | ||
| $source_file, | ||
| $layout, | ||
| ){ | ||
|
|
||
| if ( $source_file == '') { | ||
| fail('source_file is required') | ||
| } | ||
|
|
||
| # Use source file if filename is not specified | ||
| $filename_real = $filename ? { | ||
| '' => $source_file, | ||
| default => $filename | ||
| } | ||
|
|
||
| $fetch_url = "${base_path}/${repo}/${layout}/${source_file}" | ||
| $full_path = "${install_path}/${filename_real}" | ||
|
|
||
| $logoutput = on_failure | ||
|
|
||
| case $osfamily { | ||
| windows: { | ||
| $command = "Import-Module BitsTransfer; Start-BitsTransfer -Source ${fetch_url} -Destination ${install_path}" | ||
| $provider = powershell | ||
| $path = '' | ||
| } | ||
| default:{ | ||
| $command = "curl -o ${full_path} ${fetch_url}" | ||
| $provider = shell | ||
| $path = '/usr/bin:/bin' | ||
| } | ||
| } | ||
|
|
||
| exec{"artifactory_fetch_${name}": | ||
| command => $command, | ||
| cwd => $install_path, | ||
| creates => $full_path, | ||
| provider => $provider, | ||
| path => $path, | ||
| logoutput => $logoutput, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| require 'spec_helper' | ||
|
|
||
| describe 'artifactory::fetch_artifact_generic', :type => :define do | ||
| let(:title) { 'myproject' } | ||
|
|
||
| context "Linux: install_path, source_file, layout provided, no filename, base_path or repo" do | ||
| let(:params) { { | ||
| :install_path => '/somewhere', | ||
| :source_file => 'test.jar', | ||
| :layout => 'myapp', | ||
| } } | ||
|
|
||
| it { should contain_exec('artifactory_fetch_myproject').with( | ||
| 'creates' => '/somewhere/test.jar', | ||
| 'command' => "curl -o /somewhere/test.jar http://artifactory/artifactory/libs-release-local/myapp/test.jar" | ||
| ) } | ||
| end | ||
|
|
||
| context "Windows OS: install_path, source_file, layout provided, no filename, base_path or repo" do | ||
| let :facts do{ | ||
| :osfamily => 'windows' | ||
| }end | ||
| let(:params) { { | ||
| :install_path => '/somewhere', | ||
| :source_file => 'test.jar', | ||
| :layout => 'myapp', | ||
| } } | ||
|
|
||
| it { should contain_exec('artifactory_fetch_myproject').with( | ||
| 'creates' => '/somewhere/test.jar', | ||
| 'command' => "Import-Module BitsTransfer; Start-BitsTransfer -Source http://artifactory/artifactory/libs-release-local/myapp/test.jar -Destination /somewhere" | ||
| ) } | ||
| end | ||
|
|
||
| context "Windows OS: install_path, source_file, layout provided, filename no base_path or repo" do | ||
| let :facts do{ | ||
| :osfamily => 'windows' | ||
| }end | ||
| let(:params) { { | ||
| :install_path => '/somewhere', | ||
| :source_file => 'test.jar', | ||
| :layout => 'myapp', | ||
| :filename => 'downloaded.jar', | ||
| } } | ||
|
|
||
| it { should contain_exec('artifactory_fetch_myproject').with( | ||
| 'creates' => '/somewhere/downloaded.jar', | ||
| 'command' => "Import-Module BitsTransfer; Start-BitsTransfer -Source http://artifactory/artifactory/libs-release-local/myapp/test.jar -Destination /somewhere" | ||
| ) } | ||
| end | ||
|
|
||
| context "Windows OS: install_path, source_file, layout provided, filename, base_path no repo" do | ||
| let :facts do{ | ||
| :osfamily => 'windows' | ||
| }end | ||
| let(:params) { { | ||
| :install_path => '/somewhere', | ||
| :source_file => 'test.jar', | ||
| :layout => 'myapp', | ||
| :filename => 'downloaded.jar', | ||
| :base_path => 'http://myhost/myrepository', | ||
| } } | ||
|
|
||
| it { should contain_exec('artifactory_fetch_myproject').with( | ||
| 'creates' => '/somewhere/downloaded.jar', | ||
| 'command' => "Import-Module BitsTransfer; Start-BitsTransfer -Source http://myhost/myrepository/libs-release-local/myapp/test.jar -Destination /somewhere" | ||
| ) } | ||
| end | ||
|
|
||
| context "Windows OS: all parameters" do | ||
| let :facts do{ | ||
| :osfamily => 'windows' | ||
| }end | ||
| let(:params) { { | ||
| :install_path => '/somewhere', | ||
| :source_file => 'test.jar', | ||
| :layout => 'myapp', | ||
| :filename => 'downloaded.jar', | ||
| :base_path => 'http://myhost/myrepository', | ||
| :repo => 'mysimple', | ||
| } } | ||
|
|
||
| it { should contain_exec('artifactory_fetch_myproject').with( | ||
| 'creates' => '/somewhere/downloaded.jar', | ||
| 'command' => "Import-Module BitsTransfer; Start-BitsTransfer -Source http://myhost/myrepository/mysimple/myapp/test.jar -Destination /somewhere" | ||
| ) } | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puppet 4 is unhappy with assigning strings to an empty value - why the change on these?