config

package
v0.0.0-...-60e47fa Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPagedRpmInsertsLimit      = 500
	DefaultIntrospectApiTimeLimitSec = 30
)
View Source
const (
	RepositorySnapshotTask          = "snapshot"                    // Task to create a snapshot for a repository config
	DeleteRepositorySnapshotsTask   = "delete-repository-snapshots" // Task to delete all snapshots for a repository config
	IntrospectTask                  = "introspect"                  // Task to introspect repository
	DeleteTemplatesTask             = "delete-templates"            // Task to delete all content templates marked for deletion
	UpdateTemplateDistributionsTask = "update-template-content"     // Task to update the pulp distributions of a template's snapshots
)
View Source
const (
	TaskStatusRunning   = "running"   // Task is running
	TaskStatusFailed    = "failed"    // Task has failed
	TaskStatusCompleted = "completed" // Task has completed
	TaskStatusCanceled  = "canceled"  // Task has been canceled
	TaskStatusPending   = "pending"   // Task is waiting to be started
)
View Source
const (
	StatusValid       = "Valid"       // Repository introspected successfully
	StatusUnavailable = "Unavailable" // Repository introspected at least once, but now errors
	StatusInvalid     = "Invalid"     // Repository has never introspected due to error
	StatusPending     = "Pending"     // Repository not introspected yet.
)
View Source
const (
	OriginExternal = "external"
	OriginRedHat   = "red_hat"
)
View Source
const AARCH64 = "aarch64"
View Source
const ANY_ARCH = "any"
View Source
const ANY_VERSION = "any"
View Source
const (
	ContentTypeRpm = "rpm"
)
View Source
const DefaultAppName = "content-sources"
View Source
const El7 = "7"
View Source
const El8 = "8"
View Source
const El9 = "9"
View Source
const FailedIntrospectionsLimit = 20
View Source
const HeaderRequestId = "x-rh-insights-request-id" // the header that contains the request ID
View Source
const IntrospectTimeInterval = time.Hour * 23
View Source
const PPC64LE = "ppc64le"
View Source
const RedHatGpgKeyPath = "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release"
View Source
const RedHatOrg = "-1"
View Source
const RepoClowderBucketName = "content-sources-central-pulp-s3"
View Source
const RequestIdLoggingKey = "request_id" // the key that represents the request ID when logged
View Source
const RhCertEnv = "RH_CDN_CERT_PAIR"
View Source
const S390x = "s390x"
View Source
const STORAGE_TYPE_LOCAL = "local"
View Source
const STORAGE_TYPE_OBJECT = "object"
View Source
const SnapshotInterval = 20 // In hours
View Source
const X8664 = "x86_64"

Variables

View Source
var DistributionArches = [...]DistributionArch{
	{
		Name:  "Any",
		Label: ANY_ARCH,
	},
	{
		Name:  "aarch64",
		Label: AARCH64,
	},
	{
		Name:  "ppc64le",
		Label: PPC64LE,
	},
	{
		Name:  "s390x",
		Label: S390x,
	},
	{
		Name:  "x86_64",
		Label: X8664,
	},
}
View Source
var DistributionVersions = [...]DistributionVersion{
	{
		Name:  "Any",
		Label: ANY_VERSION,
	},
	{
		Name:  "el7",
		Label: El7,
	}, {
		Name:  "el8",
		Label: El8,
	}, {
		Name:  "el9",
		Label: El9,
	},
}
View Source
var PopularRepos []PopularRepository
View Source
var Tang *tangy.Tangy

Functions

func ClowderS3Url

func ClowderS3Url(c clowder.ObjectStoreConfig) string

func ConfigureCertificate

func ConfigureCertificate() (*tls.Certificate, *string, error)

ConfigureCertificate loads in a cert keypair from either, an environment variable if specified, or a file path if no certificate is specified, we return no error however if a certificate is specified but cannot be loaded an error is returned.

func ConfigureLogging

func ConfigureLogging()

func ConfigureTang

func ConfigureTang() error

func CustomHTTPErrorHandler

func CustomHTTPErrorHandler(err error, c echo.Context)

func DaysTillExpiration

func DaysTillExpiration(certs *tls.Certificate) (int, error)

DaysTillExpiration Finds the number of days until the specified certificate expired tls.Certificate allows for multiple certs to be combined, so this takes the expiration date that is coming the soonest

func DefaultLogwatchStream

func DefaultLogwatchStream() string

func GetSaramaConfig

func GetSaramaConfig() (*sarama.Config, error)

func Load

func Load()

func ProgramString

func ProgramString() string

func PulpConfigured

func PulpConfigured() bool

func RedisUrl

func RedisUrl() string

func SetupCloudEventsKafkaClient

func SetupCloudEventsKafkaClient(topic string) (v2.Client, error)

SetupCloudEventsKafkaClient create the cloud event kafka client that will send event to the given kafka topic

func SetupNotifications

func SetupNotifications()

SetupNotifications creates the cloud event kafka client for sending event to the event service

func SetupTemplateEvents

func SetupTemplateEvents()

SetupTemplateEvents creates the cloud event kafka client for sending event to the patch service

func SkipLogging

func SkipLogging(c echo.Context) bool

func ValidArchLabel

func ValidArchLabel(label string) bool

ValidArchLabel Given a label, verifies that the label is a valid distribution architecture label

func ValidDistributionVersionLabels

func ValidDistributionVersionLabels(labels []string) (bool, string)

ValidDistributionVersionLabels Given a list of labels, return true if every item of the list is a valid distribution version. If at least one is not valid, returns false and the first invalid version

Types

type Candlepin

type Candlepin struct {
	Server     string
	Username   string
	Password   string
	ClientCert string `mapstructure:"client_cert"`
	ClientKey  string `mapstructure:"client_key"`
	DevelOrg   bool   `mapstructure:"devel_org"` // For use only in dev envs
}

type Certs

type Certs struct {
	CertPath           string `mapstructure:"cert_path"`
	DaysTillExpiration int
	CdnCertPair        *tls.Certificate
	CdnCertPairString  *string
}

type Clients

type Clients struct {
	RbacEnabled bool      `mapstructure:"rbac_enabled"`
	RbacBaseUrl string    `mapstructure:"rbac_base_url"`
	RbacTimeout int       `mapstructure:"rbac_timeout"`
	Pulp        Pulp      `mapstructure:"pulp"`
	Redis       Redis     `mapstructure:"redis"`
	Candlepin   Candlepin `mapstructure:"candlepin"`
}

type Cloudwatch

type Cloudwatch struct {
	Region  string
	Key     string
	Secret  string
	Session string
	Group   string
	Stream  string
}

type Configuration

type Configuration struct {
	Database            Database
	Logging             Logging
	Loaded              bool
	Certs               Certs
	Options             Options
	Kafka               kafka.KafkaConfig
	Cloudwatch          Cloudwatch
	Metrics             Metrics
	Clients             Clients            `mapstructure:"clients"`
	Mocks               Mocks              `mapstructure:"mocks"`
	Sentry              Sentry             `mapstructure:"sentry"`
	NotificationsClient cloudevents.Client `mapstructure:"notification_client"`
	TemplateEventClient cloudevents.Client `mapstructure:"template_event_client"`
	Tasking             Tasking            `mapstructure:"tasking"`
	Features            FeatureSet         `mapstructure:"features"`
}
var LoadedConfig Configuration

func Get

func Get() *Configuration

type ContextRequestIDKey

type ContextRequestIDKey struct{}

Used in the context as the Key to store the Request ID type ContextRequestIDKey struct{}

type Database

type Database struct {
	Host       string
	Port       int
	User       string
	Password   string
	Name       string
	CACertPath string `mapstructure:"ca_cert_path"`
	PoolLimit  int    `mapstructure:"pool_limit"`
}

type DistributionArch

type DistributionArch struct {
	Name  string `json:"name"`  // Human-readable form of the architecture
	Label string `json:"label"` // Static label of the architecture
}

type DistributionVersion

type DistributionVersion struct {
	Name  string `json:"name"`  // Human-readable form of the version
	Label string `json:"label"` // Static label of the version
}

type Expiration

type Expiration struct {
	Rbac            time.Duration
	PulpContentPath time.Duration
}

type Feature

type Feature struct {
	Enabled       bool
	Accounts      *[]string // Only allow access if in the accounts list
	Organizations *[]string // Or org id is in the list
	Users         *[]string // or username in the users list
}

type FeatureSet

type FeatureSet struct {
	Snapshots              Feature
	AdminTasks             Feature `mapstructure:"admin_tasks"`
	NewRepositoryFiltering Feature `mapstructure:"new_repo_filtering"`
}

type Logging

type Logging struct {
	Level   string
	Console bool
}

type Metrics

type Metrics struct {
	// Defines the path to the metrics server that the app should be configured to
	// listen on for metric traffic.
	Path string `mapstructure:"path"`

	// Defines the metrics port that the app should be configured to listen on for
	// metric traffic.
	Port int `mapstructure:"port"`
}

type Mocks

type Mocks struct {
	Namespace string `mapstructure:"namespace"`
	Rbac      struct {
		UserReadWrite     []string `mapstructure:"user_read_write"`
		UserRead          []string `mapstructure:"user_read"`
		UserNoPermissions []string `mapstructure:"user_no_permissions"`
	} `mapstructure:"rbac"`
}

type ObjectStore

type ObjectStore struct {
	URL       string
	AccessKey string `mapstructure:"access_key"`
	SecretKey string `mapstructure:"secret_key"`
	Name      string
	Region    string
}

type Options

type Options struct {
	PagedRpmInsertsLimit      int `mapstructure:"paged_rpm_inserts_limit"`
	IntrospectApiTimeLimitSec int `mapstructure:"introspect_api_time_limit_sec"`
	// If true, introspection and snapshotting always runs for nightly job invocation, regardless of how soon they happened previously.  Used for testing.
	AlwaysRunCronTasks     bool   `mapstructure:"always_run_cron_tasks"`
	EnableNotifications    bool   `mapstructure:"enable_notifications"`
	TemplateEventTopic     string `mapstructure:"template_event_topic"`
	RepositoryImportFilter string `mapstructure:"repository_import_filter"` // Used by qe to control which repos are imported
}

https://stackoverflow.com/questions/54844546/how-to-unmarshal-golang-viper-snake-case-values

type PopularRepository

type PopularRepository struct {
	UUID                 string   `json:"uuid"`                                // UUID of the repository if it exists for the user
	ExistingName         string   `json:"existing_name"`                       // Existing reference name for repository
	SuggestedName        string   `json:"suggested_name"`                      // Suggested name of the popular repository
	URL                  string   `json:"url"`                                 // URL of the remote yum repository
	DistributionVersions []string `json:"distribution_versions" example:"7,8"` // Versions to restrict client usage to
	DistributionArch     string   `json:"distribution_arch" example:"x86_64"`  // Architecture to restrict client usage to
	GpgKey               string   `json:"gpg_key"`                             // GPG key for repository
	MetadataVerification bool     `json:"metadata_verification"`               // Verify packages
}

Should match api.PopularRepositoryResponse

type Pulp

type Pulp struct {
	Server                  string
	Username                string
	Password                string
	StorageType             string       `mapstructure:"storage_type"` // s3 or local
	CustomRepoObjects       *ObjectStore `mapstructure:"custom_repo_objects"`
	DownloadPolicy          string       `mapstructure:"download_policy"`            // on_demand or immediate
	GuardSubjectDn          string       `mapstructure:"guard_subject_dn"`           // DN to allow access to via x509 identity subject_dn
	CustomRepoContentGuards bool         `mapstructure:"custom_repo_content_guards"` // To turn on or off the creation of content guards for custom repos
	Database                Database     `mapstructure:"database"`                   // for use with tangy
}

type Redis

type Redis struct {
	Host       string
	Port       int
	Username   string
	Password   string
	DB         int
	Expiration Expiration `mapstructure:"expiration"`
}

type Sentry

type Sentry struct {
	Dsn string
}

type Tasking

type Tasking struct {
	PGXLogging          bool `mapstructure:"pgx_logging"`
	Heartbeat           time.Duration
	WorkerCount         int           `mapstructure:"worker_count"`
	RetryWaitUpperBound time.Duration `mapstructure:"retry_wait_upper_bound"`
}

Jump to

Keyboard shortcuts

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