Skip to content

Commit

Permalink
Fix release for packages without indexes
Browse files Browse the repository at this point in the history
Resolves #115

Signed-off-by: James Taylor <[email protected]>
  • Loading branch information
jt-nti committed May 3, 2024
1 parent 31ac3e6 commit f6d18df
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/release/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 4 additions & 0 deletions cmd/release/testdata/buildwithindexes/image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ghcr.io/hyperledger/asset-transfer-basic",
"digest": "sha256:b35962f000d26ad046d4102f22d70a1351692fc69a9ddead89dfa13aefb942a7"
}
4 changes: 4 additions & 0 deletions cmd/release/testdata/buildwithoutindexes/image.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ghcr.io/hyperledger/asset-transfer-basic",
"digest": "sha256:b35962f000d26ad046d4102f22d70a1351692fc69a9ddead89dfa13aefb942a7"
}
12 changes: 6 additions & 6 deletions internal/util/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit f6d18df

Please sign in to comment.