Skip to content

Commit 6046710

Browse files
Feature/add properties for repository via j frog cli (#98)
1 parent 545115d commit 6046710

File tree

7 files changed

+36
-15
lines changed

7 files changed

+36
-15
lines changed

artifactory/cli/cli.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ func setPropsCmd(c *components.Context) error {
10821082
if err != nil {
10831083
return err
10841084
}
1085-
propsCmd := generic.NewSetPropsCommand().SetPropsCommand(*cmd)
1085+
propsCmd := generic.NewSetPropsCommand().SetPropsCommand(*cmd).SetRepoOnly(c.GetBoolFlagValue("repo-only"))
10861086
propsCmd.SetRetries(retries).SetRetryWaitMilliSecs(retryWaitTime)
10871087
err = commands.Exec(propsCmd)
10881088
result := propsCmd.Result()
@@ -1102,7 +1102,7 @@ func deletePropsCmd(c *components.Context) error {
11021102
if err != nil {
11031103
return err
11041104
}
1105-
propsCmd := generic.NewDeletePropsCommand().DeletePropsCommand(*cmd)
1105+
propsCmd := generic.NewDeletePropsCommand().DeletePropsCommand(*cmd).SetRepoOnly(c.GetBoolFlagValue("repo-only"))
11061106
propsCmd.SetRetries(retries).SetRetryWaitMilliSecs(retryWaitTime)
11071107
err = commands.Exec(propsCmd)
11081108
result := propsCmd.Result()
@@ -1558,6 +1558,7 @@ func createDefaultPropertiesSpec(c *components.Context) (*spec.SpecFiles, error)
15581558
Exclusions(c.GetStringsArrFlagValue("exclusions")).
15591559
IncludeDirs(c.GetBoolFlagValue("include-dirs")).
15601560
ArchiveEntries(c.GetStringFlagValue("archive-entries")).
1561+
RepoOnly(c.GetBoolTFlagValue("repo-only")).
15611562
BuildSpec(), nil
15621563
}
15631564

artifactory/commands/generic/deleteprops.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ func (dp *DeletePropsCommand) DeletePropsCommand(command PropsCommand) *DeletePr
1717
return dp
1818
}
1919

20+
func (dp *DeletePropsCommand) SetRepoOnly(repoOnly bool) *DeletePropsCommand {
21+
dp.PropsCommand.repoOnly = repoOnly
22+
return dp
23+
}
24+
2025
func (dp *DeletePropsCommand) CommandName() string {
2126
return "rt_delete_properties"
2227
}
@@ -35,7 +40,7 @@ func (dp *DeletePropsCommand) Run() error {
3540
return err
3641
}
3742
defer reader.Close()
38-
propsParams := GetPropsParams(reader, dp.props)
43+
propsParams := GetPropsParams(reader, dp.props, dp.repoOnly)
3944
success, err := servicesManager.DeleteProps(propsParams)
4045
result := dp.Result()
4146
result.SetSuccessCount(success)

artifactory/commands/generic/props.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
)
1616

1717
type PropsCommand struct {
18-
props string
19-
threads int
18+
props string
19+
threads int
20+
repoOnly bool
2021
GenericCommand
2122
}
2223

@@ -42,6 +43,11 @@ func (pc *PropsCommand) SetProps(props string) *PropsCommand {
4243
return pc
4344
}
4445

46+
func (pc *PropsCommand) SetRepoOnlyFlag(repoOnly bool) *PropsCommand {
47+
pc.repoOnly = repoOnly
48+
return pc
49+
}
50+
4551
func createPropsServiceManager(threads, httpRetries, retryWaitMilliSecs int, serverDetails *config.ServerDetails) (artifactory.ArtifactoryServicesManager, error) {
4652
certsPath, err := coreutils.GetJfrogCertsDir()
4753
if err != nil {
@@ -98,9 +104,10 @@ func searchItems(spec *spec.SpecFiles, servicesManager artifactory.ArtifactorySe
98104
return
99105
}
100106

101-
func GetPropsParams(reader *content.ContentReader, properties string) (propsParams services.PropsParams) {
107+
func GetPropsParams(reader *content.ContentReader, properties string, repoOnly bool) (propsParams services.PropsParams) {
102108
propsParams = services.NewPropsParams()
103109
propsParams.Reader = reader
104110
propsParams.Props = properties
111+
propsParams.RepoOnly = repoOnly
105112
return
106113
}

artifactory/commands/generic/setprops.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ func (setProps *SetPropsCommand) SetPropsCommand(command PropsCommand) *SetProps
1818
return setProps
1919
}
2020

21+
func (setProps *SetPropsCommand) SetRepoOnly(repoOnly bool) *SetPropsCommand {
22+
setProps.PropsCommand.repoOnly = repoOnly
23+
return setProps
24+
}
25+
2126
func (setProps *SetPropsCommand) CommandName() string {
2227
return "rt_set_properties"
2328
}
@@ -39,7 +44,7 @@ func (setProps *SetPropsCommand) Run() (err error) {
3944
defer func() {
4045
err = errors.Join(err, reader.Close())
4146
}()
42-
propsParams := GetPropsParams(reader, setProps.props)
47+
propsParams := GetPropsParams(reader, setProps.props, setProps.repoOnly)
4348
success, err := servicesManager.SetProps(propsParams)
4449

4550
result := setProps.Result()

cliutils/flagkit/flags.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ const (
153153
props = "props"
154154
targetProps = "target-props"
155155
excludeProps = "exclude-props"
156+
repoOnly = "repo-only"
156157
failNoOp = "fail-no-op"
157158
threads = "threads"
158159
syncDeletes = "sync-deletes"
@@ -579,7 +580,7 @@ var commandFlags = map[string][]string{
579580
url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, ClientCertPath,
580581
ClientCertKeyPath, specFlag, specVars, exclusions, sortBy, sortOrder, limit, offset,
581582
propsRecursive, build, includeDeps, excludeArtifacts, bundle, includeDirs, failNoOp, threads, archiveEntries, propsProps, propsExcludeProps,
582-
InsecureTls, retries, retryWaitTime, Project,
583+
InsecureTls, retries, retryWaitTime, Project, repoOnly,
583584
},
584585
BuildPublish: {
585586
url, user, password, accessToken, sshPassphrase, sshKeyPath, serverId, buildUrl, bpDryRun,
@@ -901,6 +902,7 @@ var flagsMap = map[string]components.Flag{
901902
propsRecursive: components.NewBoolFlag(Recursive, "[Default: true] When false, artifacts inside sub-folders in Artifactory will not be affected.", components.WithBoolDefaultValueFalse()),
902903
propsProps: components.NewStringFlag(props, "[Optional] List of semicolon-separated(;) properties in the form of \"key1=value1;key2=value2;...\". Only artifacts with these properties are affected.", components.SetMandatoryFalse()),
903904
propsExcludeProps: components.NewStringFlag(excludeProps, "[Optional] List of semicolon-separated(;) properties in the form of \"key1=value1;key2=value2;...\". Only artifacts without the specified properties are affected.", components.SetMandatoryFalse()),
905+
repoOnly: components.NewBoolFlag(repoOnly, "[Default: true] When false, artifacts inside sub-folders in Artifactory will be affected.", components.WithBoolDefaultValueFalse()),
904906

905907
// Build Publish and Append specific commands flags
906908
buildUrl: components.NewStringFlag(buildUrl, "[Optional] Can be used for setting the CI server build URL in the build-info.", components.SetMandatoryFalse()),

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ require (
99
github.com/jfrog/froggit-go v1.17.0
1010
github.com/jfrog/gofrog v1.7.6
1111
github.com/jfrog/jfrog-cli-core/v2 v2.59.0
12-
github.com/jfrog/jfrog-client-go v1.54.1
12+
github.com/jfrog/jfrog-client-go v1.54.2
1313
github.com/pkg/errors v0.9.1
1414
github.com/secure-systems-lab/go-securesystemslib v0.8.0
1515
github.com/spf13/viper v1.19.0
@@ -132,8 +132,9 @@ require (
132132
sigs.k8s.io/yaml v1.4.0 // indirect
133133
)
134134

135-
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128
135+
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.59.2-0.20250709124419-1e5e14be13da
136+
137+
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250709124344-d59cca9cd76a
136138

137-
replace github.com/jfrog/jfrog-client-go => github.com/naveenku-jfrog/jfrog-client-go v1.28.1-0.20250709071939-91024bdb9f76
138139

139140
//replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240811142930-ab9715567376

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ github.com/jfrog/froggit-go v1.17.0 h1:20Ie787WO27SwB2MOHDvsR6yN7fA5WfRnuAbmUqz1
137137
github.com/jfrog/froggit-go v1.17.0/go.mod h1:HvDkfFfJwIdsXFdqaB+utvD2cLDRmaC3kF8otYb6Chw=
138138
github.com/jfrog/gofrog v1.7.6 h1:QmfAiRzVyaI7JYGsB7cxfAJePAZTzFz0gRWZSE27c6s=
139139
github.com/jfrog/gofrog v1.7.6/go.mod h1:ntr1txqNOZtHplmaNd7rS4f8jpA5Apx8em70oYEe7+4=
140-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128 h1:SdNS8Z1H1c1wgtHxZJNjLf9cWx+zdfXDQPmjUwQ55Bo=
141-
github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20250619122826-54ff6f65b128/go.mod h1:JDMYJHxU3W0/jaiiSljHLAcd0QeEGwpAwsnOqVR8c/0=
140+
github.com/jfrog/jfrog-cli-core/v2 v2.59.2-0.20250709124419-1e5e14be13da h1:uDMQ6tdKI7nk3Z4fwYv0xcdQZVGnrt58+Wk5970c6Zk=
141+
github.com/jfrog/jfrog-cli-core/v2 v2.59.2-0.20250709124419-1e5e14be13da/go.mod h1:pcAx7PFOLiw82c6fBDJw3BfIfUQdoHsxWd5u/XH9XEM=
142+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250709124344-d59cca9cd76a h1:UJNIEx2O+tgwVacsWF6csTRxGo/CByminrf5LujuzTk=
143+
github.com/jfrog/jfrog-client-go v1.28.1-0.20250709124344-d59cca9cd76a/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
142144
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
143145
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
144146
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
@@ -199,8 +201,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
199201
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
200202
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
201203
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
202-
github.com/naveenku-jfrog/jfrog-client-go v1.28.1-0.20250709071939-91024bdb9f76 h1:0aD2ghvGcB28CNCN+z2DtCfTGbmTagVBw0GAgCe2nIk=
203-
github.com/naveenku-jfrog/jfrog-client-go v1.28.1-0.20250709071939-91024bdb9f76/go.mod h1:1v0eih4thdPA4clBo9TuvAMT25sGDr1IQJ81DXQ/lBY=
204204
github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc=
205205
github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
206206
github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY=

0 commit comments

Comments
 (0)