Skip to content

Commit f6d9648

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 246ea66 + fe5fd6c commit f6d9648

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

artifactory/commands/utils/templateutils.go

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ type TemplateUserCommand interface {
2121
Vars() string
2222
}
2323

24-
func ConvertTemplateToMap(tuc TemplateUserCommand) (map[string]interface{}, error) {
24+
func ConvertTemplateToMap(templateUserCommand TemplateUserCommand) (map[string]interface{}, error) {
2525
// Read the template file
26-
content, err := fileutils.ReadFile(tuc.TemplatePath())
26+
content, err := fileutils.ReadFile(templateUserCommand.TemplatePath())
2727
if errorutils.CheckError(err) != nil {
2828
return nil, err
2929
}
3030
// Replace vars string-by-string if needed
31-
if len(tuc.Vars()) > 0 {
32-
templateVars := coreutils.SpecVarsStringToMap(tuc.Vars())
31+
if len(templateUserCommand.Vars()) > 0 {
32+
templateVars := coreutils.SpecVarsStringToMap(templateUserCommand.Vars())
3333
content = coreutils.ReplaceVars(content, templateVars)
3434
}
3535
// Unmarshal template to a map
@@ -38,6 +38,36 @@ func ConvertTemplateToMap(tuc TemplateUserCommand) (map[string]interface{}, erro
3838
return configMap, errorutils.CheckError(err)
3939
}
4040

41+
func ConvertTemplateToMaps(templateUserCommand TemplateUserCommand) (interface{}, error) {
42+
content, err := fileutils.ReadFile(templateUserCommand.TemplatePath())
43+
if err != nil {
44+
return nil, errorutils.CheckError(err)
45+
}
46+
// Replace vars string-by-string if needed
47+
if len(templateUserCommand.Vars()) > 0 {
48+
templateVars := coreutils.SpecVarsStringToMap(templateUserCommand.Vars())
49+
content = coreutils.ReplaceVars(content, templateVars)
50+
}
51+
52+
var multiRepoCreateEntities []map[string]interface{}
53+
err = json.Unmarshal(content, &multiRepoCreateEntities)
54+
if err == nil {
55+
return multiRepoCreateEntities, nil
56+
}
57+
58+
if _, ok := err.(*json.SyntaxError); ok {
59+
return nil, errorutils.CheckError(err)
60+
}
61+
62+
var repoCreateEntity map[string]interface{}
63+
err = json.Unmarshal(content, &repoCreateEntity)
64+
if err == nil {
65+
return repoCreateEntity, nil
66+
}
67+
68+
return nil, errorutils.CheckError(err)
69+
}
70+
4171
func ValidateMapEntry(key string, value interface{}, writersMap map[string]ioutils.AnswerWriter) error {
4272
if _, ok := writersMap[key]; !ok {
4373
return errorutils.CheckErrorf("template syntax error: unknown key: \"" + key + "\".")

common/spec/builder.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type builder struct {
3535
transitive bool
3636
targetPathInArchive string
3737
include []string
38+
repoOnly bool
3839
}
3940

4041
func NewBuilder() *builder {
@@ -76,6 +77,11 @@ func (b *builder) Props(props string) *builder {
7677
return b
7778
}
7879

80+
func (b *builder) RepoOnly(repoOnly bool) *builder {
81+
b.repoOnly = repoOnly
82+
return b
83+
}
84+
7985
func (b *builder) TargetProps(targetProps string) *builder {
8086
b.targetProps = targetProps
8187
return b

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/jedib0t/go-pretty/v6 v6.6.5
1616
github.com/jfrog/build-info-go v1.10.14
1717
github.com/jfrog/gofrog v1.7.6
18-
github.com/jfrog/jfrog-client-go v1.54.2
18+
github.com/jfrog/jfrog-client-go v1.54.3
1919
github.com/magiconair/properties v1.8.9
2020
github.com/manifoldco/promptui v0.9.0
2121
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
@@ -114,7 +114,7 @@ require (
114114
sigs.k8s.io/yaml v1.4.0 // indirect
115115
)
116116

117-
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250707095624-7062538a0961
117+
// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250717041744-d3ea4d99f4e7
118118

119119
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20250611113558-c1a092f216fd
120120

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ github.com/jfrog/build-info-go v1.10.14 h1:PWnw+rBwiQTHZ5q+84+E8MHFjtAQkB3+Oc2sK
113113
github.com/jfrog/build-info-go v1.10.14/go.mod h1:JcISnovFXKx3wWf3p1fcMmlPdt6adxScXvoJN4WXqIE=
114114
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
115115
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
116-
github.com/jfrog/jfrog-client-go v1.54.2 h1:z7GjCyIbV5Wx35USVDCF/0vf/fCWki++pZ7lcKt0gj0=
117-
github.com/jfrog/jfrog-client-go v1.54.2/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
116+
github.com/jfrog/jfrog-client-go v1.54.3 h1:tIhhDhM7rDMT1lzgeQy4nr6H2ihlqnumhiFybIWlLz0=
117+
github.com/jfrog/jfrog-client-go v1.54.3/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
118118
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
119119
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
120120
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=

0 commit comments

Comments
 (0)