Documentation
¶
Index ¶
- func CheckIfPathExist(path string) bool
- func CheckIfServiceIsInstalled(serv string) (bool, error)
- func CheckIndexExists(url string) (bool, error)
- func CheckIndexExistsWithRetry(url string) (bool, error)
- func CreatePathIfNotExist(path string) error
- func DoReq[response any](url string, data []byte, method string, headers map[string]string, ...) (response, int, error)
- func Download(url, file string) error
- func GenerateCerts(folder string) error
- func GenerateConfig(variables any, text, output string) error
- func GenerateSecret(size int) string
- func GetLock(v int, locksDir string) bool
- func GetMainIP() (string, error)
- func GetMainIPInAirGapMode() (string, error)
- func GetMainIface(mainIP string) (string, error)
- func GetMyPath() string
- func GetStep() int
- func MakeDir(mode os.FileMode, arg ...string) string
- func Mode(mode string, options map[string]any) any
- func ParseTemplate(text string, data any) (*bytes.Buffer, error)
- func PointerOf[t any](s t) *t
- func ReadJson(fileName string, data any) error
- func ReadYAML(path string, result any) error
- func Remove(path string) error
- func RestartService(name string) error
- func RunCmd(command string, arg ...string) error
- func RunCmdWithOutput(command string, arg ...string) ([]string, error)
- func RunEnvCmd(env []string, command string, arg ...string) error
- func SetLock(v int, locksDir string) error
- func StopService(name string) error
- func UninstallService(name string) error
- func WriteJSON(path string, data any) error
- func WriteToFile(fileName string, body string) error
- func WriteYAML(url string, data any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckIfPathExist ¶
func CheckIndexExists ¶
CheckIndexExists checks if the given OpenSearch index exists by sending an HTTP GET request to the provided URL. It returns true if the index exists, false otherwise.
func CheckIndexExistsWithRetry ¶
retrying every 5 seconds up to a total duration of 1 minute.
func CreatePathIfNotExist ¶
func DoReq ¶
func DoReq[response any](url string, data []byte, method string, headers map[string]string, transCfg *http.Transport) (response, int, error)
DoReq sends an HTTP request and processes the response.
This function sends an HTTP request to the specified URL with the given method, data, and headers. It returns the response body unmarshalled into the specified response type, the HTTP status code, and an error if any occurred during the process.
Type Parameters:
- response: The type into which the response body will be unmarshalled.
Parameters:
- url: The URL to which the request is sent.
- data: The request payload as a byte slice.
- method: The HTTP method to use for the request (e.g., "GET", "POST").
- headers: A map of headers to include in the request.
Returns:
- response: The response body unmarshalled into the specified type.
- int: The HTTP status code of the response.
- error: An error if any occurred during the request or response processing, otherwise nil.
func Download ¶
Download downloads the content from the specified URL and saves it to the specified file. It returns an error if any error occurs during the process.
Parameters:
- url: The URL from which to download the content.
- file: The path to the file where the content should be saved.
Returns:
- error: An error object if an error occurs, otherwise nil.
func GenerateCerts ¶
func GenerateConfig ¶
GenerateConfig generates a configuration file from a text template.
The `variables` argument is a map of variables to be used in the template. The `text` argument is the text of the template. The `output` argument is the path to the output file.
The function returns an error if there is any problem generating the configuration file.
func GenerateSecret ¶
func GetMainIPInAirGapMode ¶
func GetMainIface ¶
func ParseTemplate ¶
ParseTemplate parses a template and executes it with the given data.
text: The text of the template. data: The data to use to render the template.
Returns: A bytes.Buffer containing the rendered template, or an error if parsing or execution failed.
func RestartService ¶
func StopService ¶
func UninstallService ¶
func WriteToFile ¶
Types ¶
This section is empty.