-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move resourcestore into core and internal packages
In preparation for moving the resource store into service factory, move the current implementation into core and internal. Core can hold the interface, details go into internal. A few new types were necessary to avoid importing the application domain.
- Loading branch information
Showing
21 changed files
with
161 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package modelupgrader | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/juju/version/v2" | ||
) | ||
|
||
// ModelAgentService provides access to the Juju agent version for the model. | ||
type ModelAgentService interface { | ||
// GetModelTargetAgentVersion returns the target agent version for the | ||
// entire model. The following errors can be returned: | ||
// - [github.com/juju/juju/domain/model/errors.NotFound] - When the model does | ||
// not exist. | ||
GetModelTargetAgentVersion(context.Context) (version.Number, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2024 Canonical Ltd. | ||
// Licensed under the AGPLv3, see LICENCE file for details. | ||
|
||
package store | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/juju/utils/v4/hash" | ||
) | ||
|
||
// ResourceStore provides a list of methods necessary for interacting with | ||
// a store for the resource. | ||
type ResourceStore interface { | ||
// Get returns an io.ReadCloser for a resource in the resource store. | ||
Get( | ||
ctx context.Context, | ||
storageKey string, | ||
) (r io.ReadCloser, size int64, err error) | ||
|
||
// Put stores data from io.Reader in the resource store using the storage | ||
// key. | ||
Put( | ||
ctx context.Context, | ||
storageKey string, | ||
r io.Reader, | ||
size int64, | ||
fingerprint Fingerprint, | ||
) (UUID, error) | ||
|
||
// Remove removes a resource from storage. | ||
Remove( | ||
ctx context.Context, | ||
storageKey string, | ||
) error | ||
} | ||
|
||
// Fingerprint represents the unique fingerprint value of a resource's data. | ||
type Fingerprint struct { | ||
hash.Fingerprint | ||
} | ||
|
||
// NewFingerprint returns a resource store Fingerprint for the given | ||
// hash Fingerprint. | ||
func NewFingerprint(f hash.Fingerprint) Fingerprint { | ||
return Fingerprint{f} | ||
} | ||
|
||
// UUID is the UUID of the stored blob in the database, this can | ||
// be used for adding referential integrity from the resource to the stored | ||
// blob. This can be an object store metadata UUID or a container image metadata | ||
// storage key. | ||
type UUID string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
domain/containerimageresourcestore/service/package_mock_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.