xml

package
v0.0.0-...-2c89c80 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProdRegion

func IsProdRegion(s string, system vespa.System) bool

IsProdRegion returns whether string s is a valid production region.

func ParseNodeCount

func ParseNodeCount(s string) (int, int, error)

ParseNodeCount parses a node count range from string s.

func Replace

func Replace(r io.Reader, parentName, name string, data interface{}) (string, error)

Replace looks for an element name in the XML read from reader r, appearing inside a element named parentName.

Any matching elements found are replaced with data. If parentName contains an ID selector, e.g. "email#my-id", only the elements inside the parent element with the attribute id="my-id" are replaced.

If data is nil, any matching elements are removed instead of replaced.

func ReplaceRaw

func ReplaceRaw(rawXML, name, value string) string

ReplaceRaw finds all elements of name in rawXML and replaces their contents with value.

Types

type Container

type Container struct {
	Root  xml.Name `xml:"container"`
	ID    string   `xml:"id,attr"`
	Nodes Nodes    `xml:"nodes"`
}

type Content

type Content struct {
	ID    string `xml:"id,attr"`
	Nodes Nodes  `xml:"nodes"`
}

type Deployment

type Deployment struct {
	Root     xml.Name   `xml:"deployment"`
	Version  string     `xml:"version,attr"`
	Instance []Instance `xml:"instance"`
	Prod     Prod       `xml:"prod"`
	// contains filtered or unexported fields
}

Deployment represents the contents of a deployment.xml file.

var DefaultDeployment Deployment

func ReadDeployment

func ReadDeployment(r io.Reader) (Deployment, error)

ReadDeployment reads deployment.xml from reader r.

func (*Deployment) Replace

func (s *Deployment) Replace(parentName, name string, data interface{}) error

Replace replaces any elements of name found under parentName with data.

func (Deployment) String

func (d Deployment) String() string

type Instance

type Instance struct {
	Prod Prod `xml:"prod"`
}

type Nodes

type Nodes struct {
	Count     string     `xml:"count,attr"`
	Resources *Resources `xml:"resources,omitempty"`
}

type Prod

type Prod struct {
	Regions []Region `xml:"region"`
}

type Region

type Region struct {
	Name string `xml:",chardata"`
}

func Regions

func Regions(names ...string) []Region

Regions returns given region names as elements.

type Resources

type Resources struct {
	Vcpu   string `xml:"vcpu,attr"`
	Memory string `xml:"memory,attr"`
	Disk   string `xml:"disk,attr"`
}

func ParseResources

func ParseResources(s string) (Resources, error)

ParseResources parses nodes resources from string s.

func (Resources) String

func (r Resources) String() string

type Services

type Services struct {
	Root      xml.Name    `xml:"services"`
	Container []Container `xml:"container"`
	Content   []Content   `xml:"content"`
	// contains filtered or unexported fields
}

Services represents the contents of a services.xml file.

func ReadServices

func ReadServices(r io.Reader) (Services, error)

ReadServices reads services.xml from reader r.

func (*Services) Replace

func (s *Services) Replace(parentName, name string, data interface{}) error

Replace replaces any elements of name found under parentName with data.

func (Services) String

func (s Services) String() string

Jump to

Keyboard shortcuts

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