-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make community site interaction into a plugin
This makes it possible to release to any combination of upload destinations, e.g. for someone who's ready to tag a release in GitHub, but doesn't necessarily want to do a community site upload.
- Loading branch information
1 parent
81c78fd
commit d601a32
Showing
8 changed files
with
95 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 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 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,40 @@ | ||
Feature: Community | ||
Background: | ||
* the Stove config is empty | ||
* the CLI options are all off | ||
* I have a cookbook named "bacon" | ||
* I am using the community server | ||
|
||
Scenario: When the configuration does not exist | ||
* I run `bake --upload --community` | ||
* it should fail with "configuration for the Chef community site does not exist" | ||
|
||
Scenario: When the username does not exist | ||
* the Stove config at "community._" is "" | ||
* I run `bake --upload --community` | ||
* it should fail with "does not contain a username" | ||
|
||
Scenario: When the key does not exist | ||
* the Stove config at "community.username" is "bobo" | ||
* I run `bake --upload --community` | ||
* it should fail with "does not contain a key" | ||
|
||
Scenario: When the category does not exist | ||
* the Stove config at "community.username" is "bobo" | ||
* the Stove config at "community.key" is "../../features/support/stove.pem" | ||
* I run `bake --upload --community` | ||
* it should fail with "You did not specify a category" | ||
|
||
Scenario: In isolation | ||
* the Stove config at "community.username" is "bobo" | ||
* the Stove config at "community.key" is "../../features/support/stove.pem" | ||
* the community server has the cookbook: | ||
| bacon | 1.2.3 | Application | | ||
* I successfully run `bake --upload --community` | ||
|
||
Scenario: When the community plugin is explicitly disabled | ||
* the Stove config at "community.username" is "bobo" | ||
* the Stove config at "community.key" is "../../features/support/stove.pem" | ||
* I successfully run `bake --upload --no-community` | ||
* the community server will not have the cookbook: | ||
| bacon | | | |
This file contains 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 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 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 |
---|---|---|
@@ -1,27 +1,11 @@ | ||
module Stove | ||
class Action::Upload < Action::Base | ||
id 'upload' | ||
description 'Upload the cookbook to the community site' | ||
|
||
validate(:configuration) do | ||
Config.has_key?(:community) | ||
end | ||
|
||
validate(:username) do | ||
Config[:community].has_key?(:username) | ||
end | ||
|
||
validate(:key) do | ||
Config[:community].has_key?(:key) | ||
end | ||
|
||
validate(:category) do | ||
!cookbook.category.nil? | ||
end | ||
description 'Publish the release to enabled plugin destinations' | ||
|
||
def run | ||
log.info('Uploading to the Chef community site') | ||
Community.upload(cookbook) | ||
log.debug('Running upload hooks...') | ||
log.info('Done!') | ||
end | ||
end | ||
end |
This file contains 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,26 @@ | ||
module Stove | ||
class Plugin::Community < Plugin::Base | ||
id 'community' | ||
description 'Publish the release to the Chef community site' | ||
|
||
validate(:configuration) do | ||
Config.has_key?(:community) | ||
end | ||
|
||
validate(:username) do | ||
Config[:community].has_key?(:username) | ||
end | ||
|
||
validate(:key) do | ||
Config[:community].has_key?(:key) | ||
end | ||
|
||
validate(:category) do | ||
!cookbook.category.nil? | ||
end | ||
|
||
after(:upload, 'Publishing the release to the Chef community site') do | ||
Community.upload(cookbook) | ||
end | ||
end | ||
end |
This file contains 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