A Go module for handling images in Docker, Docker Compose, and Helm files. This module provides structures and utilities to manage image information across different types of files in a Kubernetes environment.
go get github.com/Checkmarx/containers-types
import "github.com/Checkmarx/containers-types"
type FileImages struct {
Dockerfile []FilePath
DockerCompose []FilePath
Helm []HelmChartInfo
}
type FilePath struct {
FullPath string
RelativePath string
}
type ImageModel struct {
Name string
ImageLocations []ImageLocation
}
type HelmChartInfo struct {
Directory string // Absolute path to the Helm chart directory
ValuesFile string // Relative path to the values.yaml file
TemplateFiles []FilePath // Relative paths to template files
}
type ImageLocation struct {
Origin string
Path string
}
const (
UserInput = "UserInput"
DockerFileOrigin = "Dockerfile"
DockerComposeFileOrigin = "DockerCompose"
HelmFileOrigin = "Helm"
NoFilePath = "NONE"
)
type Microservice struct {
Spec struct {
Image struct {
Registry string yaml:"registry"
Name string yaml:"name"
Tag string yaml:"tag"
} yaml:"image"
} yaml:"spec"
}
Converts a list of image names into a list of ImageModel
structures, marking them as user input with no specific file paths.
func ToImageModels(images []string) []ImageModel {
var imageNames []ImageModel
for _, image := range images {
imageNames = append(imageNames, ImageModel{
Name: image,
ImageLocations: []ImageLocation{
{
Origin: UserInput,
Path: NoFilePath,
},
},
})
}
return imageNames
}
This project is licensed under the MIT License - see the LICENSE file for details.