github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/types/runtime.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 import ( 8 "time" 9 ) 10 11 const ( 12 // RawVariableType is the default type for a Jackal package variable 13 RawVariableType VariableType = "raw" 14 // FileVariableType is a type for a Jackal package variable that loads its contents from a file 15 FileVariableType VariableType = "file" 16 ) 17 18 // Jackal looks for these strings in jackal.yaml to make dynamic changes 19 const ( 20 JackalPackageTemplatePrefix = "###JACKAL_PKG_TMPL_" 21 JackalPackageVariablePrefix = "###JACKAL_PKG_VAR_" 22 JackalPackageArch = "###JACKAL_PKG_ARCH###" 23 JackalComponentName = "###JACKAL_COMPONENT_NAME###" 24 ) 25 26 // VariableType represents a type of a Jackal package variable 27 type VariableType string 28 29 // JackalCommonOptions tracks the user-defined preferences used across commands. 30 type JackalCommonOptions struct { 31 Confirm bool `json:"confirm" jsonschema:"description=Verify that Jackal should perform an action"` 32 Insecure bool `json:"insecure" jsonschema:"description=Allow insecure connections for remote packages"` 33 CachePath string `json:"cachePath" jsonschema:"description=Path to use to cache images and git repos on package create"` 34 TempDirectory string `json:"tempDirectory" jsonschema:"description=Location Jackal should use as a staging ground when managing files and images for package creation and deployment"` 35 OCIConcurrency int `jsonschema:"description=Number of concurrent layer operations to perform when interacting with a remote package"` 36 } 37 38 // JackalPackageOptions tracks the user-defined preferences during common package operations. 39 type JackalPackageOptions struct { 40 Shasum string `json:"shasum" jsonschema:"description=The SHA256 checksum of the package"` 41 PackageSource string `json:"packageSource" jsonschema:"description=Location where a Jackal package can be found"` 42 OptionalComponents string `json:"optionalComponents" jsonschema:"description=Comma separated list of optional components"` 43 SGetKeyPath string `json:"sGetKeyPath" jsonschema:"description=Location where the public key component of a cosign key-pair can be found"` 44 SetVariables map[string]string `json:"setVariables" jsonschema:"description=Key-Value map of variable names and their corresponding values that will be used to template manifests and files in the Jackal package"` 45 PublicKeyPath string `json:"publicKeyPath" jsonschema:"description=Location where the public key component of a cosign key-pair can be found"` 46 Retries int `json:"retries" jsonschema:"description=The number of retries to perform for Jackal deploy operations like image pushes or Helm installs"` 47 } 48 49 // JackalInspectOptions tracks the user-defined preferences during a package inspection. 50 type JackalInspectOptions struct { 51 ViewSBOM bool `json:"sbom" jsonschema:"description=View SBOM contents while inspecting the package"` 52 SBOMOutputDir string `json:"sbomOutput" jsonschema:"description=Location to output an SBOM into after package inspection"` 53 } 54 55 // JackalFindImagesOptions tracks the user-defined preferences during a prepare find-images search. 56 type JackalFindImagesOptions struct { 57 RepoHelmChartPath string `json:"repoHelmChartPath" jsonschema:"description=Path to the helm chart directory"` 58 KubeVersionOverride string `json:"kubeVersionOverride" jsonschema:"description=Kubernetes version to use for the helm chart"` 59 RegistryURL string `json:"registryURL" jsonschema:"description=Manual override for ###JACKAL_REGISTRY###"` 60 Why string `json:"why" jsonschema:"description=Find the location of the image given as an argument and print it to the console."` 61 } 62 63 // JackalDeployOptions tracks the user-defined preferences during a package deploy. 64 type JackalDeployOptions struct { 65 AdoptExistingResources bool `json:"adoptExistingResources" jsonschema:"description=Whether to adopt any pre-existing K8s resources into the Helm charts managed by Jackal"` 66 SkipWebhooks bool `json:"componentWebhooks" jsonschema:"description=Skip waiting for external webhooks to execute as each package component is deployed"` 67 Timeout time.Duration `json:"timeout" jsonschema:"description=Timeout for performing Helm operations"` 68 69 // TODO (@WSTARR): This is a library only addition to Jackal and should be refactored in the future (potentially to utilize component composability). As is it should NOT be exposed directly on the CLI 70 ValuesOverridesMap map[string]map[string]map[string]interface{} `json:"valuesOverridesMap" jsonschema:"description=[Library Only] A map of component names to chart names containing Helm Chart values to override values on deploy"` 71 } 72 73 // JackalMirrorOptions tracks the user-defined preferences during a package mirror. 74 type JackalMirrorOptions struct { 75 NoImgChecksum bool `json:"noImgChecksum" jsonschema:"description=Whether to skip adding a Jackal checksum to image references."` 76 } 77 78 // JackalPublishOptions tracks the user-defined preferences during a package publish. 79 type JackalPublishOptions struct { 80 PackageDestination string `json:"packageDestination" jsonschema:"description=Location where the Jackal package will be published to"` 81 SigningKeyPassword string `json:"signingKeyPassword" jsonschema:"description=Password to the private key signature file that will be used to sign the published package"` 82 SigningKeyPath string `json:"signingKeyPath" jsonschema:"description=Location where the private key component of a cosign key-pair can be found"` 83 } 84 85 // JackalPullOptions tracks the user-defined preferences during a package pull. 86 type JackalPullOptions struct { 87 OutputDirectory string `json:"outputDirectory" jsonschema:"description=Location where the pulled Jackal package will be placed"` 88 } 89 90 // JackalGenerateOptions tracks the user-defined options during package generation. 91 type JackalGenerateOptions struct { 92 Name string `json:"name" jsonschema:"description=Name of the package being generated"` 93 URL string `json:"url" jsonschema:"description=URL to the source git repository"` 94 Version string `json:"version" jsonschema:"description=Version of the chart to use"` 95 GitPath string `json:"gitPath" jsonschema:"description=Relative path to the chart in the git repository"` 96 Output string `json:"output" jsonschema:"description=Location where the finalized jackal.yaml will be placed"` 97 } 98 99 // JackalInitOptions tracks the user-defined options during cluster initialization. 100 type JackalInitOptions struct { 101 // Jackal init is installing the k3s component 102 ApplianceMode bool `json:"applianceMode" jsonschema:"description=Indicates if Jackal was initialized while deploying its own k8s cluster"` 103 104 // Using alternative services 105 GitServer GitServerInfo `json:"gitServer" jsonschema:"description=Information about the repository Jackal is going to be using"` 106 RegistryInfo RegistryInfo `json:"registryInfo" jsonschema:"description=Information about the container registry Jackal is going to be using"` 107 ArtifactServer ArtifactServerInfo `json:"artifactServer" jsonschema:"description=Information about the artifact registry Jackal is going to be using"` 108 109 StorageClass string `json:"storageClass" jsonschema:"description=StorageClass of the k8s cluster Jackal is initializing"` 110 } 111 112 // JackalCreateOptions tracks the user-defined options used to create the package. 113 type JackalCreateOptions struct { 114 SkipSBOM bool `json:"skipSBOM" jsonschema:"description=Disable the generation of SBOM materials during package creation"` 115 BaseDir string `json:"baseDir" jsonschema:"description=Location where the Jackal package will be created from"` 116 Output string `json:"output" jsonschema:"description=Location where the finalized Jackal package will be placed"` 117 ViewSBOM bool `json:"sbom" jsonschema:"description=Whether to pause to allow for viewing the SBOM post-creation"` 118 SBOMOutputDir string `json:"sbomOutput" jsonschema:"description=Location to output an SBOM into after package creation"` 119 SetVariables map[string]string `json:"setVariables" jsonschema:"description=Key-Value map of variable names and their corresponding values that will be used to template against the Jackal package being used"` 120 MaxPackageSizeMB int `json:"maxPackageSizeMB" jsonschema:"description=Size of chunks to use when splitting a jackal package into multiple files in megabytes"` 121 SigningKeyPath string `json:"signingKeyPath" jsonschema:"description=Location where the private key component of a cosign key-pair can be found"` 122 SigningKeyPassword string `json:"signingKeyPassword" jsonschema:"description=Password to the private key signature file that will be used to sigh the created package"` 123 DifferentialPackagePath string `json:"differentialPackagePath" jsonschema:"description=Path to a previously built package used as the basis for creating a differential package"` 124 RegistryOverrides map[string]string `json:"registryOverrides" jsonschema:"description=A map of domains to override on package create when pulling images"` 125 Flavor string `json:"flavor" jsonschema:"description=An optional variant that controls which components will be included in a package"` 126 IsSkeleton bool `json:"isSkeleton" jsonschema:"description=Whether to create a skeleton package"` 127 NoYOLO bool `json:"noYOLO" jsonschema:"description=Whether to create a YOLO package"` 128 } 129 130 // JackalSplitPackageData contains info about a split package. 131 type JackalSplitPackageData struct { 132 Sha256Sum string `json:"sha256Sum" jsonschema:"description=The sha256sum of the package"` 133 Bytes int64 `json:"bytes" jsonschema:"description=The size of the package in bytes"` 134 Count int `json:"count" jsonschema:"description=The number of parts the package is split into"` 135 } 136 137 // JackalSetVariable tracks internal variables that have been set during this run of Jackal 138 type JackalSetVariable struct { 139 Name string `json:"name" jsonschema:"description=The name to be used for the variable,pattern=^[A-Z0-9_]+$"` 140 Sensitive bool `json:"sensitive,omitempty" jsonschema:"description=Whether to mark this variable as sensitive to not print it in the Jackal log"` 141 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_."` 142 Value string `json:"value" jsonschema:"description=The value the variable is currently set with"` 143 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"` 144 } 145 146 // ConnectString contains information about a connection made with Jackal connect. 147 type ConnectString struct { 148 Description string `json:"description" jsonschema:"description=Descriptive text that explains what the resource you would be connecting to is used for"` 149 URL string `json:"url" jsonschema:"description=URL path that gets appended to the k8s port-forward result"` 150 } 151 152 // ConnectStrings is a map of connect names to connection information. 153 type ConnectStrings map[string]ConnectString 154 155 // DifferentialData contains image and repository information about the package a Differential Package is Based on. 156 type DifferentialData struct { 157 DifferentialImages map[string]bool 158 DifferentialRepos map[string]bool 159 DifferentialPackageVersion string 160 }