Skip to content

Commit

Permalink
fix: Fixes #33, add validation for replace text
Browse files Browse the repository at this point in the history
Signed-off-by: Dustin Scott <[email protected]>
  • Loading branch information
scottd018 authored and lander2k2 committed Jul 31, 2024
1 parent ec34299 commit f623317
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/workload/v1/markers/markers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
)

var (
ErrMissingReplaceText = errors.New("marker is missing the requested replace text")
ErrMissingParentOrName = errors.New("missing either parent=value or name=value marker")
ErrInvalidReplaceMarkerFieldType = errors.New("invalid marker type using replace")
ErrInvalidParentField = errors.New("invalid parent field")
Expand Down Expand Up @@ -313,6 +314,10 @@ func setValue(marker FieldMarkerProcessor, value *yaml.Node) error {
return fmt.Errorf("unable to get source code field variable for marker %s, %w", marker, err)
}

if !strings.Contains(value.Value, markerReplaceText) {
return fmt.Errorf("replace text=[%s] value=[%s], %w", markerReplaceText, value.Value, ErrMissingReplaceText)
}

value.Value = re.ReplaceAllString(value.Value, fieldVar)
} else {
value.Tag = varTag
Expand Down

0 comments on commit f623317

Please sign in to comment.