Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 8cf7e62

Browse files
Installation store now returns an error with installation and not claim
Signed-off-by: Silvin Lubecki <[email protected]>
1 parent 94a99e5 commit 8cf7e62

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

internal/store/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func (a ApplicationStore) InstallationStore(context string) (InstallationStore,
5757
if err := os.MkdirAll(path, 0755); err != nil {
5858
return nil, errors.Wrapf(err, "failed to create installation store directory for context %q", context)
5959
}
60-
return claim.NewClaimStore(crud.NewFileSystemStore(path, "json")), nil
60+
claimStore := claim.NewClaimStore(crud.NewFileSystemStore(path, "json"))
61+
return &installationStore{claimStore: claimStore}, nil
6162
}
6263

6364
// CredentialStore initializes and returns a context based credential store

internal/store/installation.go

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
11
package store
22

3-
import "github.com/deislabs/duffle/pkg/claim"
3+
import (
4+
"fmt"
5+
6+
"github.com/deislabs/duffle/pkg/claim"
7+
)
48

59
// InstallationStore is an interface to persist claims.
610
type InstallationStore interface {
711
List() ([]string, error)
8-
Store(installationName claim.Claim) error
12+
Store(installation claim.Claim) error
913
Read(installationName string) (claim.Claim, error)
1014
Delete(installationName string) error
1115
}
1216

13-
var _ InstallationStore = &claim.Store{}
17+
var _ InstallationStore = &installationStore{}
18+
19+
type installationStore struct {
20+
claimStore claim.Store
21+
}
22+
23+
func (i installationStore) List() ([]string, error) {
24+
return i.claimStore.List()
25+
}
26+
27+
func (i installationStore) Store(installation claim.Claim) error {
28+
return i.claimStore.Store(installation)
29+
}
30+
31+
func (i installationStore) Read(installationName string) (claim.Claim, error) {
32+
c, err := i.claimStore.Read(installationName)
33+
if err == claim.ErrClaimNotFound {
34+
return claim.Claim{}, fmt.Errorf("Installation %q not found", installationName)
35+
}
36+
return c, err
37+
}
38+
39+
func (i installationStore) Delete(installationName string) error {
40+
return i.claimStore.Delete(installationName)
41+
}

0 commit comments

Comments
 (0)