Documentation
¶
Index ¶
- Constants
- Variables
- func ArchiveArtifactPaths(baseDir string, artifactPaths []string) (map[string]string, error)
- func BuildDockerBuildArgs(platforms, dockerfilePath, imageURL string, cacheFrom, cacheTo []string) []string
- func BuildService(ctx context.Context, fileData []byte, token, name, specType string, ...) (serviceID string, environmentID string, productTierID string, ...)
- func BuildServiceFromRepository(cmd *cobra.Command, ctx context.Context, ...) (serviceID, devEnvironmentID, devPlanID string, ...)
- func ContainsAnyKey(m map[string]interface{}, keys []string) bool
- func ContainsOmnistrateKey(m map[string]interface{}) bool
- func DetectSpecType(yamlContent map[string]interface{}) string
- func ExpandOmctlEnvVars(data []byte) ([]byte, error)
- func RenderFile(fileData []byte, rootDir string, file string, sm utils.SpinnerManager, ...) (newFileData []byte, err error)
- func UniqueArtifactPathsFromTasks(tasks []ArtifactUploadingTask) []string
- type ArtifactStatusCallback
- type ArtifactUploadingTask
- type ServiceHierarchyResult
Constants ¶
const ( GitHubPATGenerateURL = "https://github.com/settings/tokens" DefaultProdEnvName = "Production" )
const ( DockerComposeSpecType = "DockerCompose" ServicePlanSpecType = "ServicePlanSpec" OmnistrateComposeFileName = "omnistrate-compose.yaml" DockerComposeFileName = "docker-compose.yaml" ComposeFileName = "compose.yaml" PlanSpecFileName = "spec.yaml" DeploymentTypeHosted = "hosted" DeploymentTypeByoa = "byoa" )
const ( StatusReady = "READY" StatusFailed = "FAILED" )
Variables ¶
var ( ServiceID string EnvironmentID string ProductTierID string )
var BuildCmd = &cobra.Command{ Use: "build [--file=file] [--spec-type=spec-type] [--product-name=service-name] [--description=service-description] [--service-logo-url=service-logo-url] [--environment=environment-name] [--environment-type=environment-type] [--release] [--release-as-preferred] [--no-release-as-preferred] [--release-description=release-description][--interactive] [--image=image-url] [--image-registry-auth-username=username] [--image-registry-auth-password=password] [--env-var=\"key=var\"]", Short: "Build Services from image, compose spec or service plan spec", Long: buildLong, Example: buildExample, RunE: runBuild, SilenceUsage: true, }
BuildCmd represents the build command
var BuildFromRepoCmd = &cobra.Command{ Use: "build-from-repo", Short: "Build Service from Git Repository", Long: "This command helps to build service from git repository. Run this command from the root of the repository. Make sure you have the Dockerfile in the repository and have the Docker daemon running on your machine. By default, the service name will be the repository name, but you can specify a custom service name with the --product-name flag.\n\nYou can also skip specific stages of the build process using the --skip-* flags. For example, you can skip building the Docker image with --skip-docker-build, skip creating the service with --skip-service-build, or skip SaaS portal initialization with --skip-saas-portal-init.\n\nEnvironment promotion is skipped by default. To promote the service to production, use --skip-environment-promotion=false.\n\nFor testing purposes, use the --dry-run flag to only build the Docker image locally without pushing, skip service creation, and generate a local spec file with a '-dry-run' suffix. Note that --dry-run cannot be used together with any of the --skip-* flags as they are mutually exclusive.", Example: buildFromRepoExample, RunE: runBuildFromRepo, SilenceUsage: true, }
Functions ¶
func ArchiveArtifactPaths ¶ added in v1.2.8
ArchiveArtifactPaths creates tar.gz archives for each artifact path and returns base64 encoded content. baseDir is the directory from which relative paths are resolved. Returns a map of relative path to base64 encoded tar.gz content.
func BuildDockerBuildArgs ¶ added in v1.6.0
func BuildDockerBuildArgs(platforms, dockerfilePath, imageURL string, cacheFrom, cacheTo []string) []string
BuildDockerBuildArgs constructs the arguments for a `docker buildx build` command, including optional --cache-from and --cache-to flags from the compose spec. --load is always included for single-platform builds so the image is available locally for subsequent `docker push`. It is only omitted for multi-platform builds where --load is incompatible with the buildx driver.
func BuildService ¶ added in v1.0.31
func BuildService(ctx context.Context, fileData []byte, token, name, specType string, description, serviceLogoURL, environment, environmentType *string, release, releaseAsPreferred bool, releaseName *string, dryRun bool, forceCreateNewServicePlanVersion bool) (serviceID string, environmentID string, productTierID string, undefinedResources map[string]string, isNewVersionCreated bool, err error)
func BuildServiceFromRepository ¶ added in v1.0.31
func BuildServiceFromRepository(cmd *cobra.Command, ctx context.Context, token, serviceName, releaseDescription string, resetPAT, dryRun, skipDockerBuild, skipServiceBuild bool, deploymentType, awsAccountID, gcpProjectID, gcpProjectNumber, azureSubscriptionID, azureTenantID string, sm utils.SpinnerManager, file string, envVars, platforms []string, forceCreateServicePlanVersion bool) (serviceID, devEnvironmentID, devPlanID string, undefinedResources map[string]string, err error)
func ContainsAnyKey ¶ added in v1.0.44
ContainsAnyKey recursively searches for any key in keys in a map
func ContainsOmnistrateKey ¶ added in v1.0.44
ContainsOmnistrateKey recursively searches for any x-omnistrate key in a map
func DetectSpecType ¶ added in v1.0.44
DetectSpecType analyzes YAML content to determine if it contains service plan specifications Returns ServicePlanSpecType if plan-specific keys are found, otherwise DockerComposeSpecType
func ExpandOmctlEnvVars ¶ added in v1.4.9
ExpandOmctlEnvVars expands environment variable references prefixed with OMCTL_ in the given data. Only ${OMCTL_*} patterns are expanded to avoid interfering with other $var or $sys references used in Omnistrate spec files. Returns an error listing all unresolved OMCTL_ placeholders.
func RenderFile ¶ added in v0.14.43
func UniqueArtifactPathsFromTasks ¶ added in v1.2.8
func UniqueArtifactPathsFromTasks(tasks []ArtifactUploadingTask) []string
UniqueArtifactPathsFromTasks returns deduplicated artifact paths from ArtifactUploadingTasks
Types ¶
type ArtifactStatusCallback ¶ added in v1.2.8
ArtifactStatusCallback is called when an artifact's status changes during polling. artifactID is the artifact ID, status is the new status (e.g., "READY", "FAILED", "UPLOADING").
type ArtifactUploadingTask ¶ added in v1.2.8
type ArtifactUploadingTask struct {
ArtifactPath string // The artifact path expected by the server
AccountConfigID string // The resolved account config ID for this upload
ServiceName string // The service name
ProductTierName string // The product tier name
EnvironmentType string // The environment type (e.g., "DEV", "PROD")
}
ArtifactUploadingTask represents a single artifact upload task returned by the prepare API. It contains all the server-side resolved parameters needed to call the upload artifact API.
type ServiceHierarchyResult ¶ added in v1.2.8
type ServiceHierarchyResult struct {
ServiceID string
EnvironmentID string
ProductTierID string
IsNewProductTier bool
// ArtifactUploadingTasks contains artifact upload tasks returned by the prepare API.
// Each task describes one artifact that needs to be uploaded, with all server-resolved parameters.
ArtifactUploadingTasks []ArtifactUploadingTask
}
ServiceHierarchyResult holds the result of finding or creating the service hierarchy
func FindOrCreateServiceHierarchy ¶ added in v1.2.8
func FindOrCreateServiceHierarchy( ctx context.Context, token string, serviceName string, fileData []byte, environmentName *string, environmentType *string, ) (*ServiceHierarchyResult, error)
FindOrCreateServiceHierarchy uses the prepare service plan spec API to find or create the service hierarchy (service -> environment -> product tier) in a single server-side call. The response also includes artifact uploading tasks that the caller should follow to upload artifacts. environmentName and environmentType are optional - if nil, defaults to "Development" and "DEV" respectively.