github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/types/package.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: 2021-Present The Jackal Authors 3 4 // Package types contains all the types used by Jackal. 5 package types 6 7 // JackalPackageKind is an enum of the different kinds of Jackal packages. 8 type JackalPackageKind string 9 10 const ( 11 // JackalInitConfig is the kind of Jackal package used during `jackal init`. 12 JackalInitConfig JackalPackageKind = "JackalInitConfig" 13 // JackalPackageConfig is the default kind of Jackal package, primarily used during `jackal package`. 14 JackalPackageConfig JackalPackageKind = "JackalPackageConfig" 15 ) 16 17 // JackalPackage the top-level structure of a Jackal config file. 18 type JackalPackage struct { 19 Kind JackalPackageKind `json:"kind" jsonschema:"description=The kind of Jackal package,enum=JackalInitConfig,enum=JackalPackageConfig,default=JackalPackageConfig"` 20 Metadata JackalMetadata `json:"metadata,omitempty" jsonschema:"description=Package metadata"` 21 Build JackalBuildData `json:"build,omitempty" jsonschema:"description=Jackal-generated package build data"` 22 Components []JackalComponent `json:"components" jsonschema:"description=List of components to deploy in this package"` 23 Constants []JackalPackageConstant `json:"constants,omitempty" jsonschema:"description=Constant template values applied on deploy for K8s resources"` 24 Variables []JackalPackageVariable `json:"variables,omitempty" jsonschema:"description=Variable template values applied on deploy for K8s resources"` 25 } 26 27 // IsInitConfig returns whether a Jackal package is an init config. 28 func (pkg JackalPackage) IsInitConfig() bool { 29 return pkg.Kind == JackalInitConfig 30 } 31 32 // IsSBOMAble checks if a package has contents that an SBOM can be created on (i.e. images, files, or data injections). 33 func (pkg JackalPackage) IsSBOMAble() bool { 34 for _, c := range pkg.Components { 35 if len(c.Images) > 0 || len(c.Files) > 0 || len(c.DataInjections) > 0 { 36 return true 37 } 38 } 39 return false 40 } 41 42 // JackalMetadata lists information about the current JackalPackage. 43 type JackalMetadata struct { 44 Name string `json:"name" jsonschema:"description=Name to identify this Jackal package,pattern=^[a-z0-9\\-]*[a-z0-9]$"` 45 Description string `json:"description,omitempty" jsonschema:"description=Additional information about this package"` 46 Version string `json:"version,omitempty" jsonschema:"description=Generic string set by a package author to track the package version (Note: JackalInitConfigs will always be versioned to the CLIVersion they were created with)"` 47 URL string `json:"url,omitempty" jsonschema:"description=Link to package information when online"` 48 Image string `json:"image,omitempty" jsonschema:"description=An image URL to embed in this package (Reserved for future use in Jackal UI)"` 49 Uncompressed bool `json:"uncompressed,omitempty" jsonschema:"description=Disable compression of this package"` 50 Architecture string `json:"architecture,omitempty" jsonschema:"description=The target cluster architecture for this package,example=arm64,example=amd64"` 51 YOLO bool `json:"yolo,omitempty" jsonschema:"description=Yaml OnLy Online (YOLO): True enables deploying a Jackal package without first running jackal init against the cluster. This is ideal for connected environments where you want to use existing VCS and container registries."` 52 Authors string `json:"authors,omitempty" jsonschema:"description=Comma-separated list of package authors (including contact info),example=Doug <hello@defenseunicorns.com>, Pepr <hello@defenseunicorns.com>"` 53 Documentation string `json:"documentation,omitempty" jsonschema:"description=Link to package documentation when online"` 54 Source string `json:"source,omitempty" jsonschema:"description=Link to package source code when online"` 55 Vendor string `json:"vendor,omitempty" jsonschema_description:"Name of the distributing entity, organization or individual."` 56 AggregateChecksum string `json:"aggregateChecksum,omitempty" jsonschema:"description=Checksum of a checksums.txt file that contains checksums all the layers within the package."` 57 } 58 59 // JackalBuildData is written during the packager.Create() operation to track details of the created package. 60 type JackalBuildData struct { 61 Terminal string `json:"terminal" jsonschema:"description=The machine name that created this package"` 62 User string `json:"user" jsonschema:"description=The username who created this package"` 63 Architecture string `json:"architecture" jsonschema:"description=The architecture this package was created on"` 64 Timestamp string `json:"timestamp" jsonschema:"description=The timestamp when this package was created"` 65 Version string `json:"version" jsonschema:"description=The version of Jackal used to build this package"` 66 Migrations []string `json:"migrations,omitempty" jsonschema:"description=Any migrations that have been run on this package"` 67 RegistryOverrides map[string]string `json:"registryOverrides,omitempty" jsonschema:"description=Any registry domains that were overridden on package create when pulling images"` 68 Differential bool `json:"differential,omitempty" jsonschema:"description=Whether this package was created with differential components"` 69 DifferentialPackageVersion string `json:"differentialPackageVersion,omitempty" jsonschema:"description=Version of a previously built package used as the basis for creating this differential package"` 70 DifferentialMissing []string `json:"differentialMissing,omitempty" jsonschema:"description=List of components that were not included in this package due to differential packaging"` 71 LastNonBreakingVersion string `json:"lastNonBreakingVersion,omitempty" jsonschema:"description=The minimum version of Jackal that does not have breaking package structure changes"` 72 Flavor string `json:"flavor,omitempty" jsonschema:"description=The flavor of Jackal used to build this package"` 73 } 74 75 // JackalPackageVariable are variables that can be used to dynamically template K8s resources. 76 type JackalPackageVariable struct { 77 Name string `json:"name" jsonschema:"description=The name to be used for the variable,pattern=^[A-Z0-9_]+$"` 78 Description string `json:"description,omitempty" jsonschema:"description=A description of the variable to be used when prompting the user a value"` 79 Default string `json:"default,omitempty" jsonschema:"description=The default value to use for the variable"` 80 Prompt bool `json:"prompt,omitempty" jsonschema:"description=Whether to prompt the user for input for this variable"` 81 Sensitive bool `json:"sensitive,omitempty" jsonschema:"description=Whether to mark this variable as sensitive to not print it in the Jackal log"` 82 AutoIndent bool `json:"autoIndent,omitempty" jsonschema:"description=Whether to automatically indent the variable's value (if multiline) when templating. Based on the number of chars before the start of ###JACKAL_VAR_."` 83 Pattern string `json:"pattern,omitempty" jsonschema:"description=An optional regex pattern that a variable value must match before a package can be deployed."` 84 Type VariableType `json:"type,omitempty" jsonschema:"description=Changes the handling of a variable to load contents differently (i.e. from a file rather than as a raw variable - templated files should be kept below 1 MiB),enum=raw,enum=file"` 85 } 86 87 // JackalPackageConstant are constants that can be used to dynamically template K8s resources. 88 type JackalPackageConstant struct { 89 Name string `json:"name" jsonschema:"description=The name to be used for the constant,pattern=^[A-Z0-9_]+$"` 90 Value string `json:"value" jsonschema:"description=The value to set for the constant during deploy"` 91 // Include a description that will only be displayed during package create/deploy confirm prompts 92 Description string `json:"description,omitempty" jsonschema:"description=A description of the constant to explain its purpose on package create or deploy confirmation prompts"` 93 AutoIndent bool `json:"autoIndent,omitempty" jsonschema:"description=Whether to automatically indent the variable's value (if multiline) when templating. Based on the number of chars before the start of ###JACKAL_CONST_."` 94 Pattern string `json:"pattern,omitempty" jsonschema:"description=An optional regex pattern that a constant value must match before a package can be created."` 95 }