-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand.go
72 lines (66 loc) · 2.02 KB
/
command.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
package main
import (
"code.cloudfoundry.org/cli/command/flag"
"code.cloudfoundry.org/cli/command/v2"
"fmt"
"path/filepath"
)
type MavenPushCommand struct {
RepoUrl string `long:"maven-repo-url"`
GroupId string `long:"maven-group-id"`
ArtifactId string `long:"maven-artifact-id"`
Version string `long:"maven-version"`
Classifier string `long:"maven-classifier"`
Extension string `long:"maven-extension"`
RepoUsername string `long:"maven-repo-username"`
RepoPassword string `long:"maven-repo-password"`
RemoteManifestUrl string `long:"remote-manifest-url"`
RemoteManifestUsername string `long:"remote-manifest-username"`
RemoteManifestPassword string `long:"remote-manifest-password"`
Push v2.V2PushCommand
}
func (cmd *MavenPushCommand) ManifestPath() string {
if cmd.Push.PathToManifest == "" {
return "manifest.yml"
}
return string(cmd.Push.PathToManifest)
}
func (cmd *MavenPushCommand) Merge(config MavenConfig) MavenConfig {
if cmd.RepoUrl != "" {
config.RepoUrl = cmd.RepoUrl
}
if cmd.GroupId != "" {
config.GroupId = cmd.GroupId
}
if cmd.ArtifactId != "" {
config.ArtifactId = cmd.ArtifactId
}
if cmd.Version != "" {
config.Version = cmd.Version
}
if cmd.Classifier != "" {
config.Classifier = cmd.Classifier
}
if cmd.Extension != "" {
config.Extension = cmd.Extension
}
if cmd.RepoUsername != "" {
config.RepoUsername = cmd.RepoUsername
}
if cmd.RepoPassword != "" {
config.RepoPassword = cmd.RepoPassword
}
return config
}
func (cmd *MavenPushCommand) ConfigureRemoteManifestIfPresent(tempDir string) error {
if cmd.RemoteManifestUrl == "" {
return fmt.Errorf("remote manifest url is not configured")
}
manifestFile := filepath.Join(tempDir, "manifest.yml")
err := DownloadFile(cmd.RemoteManifestUrl, manifestFile, cmd.RemoteManifestUsername, cmd.RemoteManifestPassword)
if err != nil {
return err
}
cmd.Push.PathToManifest = flag.PathWithExistenceCheck(manifestFile)
return nil
}