common

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package common contains common functions used throughout the cli commands. Functions like display.s, CreateFileWithContent and GetEnvDir

Index

Constants

This section is empty.

Variables

View Source
var ErrImageMissing = errors.New("image not found locally")
View Source
var Version = "dev"

Functions

func BuildEnvPath

func BuildEnvPath(customPath, name, prefix string) (string, error)

BuildEnvPath constructs the environment directory path

func CheckEnvForUpdates

func CheckEnvForUpdates(envFile string) ([]display.ImageUpdateInfo, error)

func Confirm

func Confirm(prompt string) (bool, error)

func CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies a directory from src to dst

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst

func CopyToClipboard

func CopyToClipboard(text string) error

func CreateFileWithContent

func CreateFileWithContent(filePath, content string) error

CreateFileWithContent creates a file with given content

func CreateTmpCopy

func CreateTmpCopy(dir string) (string, error)

CreateTmpCopy creates a backup copy of the environment directory in a temporary location

func DeleteEnvDir

func DeleteEnvDir(path string) error

func Export

func Export(path, filename string, content []byte) error

func FindFreePort

func FindFreePort() (int, error)

func GenerateExportHeader

func GenerateExportHeader() string

GenerateExportHeader returns a standardized header for exported files

func GetContentFromPathOrDefault

func GetContentFromPathOrDefault(filePath, defaultContent string) (string, error)

GetContentFromPathOrDefault reads content from filePath if provided, otherwise returns defaultContent

func GetCurrentKubeContext

func GetCurrentKubeContext() (string, error)

GetCurrentKubeContext retrieves the current kubectl context.

func GetKubeContexts

func GetKubeContexts() ([]string, error)

GetKubeContexts retrieves the list of available kubectl contexts.

func GetLocalIP

func GetLocalIP() (string, error)

func GetVersion

func GetVersion() string

GetVersion returns the version of the CLI

func IsPortFree

func IsPortFree(port int) (bool, error)

func OpenBrowser

func OpenBrowser(url string) error

func OpenDirectory

func OpenDirectory(dir string) error

func OpenWithCommand

func OpenWithCommand(command, target string) error

func PopulateEnv

func PopulateEnv(ttlPath, endpointURL string, parallel int) ([]string, error)

PopulateEnv ingests TTL (Turtle) files into an environment by posting them to the gateway endpoint. It accepts either a single file or a directory path. When given a directory, it recursively walks through all subdirectories and ingests all *.ttl files found, processing them in parallel according to the specified concurrency limit.

On partial failure (e.g., some files fail to ingest), the function returns successfully ingested file paths along with an error indicating the failure. This allows callers to handle partial successes (e.g., save successful ingestions) while still being notified of issues. The returned slice is always non-nil.

Parameters:

  • ttlPath: Path to a TTL file or directory containing TTL files
  • gatewayURL: Base URL of the EPOS gateway (e.g., "http://gateway/api/v1")
  • parallel: Maximum number of concurrent file ingestions (use 1 for sequential processing)

Returns a list of successfully ingested file paths and an error if any file fails to ingest or if the path is invalid.

func PopulateExample

func PopulateExample(endpointURL string, parallel int) ([]string, error)

PopulateExample ingests example TTL files from predefined URLs into an environment. It processes the examples in parallel according to the specified concurrency limit.

On partial failure (e.g., some files fail to ingest), the function returns successfully ingested file paths along with an error indicating the failure. This allows callers to handle partial successes (e.g., save successful ingestions) while still being notified of issues. The returned slice is always non-nil.

Parameters:

  • endpointURL: Base URL of the EPOS gateway (e.g., "http://gateway/api/v1")
  • parallel: Maximum number of concurrent example ingestions (use 1 for sequential processing)

Returns a list of successfully ingested example URLs and an error if any example fails to ingest.

func PopulateOntologies

func PopulateOntologies(baseURL string) error

PopulateOntologies populates an environment deployed in a dir with the base ontologies for the ingestor

func RemoveEnvDir

func RemoveEnvDir(dir string) error

RemoveEnvDir deletes the environment directory with logs

func RemoveTmpDir

func RemoveTmpDir(tmpDir string) error

RemoveTmpDir removes the temporary backup directory with logs

func RestoreTmpDir

func RestoreTmpDir(tmpDir, targetDir string) error

RestoreTmpDir restores the environment from temporary backup to target directory

func SharedValidArgsFunction

func SharedValidArgsFunction(cmd *cobra.Command, args []string, toComplete string, nameGetter NameGetter) ([]string, cobra.ShellCompDirective)

SharedValidArgsFunction provides completion for environment names based on the command use.

Types

type NameGetter

type NameGetter func() ([]string, error)

NameGetter is a function type for retrieving environment names.

Jump to

Keyboard shortcuts

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