pkg

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 24 Imported by: 10

Documentation

Overview

Copyright (C) 2021-2023, Kubefirst

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

This program is licensed under MIT. See the LICENSE file for more details.

Index

Constants

View Source
const (
	JSONContentType              = "application/json"
	SoftServerURI                = "ssh://127.0.0.1:8022/config"
	GitHubOAuthClientId          = "2ced340927e0a6c49a45"
	CloudK3d                     = "k3d"
	CloudAws                     = "aws"
	DefaultS3Region              = "us-east-1"
	GitHubProviderName           = "github"
	GitHubHost                   = "github.com"
	LocalClusterName             = "kubefirst"
	MinimumAvailableDiskSize     = 10 // 10 GB
	KubefirstGitOpsRepository    = "gitops"
	KubefirstGitOpsRepositoryURL = "https://github.com/kubefirst/gitops-template"
	LocalDomainName              = "kubefirst.dev"
	LocalhostARCH                = runtime.GOARCH
	LocalhostOS                  = runtime.GOOS
	AwsECRUsername               = "AWS"
	RegistryAppName              = "registry"
	MinioDefaultUsername         = "k-ray"
	MinioDefaultPassword         = "feedkraystars"

	// github.com/kubefirst/manifests ref ver
	KubefirstManifestRepoRef = "0.1.0"
)
View Source
const (
	VaultPodName        = "vault-0"
	VaultNamespace      = "vault"
	VaultPodPort        = 8200
	VaultPodLocalPort   = 8200
	VaultPortForwardURL = "http://localhost:8200"
)

Vault

View Source
const (
	ArgoPodName          = "argo-server"
	ArgoNamespace        = "argo"
	ArgoPodPort          = 2746
	ArgoPodLocalPort     = 2746
	ArgocdPortForwardURL = "http://localhost:8080"
)

Argo

View Source
const (
	ArgoCDPodName      = "argocd-server"
	ArgoCDNamespace    = "argocd"
	ArgoCDPodPort      = 8080
	ArgoCDPodLocalPort = 8080
	ArgoCDLocalBaseURL = "https://localhost:8080/api/v1"
)

ArgoCD

View Source
const (
	ChartmuseumPodName      = "chartmuseum"
	ChartmuseumNamespace    = "chartmuseum"
	ChartmuseumPodPort      = 8080
	ChartmuseumPodLocalPort = 8181
	ChartmuseumLocalURL     = "http://localhost:8181"
)

ChartMuseum

View Source
const (
	MinioPodName             = "minio"
	MinioNamespace           = "minio"
	MinioPodPort             = 9000
	MinioPodLocalPort        = 9000
	MinioPortForwardEndpoint = "localhost:9000"
	MinioRegion              = "us-k3d-1"
)

Minio

View Source
const (
	MinioConsolePodName      = "minio"
	MinioConsoleNamespace    = "minio"
	MinioConsolePodPort      = 9001
	MinioConsolePodLocalPort = 9001
)

Minio Console

View Source
const (
	KubefirstConsolePodName       = "kubefirst-console"
	KubefirstConsoleNamespace     = "kubefirst"
	KubefirstConsolePodPort       = 80
	KubefirstConsolePodLocalPort  = 9094
	KubefirstConsoleLocalURLCloud = "http://localhost:9094"
)

Kubefirst Console

View Source
const (
	AtlantisPodPort           = 4141
	AtlantisPodName           = "atlantis-0"
	AtlantisNamespace         = "atlantis"
	AtlantisPodLocalPort      = 4141
	LocalAtlantisURLTEMPORARY = "localhost:4141" // todo:
)

Atlantis

View Source
const (
	MetaphorFrontendDevelopmentServiceName      = "metaphor-development"
	MetaphorFrontendDevelopmentNamespace        = "development"
	MetaphorFrontendDevelopmentServicePort      = 443
	MetaphorFrontendDevelopmentServiceLocalPort = 4000
	MetaphorFrontendDevelopmentLocalURL         = "http://localhost:4000"
)

MetaphorFrontendDevelopment

View Source
const (
	MetaphorGoDevelopmentServiceName      = "metaphor-go-development"
	MetaphorGoDevelopmentNamespace        = "development"
	MetaphorGoDevelopmentServicePort      = 443
	MetaphorGoDevelopmentServiceLocalPort = 5000
	MetaphorGoDevelopmentLocalURL         = "http://localhost:5000"
)

MetaphorGoDevelopment

View Source
const (
	MetaphorDevelopmentServiceName      = "metaphor-development"
	MetaphorDevelopmentNamespace        = "development"
	MetaphorDevelopmentServicePort      = 443
	MetaphorDevelopmentServiceLocalPort = 3000
	MetaphorDevelopmentLocalURL         = "http://localhost:3000"
)

MetaphorDevelopment

View Source
const CloneAndDetokenizeGitOpsTemplate = "Clone and Detokenize (GitOps)"
View Source
const CloneAndDetokenizeMetaphorTemplate = "Clone and Detokenize (Metaphor)"
View Source
const CreateBuckets = "Create Buckets"
View Source
const CreateSSHKey = "Create SSH keys"
View Source
const DownloadDependencies = "Download dependencies"
View Source
const GetAccountInfo = "Get Account Info"
View Source
const GetDNSInfo = "Get DNS Info"
View Source
const SendTelemetry = "Send Telemetry"
View Source
const TestHostedZoneLiveness = "Test Domain Liveness"

Variables

View Source
var (
	VaultLocalURL    = fmt.Sprintf("http://vault.%s", LocalDomainName)
	VaultLocalURLTLS = fmt.Sprintf("https://vault.%s", LocalDomainName)
)
View Source
var (
	ArgoCDLocalURL    = fmt.Sprintf("http://argocd.%s", LocalDomainName)
	ArgoCDLocalURLTLS = fmt.Sprintf("https://argocd.%s", LocalDomainName)
)
View Source
var (
	KubefirstConsoleLocalURL    = fmt.Sprintf("http://kubefirst.%s", LocalDomainName)
	KubefirstConsoleLocalURLTLS = fmt.Sprintf("https://kubefirst.%s", LocalDomainName)
)
View Source
var (
	AtlantisLocalURLTEST = fmt.Sprintf("atlantis.%s", LocalDomainName)
	AtlantisLocalURL     = fmt.Sprintf("http://atlantis.%s", LocalDomainName)
	AtlantisLocalURLTLS  = fmt.Sprintf("https://atlantis.%s", LocalDomainName)
)
View Source
var (
	MetaphorFrontendSlimTLSDev     = fmt.Sprintf("https://metaphor-development.%s", LocalDomainName)
	MetaphorFrontendSlimTLSStaging = fmt.Sprintf("https://metaphor-staging.%s", LocalDomainName)
	MetaphorFrontendSlimTLSProd    = fmt.Sprintf("https://metaphor-production.%s", LocalDomainName)
)
View Source
var (
	ArgoLocalURLTLS = fmt.Sprintf("https://argo.%s", LocalDomainName)
)
View Source
var (
	BetaProviders []string = []string{"digitalocean", "gcp", "vultr"}
)
View Source
var (
	ChartmuseumLocalURLTLS = fmt.Sprintf("https://chartmuseum.%s", LocalDomainName)
)
View Source
var (
	MinioConsoleURLTLS = fmt.Sprintf("https://minio-console.%s", LocalDomainName)
)
View Source
var (
	MinioURL = fmt.Sprintf("https://minio.%s", LocalDomainName)
)
View Source
var SupportedPlatforms = []string{
	"aws-github",
	"aws-gitlab",
	"civo-github",
	"civo-gitlab",
	"digitalocean-github",
	"digitalocean-gitlab",
	"gcp-github",
	"gcp-gitlab",
	"k3d-github",
	"k3d-gitlab",
	"vultr-github",
	"vultr-gitlab",
}
View Source
var (
	Trackers map[string]*ActionTracker
)

Functions

func AwaitHostNTimes

func AwaitHostNTimes(url string, times int, gracePeriod time.Duration)

AwaitHostNTimes - Wait for a Host to return a 200 - To return 200 - To return true if host is ready, or false if not - Supports a number of times to test an endpoint - Supports the grace period after status 200 to wait before returning

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string) error

func CreateFile

func CreateFile(fileName string, fileContent []byte) error

CreateFile - Create a file with its contents

func CreateFullPath

func CreateFullPath(p string) (*os.File, error)

CreateFullPath - Create path and its parents

func CreateTracker

func CreateTracker(title string, total int64) *progress.Tracker

CreateTracker receives Tracker data and return a new Tracker.

func ExecShellReturnStrings

func ExecShellReturnStrings(command string, args ...string) (string, string, error)

ExecShellReturnStrings Exec shell actions returning a string for use by the caller.

func ExecShellReturnStringsV2

func ExecShellReturnStringsV2(command string, args ...string) (string, error)

ExecShellReturnStringsV2 exec shell, discard stdout

func ExecShellWithVars

func ExecShellWithVars(osvars map[string]string, command string, args ...string) error

ExecShellWithVars Exec shell actions supporting:

  • On-the-fly logging of result
  • Map of Vars loaded

func FindStringInSlice

func FindStringInSlice(s []string, str string) bool

FindStringInSlice takes []string and returns true if the supplied string is in the slice.

func GenerateClusterID

func GenerateClusterID() string

func GetAvailableDiskSize

func GetAvailableDiskSize() (uint64, error)

GetAvailableDiskSize returns the available disk size in the user machine. In that way Kubefirst can validate if the available disk size is enough to start a installation.

func GetFileContent

func GetFileContent(filePath string) ([]byte, error)

GetFileContent receives a file path, and return its content.

func GetLogLevelByString

func GetLogLevelByString(logLevel string) zerolog.Level

GetLogLevelByString receives a log level string, and returns it's related zerolog Level iota panic (zerolog.PanicLevel, 5) fatal (zerolog.FatalLevel, 4) error (zerolog.ErrorLevel, 3) warn (zerolog.WarnLevel, 2) info (zerolog.InfoLevel, 1) debug (zerolog.DebugLevel, 0) trace (zerolog.TraceLevel, -1)

func GetTrackers

func GetTrackers() map[string]*ActionTracker

GetTrackers keeps one single instance of Trackers alive using singleton pattern.

func InformUser

func InformUser(message string, silentMode bool)

todo: deprecate cmd.informUser

func IsConsoleUIAvailable

func IsConsoleUIAvailable(url string) error

todo: this is temporary

func IsValidURL

func IsValidURL(rawURL string) error

IsValidURL checks if a URL is valid

func OpenBrowser

func OpenBrowser(url string) error

OpenBrowser opens the browser with the given URL At this time, support is limited to darwin platforms

func OpenLogFile

func OpenLogFile(path string) (*os.File, error)

func Random

func Random(seq int) string

func RemoveSubDomain

func RemoveSubDomain(fullURL string) (string, error)

RemoveSubDomain receives a host and remove its subdomain, if exists.

func RemoveSubdomainV2

func RemoveSubdomainV2(domainName string) (string, error)

func ReplaceFileContent

func ReplaceFileContent(filPath string, oldContent string, newContent string) error

ReplaceFileContent receives a file path, oldContent and newContent. oldContent is the previous value that is in the file, newContent is the new content you want to replace.

Example:

err := ReplaceFileContent(vaultMainFile, "http://127.0.0.1:9000", "http://minio.minio.svc.cluster.local:9000")

func ResetK1Dir

func ResetK1Dir(k1Dir string) error

func SetupProgress

func SetupProgress(numTrackers int)

SetupProgress prepare the progress bar setting its initial configuration

func SetupViper

func SetupViper(config *configs.Config) error

SetupViper handles Viper config file. If config file doesn't exist, create, in case the file is available, use it.

func StringWithCharset

func StringWithCharset(length int, charset string) string

func UpdateTerraformS3BackendForK8sAddress

func UpdateTerraformS3BackendForK8sAddress(k1Dir string) error

UpdateTerraformS3BackendForK8sAddress during the installation process, Terraform must reach port-forwarded resources to be able to communicate with the services. When Kubefirst finish the installation, and Terraform needs to communicate with the services, it must use the internal Kubernetes addresses.

func UpdateTerraformS3BackendForLocalhostAddress

func UpdateTerraformS3BackendForLocalhostAddress() error

UpdateTerraformS3BackendForLocalhostAddress during the destroy process, Terraform must reach port-forwarded resources to be able to communicate with the services.

func ValidateK1Folder

func ValidateK1Folder(folderPath string) error

ValidateK1Folder receives a folder path, and expects the Kubefirst configuration folder doesn't contain "argocd-init-values.yaml" and/or "gitops/" folder. It follows this validation order:

  • If folder doesn't exist, try to create it (happy path)
  • If folder exists, and has "argocd-init-values.yaml" and/or "gitops/", abort and return error describing the issue and what should be done

func ZerologSetup

func ZerologSetup(logFile *os.File, level zerolog.Level) zerolog.Logger

ZerologSetup setup Zerolog and return the configured Zerolog instance

Types

type ActionTracker

type ActionTracker struct {
	Tracker *progress.Tracker
}

type CertificateAppList

type CertificateAppList struct {
	Namespace string
	AppName   string
}

func GetCertificateAppList

func GetCertificateAppList() []CertificateAppList

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type HTTPMock

type HTTPMock struct{}

func (HTTPMock) Do

func (httpMock HTTPMock) Do(req *http.Request) (*http.Response, error)

type SegmentIOMock

type SegmentIOMock struct{}

func (SegmentIOMock) Close

func (segmentIOMock SegmentIOMock) Close() error

func (SegmentIOMock) Enqueue

func (segmentIOMock SegmentIOMock) Enqueue(message analytics.Message) error

Jump to

Keyboard shortcuts

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