-
-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove non-hermetic sprig functions (#2201)
Closes #2087
- Loading branch information
Alano Terblanche
authored
Feb 9, 2022
1 parent
e9087a1
commit 78d5b58
Showing
4 changed files
with
87 additions
and
5 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
courier/template/courier/builtin/templates/test_stub/email.body.sprig.gotmpl
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,5 +1,5 @@ | ||
{{ $t1 := title .input }} | ||
{{ $t1 := nospace $t1 }} | ||
{{ $t2 := upper $t1 }} | ||
{{ $t2 := upper $t1 }} | ||
{{ $t3 := cat $t1 "," $t2 }} | ||
{{ nospace $t3 }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package x | ||
|
||
import ( | ||
"io" | ||
"io/fs" | ||
"time" | ||
) | ||
|
||
type StubFS struct { | ||
name string | ||
data []byte | ||
offset int | ||
} | ||
|
||
func NewStubFS(name string, data []byte) fs.FS { | ||
return &StubFS{ | ||
name: name, | ||
data: data, | ||
} | ||
} | ||
|
||
func (stub *StubFS) Mode() fs.FileMode { | ||
return 0444 | ||
} | ||
|
||
func (stub *StubFS) ModTime() time.Time { | ||
return time.Time{} | ||
} | ||
|
||
func (stub *StubFS) IsDir() bool { | ||
return false | ||
} | ||
|
||
func (stub *StubFS) Sys() interface{} { | ||
return nil | ||
} | ||
|
||
func (stub *StubFS) Stat() (fs.FileInfo, error) { | ||
return stub, nil | ||
} | ||
|
||
func (stub *StubFS) Read(bytes []byte) (int, error) { | ||
if stub.offset >= len(stub.data) { | ||
return 0, io.EOF | ||
} | ||
n := copy(bytes, stub.data[stub.offset:]) | ||
stub.offset += n | ||
return n, nil | ||
} | ||
|
||
func (stub *StubFS) Close() error { | ||
return nil | ||
} | ||
|
||
func (stub *StubFS) Open(name string) (fs.File, error) { | ||
return stub, nil | ||
} | ||
|
||
func (stub *StubFS) Name() string { | ||
return stub.name | ||
} | ||
|
||
func (stub *StubFS) Size() int64 { | ||
return int64(len(stub.data)) | ||
} |