mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Merge pull request #2812 from monopole/baseApiCleanup
Remove old constants from kyaml
This commit is contained in:
@@ -179,7 +179,7 @@ func (r *ByteReader) Read() ([]*yaml.RNode, error) {
|
|||||||
func isEmptyDocument(node *yaml.Node) bool {
|
func isEmptyDocument(node *yaml.Node) bool {
|
||||||
// node is a Document with no content -- e.g. "---\n---"
|
// node is a Document with no content -- e.g. "---\n---"
|
||||||
return node.Kind == yaml.DocumentNode &&
|
return node.Kind == yaml.DocumentNode &&
|
||||||
node.Content[0].Tag == yaml.NullNodeTag
|
node.Content[0].Tag == yaml.NodeTagNull
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ByteReader) decode(index int, decoder *yaml.Decoder) (*yaml.RNode, error) {
|
func (r *ByteReader) decode(index int, decoder *yaml.Decoder) (*yaml.RNode, error) {
|
||||||
|
|||||||
@@ -26,22 +26,16 @@ const (
|
|||||||
NodeTagMap = "!!map"
|
NodeTagMap = "!!map"
|
||||||
NodeTagSeq = "!!seq"
|
NodeTagSeq = "!!seq"
|
||||||
NodeTagEmpty = ""
|
NodeTagEmpty = ""
|
||||||
|
|
||||||
// TODO: deprecate these
|
|
||||||
NullNodeTag = NodeTagNull
|
|
||||||
StringTag = NodeTagString
|
|
||||||
BoolTag = NodeTagBool
|
|
||||||
IntTag = NodeTagInt
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NullNode returns a RNode point represents a null; value
|
// MakeNullNode returns an RNode that represents an empty document.
|
||||||
func NullNode() *RNode {
|
func MakeNullNode() *RNode {
|
||||||
return NewRNode(&Node{Tag: NullNodeTag})
|
return NewRNode(&Node{Tag: NodeTagNull})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMissingOrNull returns true if the RNode is nil or contains and explicitly null value.
|
// IsMissingOrNull returns true if the RNode is nil or contains and explicitly null value.
|
||||||
func IsMissingOrNull(node *RNode) bool {
|
func IsMissingOrNull(node *RNode) bool {
|
||||||
return node == nil || node.YNode() == nil || node.YNode().Tag == NullNodeTag
|
return node == nil || node.YNode() == nil || node.YNode().Tag == NodeTagNull
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEmpty returns true if the RNode is MissingOrNull
|
// IsEmpty returns true if the RNode is MissingOrNull
|
||||||
@@ -59,12 +53,12 @@ func IsEmptyMap(node *RNode) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IsNull(node *RNode) bool {
|
func IsNull(node *RNode) bool {
|
||||||
return node != nil && node.YNode() != nil && node.YNode().Tag == NullNodeTag
|
return node != nil && node.YNode() != nil && node.YNode().Tag == NodeTagNull
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsFieldEmpty(node *MapNode) bool {
|
func IsFieldEmpty(node *MapNode) bool {
|
||||||
if node == nil || node.Value == nil || node.Value.YNode() == nil ||
|
if node == nil || node.Value == nil || node.Value.YNode() == nil ||
|
||||||
node.Value.YNode().Tag == NullNodeTag {
|
node.Value.YNode().Tag == NodeTagNull {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +82,7 @@ func GetValue(node *RNode) string {
|
|||||||
|
|
||||||
func IsFieldNull(node *MapNode) bool {
|
func IsFieldNull(node *MapNode) bool {
|
||||||
return node != nil && node.Value != nil && node.Value.YNode() != nil &&
|
return node != nil && node.Value != nil && node.Value.YNode() != nil &&
|
||||||
node.Value.YNode().Tag == NullNodeTag
|
node.Value.YNode().Tag == NodeTagNull
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parser parses values into configuration.
|
// Parser parses values into configuration.
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ func TestIsMissingOrNull(t *testing.T) {
|
|||||||
t.Fatalf("input: valid node")
|
t.Fatalf("input: valid node")
|
||||||
}
|
}
|
||||||
// node with NullNodeTag
|
// node with NullNodeTag
|
||||||
if !IsMissingOrNull(NullNode()) {
|
if !IsMissingOrNull(MakeNullNode()) {
|
||||||
t.Fatalf("input: with NullNodeTag")
|
t.Fatalf("input: with NullNodeTag")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user