-
Notifications
You must be signed in to change notification settings - Fork 58
/
createbundle.go
62 lines (50 loc) · 1.82 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
package distribution
import (
"github.com/jfrog/jfrog-cli-core/artifactory/spec"
"github.com/jfrog/jfrog-cli-core/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/utils/config"
"github.com/jfrog/jfrog-client-go/distribution/services"
distributionServicesUtils "github.com/jfrog/jfrog-client-go/distribution/services/utils"
)
type CreateBundleCommand struct {
rtDetails *config.ArtifactoryDetails
releaseBundlesParams distributionServicesUtils.ReleaseBundleParams
spec *spec.SpecFiles
dryRun bool
}
func NewReleaseBundleCreateCommand() *CreateBundleCommand {
return &CreateBundleCommand{}
}
func (cb *CreateBundleCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *CreateBundleCommand {
cb.rtDetails = rtDetails
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.rtDetails, cb.dryRun)
if err != nil {
return err
}
for _, spec := range cb.spec.Files {
cb.releaseBundlesParams.SpecFiles = append(cb.releaseBundlesParams.SpecFiles, spec.ToArtifactoryCommonParams())
}
params := services.CreateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams}
return servicesManager.CreateReleaseBundle(params)
}
func (cb *CreateBundleCommand) RtDetails() (*config.ArtifactoryDetails, error) {
return cb.rtDetails, nil
}
func (cb *CreateBundleCommand) CommandName() string {
return "rt_bundle_create"
}