prep for actual admission/hook efforts

This commit is contained in:
2023-03-18 11:43:52 -05:00
parent 9c1f349c97
commit 9dd4366e73
8 changed files with 212 additions and 148 deletions

View File

@@ -0,0 +1,61 @@
package operations
const (
addOperation = "add"
removeOperation = "remove"
replaceOperation = "replace"
copyOperation = "copy"
moveOperation = "move"
)
// PatchOperation is an operation of a JSON patch https://tools.ietf.org/html/rfc6902.
type PatchOperation struct {
Op string `json:"op"`
Path string `json:"path"`
From string `json:"from"`
Value interface{} `json:"value,omitempty"`
}
// AddPatchOperation returns an add JSON patch operation.
func AddPatchOperation(path string, value interface{}) PatchOperation {
return PatchOperation{
Op: addOperation,
Path: path,
Value: value,
}
}
// RemovePatchOperation returns a remove JSON patch operation.
func RemovePatchOperation(path string) PatchOperation {
return PatchOperation{
Op: removeOperation,
Path: path,
}
}
// ReplacePatchOperation returns a replace JSON patch operation.
func ReplacePatchOperation(path string, value interface{}) PatchOperation {
return PatchOperation{
Op: replaceOperation,
Path: path,
Value: value,
}
}
// CopyPatchOperation returns a copy JSON patch operation.
func CopyPatchOperation(from, path string) PatchOperation {
return PatchOperation{
Op: copyOperation,
Path: path,
From: from,
}
}
// MovePatchOperation returns a move JSON patch operation.
func MovePatchOperation(from, path string) PatchOperation {
return PatchOperation{
Op: moveOperation,
Path: path,
From: from,
}
}