Documentation
¶
Overview ¶
Package yamlutil provides utilities for manipulating YAML files while preserving formatting, comments, and structure. It uses text-based manipulation to guarantee zero data loss when updating YAML configuration files.
Package yamlutil provides utilities for manipulating YAML files while preserving formatting, comments, and structure. It uses text-based manipulation to guarantee zero data loss when updating YAML configuration files.
Package yamlutil provides utilities for manipulating YAML files while preserving formatting, comments, and structure. It uses text-based manipulation to guarantee zero data loss when updating YAML configuration files.
Index ¶
- func AppendToArraySection(content string, opts ArrayAppendOptions) (string, int, error)
- func FindServiceInSection(lines []string, servicesInfo *sectionInfo, serviceName string) (*serviceInfo, error)
- func UpdateServiceLogsConfig(azureYamlPath, serviceName string, tables []string, query string) error
- func UpdateServicePort(azureYamlPath, serviceName string, port int) error
- type ArrayAppendOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToArraySection ¶
func AppendToArraySection(content string, opts ArrayAppendOptions) (string, int, error)
AppendToArraySection appends items to a YAML array section while preserving all comments, formatting, and other content in the file.
This uses text-based manipulation to guarantee zero data loss, only appending new items to the specified array section.
func FindServiceInSection ¶
func FindServiceInSection(lines []string, servicesInfo *sectionInfo, serviceName string) (*serviceInfo, error)
FindServiceInSection finds a specific service within the services section. Exported for use by other yamlutil functions.
func UpdateServiceLogsConfig ¶
func UpdateServiceLogsConfig(azureYamlPath, serviceName string, tables []string, query string) error
UpdateServiceLogsConfig updates the logs configuration for a specific service in azure.yaml. This preserves all comments, formatting, schema fields, and other content in the file. It only modifies the specific analytics configuration (tables or query) for the given service.
func UpdateServicePort ¶
UpdateServicePort adds or updates the ports field for a specific service in azure.yaml. This preserves all comments, formatting, and other content in the file. The port is added as a single-element ports array: ports: ["8080"]
Types ¶
type ArrayAppendOptions ¶
type ArrayAppendOptions struct {
SectionKey string // The YAML key to find (e.g., "reqs")
Items []map[string]any // Items to append
ItemIDKey string // Key to use for deduplication (e.g., "id")
FormatItem func(map[string]any, string) string // Custom formatter for items
}
ArrayAppendOptions configures how array items should be appended to a YAML section.