shared

package
v0.0.0-...-6bf6c2b Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateArchive

func CreateArchive(directory string, buf io.Writer) error

CreateArchive will create a tar file from a directory.

func FixInterface

func FixInterface(input map[interface{}]interface{}) map[string]interface{}

FixInterface converts a map[interface{}]interface{} into a map[string]interface{}

func FixNumbers

func FixNumbers(m map[string]interface{}) map[string]interface{}

FixNumbers will convert all json.Number values to integer values

func GetFields

func GetFields(fg FieldGroup) []string

GetFields will return the list of YAML fields in a given field group

func GetTlsConfig

func GetTlsConfig(opts Options) (*tls.Config, error)

GetTlsConfig will build a tls config struct given a set of CA certs

func HasOIDCProvider

func HasOIDCProvider(fullConfig map[string]interface{}) bool

HasOIDCProvider will find if an OIDC provider is included in a config.yaml

func InterfaceArrayToStringArray

func InterfaceArrayToStringArray(input []interface{}) []string

InterfaceArrayToStringArray converts a []interface{} to []string

func LoadCerts

func LoadCerts(dir string) map[string][]byte

LoadCerts will load certificates in a config directory.

func RemoveNullValues

func RemoveNullValues(m map[string]interface{}) map[string]interface{}

RemoveNullValues will remove empty values from a config.yaml. This will prevent a panic when it is unmarshalled.

func ValidateBitbucketOAuth

func ValidateBitbucketOAuth(clientID, clientSecret string) bool

ValidateBitbucketOAuth checks that the Bitbucker OAuth credentials are correct

func ValidateDatabaseConnection

func ValidateDatabaseConnection(opts Options, rawURI, caCert string, threadlocals, autorollback bool, sslmode, sslrootcert, fgName string) error

ValidateDatabaseConnection checks that the Bitbucker OAuth credentials are correct

func ValidateElasticSearchCredentials

func ValidateElasticSearchCredentials(url, accessKey, accessSecret string) bool

ValidateElasticSearchCredentials will validate credentials

func ValidateGitHubOAuth

func ValidateGitHubOAuth(opts Options, clientID, clientSecret, githubEndpoint string) bool

ValidateGitHubOAuth checks that the Bitbucker OAuth credentials are correct

func ValidateGitLabOAuth

func ValidateGitLabOAuth(clientID, clientSecret, gitlabEndpoint string) bool

ValidateGitLabOAuth checks that the Bitbucker OAuth credentials are correct

func ValidateGoogleOAuth

func ValidateGoogleOAuth(clientID, clientSecret string) bool

ValidateGoogleOAuth checks that the Bitbucker OAuth credentials are correct

Types

type DistributedStorageArgs

type DistributedStorageArgs struct {
	// Args for RHOCSStorage, RadosGWStorage, IBMCloudStorage
	Hostname    string `default:"" validate:"" json:"hostname,omitempty" yaml:"hostname,omitempty"`
	Port        int    `default:"" validate:"" json:"port,omitempty" yaml:"port,omitempty"`
	IsSecure    bool   `default:"" validate:"" json:"is_secure" yaml:"is_secure"`
	StoragePath string `default:"" validate:"" json:"storage_path,omitempty" yaml:"storage_path,omitempty"`
	AccessKey   string `default:"" validate:"" json:"access_key,omitempty" yaml:"access_key,omitempty"`
	SecretKey   string `default:"" validate:"" json:"secret_key,omitempty" yaml:"secret_key,omitempty"`
	BucketName  string `default:"" validate:"" json:"bucket_name,omitempty" yaml:"bucket_name,omitempty"`
	// Args for S3Storage
	S3Bucket    string `default:"" validate:"" json:"s3_bucket,omitempty" yaml:"s3_bucket,omitempty"`
	S3AccessKey string `default:"" validate:"" json:"s3_access_key,omitempty" yaml:"s3_access_key,omitempty"`
	S3SecretKey string `default:"" validate:"" json:"s3_secret_key,omitempty" yaml:"s3_secret_key,omitempty"`
	Host        string `default:"" validate:"" json:"host,omitempty" yaml:"host,omitempty"`
	// Args for AzureStorage
	AzureContainer   string `default:"" validate:"" json:"azure_container,omitempty" yaml:"azure_container,omitempty"`
	AzureAccountName string `default:"" validate:"" json:"azure_account_name,omitempty" yaml:"azure_account_name,omitempty"`
	AzureAccountKey  string `default:"" validate:"" json:"azure_account_key,omitempty" yaml:"azure_account_key,omitempty"`
	SASToken         string `default:"" validate:"" json:"sas_token,omitempty" yaml:"sas_token,omitempty"`
	EndpointURL      string `default:"" validate:"" json:"endpoint_url,omitempty" yaml:"endpoint_url,omitempty"`
	// Args for Cloudfront
	CloudfrontDistributionDomain string `default:"" validate:"" json:"cloudfront_distribution_domain,omitempty" yaml:"cloudfront_distribution_domain,omitempty"`
	CloudfrontKeyID              string `default:"" validate:"" json:"cloudfront_key_id,omitempty" yaml:"cloudfront_key_id,omitempty"`
	// Args for SwiftStorage
	SwiftAuthVersion int                    `default:"" validate:"" json:"auth_version,omitempty" yaml:"auth_version,omitempty"`
	SwiftAuthURL     string                 `default:"" validate:"" json:"auth_url,omitempty" yaml:"auth_url,omitempty"`
	SwiftContainer   string                 `default:"" validate:"" json:"swift_container,omitempty" yaml:"swift_container,omitempty"`
	SwiftUser        string                 `default:"" validate:"" json:"swift_user,omitempty" yaml:"swift_user,omitempty"`
	SwiftPassword    string                 `default:"" validate:"" json:"swift_password,omitempty" yaml:"swift_password,omitempty"`
	SwiftCaCertPath  string                 `default:"" validate:"" json:"ca_cert_path,omitempty" yaml:"ca_cert_path,omitempty"`
	SwiftTempURLKey  string                 `default:"" validate:"" json:"temp_url_key,omitempty" yaml:"temp_url_key,omitempty"`
	SwiftOsOptions   map[string]interface{} `default:"" validate:"" json:"os_options,omitempty" yaml:"os_options,omitempty"`
	// Args for CloudFlare
	CloudflareDomain string `default:"" validate:"" json:"cloudflare_domain,omitempty" yaml:"cloudflare_domain,omitempty"`
	// Args for MultiCDNStorage
	DefaultProvider string                 `default:"" validate:"" json:"default_provider,omitempty" yaml:"default_provider,omitempty"`
	Providers       map[string]interface{} `default:"" validate:"" json:"providers,omitempty" yaml:"providers,omitempty"`
	StorageConfig   map[string]interface{} `default:"" validate:"" json:"storage_config,omitempty" yaml:"storage_config,omitempty"`
	// Args for STSS3Storage
	STSUserAccessKey string `default:"" validate:"" json:"sts_user_access_key,omitempty" yaml:"sts_user_access_key,omitempty"`
	STSUserSecretKey string `default:"" validate:"" json:"sts_user_secret_key,omitempty" yaml:"sts_user_secret_key,omitempty"`
	STSRoleArn       string `default:"" validate:"" json:"sts_role_arn,omitempty" yaml:"sts_role_arn,omitempty"`
}

DistributedStorageArgs

type FieldGroup

type FieldGroup interface {
	Validate(opts Options) []ValidationError
	Fields() []string
}

FieldGroup is an interface that implements the Validate() function

type IntOrString

type IntOrString int

IntOrString is an int that may be unmarshaled from either a JSON number literal, or a JSON string.

func (*IntOrString) UnmarshalJSON

func (i *IntOrString) UnmarshalJSON(d []byte) error

UnmarshalJSON will unmarshal an array of bytes into this type

type Options

type Options struct {
	Mode         string // One of Online, Offline, Testing
	Certificates map[string][]byte
}

Options is a struct that tells the validator how to validate

type ValidationError

type ValidationError struct {
	FieldGroup string
	Tags       []string
	Message    string
}

ValidationError is a struct that holds information about a failed field group policy

func ValidateAtLeastOneOfBool

func ValidateAtLeastOneOfBool(inputs []bool, fields []string, fgName string) (bool, ValidationError)

ValidateAtLeastOneOfBool validates that at least one of the given options is true

func ValidateAtLeastOneOfString

func ValidateAtLeastOneOfString(inputs []string, fields []string, fgName string) (bool, ValidationError)

ValidateAtLeastOneOfString validates that at least one of the given options is true

func ValidateCertPairWithHostname

func ValidateCertPairWithHostname(cert, key []byte, hostname string, fgName string) (bool, ValidationError)

ValidateCertPairWithHostname will validate that a public private key pair are valid and have the correct hostname

func ValidateCertsPresent

func ValidateCertsPresent(opts Options, requiredCertNames []string, fgName string) (bool, ValidationError)

ValidateCertsPresent validates that all required certificates are present in the options struct

func ValidateEmailServer

func ValidateEmailServer(opts Options, mailServer string, mailPort int, useTLS bool, useAuth bool, username string, password string, fgName string) (bool, ValidationError)

ValidateEmailServer validates that the provided smtp server is valid

func ValidateFileExists

func ValidateFileExists(input string, field string, fgName string) (bool, ValidationError)

ValidateFileExists will check if a path exists on the current machine

func ValidateHostIsReachable

func ValidateHostIsReachable(opts Options, input string, field string, fgName string) (bool, ValidationError)

ValidateHostIsReachable will check if a get request returns a 200 status code

func ValidateIsHostname

func ValidateIsHostname(input string, field string, fgName string) (bool, ValidationError)

ValidateIsHostname tests a string to determine if it is a well-structured hostname or not.

func ValidateIsOneOfString

func ValidateIsOneOfString(input string, options []string, field string, fgName string) (bool, ValidationError)

ValidateIsOneOfString validates that a string is one of a given option

func ValidateIsURL

func ValidateIsURL(input string, field string, fgName string) (bool, ValidationError)

ValidateIsURL tests a string to determine if it is a well-structured url or not.

func ValidateLDAPServer

func ValidateLDAPServer(opts Options, ldapUri, ldapAdminDn, ldapAdminPasswd, ldapUidAttr, ldapEmailAttr, ldapUserFilter string, ldapBaseDn []interface{}, fgName string) (bool, ValidationError)

ValidateLDAPServer validates that the provided ldap server is valid

func ValidateOIDCServer

func ValidateOIDCServer(opts Options, oidcServer, clientID, clientSecret, serviceName string, loginScopes []interface{}, fgName string) (bool, ValidationError)

ValidateOIDCServer validates that the provided oidc server is valid

func ValidateRedisConnection

func ValidateRedisConnection(options *redis.Options, field, fgName string) (bool, ValidationError)

ValidateRedisConnection validates that a Redis connection can successfully be established

func ValidateRequiredObject

func ValidateRequiredObject(input interface{}, field, fgName string) (bool, ValidationError)

ValidateRequiredObject validates that a object input is not nil

func ValidateRequiredString

func ValidateRequiredString(input, field, fgName string) (bool, ValidationError)

ValidateRequiredString validates that a string input is not empty

func ValidateStorage

func ValidateStorage(opts Options, storageName string, storageType string, args *DistributedStorageArgs, fgName string) (bool, []ValidationError)

ValidateStorage will validate a S3 storage connection.

func ValidateTimePattern

func ValidateTimePattern(input string, field string, fgName string) (bool, ValidationError)

ValidateTimePattern validates that a string has the pattern ^[0-9]+(w|m|d|h|s)$

func (ValidationError) String

func (ve ValidationError) String() string

Jump to

Keyboard shortcuts

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