kubejson

package
v0.0.0-...-9bbed00 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

This is heavily based on the protojson code, but we currently need some special handling for apiVersion and kind.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(m proto.Message) string

Format formats the message as a multiline string. This function is only intended for human consumption and ignores errors. Do not depend on the output being stable. It may change over time across different versions of the program.

func Marshal

func Marshal(m proto.Message) ([]byte, error)

Marshal writes the given proto.Message in JSON format using default options. Do not depend on the output being stable. It may change over time across different versions of the program.

func Unmarshal

func Unmarshal(b []byte, m proto.Message) error

Unmarshal reads the given []byte into the given proto.Message. The provided message must be mutable (e.g., a non-nil pointer to a message).

Types

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder provides methods to write out JSON constructs and values. The user is responsible for producing valid sequences of JSON constructs and values.

func NewEncoder

func NewEncoder(indent string) (*Encoder, error)

NewEncoder returns an Encoder.

If indent is a non-empty string, it causes every entry for an Array or Object to be preceded by the indent and trailed by a newline.

func (*Encoder) Bytes

func (e *Encoder) Bytes() []byte

Bytes returns the content of the written bytes.

func (*Encoder) EndArray

func (e *Encoder) EndArray()

EndArray writes out the ']' symbol.

func (*Encoder) EndObject

func (e *Encoder) EndObject()

EndObject writes out the '}' symbol.

func (*Encoder) StartArray

func (e *Encoder) StartArray()

StartArray writes out the '[' symbol.

func (*Encoder) StartObject

func (e *Encoder) StartObject()

StartObject writes out the '{' symbol.

func (*Encoder) WriteBool

func (e *Encoder) WriteBool(b bool)

WriteBool writes out the given boolean value.

func (*Encoder) WriteFloat

func (e *Encoder) WriteFloat(n float64, bitSize int)

WriteFloat writes out the given float and bitSize in JSON number value.

func (*Encoder) WriteInt

func (e *Encoder) WriteInt(n int64)

WriteInt writes out the given signed integer in JSON number value.

func (*Encoder) WriteName

func (e *Encoder) WriteName(s string) error

WriteName writes out the given string in JSON string value and the name separator ':'. Returns error if input string contains invalid UTF-8, which should not be likely as protobuf field names should be valid.

func (*Encoder) WriteNull

func (e *Encoder) WriteNull()

WriteNull writes out the null value.

func (*Encoder) WriteString

func (e *Encoder) WriteString(s string) error

WriteString writes out the given string in JSON string value. Returns error if input string contains invalid UTF-8.

func (*Encoder) WriteUint

func (e *Encoder) WriteUint(n uint64)

WriteUint writes out the given unsigned integer in JSON number value.

type KubeListObjectMeta

type KubeListObjectMeta struct {
	APIVersion string
	Kind       string
}

type UnmarshalOptions

type UnmarshalOptions struct {

	// If AllowPartial is set, input for messages that will result in missing
	// required fields will not return an error.
	AllowPartial bool

	// If DiscardUnknown is set, unknown fields are ignored.
	DiscardUnknown bool

	// Resolver is used for looking up types when unmarshaling
	// google.protobuf.Any messages or extension fields.
	// If nil, this defaults to using protoregistry.GlobalTypes.
	Resolver interface {
		protoregistry.MessageTypeResolver
		protoregistry.ExtensionTypeResolver
	}
}

UnmarshalOptions is a configurable JSON format parser.

func (UnmarshalOptions) Unmarshal

func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error

Unmarshal reads the given []byte and populates the given proto.Message using options in the UnmarshalOptions object. It will clear the message first before setting the fields. If it returns an error, the given message may be partially set. The provided message must be mutable (e.g., a non-nil pointer to a message).

func (UnmarshalOptions) UnmarshalKubeList

func (o UnmarshalOptions) UnmarshalKubeList(b []byte, m proto.Message, callback func(m proto.Message)) (*KubeListObjectMeta, error)

Directories

Path Synopsis
internal
set
Package set provides simple set data structures for uint64s.
Package set provides simple set data structures for uint64s.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL