-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow P2F custom templates via ConfigMap
- Loading branch information
1 parent
25b2bc5
commit cf9572a
Showing
11 changed files
with
421 additions
and
41 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
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
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,33 @@ | ||
package pushtofile | ||
|
||
import ( | ||
"io" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
type pullFromReaderFunc func( | ||
reader io.Reader, | ||
) (string, error) | ||
|
||
type openReadCloserFunc func( | ||
path string, | ||
) (io.ReadCloser, error) | ||
|
||
func openFileAsReadCloser(path string) (io.ReadCloser, error) { | ||
reader, err := os.Open(path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ioutil.NopCloser(reader), nil | ||
} | ||
|
||
func pullFromReader( | ||
reader io.Reader, | ||
) (string, error) { | ||
content, err := ioutil.ReadAll(reader) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(content), 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,34 @@ | ||
package pushtofile | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
) | ||
|
||
type pullFromReaderTestCase struct { | ||
description string | ||
content string | ||
assert func(*testing.T, string, error) | ||
} | ||
|
||
func (tc pullFromReaderTestCase) Run(t *testing.T) { | ||
t.Run(tc.description, func(t *testing.T) { | ||
buf := bytes.NewBufferString(tc.content) | ||
readContent, err := pullFromReader(buf) | ||
tc.assert(t, readContent, err) | ||
}) | ||
} | ||
|
||
var pullFromReaderTestCases = []pullFromReaderTestCase{ | ||
{ | ||
description: "happy case", | ||
content: "template file content", | ||
assert: assertGoodOutput("template file content"), | ||
}, | ||
} | ||
|
||
func TestPullFromReader(t *testing.T) { | ||
for _, tc := range pullFromReaderTestCases { | ||
tc.Run(t) | ||
} | ||
} |
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
Oops, something went wrong.