Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stack association to buildpack model [#153256959]
- Add "stack" to buildpack model - At migration time, stacks.yml will be read (location from STACKS_YML env var) to determine what stack should be assigned to existing buildpacks - Buildpacks are now unique over name AND stack - Sets buildpack stack from manifest.yml in buildpack zip on creation - Validate buildpack model stack against stack in buildpack zip manifest.yml - Validate stack exists upon buildpack bits upload - Include stack name in serialized buildpack filename - Only provide buildpacks for the relevant stack to the staging container - Handle buildpack stacks appropriately in the buildpack installer NOTE: The API checkshum has changed due to adding stack as an input Signed-off-by: Dave Goddard <dave@goddard.id.au> Signed-off-by: Victoria Henry <vhenry@pivotal.io> Signed-off-by: Jackson Feeny <jacksonfeeny@gmail.com> Signed-off-by: Sam Coward <scoward@pivotal.io> Signed-off-by: Dave Goddard <dave@goddard.id.au> Signed-off-by: Sam Coward <scoward@pivotal.io>
- Loading branch information
Showing
27 changed files
with
545 additions
and
130 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
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,17 @@ | ||
module CloudController | ||
module Presenters | ||
module V2 | ||
class BuildpackPresenter < DefaultPresenter | ||
extend PresenterProvider | ||
|
||
present_for_class 'VCAP::CloudController::Buildpack' | ||
|
||
def entity_hash(controller, buildpack, opts, depth, parents, orphans=nil) | ||
entity = super | ||
entity['filename'] = "#{buildpack.filename} (#{buildpack.stack})".strip | ||
entity | ||
end | ||
end | ||
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
30 changes: 30 additions & 0 deletions
30
db/migrations/20180102183100_add_stack_to_buildpack_table.rb
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,30 @@ | ||
require 'yaml' | ||
|
||
def default_stack | ||
stacks_yml_path = ENV.fetch('STACKS_YML', nil) | ||
YAML.safe_load(File.read(stacks_yml_path))['default'] if stacks_yml_path && File.exist?(stacks_yml_path) | ||
end | ||
|
||
Sequel.migration do | ||
up do | ||
alter_table(:buildpacks) do | ||
add_column :stack, String, size: 255, null: true | ||
drop_index :name, unique: true | ||
add_index [:name, :stack], unique: true, name: :unique_name_and_stack | ||
end | ||
|
||
self['UPDATE buildpacks SET stack = ?', default_stack || 'unknown'].update | ||
|
||
alter_table(:buildpacks) do | ||
set_column_not_null :stack | ||
end | ||
end | ||
|
||
down do | ||
alter_table(:buildpacks) do | ||
drop_index [:name, :stack], unique: true | ||
drop_column :stack | ||
add_index :name, unique: true, name: :unique_name | ||
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
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
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
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,14 +1,15 @@ | ||
require 'zip' | ||
|
||
module TestZip | ||
def self.create(zip_name, file_count, file_size=1024) | ||
files = [] | ||
file_count.times do |i| | ||
tf = Tempfile.new("ziptest_#{i}") | ||
files << tf | ||
tf.write('A' * file_size) | ||
tf.close | ||
end | ||
def self.create(zip_name, file_count, file_size=1024, &blk) | ||
Zip::File.open(zip_name, Zip::File::CREATE) do |zipfile| | ||
file_count.times do |i| | ||
zipfile.get_output_stream("ziptest_#{i}") do |f| | ||
f.write('A' * file_size) | ||
end | ||
end | ||
|
||
child = POSIX::Spawn::Child.new('zip', zip_name, *files.map(&:path)) | ||
child.status.exitstatus == 0 || raise("Failed zipping:\n#{child.err}\n#{child.out}") | ||
blk.call(zipfile) if blk | ||
end | ||
end | ||
end |
Oops, something went wrong.