Skip to content

Commit fbf4ed9

Browse files
committed
Fix for 'include' flag with spec file
1 parent e689762 commit fbf4ed9

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

common/cliutils/spec.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cliutils
22

33
import (
4+
"strconv"
5+
"strings"
6+
47
speccore "github.com/jfrog/jfrog-cli-core/v2/common/spec"
58
"github.com/jfrog/jfrog-cli-core/v2/plugins/components"
69
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
7-
"strconv"
8-
"strings"
910
)
1011

1112
func GetSpec(c *components.Context, isDownload, overrideFieldsIfSet bool) (specFiles *speccore.SpecFiles, err error) {
@@ -58,6 +59,15 @@ func OverrideFieldsIfSet(spec *speccore.File, c *components.Context) {
5859
overrideStringIfSet(&spec.Symlinks, c, "symlinks")
5960
overrideStringIfSet(&spec.Transitive, c, "transitive")
6061
overrideStringIfSet(&spec.PublicGpgKey, c, "gpg-key")
62+
overrideIncludeIfSet(spec, c)
63+
}
64+
65+
// If `include` exist in the cli args, read it to spec.include as an array split by `;`.
66+
func overrideIncludeIfSet(spec *speccore.File, c *components.Context) {
67+
if c.IsFlagSet("include") {
68+
include := strings.Split(c.GetStringFlagValue("include"), ";")
69+
spec.SetInclude(include)
70+
}
6171
}
6272

6373
// If `fieldName` exist in the cli args, read it to `field` as a string.

common/spec/specfiles.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ func (f File) GetInclude() []string {
103103
return f.include
104104
}
105105

106+
func (f *File) SetInclude(include []string) {
107+
f.include = include
108+
}
109+
106110
func (f File) IsFlat(defaultValue bool) (bool, error) {
107111
return clientutils.StringToBool(f.Flat, defaultValue)
108112
}

plugins/common/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,13 @@ func OverrideSpecFieldsIfSet(spec *spec.File, c *components.Context) {
6363
OverrideStringIfSet(&spec.Symlinks, c, "symlinks")
6464
OverrideStringIfSet(&spec.Transitive, c, "transitive")
6565
OverrideStringIfSet(&spec.PublicGpgKey, c, "gpg-key")
66+
overrideIncludeIfSet(spec, c)
67+
}
68+
69+
// If `include` exist in the cli args, read it to spec.include as an array split by `;`.
70+
func overrideIncludeIfSet(spec *spec.File, c *components.Context) {
71+
if c.IsFlagSet("include") {
72+
include := strings.Split(c.GetStringFlagValue("include"), ";")
73+
spec.SetInclude(include)
74+
}
6675
}

0 commit comments

Comments
 (0)