Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Merge pull request #297 from bluebosh/PR292
Browse files Browse the repository at this point in the history
Support fissile build packages from final BOSH release and update docs
  • Loading branch information
Vlad Iovanov authored Nov 15, 2017
2 parents afc2831 + 377d739 commit eabeb9d
Show file tree
Hide file tree
Showing 42 changed files with 829 additions and 420 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

![fissile-logo](./docs/fissile-logo.png)

Fissile converts existing [BOSH] dev releases into docker images.
Fissile converts existing [BOSH] final or dev releases into docker images.

It does this using just the releases, without a BOSH deployment, CPIs, or a BOSH
agent.
Expand Down
56 changes: 47 additions & 9 deletions app/fissile.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewFissileApplication(version string, ui *termui.UI) *Fissile {
}
}

// ListPackages will list all BOSH packages within a list of dev releases
// ListPackages will list all BOSH packages within a list of releases
func (f *Fissile) ListPackages(verbose bool) error {
if len(f.releases) == 0 {
return fmt.Errorf("Releases not loaded")
Expand Down Expand Up @@ -90,7 +90,7 @@ func (f *Fissile) ListPackages(verbose bool) error {
return nil
}

// ListJobs will list all jobs within a list of dev releases
// ListJobs will list all jobs within a list of releases
func (f *Fissile) ListJobs(verbose bool) error {
if len(f.releases) == 0 {
return fmt.Errorf("Releases not loaded")
Expand Down Expand Up @@ -128,7 +128,7 @@ func (f *Fissile) ListJobs(verbose bool) error {
return nil
}

// ListProperties will list all properties in all jobs within a list of dev releases
// ListProperties will list all properties in all jobs within a list of releases
func (f *Fissile) ListProperties(outputFormat OutputFormat) error {
if len(f.releases) == 0 {
return fmt.Errorf("Releases not loaded")
Expand Down Expand Up @@ -190,7 +190,7 @@ func (f *Fissile) SerializeReleases() (map[string]interface{}, error) {
return releases, nil
}

// SerializeJobs will return all of the jobs within the dev releases, keyed by fingerprint
// SerializeJobs will return all of the jobs within the releases, keyed by fingerprint
func (f *Fissile) SerializeJobs() (map[string]interface{}, error) {
if len(f.releases) == 0 {
return nil, fmt.Errorf("Releases not loaded")
Expand Down Expand Up @@ -324,7 +324,7 @@ func (f *Fissile) Compile(stemcellImageName string, targetPath, roleManifestPath
return err
}

f.UI.Println(color.GreenString("Compiling packages for dev releases:"))
f.UI.Println(color.GreenString("Compiling packages for releases:"))
for _, release := range releases {
f.UI.Printf(" %s (%s)\n", color.YellowString(release.Name), color.MagentaString(release.Version))
}
Expand Down Expand Up @@ -515,7 +515,7 @@ func (f *Fissile) GeneratePackagesRoleTarball(repository string, roleManifest *m
return nil
}

// GenerateRoleImages generates all role images using dev releases
// GenerateRoleImages generates all role images using releases
func (f *Fissile) GenerateRoleImages(targetPath, registry, organization, repository, stemcellImageName, stemcellImageID, metricsPath string, noBuild, force bool, tagExtra string, roleNames []string, workerCount int, roleManifestPath, compiledPackagesPath, lightManifestPath, darkManifestPath, outputDirectory string) error {
if len(f.releases) == 0 {
return fmt.Errorf("Releases not loaded")
Expand Down Expand Up @@ -681,9 +681,19 @@ func (f *Fissile) LoadReleases(releasePaths, releaseNames, releaseVersions []str
releaseVersion = releaseVersions[idx]
}

release, err := model.NewDevRelease(releasePath, releaseName, releaseVersion, cacheDir)
if err != nil {
return fmt.Errorf("Error loading release information: %s", err.Error())
var release *model.Release
var err error
if _, err = isFinalReleasePath(releasePath); err == nil {
// For final releases, only can use release name and version defined in release.MF, cannot specify them through flags.
release, err = model.NewFinalRelease(releasePath)
if err != nil {
return fmt.Errorf("Error loading final release information: %s", err.Error())
}
} else {
release, err = model.NewDevRelease(releasePath, releaseName, releaseVersion, cacheDir)
if err != nil {
return fmt.Errorf("Error loading dev release information: %s", err.Error())
}
}

releases[idx] = release
Expand All @@ -694,6 +704,34 @@ func (f *Fissile) LoadReleases(releasePaths, releaseNames, releaseVersions []str
return nil
}

func isFinalReleasePath(releasePath string) (bool, error) {
if err := util.ValidatePath(releasePath, true, "release directory"); err != nil {
return false, err
}

if err := util.ValidatePath(filepath.Join(releasePath, "release.MF"), false, "release 'release.MF' file"); err != nil {
return false, err
}

if err := util.ValidatePath(filepath.Join(releasePath, "dev_releases"), true, "release 'dev_releases' file"); err == nil {
return false, err
}

if err := util.ValidatePath(filepath.Join(releasePath, "jobs"), true, "release 'jobs' directory"); err != nil {
return false, err
}

if err := util.ValidatePath(filepath.Join(releasePath, "packages"), true, "release 'packages' directory"); err != nil {
return false, err
}

if err := util.ValidatePath(filepath.Join(releasePath, "LICENSE"), false, "release 'LICENSE' file"); err != nil {
return false, err
}

return true, nil
}

// getReleasesByName returns all named releases, or all releases if no names are given
func (f *Fissile) getReleasesByName(releaseNames []string) ([]*model.Release, error) {
if len(releaseNames) == 0 {
Expand Down
8 changes: 4 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var RootCmd = &cobra.Command{
Use: "fissile",
Short: "The BOSH disintegrator",
Long: `
Fissile converts existing BOSH dev releases into docker images.
Fissile converts existing BOSH final or dev releases into docker images.
It does this using just the releases, without a BOSH deployment, CPIs, or a BOSH
agent.
Expand Down Expand Up @@ -96,23 +96,23 @@ func init() {
"release",
"r",
"",
"Path to dev BOSH release(s).",
"Path to final or dev BOSH release(s).",
)

// We can't use slices here because of https://github.com/spf13/viper/issues/112
RootCmd.PersistentFlags().StringP(
"release-name",
"n",
"",
"Name of a dev BOSH release; if empty, default configured dev release name will be used",
"Name of a dev BOSH release; if empty, default configured dev release name will be used; Final release always use the name in release.MF",
)

// We can't use slices here because of https://github.com/spf13/viper/issues/112
RootCmd.PersistentFlags().StringP(
"release-version",
"v",
"",
"Version of a dev BOSH release; if empty, the latest dev release will be used",
"Version of a dev BOSH release; if empty, the latest dev release will be used; Final release always use the version in release.MF",
)

RootCmd.PersistentFlags().StringP(
Expand Down
6 changes: 2 additions & 4 deletions docs/generated/fissile.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The BOSH disintegrator



Fissile converts existing BOSH dev releases into docker images.
Fissile converts existing BOSH final or dev releases into docker images.

It does this using just the releases, without a BOSH deployment, CPIs, or a BOSH
agent.
Expand All @@ -19,9 +19,7 @@ agent.
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -42,4 +40,4 @@ agent.
* [fissile show](fissile_show.md) - Has subcommands that display information about build artifacts.
* [fissile version](fissile_version.md) - Displays fissile's version.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
4 changes: 1 addition & 3 deletions docs/generated/fissile_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Has subcommands to build all images and necessary artifacts.
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -38,4 +36,4 @@ Has subcommands to build all images and necessary artifacts.
* [fissile build kube](fissile_build_kube.md) - Creates Kubernetes configuration files.
* [fissile build packages](fissile_build_packages.md) - Builds BOSH packages in a Docker container.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
4 changes: 1 addition & 3 deletions docs/generated/fissile_build_cleancache.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ fissile build cleancache
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -39,4 +37,4 @@ fissile build cleancache
### SEE ALSO
* [fissile build](fissile_build.md) - Has subcommands to build all images and necessary artifacts.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
5 changes: 1 addition & 4 deletions docs/generated/fissile_build_helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fissile build helm
```
-D, --defaults-file string Env files that contain defaults for the configuration variables
--output-dir string Helm chart files will be written to this directory (default ".")
--tag-extra string Additional information to use in computing the image tags
--use-memory-limits Include memory limits when generating helm chart (default true)
```

Expand All @@ -27,9 +26,7 @@ fissile build helm
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -46,4 +43,4 @@ fissile build helm
### SEE ALSO
* [fissile build](fissile_build.md) - Has subcommands to build all images and necessary artifacts.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
5 changes: 1 addition & 4 deletions docs/generated/fissile_build_images.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ fissile build images
--roles string Build only images with the given role name; comma separated.
-s, --stemcell string The source stemcell
--stemcell-id string Docker image ID for the stemcell (intended for CI)
--tag-extra string Additional information to use in computing the image tags
```

### Options inherited from parent commands
Expand All @@ -49,9 +48,7 @@ fissile build images
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -68,4 +65,4 @@ fissile build images
### SEE ALSO
* [fissile build](fissile_build.md) - Has subcommands to build all images and necessary artifacts.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
5 changes: 1 addition & 4 deletions docs/generated/fissile_build_kube.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ fissile build kube
```
-D, --defaults-file string Env files that contain defaults for the parameters generated by kube
--output-dir string Kubernetes configuration files will be written to this directory (default ".")
--tag-extra string Additional information to use in computing the image tags
--use-memory-limits Include memory limits when generating kube configurations (default true)
```

Expand All @@ -27,9 +26,7 @@ fissile build kube
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -46,4 +43,4 @@ fissile build kube
### SEE ALSO
* [fissile build](fissile_build.md) - Has subcommands to build all images and necessary artifacts.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
4 changes: 1 addition & 3 deletions docs/generated/fissile_build_packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ fissile build packages
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -61,4 +59,4 @@ fissile build packages
### SEE ALSO
* [fissile build](fissile_build.md) - Has subcommands to build all images and necessary artifacts.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
4 changes: 1 addition & 3 deletions docs/generated/fissile_diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ fissile diff
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -41,4 +39,4 @@ fissile diff
### SEE ALSO
* [fissile](fissile.md) - The BOSH disintegrator

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
4 changes: 1 addition & 3 deletions docs/generated/fissile_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ Has subcommands to create documentation for fissile.
--config string config file (default is $HOME/.fissile.yaml)
-d, --dark-opinions string Path to a BOSH deployment manifest file that contains properties that should not have opinionated defaults.
--docker-organization string Docker organization used when referencing image names
--docker-password string Password for authenticated docker registry
--docker-registry string Docker registry used when referencing image names
--docker-username string Username for authenticated docker registry
-l, --light-opinions string Path to a BOSH deployment manifest file that contains properties to be used as defaults.
-M, --metrics string Path to a CSV file to store timing metrics into.
-o, --output string Choose output format, one of human, json, or yaml (currently only for 'show properties') (default "human")
Expand All @@ -36,4 +34,4 @@ Has subcommands to create documentation for fissile.
* [fissile docs man](fissile_docs_man.md) - Generates man pages for fissile.
* [fissile docs markdown](fissile_docs_markdown.md) - Generates markdown documentation for fissile.

###### Auto generated by spf13/cobra on 20-Oct-2017
###### Auto generated by spf13/cobra on 12-Nov-2017
Loading

0 comments on commit eabeb9d

Please sign in to comment.