registration

package
v0.0.0-...-176c957 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 31

Documentation

Overview

package registration provides managed instance information

package registration provides managed instance information

Index

Examples

Constants

View Source
const (
	RegVaultKey             = "RegistrationKey"
	EC2RegistrationVaultKey = "EC2RegistrationKey"
)

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(log log.T) (string, error)

Fingerprint of the managed instance.

func GenerateKeyPair

func GenerateKeyPair() (publicKey, privateKey, keyType string, err error)

GenerateKeyPair generate a new keypair

func GeneratePublicKey

func GeneratePublicKey(privateKey string) (publicKey string, err error)

func HasManagedInstancesCredentials

func HasManagedInstancesCredentials(log log.T, manifestFileNamePrefix, vaultKey string) bool

HasManagedInstancesCredentials returns true when the valid registration information is present

func InstanceID

func InstanceID(log log.T, manifestFileNamePrefix, vaultKey string) string

InstanceID of the managed instance.

Example
file = fileStub{}
vault = vaultStub{rKey: sampleRegistrationKey, data: sampleJson, exists: true}
loadServerInfo("", RegVaultKey) // load info with mocked vault
instanceID := InstanceID(log.NewMockLog(), "", RegVaultKey)
fmt.Println(instanceID)
Output:

mi-e6c6f145e6c6f145

func PrivateKey

func PrivateKey(log log.T, manifestFileNamePrefix, vaultKey string) string

PrivateKey of the managed instance.

Example
file = fileStub{}
vault = vaultStub{rKey: sampleRegistrationKey, data: sampleJson, exists: true}
loadServerInfo("", RegVaultKey) // load info with mocked vault
privateKey := PrivateKey(log.NewMockLog(), "", RegVaultKey)
fmt.Println(privateKey)
Output:

KEYe6c6f145e6c6f145

func PrivateKeyType

func PrivateKeyType(log log.T, manifestFileNamePrefix, vaultKey string) string

PrivateKeyType of the managed instance.

func PublicKey

func PublicKey(log log.T, manifestFileNamePrefix, vaultKey string) string

PublicKey of the instance.

func Region

func Region(log log.T, manifestFileNamePrefix, vaultKey string) string

Region of the managed instance.

Example
file = fileStub{}
vault = vaultStub{rKey: sampleRegistrationKey, data: sampleJson, exists: true}
loadServerInfo("", RegVaultKey) // load info with mocked vault
region := Region(log.NewMockLog(), "", RegVaultKey)
fmt.Println(region)
Output:

us-west-1

func ReloadInstanceInfo

func ReloadInstanceInfo(log log.T, manifestFileNamePrefix, vaultKey string)

func ShouldRotatePrivateKey

func ShouldRotatePrivateKey(log log.T, executableToRotateKey string, privateKeyMaxDaysAge int, serviceSaysRotate bool, manifestFileNamePrefix, vaultKey string) (bool, error)

ShouldRotatePrivateKey returns true if serviceSaysRotate or private key has surpassed privateKeyMaxDaysAge

func UpdatePrivateKey

func UpdatePrivateKey(log log.T, privateKey, privateKeyType, manifestFileNamePrefix, vaultKey string) (err error)

UpdatePrivateKey saves the private key into the registration persistence store

func UpdateServerInfo

func UpdateServerInfo(instanceID, region, publicKey, privateKey, privateKeyType, manifestFileNamePrefix, vaultKey string) (err error)

UpdateServerInfo saves the instance info into the registration persistence store

Types

type IOnpremRegistrationInfo

type IOnpremRegistrationInfo interface {
	InstanceID(log.T, string, string) string
	Region(log.T, string, string) string
	PrivateKey(log.T, string, string) string
	PrivateKeyType(log.T, string, string) string
	Fingerprint(log.T) (string, error)
	GenerateKeyPair() (string, string, string, error)
	UpdatePrivateKey(log.T, string, string, string, string) error
	HasManagedInstancesCredentials(log.T, string, string) bool
	GeneratePublicKey(string) (string, error)
	ShouldRotatePrivateKey(log.T, string, int, bool, string, string) (bool, error)
	ReloadInstanceInfo(log.T, string, string)
}

func NewOnpremRegistrationInfo

func NewOnpremRegistrationInfo() IOnpremRegistrationInfo

Temp moved here, should refactor entire file to be behind interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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