Documentation
¶
Overview ¶
Package common contains common functions used throughout the cli commands. Functions like display.s, CreateFileWithContent and GetEnvDir
Index ¶
- Variables
- func BuildEnvPath(customPath, name, prefix string) (string, error)
- func CheckEnvForUpdates(envFile string) ([]display.ImageUpdateInfo, error)
- func Confirm(prompt string) (bool, error)
- func CopyDir(src, dst string) error
- func CopyFile(src, dst string) error
- func CopyToClipboard(text string) error
- func CreateFileWithContent(filePath, content string) error
- func CreateTmpCopy(dir string) (string, error)
- func DeleteEnvDir(path string) error
- func Export(path, filename string, content []byte) error
- func FindFreePort() (int, error)
- func GenerateExportHeader() string
- func GetContentFromPathOrDefault(filePath, defaultContent string) (string, error)
- func GetCurrentKubeContext() (string, error)
- func GetKubeContexts() ([]string, error)
- func GetLocalIP() (string, error)
- func GetVersion() string
- func IsPortFree(port int) (bool, error)
- func OpenBrowser(url string) error
- func OpenDirectory(dir string) error
- func OpenWithCommand(command, target string) error
- func PopulateEnv(ttlPath, endpointURL string, parallel int) ([]string, error)
- func PopulateExample(endpointURL string, parallel int) ([]string, error)
- func PopulateOntologies(baseURL string) error
- func RemoveEnvDir(dir string) error
- func RemoveTmpDir(tmpDir string) error
- func RestoreTmpDir(tmpDir, targetDir string) error
- func SharedValidArgsFunction(cmd *cobra.Command, args []string, toComplete string, nameGetter NameGetter) ([]string, cobra.ShellCompDirective)
- type NameGetter
Constants ¶
This section is empty.
Variables ¶
var ErrImageMissing = errors.New("image not found locally")
var Version = "dev"
Functions ¶
func BuildEnvPath ¶
BuildEnvPath constructs the environment directory path
func CheckEnvForUpdates ¶
func CheckEnvForUpdates(envFile string) ([]display.ImageUpdateInfo, error)
func CopyToClipboard ¶
func CreateFileWithContent ¶
CreateFileWithContent creates a file with given content
func CreateTmpCopy ¶
CreateTmpCopy creates a backup copy of the environment directory in a temporary location
func DeleteEnvDir ¶
func FindFreePort ¶
func GenerateExportHeader ¶
func GenerateExportHeader() string
GenerateExportHeader returns a standardized header for exported files
func GetContentFromPathOrDefault ¶
GetContentFromPathOrDefault reads content from filePath if provided, otherwise returns defaultContent
func GetCurrentKubeContext ¶
GetCurrentKubeContext retrieves the current kubectl context.
func GetKubeContexts ¶
GetKubeContexts retrieves the list of available kubectl contexts.
func GetLocalIP ¶
func IsPortFree ¶
func OpenBrowser ¶
func OpenDirectory ¶
func OpenWithCommand ¶
func PopulateEnv ¶
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 ¶
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 ¶
PopulateOntologies populates an environment deployed in a dir with the base ontologies for the ingestor
func RemoveEnvDir ¶
RemoveEnvDir deletes the environment directory with logs
func RemoveTmpDir ¶
RemoveTmpDir removes the temporary backup directory with logs
func RestoreTmpDir ¶
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 ¶
NameGetter is a function type for retrieving environment names.