utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PowershellPathEnvVar  = "POWERSHELL_PATH"
	DefaultPowershellPath = "powershell.exe"
)
View Source
const (
	Windows = false
)

Variables

View Source
var (
	// DLLPath is where the DLL will be stored within the DLLDirectory
	DLLPath = "RanchergMSACredentialProvider.dll"

	// DLLInstallScriptPath is where DLL install script will be stored within the DLLDirectory
	DLLInstallScriptPath = "install-plugin.ps1"

	// DLLUninstallScriptPat is where the DLL uninstall script will be stored within the DLLDirectory
	DLLUninstallScriptPath = "uninstall-plugin.ps1"

	// DLLGuid is the GUID that we register the Rancher CCG Plugin DLL under
	//
	// Developer Note:
	// This value should never be changed unless absolutely necessary since the DLL GUID is
	// used to create GMSACredentialSpec resources. Changing this value would immediately render
	// all user-created GMSACredentialSpecs that were targeting this CCG Plugin no longer apply to
	// this installation of the CCG Plugin.
	DLLGuid = "E4781092-F116-4B79-B55E-28EB6A224E26"

	// CCGCOMClassKey is the Windows Registry Key which is used by CCG to invoke the DLL
	CCGCOMClassesKey = filepath.Join(
		"SYSTEM",
		"CurrentControlSet",
		"Control",
		"CCG",
		"COMClasses",
		fmt.Sprintf("{%s}", strings.ToLower(DLLGuid)),
	)

	// ClassesRootKey is the Windows Registry Key which is added by regsvc upon registering the dll. It is also used to invoke the DLL
	CLSIDKey = filepath.Join(
		"CLSID",
		fmt.Sprintf("{%s}", DLLGuid),
	)
)
View Source
var (
	// DLLDirectory contains resources for the CCG Plugin DLL
	DLLDirectory = filepath.Join("dist", "rancher-plugin-gmsa", "ccg-plugin-installer")

	// ProviderDirectory contains namespace directories for CCG Plugin Account Providers
	ProviderDirectory = filepath.Join("dist", "rancher-plugin-gmsa", "gmsa-account-provider")
)
View Source
var (
	DryRun         bool
	PowershellPath string
)
View Source
var (
	CertStoreLocation = filepath.Join("Cert:", "LocalMachine", "Root")
)
View Source
var DeleteBackoff = wait.Backoff{
	Steps:    5,
	Duration: 100 * time.Millisecond,
	Factor:   2.0,
	Jitter:   0.1,
}
View Source
var (
	IsValidNamespace = regexp.MustCompile(`^[a-z]([a-z\-0-9]{1,61}[a-z0-9])?$`).MatchString
)

Functions

func CreateAndImportPfx

func CreateAndImportPfx(certFile string, pfxFile string) error

func CreateDirectory

func CreateDirectory(dir string) error

func DeleteDirectory

func DeleteDirectory(dir string) error

func DeleteFile

func DeleteFile(file string) error

func DirectoryExists

func DirectoryExists(dir string) (bool, error)

func FileExists

func FileExists(file string) (bool, error)

func FileHas

func FileHas(file string, content []byte) (bool, error)

func GetFile

func GetFile(file string) ([]byte, error)

func ImportCertificate

func ImportCertificate(certPath string) error

func IsMemFs

func IsMemFs() bool

IsMemFs returns whether the default manager is using a in-memory filesystem

func ReadDirectory

func ReadDirectory(dir string) ([]os.FileInfo, error)

func RenameTempFile

func RenameTempFile(file string) (func() error, func() error, error)

func RunPowershell

func RunPowershell(path string) error

func RunPowershellCommand

func RunPowershellCommand(cmd string) error

func RunPowershellCommandWithOutput

func RunPowershellCommandWithOutput(cmd string) ([]byte, error)

func SetFile

func SetFile(file string, content []byte) error

func SetupEnv

func SetupEnv()

SetupEnv sets up the default fs manager to use the real host (OS) filesystems

func SetupTestEnv

func SetupTestEnv()

SetupTestEnv sets up the default fs manager to use in-memory filesystems Any subsequent call to SetupTestEnv or SetupEnv will wipe out the filesystems created here.

func UnimportCertificate

func UnimportCertificate(certPath string) error

func ValidateNamespace

func ValidateNamespace(namespace string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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