yamlparser

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseComposeContent

func ParseComposeContent(content string) ([]string, error)

ParseComposeContent 解析docker-compose.yaml内容并提取所有镜像

func ParseComposeFile

func ParseComposeFile(filePath string) ([]string, error)

ParseComposeFile 解析docker-compose.yaml文件并提取所有镜像

func ParseContent

func ParseContent(content string, fileType FileType) ([]string, error)

ParseContent 解析YAML内容并提取镜像 根据内容自动判断是docker-compose还是k8s文件

func ParseFile

func ParseFile(filePath string) ([]string, error)

ParseFile 解析YAML文件并提取镜像 根据文件名和内容综合判断是docker-compose还是k8s文件

func ParseK8sContent

func ParseK8sContent(content string) ([]string, error)

ParseK8sContent 解析Kubernetes YAML内容并提取所有镜像

func ParseK8sFile

func ParseK8sFile(filePath string) ([]string, error)

ParseK8sFile 解析Kubernetes YAML文件并提取所有镜像

Types

type ComposeConfig

type ComposeConfig struct {
	Version  string                   `yaml:"version"`
	Services map[string]ServiceConfig `yaml:"services"`
}

ComposeConfig docker-compose.yaml配置结构

type FileType

type FileType string

FileType YAML文件类型

const (
	// FileTypeUnknown 未知文件类型
	FileTypeUnknown FileType = "unknown"
	// FileTypeCompose docker-compose文件
	FileTypeCompose FileType = "compose"
	// FileTypeK8s Kubernetes文件
	FileTypeK8s FileType = "k8s"
)

func DetectFileType

func DetectFileType(filePath string) FileType

DetectFileType 根据文件路径或内容检测YAML文件类型

type K8sResource

type K8sResource struct {
	APIVersion string      `yaml:"apiVersion"`
	Kind       string      `yaml:"kind"`
	Metadata   interface{} `yaml:"metadata"`
	Spec       interface{} `yaml:"spec"`
}

简化的Kubernetes资源结构

type ServiceConfig

type ServiceConfig struct {
	Image string `yaml:"image"`
	Build string `yaml:"build"`
}

ServiceConfig docker-compose服务配置

Jump to

Keyboard shortcuts

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