utils

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package utils

This package contains generic functions that are used in other packages.

Index

Constants

View Source
const (
	MessengerDebug = iota
	MessengerInfo
	MessengerWarning
	MessengerError
)

Variables

This section is empty.

Functions

func ConvertTemplateNameToFile added in v0.4.0

func ConvertTemplateNameToFile(s string) string

ConvertTemplateNameToFile Convert template name like 'web@siteA.container' to 'web@.container'

func FindImageExposedPorts

func FindImageExposedPorts(props FindImageExposedPortsProperty) []string

FindImageExposedPorts This function looking around the current working directory and looking for references of the specified name

func FindReferences added in v0.7.0

func FindReferences(prop GoReferenceProperty, currentFileName, rootDir string) ([]protocol.Location, error)

FindReferences in other Quadlet files for the specific file

func FindSection

func FindSection(lines []string, lineNumber uint32) string

FindSection This function looking for that the cursor currently in which section. Sections are like `[Container]`, `[Unit]`, and so on.

func FirstCharacterToUpper

func FirstCharacterToUpper(s string) string

FirstCharacterToUpper makes the first character upper case

func ListQuadletFiles

func ListQuadletFiles(ext, rootDir string, level int) ([]protocol.CompletionItem, error)

ListQuadletFiles List quadlet files from the current work directory based on extenstion

func QuadletWalkDir added in v0.7.0

func QuadletWalkDir(root string, level int, fn fs.WalkDirFunc) error

func ReturnAsPtr added in v0.7.0

func ReturnAsPtr[T any](s T) *T

ReturnAsPtr return with pointer of any type

func ReturnAsStringPtr

func ReturnAsStringPtr(s string) *string

ReturnAsStringPtr I did not find better solution, probably not nice but works

func ScanQadlet added in v0.3.0

func ScanQadlet(
	text string,
	podmanVer PodmanVersion,
	properties map[ScanProperty]struct{},
	action func(q QuadletLine, p PodmanVersion, extraInfo any) []protocol.Diagnostic,
	extraInfo any,
) []protocol.Diagnostic

Types

type CommandExecutor

type CommandExecutor struct{}

func (CommandExecutor) Run

func (c CommandExecutor) Run(name string, args ...string) ([]string, error)

Run This method execute an OS command and return with its output

type Commander

type Commander interface {
	Run(name string, args ...string) ([]string, error)
}

type ContextMessenger added in v0.3.0

type ContextMessenger struct {
	Context *glsp.Context
}

func (*ContextMessenger) SendMessage added in v0.3.0

func (m *ContextMessenger) SendMessage(level MessengerLevel, text string)

type Documents

type Documents struct {
	// contains filtered or unexported fields
}

func NewDocuments

func NewDocuments() Documents

func (*Documents) Add

func (d *Documents) Add(uri, text string)

func (*Documents) CheckURI added in v0.5.0

func (d *Documents) CheckURI(uri string) (string, bool)

func (*Documents) Delete

func (d *Documents) Delete(uri string)

func (*Documents) ListFileNames

func (d *Documents) ListFileNames() []string

func (*Documents) Read

func (d *Documents) Read(uri string) string

type FindImageExposedPortsProperty added in v0.7.0

type FindImageExposedPortsProperty struct {
	C        Commander
	Name     string
	RootDir  string
	URI      string
	DirLevel int
}

type FindItemProperty added in v0.5.0

type FindItemProperty struct {
	URI           string // URI that is passed from editor
	RootDirectory string // Workspace root directory
	Text          string // Text of the current document
	Section       string // Section we are looking for
	Property      string // Property we are looking for within the section
	DirLevel      int    // How deep we want to search
}

FindItemProperty Parameter of FindItems() function.

type GoReferenceProperty added in v0.7.0

type GoReferenceProperty struct {
	Property string
	SearchIn []string
	DirLevel int
}

type Messenger added in v0.3.0

type Messenger interface {
	SendMessage(level MessengerLevel, text string)
}

type MessengerLevel added in v0.3.0

type MessengerLevel int

type PodmanVersion

type PodmanVersion struct {
	Version int
	Release int
	Minor   int
}

func BuildPodmanVersion

func BuildPodmanVersion(version, release, minor int) PodmanVersion

func NewPodmanVersion

func NewPodmanVersion(c Commander) (PodmanVersion, error)

func ParseVersion

func ParseVersion(raw string) (PodmanVersion, error)

func (PodmanVersion) GreaterOrEqual

func (p PodmanVersion) GreaterOrEqual(other PodmanVersion) bool

func (PodmanVersion) IsSupported

func (p PodmanVersion) IsSupported() bool

type ProjectProperty added in v0.7.0

type ProjectProperty struct {
	DirLevel *int   `json:"dirLevel"`
	RootDir  string `json:"rootDir"`
}

type QuadletConfig

type QuadletConfig struct {
	Mu            sync.RWMutex    `json:"-"`
	Disable       []string        `json:"disable"`
	PodmanVersion string          `json:"podmanVersion"`
	Project       ProjectProperty `json:"project"`
	Podman        PodmanVersion   `json:"-"`
	WorkspaceRoot string          `json:"-"`
}

func LoadConfig

func LoadConfig(workspaceRoot string, c Commander) (*QuadletConfig, error)

type QuadletLine

type QuadletLine struct {
	LineNumber uint32
	Length     uint32
	Property   string
	Value      string
	RawLine    string
	Section    string
	FilePath   string
}

func FindItems

func FindItems(params FindItemProperty) []QuadletLine

FindItems This function scanning the passed text and looking for property in specific section.

type ScanProperty added in v0.3.0

type ScanProperty struct {
	Property string
	Section  string
}

Jump to

Keyboard shortcuts

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