From cf2309ca83e23cc599343b10235de8d36168cfe2 Mon Sep 17 00:00:00 2001 From: Christopher Hunter Date: Fri, 7 Jul 2023 19:01:26 -0400 Subject: [PATCH] feat: always add tile source revision and kiln version to kiln_metadata in product template --- go.mod | 4 +- go.sum | 4 +- internal/acceptance/bake/bake_test.go | 38 +++++--- .../metadata-with-multiple-stemcells.yml | 1 + .../metadata-with-stemcell-criteria.yml | 1 + .../metadata-with-stemcell-tarball.yml | 1 + .../acceptance/workflows/acceptance_test.go | 3 +- internal/acceptance/workflows/hello-tile | 2 +- internal/builder/interpolator.go | 15 +++- internal/builder/kiln_metadata.go | 54 ++++++++++++ internal/builder/kiln_metadata_test.go | 31 +++++++ .../append_kiln_metadata/input_metadata.yml | 83 ++++++++++++++++++ .../append_kiln_metadata/output_metadata.yml | 86 +++++++++++++++++++ .../replace_kiln_metadata/input_metadata.yml | 86 +++++++++++++++++++ .../replace_kiln_metadata/output_metadata.yml | 86 +++++++++++++++++++ internal/commands/bake.go | 3 + internal/commands/test_tile_test.go | 1 - main.go | 6 +- 18 files changed, 486 insertions(+), 19 deletions(-) create mode 100644 internal/builder/kiln_metadata.go create mode 100644 internal/builder/kiln_metadata_test.go create mode 100644 internal/builder/testdata/append_kiln_metadata/input_metadata.yml create mode 100644 internal/builder/testdata/append_kiln_metadata/output_metadata.yml create mode 100644 internal/builder/testdata/replace_kiln_metadata/input_metadata.yml create mode 100644 internal/builder/testdata/replace_kiln_metadata/output_metadata.yml diff --git a/go.mod b/go.mod index 639d924b4..0bffdec33 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/cloudfoundry/bosh-cli v6.4.1+incompatible github.com/cloudfoundry/bosh-utils v0.0.0-20210130100352-ab14c90ad9f2 github.com/cppforlife/go-patch v0.2.0 - github.com/crhntr/yamlutil v0.0.0-20230523004714-d7a84a7a5d64 + github.com/crhntr/yamlutil v0.0.0-20230524174859-4e4388958875 github.com/cucumber/godog v0.12.5 github.com/cucumber/messages-go/v16 v16.0.1 github.com/docker/docker v23.0.0-rc.1+incompatible @@ -149,6 +149,6 @@ require ( ) retract ( - v1.0.0 // Published accidentally v1.0.1 // Using this as a workaround to retract the previous version. See https://github.com/golang/go/issues/60336 where a go maintainer described this workaround. + v1.0.0 // Published accidentally ) diff --git a/go.sum b/go.sum index dad0777b1..6a16e83b1 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ github.com/cppforlife/go-semi-semantic v0.0.0-20160921010311-576b6af77ae4 h1:J+g github.com/cppforlife/go-semi-semantic v0.0.0-20160921010311-576b6af77ae4/go.mod h1:socxpf5+mELPbosI149vWpNlHK6mbfWFxSWOoSndXR8= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/crhntr/yamlutil v0.0.0-20230523004714-d7a84a7a5d64 h1:v9TB0YLlfTV7nZtDt8Amb9ml/udpjSE63P+0qmfK6aA= -github.com/crhntr/yamlutil v0.0.0-20230523004714-d7a84a7a5d64/go.mod h1:ksg8an2nXLcrZReC9jceNV/Wj9OPSrN4YIH3qYRCswo= +github.com/crhntr/yamlutil v0.0.0-20230524174859-4e4388958875 h1:AqLZ3TsDKb96pHcL5/SgUAlq7hM26OKFTFs0E1SozxU= +github.com/crhntr/yamlutil v0.0.0-20230524174859-4e4388958875/go.mod h1:ksg8an2nXLcrZReC9jceNV/Wj9OPSrN4YIH3qYRCswo= github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE= github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw= github.com/cucumber/godog v0.12.5 h1:FZIy6VCfMbmGHts9qd6UjBMT9abctws/pQYO/ZcwOVs= diff --git a/internal/acceptance/bake/bake_test.go b/internal/acceptance/bake/bake_test.go index df2f356e1..37273a0c7 100644 --- a/internal/acceptance/bake/bake_test.go +++ b/internal/acceptance/bake/bake_test.go @@ -12,6 +12,8 @@ import ( "testing" "time" + "github.com/pivotal-cf/kiln/internal/builder" + "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" @@ -20,9 +22,13 @@ import ( . "github.com/pivotal-cf-experimental/gomegamatchers" ) +const ( + buildVersion = "0.0.0-dev.0+acceptance" +) + var ( - pathToMain string - buildVersion string + pathToMain string + tileSourceRevision string ) func TestAcceptance(t *testing.T) { @@ -32,12 +38,12 @@ func TestAcceptance(t *testing.T) { } var _ = BeforeSuite(func() { - buildVersion = fmt.Sprintf("v0.0.0-dev.%d", time.Now().Unix()) - var err error pathToMain, err = gexec.Build("github.com/pivotal-cf/kiln", "--ldflags", fmt.Sprintf("-X main.version=%s", buildVersion)) Expect(err).NotTo(HaveOccurred()) + tileSourceRevision, err = builder.GitMetadataSHA(".", true)() + Expect(err).NotTo(HaveOccurred()) }) var _ = AfterSuite(func() { @@ -147,7 +153,7 @@ var _ = Describe("bake command", func() { metadataContents, err := io.ReadAll(file) Expect(err).NotTo(HaveOccurred()) - renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1, tileSourceRevision) Expect(metadataContents).To(HelpfullyMatchYAML(renderedYAML)) archivedMigration1, err := bakedTile.Open("migrations/v1/201603041539_custom_buildpacks.js") @@ -218,7 +224,7 @@ var _ = Describe("bake command", func() { metadataContents, err := io.ReadAll(file) Expect(err).NotTo(HaveOccurred()) - renderedYAML := fmt.Sprintf(expectedMetadataWithMultipleStemcells, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadataWithMultipleStemcells, cfSHA1, tileSourceRevision) Expect(metadataContents).To(HelpfullyMatchYAML(renderedYAML)) }) }) @@ -261,7 +267,7 @@ var _ = Describe("bake command", func() { metadataContents, err := io.ReadAll(file) Expect(err).NotTo(HaveOccurred()) - renderedYAML := fmt.Sprintf(expectedMetadataWithStemcellTarball, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadataWithStemcellTarball, cfSHA1, tileSourceRevision) Expect(metadataContents).To(HelpfullyMatchYAML(renderedYAML)) }) }) @@ -350,7 +356,7 @@ var _ = Describe("bake command", func() { metadataContents, err := io.ReadAll(file) Expect(err).NotTo(HaveOccurred()) - renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1, tileSourceRevision) Expect(metadataContents).To(HelpfullyMatchYAML(renderedYAML)) archivedMigration1, err := bakedTile.Open("migrations/v1/201603041539_custom_buildpacks.js") @@ -458,7 +464,7 @@ var _ = Describe("bake command", func() { // intervals added to make tests pass. it is taking too long locally Eventually(session, time.Second*10).Should(gexec.Exit(0)) - renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadata, diegoSHA1, cfSHA1, tileSourceRevision) Eventually(session.Out.Contents).Should(HelpfullyMatchYAML(renderedYAML)) }) }) @@ -701,7 +707,7 @@ var _ = Describe("bake command", func() { metadataContents, err := io.ReadAll(file) Expect(err).NotTo(HaveOccurred()) - renderedYAML := fmt.Sprintf(expectedMetadataWithStemcellCriteria, diegoSHA1, cfSHA1) + renderedYAML := fmt.Sprintf(expectedMetadataWithStemcellCriteria, diegoSHA1, cfSHA1, tileSourceRevision) Expect(metadataContents).To(HelpfullyMatchYAML(renderedYAML)) Eventually(session.Err).Should(gbytes.Say("Reading release manifests")) @@ -873,6 +879,9 @@ some_runtime_configs: version: some-addon-version serial: false selected_value: "235" +kiln_metadata: + kiln_version: 0.0.0-dev.0+acceptance + metadata_git_sha: %s ` var expectedMetadataWithStemcellCriteria = `--- @@ -895,6 +904,9 @@ stemcell_criteria: version: 250.21 requires_cpi: false enable_patch_security_updates: true +kiln_metadata: + kiln_version: 0.0.0-dev.0+acceptance + metadata_git_sha: %s ` var expectedMetadataWithMultipleStemcells = `--- @@ -914,6 +926,9 @@ stemcell_criteria: additional_stemcells_criteria: - os: windows version: "2019.4" +kiln_metadata: + kiln_version: 0.0.0-dev.0+acceptance + metadata_git_sha: %s ` var expectedMetadataWithStemcellTarball = `--- @@ -930,4 +945,7 @@ some_releases: stemcell_criteria: os: ubuntu-trusty version: "3215.4" +kiln_metadata: + kiln_version: 0.0.0-dev.0+acceptance + metadata_git_sha: %s ` diff --git a/internal/acceptance/bake/fixtures/metadata-with-multiple-stemcells.yml b/internal/acceptance/bake/fixtures/metadata-with-multiple-stemcells.yml index 044f5054b..126767ef3 100644 --- a/internal/acceptance/bake/fixtures/metadata-with-multiple-stemcells.yml +++ b/internal/acceptance/bake/fixtures/metadata-with-multiple-stemcells.yml @@ -9,3 +9,4 @@ label: Pivotal Elastic Runtime stemcell_criteria: $( stemcell "ubuntu-trusty" ) additional_stemcells_criteria: - $( stemcell "windows" ) +kiln_metadata: {} \ No newline at end of file diff --git a/internal/acceptance/bake/fixtures/metadata-with-stemcell-criteria.yml b/internal/acceptance/bake/fixtures/metadata-with-stemcell-criteria.yml index d537604d4..4e9133cbf 100644 --- a/internal/acceptance/bake/fixtures/metadata-with-stemcell-criteria.yml +++ b/internal/acceptance/bake/fixtures/metadata-with-stemcell-criteria.yml @@ -12,3 +12,4 @@ stemcell_criteria: version: 250.21 requires_cpi: false enable_patch_security_updates: true +kiln_metadata: {} \ No newline at end of file diff --git a/internal/acceptance/bake/fixtures/metadata-with-stemcell-tarball.yml b/internal/acceptance/bake/fixtures/metadata-with-stemcell-tarball.yml index cd41fcf1f..484b7d88a 100644 --- a/internal/acceptance/bake/fixtures/metadata-with-stemcell-tarball.yml +++ b/internal/acceptance/bake/fixtures/metadata-with-stemcell-tarball.yml @@ -7,3 +7,4 @@ icon_img: $( icon ) product_version: $( version ) label: Pivotal Elastic Runtime stemcell_criteria: $( stemcell ) +kiln_metadata: {} \ No newline at end of file diff --git a/internal/acceptance/workflows/acceptance_test.go b/internal/acceptance/workflows/acceptance_test.go index 5021702a9..c87e1d658 100644 --- a/internal/acceptance/workflows/acceptance_test.go +++ b/internal/acceptance/workflows/acceptance_test.go @@ -13,13 +13,14 @@ package workflows import ( "context" - "golang.org/x/exp/slices" "os" "os/exec" "path/filepath" "strings" "testing" + "golang.org/x/exp/slices" + "github.com/cucumber/godog" "github.com/pivotal-cf/kiln/internal/acceptance/workflows/scenario" diff --git a/internal/acceptance/workflows/hello-tile b/internal/acceptance/workflows/hello-tile index 1a3861bea..11847a133 160000 --- a/internal/acceptance/workflows/hello-tile +++ b/internal/acceptance/workflows/hello-tile @@ -1 +1 @@ -Subproject commit 1a3861bea8b89a999cb006221bb22f692cfaa5bd +Subproject commit 11847a13372908555ea13f109d5aa11bbd250924 diff --git a/internal/builder/interpolator.go b/internal/builder/interpolator.go index 1ee226c90..ea5b8d775 100644 --- a/internal/builder/interpolator.go +++ b/internal/builder/interpolator.go @@ -35,6 +35,7 @@ type Interpolator struct{} type InterpolateInput struct { Version string + KilnVersion string BOSHVariables map[string]interface{} Variables map[string]interface{} ReleaseManifests map[string]interface{} @@ -55,6 +56,15 @@ func NewInterpolator() Interpolator { } func (i Interpolator) Interpolate(input InterpolateInput, name string, templateYAML []byte) ([]byte, error) { + var gitMetadataSHA string + if input.MetadataGitSHA != nil { + sha, err := input.MetadataGitSHA() + if err != nil { + return nil, err + } + gitMetadataSHA = sha + } + interpolatedYAML, err := i.interpolate(input, name, templateYAML) if err != nil { return nil, err @@ -65,7 +75,10 @@ func (i Interpolator) Interpolate(input InterpolateInput, name string, templateY return nil, err // un-tested } - return prettyMetadata, nil + return setKilnMetadata(prettyMetadata, KilnMetadata{ + KilnVersion: input.KilnVersion, + MetadataGitSHA: gitMetadataSHA, + }) } func (i Interpolator) functions(input InterpolateInput) template.FuncMap { diff --git a/internal/builder/kiln_metadata.go b/internal/builder/kiln_metadata.go new file mode 100644 index 000000000..ce620fcd9 --- /dev/null +++ b/internal/builder/kiln_metadata.go @@ -0,0 +1,54 @@ +package builder + +import ( + "bytes" + "fmt" + + "github.com/crhntr/yamlutil/yamlnode" + "gopkg.in/yaml.v3" +) + +type KilnMetadata struct { + MetadataGitSHA string `yaml:"metadata_git_sha,omitempty"` + KilnVersion string `yaml:"kiln_version,omitempty"` +} + +func setKilnMetadata(in []byte, kilnMetadata KilnMetadata) ([]byte, error) { + var productTemplate yaml.Node + err := yaml.Unmarshal(in, &productTemplate) + if err != nil { + return nil, fmt.Errorf("failed to parse product template: %w", err) + } + + _, hasMetadataVersionKey := yamlnode.LookupKey(&productTemplate, "metadata_version") + if !hasMetadataVersionKey { + return in, nil + } + + kilnMetadataValueNode, fieldExists := yamlnode.LookupKey(&productTemplate, "kiln_metadata") + if fieldExists { + fmt.Println("WARNING: kiln_metadata is not set by kiln please remove it from your product template") + if err := kilnMetadataValueNode.Encode(kilnMetadata); err != nil { + return nil, err + } + } else { + var productTemplatePartial yaml.Node + if err := productTemplatePartial.Encode(struct { + KilnMetadata KilnMetadata `yaml:"kiln_metadata"` + }{ + KilnMetadata: kilnMetadata, + }); err != nil { + return nil, fmt.Errorf("failed to encode kiln_metadata: %w", err) + } + productTemplate.Content[0].Content = append(productTemplate.Content[0].Content, productTemplatePartial.Content...) + } + + var buf bytes.Buffer + enc := yaml.NewEncoder(&buf) + enc.SetIndent(2) + err = enc.Encode(productTemplate.Content[0]) + if err != nil { + return nil, fmt.Errorf("failed to encode product template: %w", err) + } + return buf.Bytes(), nil +} diff --git a/internal/builder/kiln_metadata_test.go b/internal/builder/kiln_metadata_test.go new file mode 100644 index 000000000..7a8e305c8 --- /dev/null +++ b/internal/builder/kiln_metadata_test.go @@ -0,0 +1,31 @@ +package builder + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func Test_setKilnMetadata(t *testing.T) { + for _, tt := range []struct{ Name string }{ + {Name: "append_kiln_metadata"}, + {Name: "replace_kiln_metadata"}, + } { + t.Run(tt.Name, func(t *testing.T) { + inputMetadataYML, err := os.ReadFile(filepath.Join("testdata", tt.Name, "input_metadata.yml")) + require.NoError(t, err) + outputMetadataYML, err := os.ReadFile(filepath.Join("testdata", tt.Name, "output_metadata.yml")) + require.NoError(t, err) + + result, err := setKilnMetadata(inputMetadataYML, KilnMetadata{ + MetadataGitSHA: "some-commit-sha", + KilnVersion: "some-kiln-version", + }) + require.NoError(t, err) + assert.Equal(t, string(outputMetadataYML), string(result)) + }) + } +} diff --git a/internal/builder/testdata/append_kiln_metadata/input_metadata.yml b/internal/builder/testdata/append_kiln_metadata/input_metadata.yml new file mode 100644 index 000000000..4d32b4daa --- /dev/null +++ b/internal/builder/testdata/append_kiln_metadata/input_metadata.yml @@ -0,0 +1,83 @@ +description: Serves a "Hello World" server. +icon_image: some-image +form_types: [] +job_types: + - description: HTTP Server + dynamic_ip: 0 + instance_definition: + configurable: true + constraints: + max: 1 + min: 0 + default: 1 + label: Instances + name: instances + type: integer + label: Server + max_in_flight: 1 + name: hello-server + resource_definitions: + - configurable: true + constraints: + min: 1024 + default: 1024 + label: RAM + name: ram + type: integer + - configurable: true + constraints: + min: 2000 + default: 4000 + label: Ephemeral Disk + name: ephemeral_disk + type: integer + - configurable: false + constraints: + min: 2000 + default: 4000 + label: Persistent Disk + name: persistent_disk + type: integer + - configurable: true + constraints: + min: 1 + default: 1 + label: CPU + name: cpu + type: integer + resource_label: Server + single_az_only: true + static_ip: 1 + templates: + - manifest: | + job-properties: + port: 8080 + name: hello-server + release: hello-release + - manifest: {} + name: bpm + release: bpm +label: Hello +metadata_version: 2.7.0 +minimum_version_for_upgrade: 0.1.0 +name: hello +product_version: 0.1.2 +property_blueprints: [] +provides_product_versions: + - name: hello + version: 0.1.2 +rank: 90 +releases: + - file: hello-release-v0.1.4-ubuntu-xenial-621.256.tgz + name: hello-release + sha1: c471ac6371eb8fc24508b14d9a49a44f9a5ef98c + version: v0.1.4 + - file: bpm-1.1.18-ubuntu-xenial-621.256.tgz + name: bpm + sha1: 476c516e0644564838c025b165560bb24102fe6f + version: 1.1.18 +runtime_configs: [] +serial: false +stemcell_criteria: + os: ubuntu-xenial + version: "621.256" diff --git a/internal/builder/testdata/append_kiln_metadata/output_metadata.yml b/internal/builder/testdata/append_kiln_metadata/output_metadata.yml new file mode 100644 index 000000000..f029ed4e3 --- /dev/null +++ b/internal/builder/testdata/append_kiln_metadata/output_metadata.yml @@ -0,0 +1,86 @@ +description: Serves a "Hello World" server. +icon_image: some-image +form_types: [] +job_types: + - description: HTTP Server + dynamic_ip: 0 + instance_definition: + configurable: true + constraints: + max: 1 + min: 0 + default: 1 + label: Instances + name: instances + type: integer + label: Server + max_in_flight: 1 + name: hello-server + resource_definitions: + - configurable: true + constraints: + min: 1024 + default: 1024 + label: RAM + name: ram + type: integer + - configurable: true + constraints: + min: 2000 + default: 4000 + label: Ephemeral Disk + name: ephemeral_disk + type: integer + - configurable: false + constraints: + min: 2000 + default: 4000 + label: Persistent Disk + name: persistent_disk + type: integer + - configurable: true + constraints: + min: 1 + default: 1 + label: CPU + name: cpu + type: integer + resource_label: Server + single_az_only: true + static_ip: 1 + templates: + - manifest: | + job-properties: + port: 8080 + name: hello-server + release: hello-release + - manifest: {} + name: bpm + release: bpm +label: Hello +metadata_version: 2.7.0 +minimum_version_for_upgrade: 0.1.0 +name: hello +product_version: 0.1.2 +property_blueprints: [] +provides_product_versions: + - name: hello + version: 0.1.2 +rank: 90 +releases: + - file: hello-release-v0.1.4-ubuntu-xenial-621.256.tgz + name: hello-release + sha1: c471ac6371eb8fc24508b14d9a49a44f9a5ef98c + version: v0.1.4 + - file: bpm-1.1.18-ubuntu-xenial-621.256.tgz + name: bpm + sha1: 476c516e0644564838c025b165560bb24102fe6f + version: 1.1.18 +runtime_configs: [] +serial: false +stemcell_criteria: + os: ubuntu-xenial + version: "621.256" +kiln_metadata: + metadata_git_sha: some-commit-sha + kiln_version: some-kiln-version diff --git a/internal/builder/testdata/replace_kiln_metadata/input_metadata.yml b/internal/builder/testdata/replace_kiln_metadata/input_metadata.yml new file mode 100644 index 000000000..b95a3c76b --- /dev/null +++ b/internal/builder/testdata/replace_kiln_metadata/input_metadata.yml @@ -0,0 +1,86 @@ +description: Serves a "Hello World" server. +icon_image: some-image +form_types: [] +job_types: + - description: HTTP Server + dynamic_ip: 0 + instance_definition: + configurable: true + constraints: + max: 1 + min: 0 + default: 1 + label: Instances + name: instances + type: integer + label: Server + max_in_flight: 1 + name: hello-server + resource_definitions: + - configurable: true + constraints: + min: 1024 + default: 1024 + label: RAM + name: ram + type: integer + - configurable: true + constraints: + min: 2000 + default: 4000 + label: Ephemeral Disk + name: ephemeral_disk + type: integer + - configurable: false + constraints: + min: 2000 + default: 4000 + label: Persistent Disk + name: persistent_disk + type: integer + - configurable: true + constraints: + min: 1 + default: 1 + label: CPU + name: cpu + type: integer + resource_label: Server + single_az_only: true + static_ip: 1 + templates: + - manifest: | + job-properties: + port: 8080 + name: hello-server + release: hello-release + - manifest: {} + name: bpm + release: bpm +kiln_metadata: + metadata_git_sha: peach + kiln_version: orange +label: Hello +metadata_version: 2.7.0 +minimum_version_for_upgrade: 0.1.0 +name: hello +product_version: 0.1.2 +property_blueprints: [] +provides_product_versions: + - name: hello + version: 0.1.2 +rank: 90 +releases: + - file: hello-release-v0.1.4-ubuntu-xenial-621.256.tgz + name: hello-release + sha1: c471ac6371eb8fc24508b14d9a49a44f9a5ef98c + version: v0.1.4 + - file: bpm-1.1.18-ubuntu-xenial-621.256.tgz + name: bpm + sha1: 476c516e0644564838c025b165560bb24102fe6f + version: 1.1.18 +runtime_configs: [] +serial: false +stemcell_criteria: + os: ubuntu-xenial + version: "621.256" diff --git a/internal/builder/testdata/replace_kiln_metadata/output_metadata.yml b/internal/builder/testdata/replace_kiln_metadata/output_metadata.yml new file mode 100644 index 000000000..3deb47241 --- /dev/null +++ b/internal/builder/testdata/replace_kiln_metadata/output_metadata.yml @@ -0,0 +1,86 @@ +description: Serves a "Hello World" server. +icon_image: some-image +form_types: [] +job_types: + - description: HTTP Server + dynamic_ip: 0 + instance_definition: + configurable: true + constraints: + max: 1 + min: 0 + default: 1 + label: Instances + name: instances + type: integer + label: Server + max_in_flight: 1 + name: hello-server + resource_definitions: + - configurable: true + constraints: + min: 1024 + default: 1024 + label: RAM + name: ram + type: integer + - configurable: true + constraints: + min: 2000 + default: 4000 + label: Ephemeral Disk + name: ephemeral_disk + type: integer + - configurable: false + constraints: + min: 2000 + default: 4000 + label: Persistent Disk + name: persistent_disk + type: integer + - configurable: true + constraints: + min: 1 + default: 1 + label: CPU + name: cpu + type: integer + resource_label: Server + single_az_only: true + static_ip: 1 + templates: + - manifest: | + job-properties: + port: 8080 + name: hello-server + release: hello-release + - manifest: {} + name: bpm + release: bpm +kiln_metadata: + metadata_git_sha: some-commit-sha + kiln_version: some-kiln-version +label: Hello +metadata_version: 2.7.0 +minimum_version_for_upgrade: 0.1.0 +name: hello +product_version: 0.1.2 +property_blueprints: [] +provides_product_versions: + - name: hello + version: 0.1.2 +rank: 90 +releases: + - file: hello-release-v0.1.4-ubuntu-xenial-621.256.tgz + name: hello-release + sha1: c471ac6371eb8fc24508b14d9a49a44f9a5ef98c + version: v0.1.4 + - file: bpm-1.1.18-ubuntu-xenial-621.256.tgz + name: bpm + sha1: 476c516e0644564838c025b165560bb24102fe6f + version: 1.1.18 +runtime_configs: [] +serial: false +stemcell_criteria: + os: ubuntu-xenial + version: "621.256" diff --git a/internal/commands/bake.go b/internal/commands/bake.go index 07c389317..98ff59810 100644 --- a/internal/commands/bake.go +++ b/internal/commands/bake.go @@ -141,6 +141,8 @@ type Bake struct { stemcell stemcellService releases fromDirectories + KilnVersion string + boshVariables, forms, instanceGroups, @@ -463,6 +465,7 @@ func (b Bake) Execute(args []string) error { } input := builder.InterpolateInput{ + KilnVersion: b.KilnVersion, Version: b.Options.Version, Variables: templateVariables, BOSHVariables: boshVariables, diff --git a/internal/commands/test_tile_test.go b/internal/commands/test_tile_test.go index 73aa5c3b7..f6fc0075c 100644 --- a/internal/commands/test_tile_test.go +++ b/internal/commands/test_tile_test.go @@ -345,7 +345,6 @@ var _ = Describe("kiln test docker", func() { Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Docker daemon is not running")) }) - }) }) diff --git a/main.go b/main.go index 77d219d33..00a930027 100644 --- a/main.go +++ b/main.go @@ -79,7 +79,11 @@ func main() { commandSet := jhanda.CommandSet{} fetch := commands.NewFetch(outLogger, mrsProvider, localReleaseDirectory) commandSet["fetch"] = fetch - commandSet["bake"] = commands.NewBake(fs, releasesService, outLogger, errLogger, fetch) + + bakeCommand := commands.NewBake(fs, releasesService, outLogger, errLogger, fetch) + bakeCommand.KilnVersion = version + commandSet["bake"] = bakeCommand + mobyClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation()) if err != nil { log.Fatal(err)