Class: Chef::Knife::ArtifactoryShare
- Inherits:
-
Knife::SupermarketShare
- Object
- Knife::SupermarketShare
- Chef::Knife::ArtifactoryShare
- Defined in:
- lib/chef/knife/artifactory_share.rb
Instance Method Summary collapse
-
#cookbook_version ⇒ String?
Version of cookbook present in cookbook path or nil if no coobook versions exist locally.
-
#cookbook_versions_in_artifactory ⇒ Array<String>
Versions in artifactory.
- #orig_do_upload ⇒ Object
- #orig_get_category ⇒ Object
- #orig_run ⇒ Object
- #run ⇒ Object
Instance Method Details
#cookbook_version ⇒ String?
Returns version of cookbook present in cookbook path or nil if no coobook versions exist locally.
81 82 83 84 85 86 87 |
# File 'lib/chef/knife/artifactory_share.rb', line 81 def cookbook_version cl = Chef::CookbookLoader.new(cookbook_path) if cl.cookbook_exists?(cookbook_name) cookbook = cl[cookbook_name] cookbook.version end end |
#cookbook_versions_in_artifactory ⇒ Array<String>
Returns versions in artifactory.
61 62 63 64 65 66 |
# File 'lib/chef/knife/artifactory_share.rb', line 61 def cookbook_versions_in_artifactory return [] if cookbook_name.nil? data = noauth_rest.get("#{supermarket_uri}/cookbooks/#{cookbook_name}") data["metrics"]["downloads"]["versions"].keys end |
#orig_do_upload ⇒ Object
32 |
# File 'lib/chef/knife/artifactory_share.rb', line 32 alias_method :orig_do_upload, :do_upload |
#orig_get_category ⇒ Object
31 |
# File 'lib/chef/knife/artifactory_share.rb', line 31 alias_method :orig_get_category, :get_category |
#orig_run ⇒ Object
30 |
# File 'lib/chef/knife/artifactory_share.rb', line 30 alias_method :orig_run, :run |
#run ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/chef/knife/artifactory_share.rb', line 34 def run # I'm forced to use threadlocal until we find a better solution... can't really find a way to pass configuration # down to the Chef::CookbookUploader, Chef::ServerAPI, Chef::HTTP or Chef::HTTP::Authenticator # (which are created one after another starting) with CookbookUploader to make it skip the signing key verification. # Can make the authenticator skip by passing load_signing_key(nil, nil) and opts[:sign_request] => false Thread.current[:artifactory_deploy] = "yes" # Send artifactory deploy flag to super config[:artifactory_deploy] = true Chef::Log.debug("[KNIFE-ART] running site share with config: #{config}") if !overwrite_cookbook? && cookbook_versions_in_artifactory.include?(cookbook_version) ui.info("Cookbook version already exists, skipping upload.") exit(0) end orig_run ensure # always cleanup threadlocal Thread.current[:artifactory_deploy] = nil end |