Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions TILE_AUTHOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,43 @@ The property definition in [releen/hello-tile/properties/hello.yml](https://gith
in referenced in `base.yml` using `$( property "port" )`.
Most other product template part functions behave similarly.

### Carvel / Kubernetes Tile Metadata (`base.yml`)

When building Carvel/Kubernetes tiles using `kiln carvel bake`, the `base.yml` metadata file supports the following additional top-level fields:

- `supports_parallel_deploys` (boolean): Indicates whether the tile supports parallel deployments in Ops Manager.
- `requires_product_versions` (list): Specifies product version dependencies required by the tile.
- `name`: Product name.
- `version`: Version requirement constraint (e.g. `>=1.0.0`).
- `optional` (boolean): Whether the dependency is optional.
- `compatible_kubernetes_distributions` (list): Supported Kubernetes distribution criteria.
- `name`: Distribution name (e.g. `k0s`).
- `version`: Version requirement constraint (e.g. `>0.0.0`).
- `package_installs` (list): References to Carvel package install templates.

Example Carvel tile `base.yml`:

```yaml
name: k8s-tile-name
label: "My K8s Tile"
icon_image: $( icon )
metadata_version: "3.2.0"
minimum_version_for_upgrade: 0.0.0
product_version: $( version )
rank: 1
serial: false
supports_parallel_deploys: true
requires_product_versions:
- name: some-other-product
version: ">=1.0.0"
optional: true
compatible_kubernetes_distributions:
- name: k0s
version: ">0.0.0"
package_installs:
- $( package "my-package" )
```
## <a id="bosh-release-tarballs"></a> Managing BOSH Release Tarballs
`kiln fetch` downloads BOSH Release Tarballs from any of the following "sources"
Expand Down
5 changes: 5 additions & 0 deletions internal/acceptance/carvel/fixtures/sample-tile/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ package_installs:
compatible_kubernetes_distributions:
- name: k0s
version: '>0.0.0'
supports_parallel_deploys: true
requires_product_versions:
- name: some-other-product
version: '>=1.0.0'
optional: true
2 changes: 2 additions & 0 deletions internal/carvel/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,8 @@ func (b *baker) generateBaseYaml() error {
meta.Rank = b.metadata.Rank
meta.Serial = b.metadata.Serial
meta.CompatibleKubernetesDistributions = b.metadata.CompatibleKubernetesDistributions
meta.SupportsParallelDeploys = b.metadata.SupportsParallelDeploys
meta.RequiresProductVersions = b.metadata.RequiresProductVersions
meta.FormTypes = b.metadata.FormTypes
meta.PropertyBlueprints = b.metadata.PropertyBlueprints
meta.Variables = b.metadata.Variables
Expand Down
47 changes: 47 additions & 0 deletions internal/carvel/baker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ consumes:
Expect(outMeta.CompatibleKubernetesDistributions[0].Name).To(Equal("k0s"))
Expect(outMeta.CompatibleKubernetesDistributions[0].Version).To(Equal(">0.0.0"))
Expect(outMeta.RequiresKubernetes).To(BeTrue())
Expect(outMeta.SupportsParallelDeploys).To(BeTrue())
Expect(outMeta.RequiresProductVersions).To(HaveLen(1))
Expect(outMeta.RequiresProductVersions[0].Name).To(Equal("some-other-product"))
Expect(outMeta.RequiresProductVersions[0].Version).To(Equal(">=1.0.0"))
Expect(outMeta.RequiresProductVersions[0].Optional).To(BeTrue())
})
It("creates empty instance_group and jobs directories", func() {
Expect(filepath.Join(outputPath, "instance_groups")).To(BeADirectory())
Expand Down Expand Up @@ -553,6 +558,48 @@ consumes:
Expect(err.Error()).To(ContainSubstring("tile metadata_version too old"))
})
})

When("the tile does not set parallel deploys or product version requirements", func() {
BeforeEach(func() {
m := models.Metadata{
Name: "k8s-tile-test",
Label: "test tile",
IconImage: "$( icon )",
MetadataVersion: "3.2.0",
MinimumVersionForUpgrade: "0.0.0",
ProductVersion: "$( version )",
Rank: 1,
Serial: false,
PropertyBlueprints: []string{
`$( property "database_name" )`,
`$( property "admin_password" )`,
},
FormTypes: []string{`$( form "db_props" )`},
Variables: []proofing.Variable{},
PackageInstalls: []string{`$( package "test-install" )`},
}
yamlData, err := yaml.Marshal(&m)
Expect(err).NotTo(HaveOccurred())
err = os.WriteFile(path.Join(inputPath, "base.yml"), yamlData, 0644) // 0644 sets file permissions
Expect(err).NotTo(HaveOccurred())
})

It("omits both fields from the generated base.yml", func() {
Expect(err).NotTo(HaveOccurred())

yamlPath := path.Join(outputPath, "base.yml")
rawYaml, err := os.ReadFile(yamlPath)
Expect(err).NotTo(HaveOccurred())
Expect(string(rawYaml)).NotTo(ContainSubstring("supports_parallel_deploys"))
Expect(string(rawYaml)).NotTo(ContainSubstring("requires_product_versions"))

outMeta := models.MetadataOut{}
err = yaml.Unmarshal(rawYaml, &outMeta)
Expect(err).NotTo(HaveOccurred())
Expect(outMeta.SupportsParallelDeploys).To(BeFalse())
Expect(outMeta.RequiresProductVersions).To(BeEmpty())
})
})
})
})

Expand Down
28 changes: 15 additions & 13 deletions internal/carvel/models/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package models
import "github.com/pivotal-cf/kiln/pkg/proofing"

type Metadata struct {
Name string `yaml:"name"`
ProductVersion string `yaml:"product_version"`
IconImage string `yaml:"icon_image"`
Label string `yaml:"label"`
MetadataVersion string `yaml:"metadata_version"`
MinimumVersionForUpgrade string `yaml:"minimum_version_for_upgrade"`
Rank int `yaml:"rank"`
Serial bool `yaml:"serial"`
PropertyBlueprints []string `yaml:"property_blueprints"`
FormTypes []string `yaml:"form_types"`
Variables []proofing.Variable `yaml:"variables"`
PackageInstalls []string `yaml:"package_installs"`
CompatibleKubernetesDistributions []ProductVersion `yaml:"compatible_kubernetes_distributions,omitempty"`
Name string `yaml:"name"`
ProductVersion string `yaml:"product_version"`
IconImage string `yaml:"icon_image"`
Label string `yaml:"label"`
MetadataVersion string `yaml:"metadata_version"`
MinimumVersionForUpgrade string `yaml:"minimum_version_for_upgrade"`
Rank int `yaml:"rank"`
Serial bool `yaml:"serial"`
PropertyBlueprints []string `yaml:"property_blueprints"`
FormTypes []string `yaml:"form_types"`
Variables []proofing.Variable `yaml:"variables"`
PackageInstalls []string `yaml:"package_installs"`
CompatibleKubernetesDistributions []ProductVersion `yaml:"compatible_kubernetes_distributions,omitempty"`
SupportsParallelDeploys bool `yaml:"supports_parallel_deploys,omitempty"`
RequiresProductVersions []RequiredProductVersion `yaml:"requires_product_versions,omitempty"`
}
42 changes: 25 additions & 17 deletions internal/carvel/models/metadata_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@ package models
import "github.com/pivotal-cf/kiln/pkg/proofing"

type MetadataOut struct {
Name string `yaml:"name"`
ProductVersion string `yaml:"product_version"`
IconImage string `yaml:"icon_image"`
Label string `yaml:"label"`
MetadataVersion string `yaml:"metadata_version"`
MinimumVersionForUpgrade string `yaml:"minimum_version_for_upgrade"`
Rank int `yaml:"rank"`
Serial bool `yaml:"serial"`
PropertyBlueprints []string `yaml:"property_blueprints"`
FormTypes []string `yaml:"form_types"`
Variables []proofing.Variable `yaml:"variables"`
InstanceGroups []string `yaml:"job_types"`
StemcellCriteria StemcellCriteria `yaml:"stemcell_criteria"`
Releases []string `yaml:"releases"`
RuntimeConfigs []string `yaml:"runtime_configs"`
RequiresKubernetes bool `yaml:"requires_kubernetes"`
CompatibleKubernetesDistributions []ProductVersion `yaml:"compatible_kubernetes_distributions"`
Name string `yaml:"name"`
ProductVersion string `yaml:"product_version"`
IconImage string `yaml:"icon_image"`
Label string `yaml:"label"`
MetadataVersion string `yaml:"metadata_version"`
MinimumVersionForUpgrade string `yaml:"minimum_version_for_upgrade"`
Rank int `yaml:"rank"`
Serial bool `yaml:"serial"`
PropertyBlueprints []string `yaml:"property_blueprints"`
FormTypes []string `yaml:"form_types"`
Variables []proofing.Variable `yaml:"variables"`
InstanceGroups []string `yaml:"job_types"`
StemcellCriteria StemcellCriteria `yaml:"stemcell_criteria"`
Releases []string `yaml:"releases"`
RuntimeConfigs []string `yaml:"runtime_configs"`
RequiresKubernetes bool `yaml:"requires_kubernetes"`
CompatibleKubernetesDistributions []ProductVersion `yaml:"compatible_kubernetes_distributions"`
SupportsParallelDeploys bool `yaml:"supports_parallel_deploys,omitempty"`
RequiresProductVersions []RequiredProductVersion `yaml:"requires_product_versions,omitempty"`
}

type StemcellCriteria struct {
Expand All @@ -31,3 +33,9 @@ type ProductVersion struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
}

type RequiredProductVersion struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Optional bool `yaml:"optional,omitempty"`
}
5 changes: 5 additions & 0 deletions internal/carvel/testdata/sample-tile/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ package_installs:
compatible_kubernetes_distributions:
- name: k0s
version: '>0.0.0'
supports_parallel_deploys: true
requires_product_versions:
- name: some-other-product
version: '>=1.0.0'
optional: true
Loading