-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from gchiesa/62-support-for-automatic-ignore-f…
…iles-in-ska-upstream feat: implement support for automatically add ignorePaths in generated ska-config
- Loading branch information
Showing
10 changed files
with
139 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
internal/processor/filetreeprocessor.go → ...al/filetreeprocessor/filetreeprocessor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processor | ||
package filetreeprocessor | ||
|
||
import ( | ||
"github.com/apex/log" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
internal/processor/type.go → internal/filetreeprocessor/type.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processor | ||
package filetreeprocessor | ||
|
||
import ( | ||
"github.com/apex/log" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package stringprocessor | ||
|
||
import ( | ||
"bytes" | ||
"github.com/apex/log" | ||
"github.com/gchiesa/ska/internal/templateprovider" | ||
) | ||
|
||
func NewStringProcessor(options ...func(stringProcessor *StringProcessor)) *StringProcessor { | ||
logCtx := log.WithFields(log.Fields{ | ||
"pkg": "string-processor", | ||
}) | ||
|
||
sp := &StringProcessor{ | ||
template: nil, | ||
log: logCtx, | ||
} | ||
// configure options | ||
for _, opt := range options { | ||
opt(sp) | ||
} | ||
return sp | ||
} | ||
|
||
func WithTemplateService(ts templateprovider.TemplateService) func(sp *StringProcessor) { | ||
return func(sp *StringProcessor) { | ||
sp.template = ts | ||
} | ||
} | ||
|
||
func (sp *StringProcessor) Render(text string, withVariables map[string]interface{}) (string, error) { | ||
logger := sp.log.WithFields(log.Fields{"method": "Render"}) | ||
|
||
if err := sp.template.FromString(text); err != nil { | ||
return "", err | ||
} | ||
|
||
// render the template | ||
buff := bytes.NewBufferString("") | ||
if err := sp.template.Execute(buff, withVariables); err != nil { | ||
if sp.template.IsMissingKeyError(err) { | ||
logger.WithFields(log.Fields{"error": err.Error()}).Errorf("missing variable while rendering string: %v", err) | ||
} | ||
return "", err | ||
} | ||
return buff.String(), nil | ||
} | ||
|
||
func (sp *StringProcessor) RenderSliceOfStrings(text []string, variables map[string]interface{}) ([]string, error) { | ||
var result []string | ||
for _, entry := range text { | ||
renderedEntry, err := sp.Render(entry, variables) | ||
if err != nil { | ||
return nil, err | ||
} | ||
result = append(result, renderedEntry) | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package stringprocessor | ||
|
||
import ( | ||
"github.com/apex/log" | ||
"github.com/gchiesa/ska/internal/templateprovider" | ||
) | ||
|
||
type StringProcessor struct { | ||
template templateprovider.TemplateService | ||
log *log.Entry | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters