Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bundles): refactor bundle copy implementation
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
- Loading branch information
1 parent
ae8c259
commit 63d13d0
Showing
6 changed files
with
371 additions
and
318 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
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,35 @@ | ||
package bundles | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"helm.sh/helm/v3/pkg/chart" | ||
|
||
"github.com/werf/werf/pkg/docker_registry" | ||
) | ||
|
||
type BundleAccessor interface { | ||
ReadChart(ctx context.Context) (*chart.Chart, error) | ||
WriteChart(ctx context.Context, ch *chart.Chart) error | ||
|
||
CopyTo(ctx context.Context, to BundleAccessor) error | ||
CopyFromArchive(ctx context.Context, fromArchive *BundleArchive) error | ||
CopyFromRemote(ctx context.Context, fromRemote *RemoteBundle) error | ||
} | ||
|
||
type BundleAccessorOptions struct { | ||
BundlesRegistryClient BundlesRegistryClient | ||
RegistryClient docker_registry.Interface | ||
} | ||
|
||
func NewBundleAccessor(addr *Addr, opts BundleAccessorOptions) BundleAccessor { | ||
switch { | ||
case addr.RegistryAddress != nil: | ||
return NewRemoteBundle(addr.RegistryAddress, opts.BundlesRegistryClient, opts.RegistryClient) | ||
case addr.ArchiveAddress != nil: | ||
return NewBundleArchive(addr.ArchiveAddress.Path) | ||
default: | ||
panic(fmt.Sprintf("invalid address given %#v", addr)) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package bundles | ||
|
||
import ( | ||
"helm.sh/helm/v3/pkg/chart" | ||
|
||
bundles_registry "github.com/werf/werf/pkg/deploy/bundles/registry" | ||
) | ||
|
||
type BundlesRegistryClient interface { | ||
PullChartToCache(ref *bundles_registry.Reference) error | ||
LoadChart(ref *bundles_registry.Reference) (*chart.Chart, error) | ||
SaveChart(ch *chart.Chart, ref *bundles_registry.Reference) error | ||
PushChart(ref *bundles_registry.Reference) error | ||
} |
Oops, something went wrong.