Skip to content

Commit

Permalink
Merge pull request #224 from SAP/manifest_fix
Browse files Browse the repository at this point in the history
Manifest fix -
  • Loading branch information
ShimiT authored Feb 4, 2019
2 parents 6e9cc5c + a5bc1ae commit 961f1f7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 13 deletions.
24 changes: 17 additions & 7 deletions internal/artifacts/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,8 @@ func setManifestDesc(ep dir.ITargetArtifacts, targetPathGetter dir.ITargetPath,
return errors.Wrapf(err,
"failed to generate the manifest file when getting the %s module content type", mod.Name)
}
moduleEntry := entry{
EntryName: mod.Name,
EntryPath: getModulePath(mod, targetPathGetter),
ContentType: contentType,
EntryType: moduleEntry,
}
entries = append(entries, moduleEntry)

entries = addModuleEntry(targetPathGetter, entries, mod, contentType)

if onlyModules {
continue
Expand All @@ -95,6 +90,21 @@ func setManifestDesc(ep dir.ITargetArtifacts, targetPathGetter dir.ITargetPath,
return genManifest(ep.GetManifestPath(), entries)
}

func addModuleEntry(targetPathGetter dir.ITargetPath, entries []entry, module *mta.Module, contentType string) []entry {
result := entries
modulePath := getModulePath(module, targetPathGetter)
if modulePath != "" {
moduleEntry := entry{
EntryName: module.Name,
EntryPath: modulePath,
ContentType: contentType,
EntryType: moduleEntry,
}
result = append(entries, moduleEntry)
}
return result
}

func getResourcesEntries(targetPathGetter dir.ITargetPath, resources []*mta.Resource,
contentTypes *contenttype.ContentTypes) ([]entry, error) {
var entries []entry
Expand Down
14 changes: 14 additions & 0 deletions internal/artifacts/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ var _ = Describe("manifest", func() {
fmt.Println(golden)
Ω(actual).Should(Equal(golden))
})
It("Sanity - no paths", func() {
os.Mkdir(getTestPath("result", "mta", "node-js"), os.ModePerm)
loc := dir.Loc{SourcePath: getTestPath("mta"), TargetPath: getResultPath(), MtaFilename: "mta_no_paths.yaml"}
mtaObj, err := loc.ParseFile()
Ω(err).Should(Succeed())
Ω(setManifestDesc(&loc, &loc, mtaObj.Modules, []*mta.Resource{}, []string{}, false)).Should(Succeed())
actual := getFileContent(getTestPath("result", "mta", "META-INF", "MANIFEST.MF"))
golden := getFileContent(getTestPath("golden_assembly_manifest_no_paths.mf"))
fmt.Println(actual)
fmt.Println(golden)
Ω(actual).Should(Equal(golden))
})
It("With resources", func() {
os.MkdirAll(getTestPath("result", "assembly-sample", "META-INF"), os.ModePerm)
os.MkdirAll(getTestPath("result", "assembly-sample", "web"), os.ModePerm)
Expand All @@ -56,6 +68,8 @@ var _ = Describe("manifest", func() {
Ω(setManifestDesc(&loc, &loc, mtaObj.Modules, mtaObj.Resources, []string{}, false)).Should(Succeed())
actual := getFileContent(getTestPath("result", "assembly-sample", "META-INF", "MANIFEST.MF"))
golden := getFileContent(getTestPath("golden_assembly_manifest.mf"))
fmt.Println(actual)
fmt.Println(golden)
Ω(actual).Should(Equal(golden))
})
It("With missing module path", func() {
Expand Down
6 changes: 0 additions & 6 deletions internal/artifacts/testdata/golden_assembly_manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ Name: web/
MTA-Module: java-hello-world
Content-Type: text/directory


Name:
MTA-Module: java-hello-world-backend
Content-Type: text/directory


Name: config-site-host.json
MTA-Requires: java-hello-world-backend/java-site-host
Content-Type: application/json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
manifest-Version: 1.0
Created-By: SAP Application Archive Builder 0.0.1

Name: META-INF/mtad.yaml
Content-Type: text/plain

11 changes: 11 additions & 0 deletions internal/artifacts/testdata/mta/mta_no_paths.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ID: mta
_schema-version: '2.1'
version: 0.0.1

modules:
- name: test_node-js
type: nodejs
provides:
- name: node-js_api
properties:
url: ${default-url}

0 comments on commit 961f1f7

Please sign in to comment.