Skip to content

Commit d363377

Browse files
committed
cleanup
Signed-off-by: Kyle Quest <[email protected]>
1 parent 92c6c62 commit d363377

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

COMMUNITY_ACTIVITY_LOG.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Community Activity Log
2+
3+
## Meetings/Events
4+
5+
TBD
6+
7+
## Engaging with CNCF TAGs
8+
9+
TBD
10+
11+
## Collaborating/Integrating with Other Projects (CNCF or Not)
12+
13+
TBD
14+
15+
## Conferences
16+
17+
TBD
18+

pkg/app/master/commands/clifvgetter.go

+13-9
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ func GetContainerOverrides(xc *app.ExecutionContext, ctx *cli.Context) (*config.
239239
if envErr != nil {
240240
return nil, envErr
241241
}
242-
env := validateAndCleanEnvVariables(ctx.StringSlice(FlagEnv), xc)
242+
envList = validateAndCleanEnvVariables(xc, envList, "param.env-file.value")
243+
env := validateAndCleanEnvVariables(xc, ctx.StringSlice(FlagEnv), "param.env")
243244
envList = append(envList, env...)
244245
overrides := &config.ContainerOverrides{
245246
User: ctx.String(FlagUser),
@@ -408,9 +409,7 @@ func GetDockerClientConfig(ctx *cli.Context) *config.DockerClient {
408409
return config
409410
}
410411

411-
func validateAndCleanEnvVariables(envList []string, xc *app.ExecutionContext) []string {
412-
xc.Out.Info("Validating and cleaning environment variables")
413-
412+
func validateAndCleanEnvVariables(xc *app.ExecutionContext, envList []string, errType string) []string {
414413
var envStaging []string
415414

416415
if len(envList) == 0 {
@@ -425,19 +424,24 @@ func validateAndCleanEnvVariables(envList []string, xc *app.ExecutionContext) []
425424
}
426425

427426
if !strings.ContainsAny(kv, "=") {
428-
xc.Out.Prompt(fmt.Sprintf("Malformed env key/value (idx: %v kv: %s). Excluding from list", i, kv))
427+
xc.Out.Error(errType, fmt.Sprintf("skipping malformed env var - (index=%d data='%s')", i, kv))
429428
continue
430429
}
431430

432431
envKeyValue := strings.SplitN(kv, "=", 2)
432+
if len(envKeyValue) != 2 {
433+
xc.Out.Error(errType, fmt.Sprintf("skipping malformed env var - (index=%d data='%s')", i, kv))
434+
continue
435+
}
436+
433437
keyIsEmpty := len(strings.TrimSpace(envKeyValue[0])) == 0
434-
valIsEmpty := len(strings.TrimSpace(envKeyValue[1])) == 0
438+
//no need to trim value (it may have spaces intentionally)
439+
valIsEmpty := len(envKeyValue[1]) == 0
435440

436-
if len(envKeyValue) == 2 && !keyIsEmpty && !valIsEmpty {
437-
xc.Out.Prompt(fmt.Sprintf("Adding key value %s to list of env values", kv))
441+
if !keyIsEmpty && !valIsEmpty {
438442
envStaging = append(envStaging, kv)
439443
} else {
440-
xc.Out.Prompt(fmt.Sprintf("Malformed env key/value (idx: %v kv: %s). Excluding from list", i, kv))
444+
xc.Out.Error(errType, fmt.Sprintf("skipping malformed env var - (index=%d data='%s')", i, kv))
441445
}
442446
}
443447

pkg/app/master/commands/clifvparser.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -877,10 +877,8 @@ func ParseEnvFile(filePath string) ([]string, error) {
877877
for _, line := range lines {
878878
line = strings.TrimSpace(line)
879879
if len(line) > 0 {
880-
parts := strings.SplitN(line, "=", 2)
881-
if len(parts) == 2 {
882-
output = append(output, line)
883-
}
880+
//env var format validation is done separately
881+
output = append(output, line)
884882
}
885883
}
886884
return output, nil

pkg/app/sensor/artifact/artifact.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,9 @@ func (a *processor) ProcessReports(
447447
logger.Debug("processing data...")
448448

449449
fileCount := 0
450-
for _, processFileMap := range fanReport.ProcessFiles {
451-
fileCount += len(processFileMap)
452-
}
453450
fileList := make([]string, 0, fileCount)
454451
for _, processFileMap := range fanReport.ProcessFiles {
452+
fileCount += len(processFileMap)
455453
for fpath := range processFileMap {
456454
fileList = append(fileList, fpath)
457455
}

0 commit comments

Comments
 (0)