-
Notifications
You must be signed in to change notification settings - Fork 270
/
import.go
51 lines (39 loc) 路 1.09 KB
/
import.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package artifacts
import (
"context"
"fmt"
"os"
releasev1 "github.com/aws/eks-anywhere/release/api/v1alpha1"
)
type Import struct {
Reader Reader
Bundles *releasev1.Bundles
ImageMover ImageMover
ChartImporter ChartImporter
TmpArtifactsFolder string
FileImporter FileImporter
}
type ChartImporter interface {
Import(ctx context.Context, charts ...string) error
}
type FileImporter interface {
Push(ctx context.Context, bundles *releasev1.Bundles)
}
func (i Import) Run(ctx context.Context) error {
images, err := i.Reader.ReadImagesFromBundles(ctx, i.Bundles)
if err != nil {
return fmt.Errorf("downloading images: %v", err)
}
if err = i.ImageMover.Move(ctx, artifactNames(images)...); err != nil {
return err
}
charts := i.Reader.ReadChartsFromBundles(ctx, i.Bundles)
if err := i.ChartImporter.Import(ctx, artifactNames(charts)...); err != nil {
return err
}
i.FileImporter.Push(ctx, i.Bundles)
if err := os.RemoveAll(i.TmpArtifactsFolder); err != nil {
return fmt.Errorf("deleting tmp artifact import folder: %v", err)
}
return nil
}