-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
- Loading branch information
1 parent
133fbaf
commit a15c26e
Showing
12 changed files
with
30 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/jinzhu/copier" | ||
) | ||
|
||
type Value = interface{} | ||
|
||
// +k8s:deepcopy-gen=false | ||
type Any struct { | ||
// TODO: this is needed to workaround a bug in api machinery code | ||
// https://kubernetes.slack.com/archives/C0EG7JC6T/p1696331287543159 | ||
// +kubebuilder:pruning:PreserveUnknownFields | ||
// +kubebuilder:validation:Schemaless | ||
Value `json:",inline"` | ||
Value interface{} `json:",inline"` | ||
} | ||
|
||
func (in *Any) DeepCopyInto(out *Any) { | ||
if err := copier.Copy(out, in); err != nil { | ||
panic("deep copy failed") | ||
} | ||
} | ||
|
||
func (a *Any) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(a.Value) | ||
} | ||
|
||
func (a *Any) UnmarshalJSON(data []byte) error { | ||
var v interface{} | ||
err := json.Unmarshal(data, &v) | ||
if err != nil { | ||
return err | ||
} | ||
a.Value = v | ||
return 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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