diff --git a/cmd/release/main_test.go b/cmd/release/main_test.go index 7c776f4..540caac 100644 --- a/cmd/release/main_test.go +++ b/cmd/release/main_test.go @@ -25,7 +25,7 @@ var _ = Describe("Main", func() { Eventually(session).Should(gexec.Exit(expectedErrorCode)) }, Entry("When there is no chaincode metadata", 0, func() []string { - return []string{"BUILD_OUTPUT_DIR", "RELEASE_OUTPUT_DIR"} + return []string{"./testdata/buildwithoutindexes", "RELEASE_OUTPUT_DIR"} }), Entry("When there is chaincode metadata", 0, func() []string { return []string{"./testdata/buildwithindexes", tempDir} diff --git a/cmd/release/testdata/buildwithindexes/image.json b/cmd/release/testdata/buildwithindexes/image.json new file mode 100644 index 0000000..313f1e6 --- /dev/null +++ b/cmd/release/testdata/buildwithindexes/image.json @@ -0,0 +1,4 @@ +{ + "name": "ghcr.io/hyperledger/asset-transfer-basic", + "digest": "sha256:b35962f000d26ad046d4102f22d70a1351692fc69a9ddead89dfa13aefb942a7" +} diff --git a/cmd/release/testdata/buildwithoutindexes/image.json b/cmd/release/testdata/buildwithoutindexes/image.json new file mode 100644 index 0000000..313f1e6 --- /dev/null +++ b/cmd/release/testdata/buildwithoutindexes/image.json @@ -0,0 +1,4 @@ +{ + "name": "ghcr.io/hyperledger/asset-transfer-basic", + "digest": "sha256:b35962f000d26ad046d4102f22d70a1351692fc69a9ddead89dfa13aefb942a7" +} diff --git a/internal/util/copy.go b/internal/util/copy.go index 6eb1715..700e212 100644 --- a/internal/util/copy.go +++ b/internal/util/copy.go @@ -41,9 +41,13 @@ func CopyImageJSON(logger *log.CmdLogger, src, dest string) error { // CopyIndexFiles copies CouchDB index definitions from source to destination directories. func CopyIndexFiles(logger *log.CmdLogger, src, dest string) error { - logger.Debugf("Copying couchdb index files from %s to %s", src, dest) + indexDir := filepath.Join("statedb", "couchdb") + indexSrcDir := filepath.Join(src, MetadataDir, indexDir) + indexDestDir := filepath.Join(dest, indexDir) + + logger.Debugf("Copying couchdb index files from %s to %s", indexSrcDir, indexDestDir) - _, err := os.Lstat(src) + _, err := os.Lstat(indexSrcDir) if err != nil { if os.IsNotExist(err) { // indexes are optional @@ -53,10 +57,6 @@ func CopyIndexFiles(logger *log.CmdLogger, src, dest string) error { return err } - indexDir := filepath.Join("statedb", "couchdb") - indexSrcDir := filepath.Join(src, MetadataDir, indexDir) - indexDestDir := filepath.Join(dest, indexDir) - opt := copy.Options{ Skip: func(info os.FileInfo, src, _ string) (bool, error) { logger.Debugf("Checking source copy path: %s", src)