Skip to content

Commit 25f7f24

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

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-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/project/projectconfig.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,23 @@ func ReadResolutionOnlyConfiguration(confFilePath string) (*RepositoryConfig, er
247247
}
248248
return GetRepoConfigByPrefix(confFilePath, ProjectConfigResolverPrefix, vConfig)
249249
}
250+
251+
func GetDeploymentConfiguration(projectType ProjectType) (*RepositoryConfig, error) {
252+
confFilePath, exists, err := GetProjectConfFilePath(projectType)
253+
if err != nil {
254+
return nil, err
255+
}
256+
if !exists {
257+
return nil, errorutils.CheckErrorf("%s Project configuration does not exist.", projectType.String())
258+
}
259+
return ReadDeploymentConfiguration(confFilePath)
260+
}
261+
262+
func ReadDeploymentConfiguration(confFilePath string) (*RepositoryConfig, error) {
263+
log.Debug("Preparing to read the deployment config file", confFilePath)
264+
vConfig, err := ReadConfigFile(confFilePath, YAML)
265+
if err != nil {
266+
return nil, err
267+
}
268+
return GetRepoConfigByPrefix(confFilePath, ProjectConfigDeployerPrefix, vConfig)
269+
}

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)