Skip to content

Commit

Permalink
Add die feed/release methods for json/yaml (reconcilerio#98)
Browse files Browse the repository at this point in the history
Errors now result in a panic rather than being ignored.

New die methods:

    // DieFeedJSON returns a new die with the provided JSON. Panics on error.
    DieFeedJSON(j []byte) *MyResourceDie

    // DieFeedYAML returns a new die with the provided YAML. Panics on error.
    DieFeedYAML(y []byte) *MyResourceDie

    // DieFeedYAMLFile returns a new die loading YAML from a file path. Panics on error.
    DieFeedYAMLFile(name string) *MyResourceDie

    // DieReleaseJSON returns the resource managed by the die as JSON. Panics on error.
    DieReleaseJSON() []byte

    // DieReleaseYAML returns the resource managed by the die as YAML. Panics on error.
    DieReleaseYAML() []byte

Signed-off-by: Scott Andrews <scott@andrews.me>
  • Loading branch information
scothis authored Mar 6, 2023
1 parent e367c61 commit 21dd0e2
Show file tree
Hide file tree
Showing 31 changed files with 20,565 additions and 2,985 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,16 @@ type MyResourceDie interface {
// resource is nil, the empty value is used instead.
DieFeedPtr(r *MyResource) *MyResourceDie

// DieFeedRawExtension returns a new die with the provided raw extension.
// DieFeedJSON returns a new die with the provided JSON. Panics on error.
DieFeedJSON(j []byte) *MyResourceDie

// DieFeedYAML returns a new die with the provided YAML. Panics on error.
DieFeedYAML(y []byte) *MyResourceDie

// DieFeedYAMLFile returns a new die loading YAML from a file path. Panics on error.
DieFeedYAMLFile(name string) *MyResourceDie

// DieFeedRawExtension returns a new die with the provided raw extension. Panics on error.
DieFeedRawExtension(raw runtime.RawExtension) *MyResourceDie

// DieRelease returns the resource managed by the die.
Expand All @@ -131,8 +140,14 @@ type MyResourceDie interface {
// DieReleasePtr returns a pointer to the resource managed by the die.
DieReleasePtr() *MyResource

// DieReleaseJSON returns the resource managed by the die as JSON. Panics on error.
DieReleaseJSON() []byte

// DieReleaseYAML returns the resource managed by the die as YAML. Panics on error.
DieReleaseYAML() []byte

// DieReleaseRawExtension returns the resource managed by the die as an
// raw extension.
// raw extension. Panics on error.
DieReleaseRawExtension() runtime.RawExtension

// DieImmutable returns a new die for the current die's state that is
Expand Down
197 changes: 173 additions & 24 deletions apis/admission/v1/zz_generated.die.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 21dd0e2

Please sign in to comment.