Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Levine <stephen.levine@gmail.com>
  • Loading branch information
sclevine committed Aug 7, 2019
1 parent 0c0328b commit a13fe0a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 31 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ imports:
$(GOCMD) install -mod=vendor golang.org/x/tools/cmd/goimports
test -z $$(goimports -l -w -local github.com/buildpack/lifecycle $$(find . -type f -name '*.go' -not -path "./vendor/*"))

tools:
$(GOCMD) install -mod=vendor github.com/sclevine/yj

format:
test -z $$($(GOCMD) fmt ./...)

Expand All @@ -32,10 +35,10 @@ vet:

test: unit acceptance

unit: format imports vet
unit: format imports tools vet
$(GOTEST) -v -count=1 ./...

acceptance: format imports vet
acceptance: format imports tools vet
$(GOTEST) -v -count=1 -tags=acceptance ./acceptance/...

clean:
Expand Down
2 changes: 1 addition & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type LaunchTOML struct {

type BOMEntry struct {
Require
Buildpack Buildpack `toml:"buildpack"`
Buildpack Buildpack `toml:"buildpack" json:"buildpack"`
}

type BuildMetadata struct {
Expand Down
12 changes: 6 additions & 6 deletions detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const (
var ErrFail = errors.New("detection failed")

type Buildpack struct {
ID string `toml:"id"`
Version string `toml:"version"`
Optional bool `toml:"optional,omitempty"`
ID string `toml:"id" json:"id"`
Version string `toml:"version" json:"version"`
Optional bool `toml:"optional,omitempty" json:"optional,omitempty"`
}

func (bp Buildpack) dir() string {
Expand Down Expand Up @@ -59,9 +59,9 @@ func (be BuildPlanEntry) noOpt() BuildPlanEntry {
}

type Require struct {
Name string `toml:"name"`
Version string `toml:"version"`
Metadata map[string]interface{} `toml:"metadata"`
Name string `toml:"name" json:"name"`
Version string `toml:"version" json:"version"`
Metadata map[string]interface{} `toml:"metadata" json:"metadata"`
}

type Provide struct {
Expand Down
5 changes: 2 additions & 3 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,16 @@ func (e *Exporter) addBuildMetadataLabel(image imgutil.Image, plan []BOMEntry, l
})
}

buildJson, err := json.Marshal(metadata.BuildMetadata{
buildJSON, err := json.Marshal(metadata.BuildMetadata{
BOM: plan,
Buildpacks: bps,
Launcher: launcherMD,
})

if err != nil {
return errors.Wrap(err, "parse build metadata")
}

if err := image.SetLabel(metadata.BuildMetadataLabel, string(buildJson)); err != nil {
if err := image.SetLabel(metadata.BuildMetadataLabel, string(buildJSON)); err != nil {
return errors.Wrap(err, "set build image metadata label")
}

Expand Down
45 changes: 26 additions & 19 deletions exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,19 +383,22 @@ func testExporter(t *testing.T, when spec.G, it spec.S) {
it.Before(func() {
err := ioutil.WriteFile(filepath.Join(layersDir, "config", "metadata.toml"), []byte(`
[[processes]]
type = "web"
command = "npm start"
[bom]
[bom.auto-reconfiguration]
version = "2.7.0"
[bom.auto-reconfiguration.metadata]
name = "Spring Auto-reconfiguration"
sha256 = "0d524877db7344ec34620f7e46254053568292f5ce514f74e3a0e9b2dbfc338b"
stacks = ["io.buildpacks.stacks.bionic", "org.cloudfoundry.stacks.cflinuxfs3"]
uri = "https://example.com"
[[bom.auto-reconfiguration.metadata.licenses]]
type = "Apache-2.0"
type = "web"
command = "npm start"
[[bom]]
name = "Spring Auto-reconfiguration"
version = "2.7.0"
[bom.metadata]
sha256 = "0d524877db7344ec34620f7e46254053568292f5ce514f74e3a0e9b2dbfc338b"
stacks = ["io.buildpacks.stacks.bionic", "org.cloudfoundry.stacks.cflinuxfs3"]
uri = "https://example.com"
[bom.buildpack]
id = "buildpack.id"
version = "1.2.3"
[[bom.metadata.licenses]]
type = "Apache-2.0"
`),
os.ModePerm,
)
Expand All @@ -410,25 +413,29 @@ func testExporter(t *testing.T, when spec.G, it spec.S) {

expectedJSON := `
{
"bom": {
"auto-reconfiguration": {
"bom": [
{
"name": "Spring Auto-reconfiguration",
"version": "2.7.0",
"buildpack": {
"id": "buildpack.id",
"version": "1.2.3"
},
"metadata": {
"licenses": [
{
"type": "Apache-2.0"
}
],
"name": "Spring Auto-reconfiguration",
"sha256": "0d524877db7344ec34620f7e46254053568292f5ce514f74e3a0e9b2dbfc338b",
"stacks": [
"io.buildpacks.stacks.bionic",
"org.cloudfoundry.stacks.cflinuxfs3"
],
"uri": "https://example.com"
},
"version": "2.7.0"
}
}
},
],
"buildpacks": [
{
"id": "buildpack.id",
Expand Down

0 comments on commit a13fe0a

Please sign in to comment.