utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	VersionAPIEndpoint     = "https://api.github.com/repos/openshift/ocm-container/releases/latest"
	VersionAddressTemplate = "https://github.com/openshift/ocm-container/releases/download/v%s/ocm-container_%s_%s_%s.tar.gz" // version, version, GOOS, GOARCH
)

Variables

View Source
var (
	// GitCommit is the short git commit hash from the environment
	// Will be set during build process via GoReleaser
	// See also: https://pkg.go.dev/cmd/link
	GitCommit string

	// Version is the tag version from the environment
	// Will be set during build process via GoReleaser
	// See also: https://pkg.go.dev/cmd/link
	Version string = "v0.0.0-unknown"
)

Functions

func GetLatestVersion

func GetLatestVersion() (latest string, err error)

getLatestVersion connects to the GitHub API and returns the latest ocm-container tag name

func GetOcmContainerComponent added in v1.0.1

func GetOcmContainerComponent() string

GetOcmContainerComponent returns the component variant of the ocm-container image if running inside one, or an empty string if not running in ocm-container.

Possible return values:

  • "micro": ocm-container-micro variant (minimal tools: ocm, ocm-backplane, oc)
  • "minimal": ocm-container-minimal variant (adds AWS CLI, rosa, osdctl, yq)
  • "full": ocm-container variant (full toolset including omc, jira-cli, oc-nodepp, vault, and more)
  • "": not running in ocm-container

Example usage:

component := utils.GetOcmContainerComponent()
if component != "" {
    fmt.Printf("Running in ocm-container-%s\n", component)
}

func IsRunningInOcmContainer added in v1.0.1

func IsRunningInOcmContainer() bool

IsRunningInOcmContainer returns true if the current process is running inside an ocm-container environment. This is determined by checking the IO_OPENSHIFT_MANAGED_NAME environment variable.

This function can be imported by other Go programs (such as osdctl) to detect when they are running inside ocm-container and adjust their behavior accordingly (e.g., skipping browser auto-launch, adjusting network binding addresses).

Example usage:

import "github.com/openshift/ocm-container/pkg/utils"

if utils.IsRunningInOcmContainer() {
    // Skip browser launch, show URL instead
    fmt.Println("Running in container - open URL in your host browser")
} else {
    // Normal behavior
    openBrowser(url)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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