-
Notifications
You must be signed in to change notification settings - Fork 55
/
createbundle.go
100 lines (83 loc) · 2.75 KB
/
createbundle.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package commands
import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/distribution/services"
distributionServicesUtils "github.com/jfrog/jfrog-client-go/distribution/services/utils"
clientutils "github.com/jfrog/jfrog-client-go/utils"
)
type CreateBundleCommand struct {
serverDetails *config.ServerDetails
releaseBundlesParams distributionServicesUtils.ReleaseBundleParams
spec *spec.SpecFiles
dryRun bool
detailedSummary bool
summary *clientutils.Sha256Summary
}
func NewReleaseBundleCreateCommand() *CreateBundleCommand {
return &CreateBundleCommand{}
}
func (cb *CreateBundleCommand) SetServerDetails(serverDetails *config.ServerDetails) *CreateBundleCommand {
cb.serverDetails = serverDetails
return cb
}
func (cb *CreateBundleCommand) SetReleaseBundleCreateParams(params distributionServicesUtils.ReleaseBundleParams) *CreateBundleCommand {
cb.releaseBundlesParams = params
return cb
}
func (cb *CreateBundleCommand) SetSpec(spec *spec.SpecFiles) *CreateBundleCommand {
cb.spec = spec
return cb
}
func (cb *CreateBundleCommand) SetDryRun(dryRun bool) *CreateBundleCommand {
cb.dryRun = dryRun
return cb
}
func (cb *CreateBundleCommand) Run() error {
servicesManager, err := utils.CreateDistributionServiceManager(cb.serverDetails, cb.dryRun)
if err != nil {
return err
}
for _, spec := range cb.spec.Files {
params, err := spec.ToCommonParams()
if err != nil {
return err
}
recursive, err := spec.IsRecursive(true)
if err != nil {
return err
}
params.Recursive = recursive
cb.releaseBundlesParams.SpecFiles = append(cb.releaseBundlesParams.SpecFiles, params)
}
params := services.CreateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams}
summary, err := servicesManager.CreateReleaseBundle(params)
if cb.detailedSummary {
cb.summary = summary
}
return err
}
func (cb *CreateBundleCommand) ServerDetails() (*config.ServerDetails, error) {
return cb.serverDetails, nil
}
func (cb *CreateBundleCommand) CommandName() string {
return "rt_bundle_create"
}
func (cb *CreateBundleCommand) SetSummary(summary *clientutils.Sha256Summary) *CreateBundleCommand {
cb.summary = summary
return cb
}
func (cb *CreateBundleCommand) GetSummary() *clientutils.Sha256Summary {
return cb.summary
}
func (cb *CreateBundleCommand) SetDetailedSummary(detailedSummary bool) *CreateBundleCommand {
cb.detailedSummary = detailedSummary
return cb
}
func (cb *CreateBundleCommand) IsDetailedSummary() bool {
return cb.detailedSummary
}
func (cb *CreateBundleCommand) IsSignImmediately() bool {
return cb.releaseBundlesParams.SignImmediately
}