-
Notifications
You must be signed in to change notification settings - Fork 58
/
updatebundle.go
62 lines (50 loc) · 1.82 KB
/
updatebundle.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 UpdateBundleCommand struct {
rtDetails *config.ArtifactoryDetails
releaseBundlesParams distributionServicesUtils.ReleaseBundleParams
spec *spec.SpecFiles
dryRun bool
}
func NewReleaseBundleUpdateCommand() *UpdateBundleCommand {
return &UpdateBundleCommand{}
}
func (cb *UpdateBundleCommand) SetRtDetails(rtDetails *config.ArtifactoryDetails) *UpdateBundleCommand {
cb.rtDetails = rtDetails
return cb
}
func (cb *UpdateBundleCommand) SetReleaseBundleUpdateParams(params distributionServicesUtils.ReleaseBundleParams) *UpdateBundleCommand {
cb.releaseBundlesParams = params
return cb
}
func (cb *UpdateBundleCommand) SetSpec(spec *spec.SpecFiles) *UpdateBundleCommand {
cb.spec = spec
return cb
}
func (cb *UpdateBundleCommand) SetDryRun(dryRun bool) *UpdateBundleCommand {
cb.dryRun = dryRun
return cb
}
func (cb *UpdateBundleCommand) 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.UpdateReleaseBundleParams{ReleaseBundleParams: cb.releaseBundlesParams}
return servicesManager.UpdateReleaseBundle(params)
}
func (cb *UpdateBundleCommand) RtDetails() (*config.ArtifactoryDetails, error) {
return cb.rtDetails, nil
}
func (cb *UpdateBundleCommand) CommandName() string {
return "rt_bundle_update"
}