cli

package module
v0.1.92 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 46 Imported by: 9

README

stuttgart-things/sthingsCli

providing golang building blocks for the use in command line interface modules

MODULES

GIT
CLONE GIT REPOSITORY, GET FILE LIST + READ FILE
gitRepository         := "https://github.com/stuttgart-things/kaeffken.git"
gitBranch             := "main"
gitCommitID           := "09de9ff7b5c76aff8bb32f68cfb0bbe49cd5a7a8"

repo, cloneStatus := sthingsCli.CloneGitRepository(gitRepository, gitBranch, gitCommitID, nil)

if cloneStatus {
    fileList, directoryList = sthingsCli.GetFileListFromGitRepository("", repo)
    fmt.Println(fileList, directoryList)
}

readMe := sthingsCli.ReadFileContentFromGitRepo(repo, "README.md")
fmt.Println(readMe)

TASKFILE

task: Available tasks for this project:
* lint:       Lint code
* tag:        commit, push & tag the module
* test:       Test code

LICENSE

APACHE 2.0

Copyright 2023 patrick hermann.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author Information

Patrick Hermann, stuttgart-things 04/2023

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommitFileToGitRepository added in v0.1.38

func AddCommitFileToGitRepository(repository, branchName string, auth *http.BasicAuth, fileContent []byte, filePath, commitMsg string) (pushed bool)

func AddValueToRedisSet added in v0.1.7

func AddValueToRedisSet(redisClient *redis.Client, setKey, value string) (isSetValueunique bool)

func AskMultiSelectQuestion

func AskMultiSelectQuestion(questionText string, options []string) []string

func AskSingleInputQuestion

func AskSingleInputQuestion(questionText string, defaultAnswer string) string

func AskSingleSelectQuestion

func AskSingleSelectQuestion(questionText string, options []string) string

func CheckRedisKV added in v0.1.12

func CheckRedisKV(connectionString, redisPassword, key, expectedValue string) (keyValueExists bool)

func CheckUrlAvailability added in v0.1.41

func CheckUrlAvailability(webURL string) bool

func CheckVaultKVExistenceInSecretPath

func CheckVaultKVExistenceInSecretPath(kvpath, token string) bool

func CloneGitRepository added in v0.1.17

func CloneGitRepository(repository, branchName, commitId string, auth *http.BasicAuth) (fs billy.Filesystem, cloned bool)

func ConvertJSONToYAML added in v0.1.32

func ConvertJSONToYAML(jsonString string) string

func ConvertYAMLToJSON added in v0.1.32

func ConvertYAMLToJSON(yamlString string) string

func CreateGitAuth added in v0.1.18

func CreateGitAuth(gitUser, gitToken string) *http.BasicAuth

func CreateMinioBucket added in v0.1.84

func CreateMinioBucket(minioClient *minio.Client, bucket, location string) bool

func CreateMinioClient added in v0.1.83

func CreateMinioClient() (bool, *minio.Client)

func CreateRedisClient added in v0.1.8

func CreateRedisClient(connectionString, redisPassword string) (client *redis.Client)

func CreateTableHeader added in v0.1.5

func CreateTableHeader(s interface{}) table.Row

func CreateTableRows added in v0.1.6

func CreateTableRows(s interface{}) table.Row

func DeleteRedisSet added in v0.1.80

func DeleteRedisSet(redisClient *redis.Client, setKey string) (isSetDeleted bool)

func DownloadFileWithProgressBar added in v0.1.24

func DownloadFileWithProgressBar(downloadUrl, targetDir string)

func DownloadObjectFromMinioBucket added in v0.1.83

func DownloadObjectFromMinioBucket(minioClient *minio.Client, bucket, objectname, destinationName string) bool

func EncryptStore added in v0.1.89

func EncryptStore(ageKey, rawData string) (encryptedData string)

func EnqueueDataInRedisStreams added in v0.1.13

func EnqueueDataInRedisStreams(connectionString, redisPassword, stream string, values map[string]interface{}) (enqueue bool)

func ExtractTarGzArchive added in v0.1.31

func ExtractTarGzArchive(archiveFilePath, extractionFilePath string, extractFileMode int)

func GenerateAgeIdentitdy added in v0.1.89

func GenerateAgeIdentitdy() (identity *age.X25519Identity)

func GetAllValuesFromRedis added in v0.1.7

func GetAllValuesFromRedis(redisClient *redis.Client, ctx context.Context, key string) []string

func GetCommitInformationFromGithubRepo added in v0.1.86

func GetCommitInformationFromGithubRepo(userName, repoName, branchName, option string) (getCommits bool, allCommits []map[string]interface{}, err error)

func GetFileListFromGitRepository added in v0.1.17

func GetFileListFromGitRepository(directory string, fs billy.Filesystem) (fileList, directoryList []string)

func GetObjectsFromMinioBucket added in v0.1.83

func GetObjectsFromMinioBucket(minioClient *minio.Client, bucket string) []string

func GetRandomValueFromRedis added in v0.1.7

func GetRandomValueFromRedis(redisClient *redis.Client, ctx context.Context, key string) string

func GetRedisJSON added in v0.1.33

func GetRedisJSON(redisJSONHandler *rejson.Handler, jsonKey string) (jsonObject []byte, jsonExists bool)

func GetSecretValueFromVaultSecretEngine

func GetSecretValueFromVaultSecretEngine(vaultConnectionInformation map[string]string) (string, string, string, string)

func GetUnderlyingAsValue added in v0.1.6

func GetUnderlyingAsValue(data interface{}) reflect.Value

func GetValueFromRedisByKey added in v0.1.83

func GetValueFromRedisByKey(redisClient *redis.Client, key string) (value string)

func GetValuesFromRedisSet added in v0.1.11

func GetValuesFromRedisSet(redisClient *redis.Client, setKey string) (values []string)

func GetVaultConnectionInformation

func GetVaultConnectionInformation() map[string]string

func GetVaultKvSecretEngines

func GetVaultKvSecretEngines(vaultAddr, vaultToken, vaultNamespace string) []string

func GetVaultKvSecretPaths

func GetVaultKvSecretPaths(vaultAddr, vaultToken, vaultNamespace, kvpath string) []string

func GetVaultSecretValue

func GetVaultSecretValue(kvpath, token string) string

func GetYamlStringKey added in v0.1.47

func GetYamlStringKey(key, pathToConfig, extension string) string

func ReadFileContentFromGitRepo added in v0.1.21

func ReadFileContentFromGitRepo(repo billy.Filesystem, filePath string) string

func ReadInlineYamlToObject added in v0.1.22

func ReadInlineYamlToObject(inlineYAML []byte, yamlObject interface{}) interface{}

func ReadVaultSecretEngines

func ReadVaultSecretEngines(vaultAddr, vaultToken, vaultNamespace, kvpath string) []string

func ReadYamlKeyValuesFromFile added in v0.1.37

func ReadYamlKeyValuesFromFile(yamlFileContent []byte) (yamlStructure map[string]interface{})

func ReadYamlToObject added in v0.1.20

func ReadYamlToObject(pathToYAML, fileExtension string, yamlObject interface{}) interface{}

func RemoveValueFromRedis added in v0.1.7

func RemoveValueFromRedis(redisClient *redis.Client, ctx context.Context, key string, member string) bool

func RenderTemplateSurvey added in v0.1.46

func RenderTemplateSurvey(templateContent string, globalValues map[string]interface{}) (string, map[string]interface{})

func SendWebhookToTeams added in v0.1.10

func SendWebhookToTeams(webhook MsTeamsWebhook) bool

func SetRedisJSON added in v0.1.36

func SetRedisJSON(redisJSONHandler *rejson.Handler, jsonObject interface{}, jsonKey string)

func StoreSecretInSecretEngine

func StoreSecretInSecretEngine(vaultAddr, vaultToken, vaultNamespace, secretEngine, secretName string, secretData map[string]interface{})

func UnZipArchive added in v0.1.30

func UnZipArchive(source, destination string) error

func UploadObjectToMinioBucket added in v0.1.83

func UploadObjectToMinioBucket(minioClient *minio.Client, bucket, sourcePath, objectName string) (bool, int64)

func VerifyEnvVars

func VerifyEnvVars(envVars []string) bool

func VerifyVaultEnvVars added in v0.1.9

func VerifyVaultEnvVars() (string, bool)

Types

type Client

type Client struct {
	Token         string
	Client        *api.Client
	LeaseDuration int
}

func CreateVaultClient

func CreateVaultClient() (*Client, error)

func (*Client) GetVaultTokenFromAppRole

func (vaultClient *Client) GetVaultTokenFromAppRole() (string, error)

type MsTeamsWebhook added in v0.1.10

type MsTeamsWebhook struct {
	Title string `yaml:"title"`
	Text  string `yaml:"text"`
	Color string `yaml:"color"`
	Url   string `yaml:"url"`
}

type RenderSurvey added in v0.1.46

type RenderSurvey struct {
	SingleInputSurvey  func(string) string
	SingleSelectSurvey func(string) string
}

type Token

type Token struct {
	Auth struct {
		ClientToken   string `json:"client_token"`
		LeaseDuration int    `json:"lease_duration"`
	} `json:"auth"`
}

Jump to

Keyboard shortcuts

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