keyfetcher

package
v0.0.0-...-aae6494 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LICENSE_KEY_REGEX        = `^([a-z]{4}-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}-[0-9]{1,4})$`
	LICENSE_KEY_PATTERN_DESC = "Hexadecimal"
	SERIAL_KEY_REGEX         = `^([A-Z0-9]{26})$`
	SERIAL_KEY_PATTERN_DESC  = "26 character alphanumeric string"
	COMMERCIAL_KEY_REGEX     = `^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$`
	QUIT_KEY_REGEX           = "(q|Q)"
)
View Source
const (
	FILE_VERSION = "4.0.0"
)

Variables

View Source
var ErrInvalidKeyFormat = fmt.Errorf(fmt.Sprintf("Malformed License Key passed on command line - should be %s or %s", LICENSE_KEY_PATTERN_DESC, SERIAL_KEY_PATTERN_DESC))
View Source
var LICENSE_TYPES []string = []string{"free", "trial", "commercial"}

Functions

func DoesUserHasActiveTrialLicense

func DoesUserHasActiveTrialLicense() (out bool)

func FetchAndPersist

func FetchAndPersist() []string

func FetchLicenseKeys

func FetchLicenseKeys() (out []string)

func FetchLicenseKeysBasedOnType

func FetchLicenseKeysBasedOnType(licenseType string) (out []string)

func FetchLicenseType

func FetchLicenseType(licenseKeys []string) string

func FetchLicenseTypeBasedOnKey

func FetchLicenseTypeBasedOnKey(license_keys []string) string

func GetLastUserInput

func GetLastUserInput() string

func GlobalFetchAndPersist

func GlobalFetchAndPersist() []string

func HasUnrestrictedLicenseAdded

func HasUnrestrictedLicenseAdded(newKeys []string, licenseType string) bool

func IsLicenseRestricted

func IsLicenseRestricted(licenseType string) (out bool)

func OnPremFetchAndPersist

func OnPremFetchAndPersist() []string

func PrintLicenseKeyOverview

func PrintLicenseKeyOverview(keys []string)

func SetFileHandler

func SetFileHandler(handler FileHandler)

func SetLastUserInput

func SetLastUserInput(val string)

func StartInteractions

func StartInteractions(startID string) (keys []string)

func UpdatePromptInputs

func UpdatePromptInputs(conf map[string]string)

func ValidateKeyFormat

func ValidateKeyFormat(key string) (matches bool)

Types

type ActionDetail

type ActionDetail struct {
	Messages        []string          `yaml:"messages"`
	Options         []string          `yaml:"options,omitempty"`
	Action          string            `yaml:"action"`
	PromptType      string            `yaml:"prompt_type"`
	PromptAttribute PromptAttribute   `yaml:"prompt_attributes"`
	Paths           []string          `yaml:"paths"`
	ResponsePathMap map[string]string `yaml:"response_path_map"`
	Choice          string            `yaml:"choice"`
}

func (ActionDetail) Ask

func (ad ActionDetail) Ask() string

func (ActionDetail) CheckLicenseExpirationStatus

func (ad ActionDetail) CheckLicenseExpirationStatus() string

func (ActionDetail) DetermineRestrictionType

func (ad ActionDetail) DetermineRestrictionType() string

func (ActionDetail) DisplayLicenseInfo

func (ad ActionDetail) DisplayLicenseInfo() string

func (ActionDetail) DoesLicenseHaveValidPattern

func (ad ActionDetail) DoesLicenseHaveValidPattern() string

func (ActionDetail) Error

func (ad ActionDetail) Error() string

func (ActionDetail) FetchInvalidLicenseMessage

func (ad ActionDetail) FetchInvalidLicenseMessage() string

func (ActionDetail) FetchLicenseId

func (ad ActionDetail) FetchLicenseId() string

func (ActionDetail) FetchLicenseTypeRestricted

func (ad ActionDetail) FetchLicenseTypeRestricted() string

func (ActionDetail) FilterLicenseTypeOptions

func (ad ActionDetail) FilterLicenseTypeOptions() string

func (ActionDetail) IsCommercialLicense

func (ad ActionDetail) IsCommercialLicense() string

func (ActionDetail) IsLicenseAllowed

func (ad ActionDetail) IsLicenseAllowed() string

func (ActionDetail) IsLicenseValidOnServer

func (ad ActionDetail) IsLicenseValidOnServer() string

func (ActionDetail) IsRunAllowedOnLicenseExhausted

func (ad ActionDetail) IsRunAllowedOnLicenseExhausted() string

func (ActionDetail) Ok

func (ad ActionDetail) Ok() string

func (ActionDetail) PerformInteraction

func (ad ActionDetail) PerformInteraction() (nextID string)

func (ActionDetail) Say

func (ad ActionDetail) Say() string

func (ActionDetail) SayAndSelect

func (ad ActionDetail) SayAndSelect() string

func (ActionDetail) Select

func (ad ActionDetail) Select() string

func (ActionDetail) SetLicenseInfo

func (ad ActionDetail) SetLicenseInfo() string

func (ActionDetail) TimeoutSelect

func (ad ActionDetail) TimeoutSelect() string

func (ActionDetail) Warn

func (ad ActionDetail) Warn() string

type FileHandler

type FileHandler interface {
	CheckFilePresence(filename string) bool
	ReadFile(filename string) ([]byte, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
}

func GetFileHandler

func GetFileHandler() *FileHandler

type Interaction

type Interaction struct {
	FileFormatVersion string                  `yaml:":file_format_version"`
	Actions           map[string]ActionDetail `yaml:"interactions"`
}

type LicenseData

type LicenseData struct {
	LicenseKey  string `yaml:":license_key"`
	LicenseType string `yaml:":license_type"`
	UpdateTime  string `yaml:":update_time"`
}

type LicenseFileData

type LicenseFileData struct {
	Licenses          []LicenseData `yaml:":licenses"`
	FileFormatVersion string        `yaml:":file_format_version"`
	LicenseServerURL  string        `yaml:":license_server_url"`
}

type LicenseFileHandler

type LicenseFileHandler struct{}

func (LicenseFileHandler) CheckFilePresence

func (LicenseFileHandler) CheckFilePresence(filename string) bool

func (LicenseFileHandler) ReadFile

func (LicenseFileHandler) ReadFile(filename string) ([]byte, error)

func (LicenseFileHandler) WriteFile

func (LicenseFileHandler) WriteFile(filename string, data []byte, perm os.FileMode) error

type MockFileHandler

type MockFileHandler struct {
	Content []byte
	Error   error
	Present bool
}

func (MockFileHandler) CheckFilePresence

func (m MockFileHandler) CheckFilePresence(filename string) bool

func (MockFileHandler) ReadFile

func (m MockFileHandler) ReadFile(filename string) ([]byte, error)

func (MockFileHandler) WriteFile

func (m MockFileHandler) WriteFile(filename string, data []byte, perm os.FileMode) error

type PromptAttribute

type PromptAttribute struct {
	TimeoutWarningColor string `yaml:"timeout_warning_color"`
	TimeoutDuration     int    `yaml:"timeout_duration"`
	TimeoutMessage      string `yaml:"timeout_message"`
	TimeoutContinue     bool   `yaml:"timeout_continue"`
}

type TemplateConfig

type TemplateConfig struct {
	ProductName           string
	UnitMeasure           string
	ChefExecutableName    string
	FailureMessage        string
	IsCommercial          bool
	LicenseType           string
	LicenseID             string
	LicenseExpirationDate string
	ExpirationInDays      string
	StartID               string
}
var PromptInput TemplateConfig

Jump to

Keyboard shortcuts

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