Documentation
¶
Index ¶
- Constants
- Variables
- func IsDefaultValue(value *reflect.Value, defaultValue *string) (bool, error)
- func IsValueAllowed(value *reflect.Value, allowedValues *string) (bool, error)
- func SetUserAgentCmd(userAgentCmd string)
- type AuthType
- type ClientInfo
- type ConsumerData
- type ContentOverride
- type ContentOverridesResult
- type EngineeringProduct
- type EntCertKeysResult
- type EntitlementCertificateKeyJSON
- type EntitlementContentJSON
- type Environment
- type InstalledProduct
- type OrganizationData
- type RHSMClient
- func (rhsmClient *RHSMClient) Clean() error
- func (rhsmClient *RHSMClient) GetConsumerUUID() (*string, error)
- func (rhsmClient *RHSMClient) GetEnvironments(username string, password string, organization string, clientInfo *ClientInfo) ([]Environment, error)
- func (rhsmClient *RHSMClient) GetOrgs(username string, password string, clientInfo *ClientInfo) ([]OrganizationData, error)
- func (rhsmClient *RHSMClient) GetOwner() (*string, error)
- func (rhsmClient *RHSMClient) GetServerStatus(clientInfo *ClientInfo) (*RHSMStatus, error)
- func (rhsmClient *RHSMClient) RegisterOrgActivationKeys(org *string, activationKeys []string, options *map[string]string, ...) (*ConsumerData, error)
- func (rhsmClient *RHSMClient) RegisterUsernamePassword(username *string, password *string, options *map[string]string, ...) (*ConsumerData, error)
- func (rhsmClient *RHSMClient) Unregister(clientInfo *ClientInfo) error
- type RHSMConf
- type RHSMConfLogging
- type RHSMConfRHSM
- type RHSMConfRHSMCertDaemon
- type RHSMConfServer
- type RHSMConnection
- type RHSMStatus
- type RegisterData
- type RegisterError
- type RegisterOptions
- type SysPurposeJSON
- type SystemFacts
- type UnregisterServerError
- type UserAgentInfo
Constants ¶
const DefaultRHSMConfFilePath = "/etc/rhsm/rhsm.conf"
const DefaultRepoFilePath = "/etc/yum.repos.d/redhat.repo"
const DefaultSystemPurposeFilePath = "/etc/rhsm/syspurpose/syspurpose.json"
const DirectoryDefaultProductCertificate = "/etc/pki/product-default"
DirectoryDefaultProductCertificate is directory containing default product certificate. This certificate is pre-installed on the system. The path cannot be altered in configuration file rhsm.conf
const RedhatOidNamespace = "1.3.6.1.4.1.2312.9"
Variables ¶
var ( // UserAgent is the HTTP header used in each HTTP request UserAgent = UserAgentInfo{ "RHSM/" + constants.ApiVersion, "", } )
Functions ¶
func IsDefaultValue ¶
IsDefaultValue tries to say if given value is default value or not
func IsValueAllowed ¶
IsValueAllowed tries to say if given value is allowed or not. The allowedValues is string with comma separated values
func SetUserAgentCmd ¶
func SetUserAgentCmd(userAgentCmd string)
SetUserAgentCmd set command of UserAgent
Types ¶
type AuthType ¶
type AuthType int
AuthType is type used for specifying authentication type of connection
const ( // NoAuth does not require any authentication. It can use base64 encoded // username:password in HTTP header for authentication of client NoAuth AuthType = iota // ConsumerCertAuth uses consumer certificate for client authentication ConsumerCertAuth // EntitlementCertAuth uses entitlement certificate for client authentication EntitlementCertAuth )
Constants of authentication types
type ClientInfo ¶
type ClientInfo struct { Locale string DBusSender string // contains filtered or unexported fields }
ClientInfo holds information about current client triggering given HTTP request. Information in this structure could not be stored in rhsmClient, because RHSM client could be also rhsm2.service providing D-Bus API and each D-Bus client communicating over D-Bus can have different preferences (e.g. locale).
type ConsumerData ¶
type ConsumerData struct { Created string `json:"created"` Updated string `json:"updated"` Id string `json:"id"` Uuid string `json:"uuid"` Name string `json:"name"` Username string `json:"username"` EntitlementStatus string `json:"entitlementStatus"` ServiceLevel string `json:"serviceLevel"` Role string `json:"role"` Usage string `json:"usage"` AddOns []interface{} `json:"addOns"` SystemPurposeStatus string `json:"systemPurposeStatus"` ReleaseVer struct { ReleaseVer interface{} `json:"releaseVer"` } `json:"releaseVer"` Owner struct { Id string `json:"id"` Key string `json:"key"` DisplayName string `json:"displayName"` Href string `json:"href"` ContentAccessMode string `json:"contentAccessMode"` } `json:"owner"` Environment struct { Created interface{} `json:"created"` Updated interface{} `json:"updated"` Id interface{} `json:"id"` Name string `json:"name"` Type interface{} `json:"type"` Description interface{} `json:"description"` ContentPrefix interface{} `json:"contentPrefix"` Owner interface{} `json:"owner"` EnvironmentContent interface{} `json:"environmentContent"` } `json:"environment"` EntitlementCount int `json:"entitlementCount"` Facts struct { } `json:"facts"` LastCheckin interface{} `json:"lastCheckin"` InstalledProducts interface{} `json:"installedProducts"` CanActivate bool `json:"canActivate"` Capabilities interface{} `json:"capabilities"` HypervisorId interface{} `json:"hypervisorId"` ContentTags interface{} `json:"contentTags"` Autoheal bool `json:"autoheal"` Annotations interface{} `json:"annotations"` ContentAccessMode interface{} `json:"contentAccessMode"` Type struct { Created interface{} `json:"created"` Updated interface{} `json:"updated"` Id string `json:"id"` Label string `json:"label"` Manifest bool `json:"manifest"` } `json:"type"` IdCert struct { Created string `json:"created"` Updated string `json:"updated"` Id string `json:"id"` Key string `json:"key"` Cert string `json:"cert"` Serial struct { Created string `json:"created"` Updated string `json:"updated"` Id int64 `json:"id"` Serial int64 `json:"serial"` Expiration string `json:"expiration"` Revoked bool `json:"revoked"` } `json:"serial"` } `json:"idCert"` GuestIds []interface{} `json:"guestIds"` Href string `json:"href"` ActivationKeys []interface{} `json:"activationKeys"` ServiceType interface{} `json:"serviceType"` Environments []struct { Created string `json:"created"` Updated string `json:"updated"` Id string `json:"id"` Name string `json:"name"` Type interface{} `json:"type"` Description string `json:"description"` ContentPrefix interface{} `json:"contentPrefix"` Owner struct { Id string `json:"id"` Key string `json:"key"` DisplayName string `json:"displayName"` Href string `json:"href"` ContentAccessMode string `json:"contentAccessMode"` } `json:"owner"` EnvironmentContent []interface{} `json:"environmentContent"` } `json:"environments"` }
ConsumerData is structure used for parsing JSON data returned during registration when system was successfully registered and consumer was created
type ContentOverride ¶
type ContentOverride struct { Created string `json:"created"` Updated string `json:"updated"` Name string `json:"name"` ContentLabel string `json:"contentLabel"` Value string `json:"value"` }
ContentOverride is structure containing information about content override for given repository
type ContentOverridesResult ¶
type ContentOverridesResult struct {
// contains filtered or unexported fields
}
ContentOverridesResult is structure used in enableContent function
type EngineeringProduct ¶
type EngineeringProduct struct { Id string `json:"id"` Name string `json:"name"` Version string `json:"version"` Architectures []interface{} `json:"architectures"` Content []struct { Id string `json:"id"` Type string `json:"type"` Name string `json:"name" ini:"name"` Label string `json:"label"` Vendor string `json:"vendor"` Path string `json:"path"` Enabled bool `json:"enabled,omitempty"` Arches []string `json:"arches"` GpgUrl string `json:"gpg_url,omitempty"` MetadataExpire int `json:"metadata_expire,omitempty" ini:"metadata_expire,omitempty"` RequiredTags []string `json:"required_tags,omitempty"` } `json:"content"` }
EngineeringProduct is structure containing information about one engineering product. This structure is unmarshalled from entitlement certificate
type EntCertKeysResult ¶
type EntCertKeysResult struct {
// contains filtered or unexported fields
}
EntCertKeysResult is structure used in enableContent function
type EntitlementCertificateKeyJSON ¶
type EntitlementCertificateKeyJSON struct { Created string `json:"created"` Updated string `json:"updated"` Id string `json:"id"` Key string `json:"key"` Cert string `json:"cert"` Serial struct { Created string `json:"created"` Updated string `json:"updated"` Id int64 `json:"id"` Serial int64 `json:"serial"` Expiration string `json:"expiration"` Revoked bool `json:"revoked"` } `json:"serial"` }
EntitlementCertificateKeyJSON is structure used for un-marshaling of JSON returned from candlepin server. JSON document includes list of this objects
type EntitlementContentJSON ¶
type EntitlementContentJSON struct { Consumer string `json:"consumer"` Subscription struct { Sku string `json:"sku"` Name string `json:"name"` } `json:"subscription"` Order struct { Start time.Time `json:"start"` End time.Time `json:"end"` } `json:"order"` Products []EngineeringProduct `json:"products"` Pool struct { } `json:"pool"` }
EntitlementContentJSON is structure containing information about content (decoded from entitlement certificate)
type Environment ¶
type Environment struct { Created string `json:"created,omitempty"` Updated string `json:"updated,omitempty"` Id string `json:"id"` Name string `json:"name,omitempty"` Type interface{} `json:"type,omitempty"` Description string `json:"description,omitempty"` ContentPrefix interface{} `json:"contentPrefix,omitempty"` Owner *struct { Id string `json:"id"` Key string `json:"key,omitempty"` DisplayName string `json:"displayName,omitempty"` Href string `json:"href,omitempty"` ContentAccessMode string `json:"contentAccessMode,omitempty"` } `json:"owner,omitempty"` EnvironmentContent []interface{} `json:"environmentContent,omitempty"` }
Environment contains information about environment returned form candlepin server. The Owner is pointer on structure, because this structure is also used during registration and only ID of environment is really necessary
type InstalledProduct ¶
type InstalledProduct struct { // Following attributes are sent in the report. Id string `json:"productId"` Name string `json:"productName"` Version string `json:"version"` Architecture string `json:"arch"` // contains filtered or unexported fields }
InstalledProduct is product certificate installed to /etc/pki/product or /etc/pki/product-default. DNF plugin installs product certificates to /etc/pki/product and there is typically one pre-installed product certificate in /etc/pki/product-default, when pre-installed operating system is part of some product (Red Hat Enterprise Linux)
type OrganizationData ¶
type OrganizationData struct { Created string `json:"created"` Updated string `json:"updated"` Id string `json:"id"` DisplayName string `json:"displayName"` Key string `json:"key"` ContentPrefix interface{} `json:"contentPrefix"` DefaultServiceLevel interface{} `json:"defaultServiceLevel"` LogLevel interface{} `json:"logLevel"` ContentAccessMode string `json:"contentAccessMode"` ContentAccessModeList string `json:"contentAccessModeList"` AutobindHypervisorDisabled bool `json:"autobindHypervisorDisabled"` AutobindDisabled bool `json:"autobindDisabled"` LastRefreshed string `json:"lastRefreshed"` ParentOwner interface{} `json:"parentOwner"` UpstreamConsumer interface{} `json:"upstreamConsumer"` Anonymous interface{} `json:"anonymous"` Claimed interface{} `json:"claimed"` }
OrganizationData is structure used for parsing JSON document returned by candlepin. This structure represents one organization
type RHSMClient ¶
type RHSMClient struct { RHSMConf *RHSMConf NoAuthConnection *RHSMConnection ConsumerCertAuthConnection *RHSMConnection EntitlementCertAuthConnection *RHSMConnection }
RHSMClient contains information about client. It can hold up to 3 different type of connections, but usually it is necessary to use only ConsumerCertAuthConnection. The NoAuthConnection is used only during registration process, when no consumer certificate/key is installed. Note: we do not create special connection for "Base Auth", because it is actually NoAuthConnection with special HTTP header. EntitlementCertAuthConnection could be used for communication with CDN.
func GetRHSMClient ¶
func GetRHSMClient(confFilePath *string) (*RHSMClient, error)
GetRHSMClient tries to return instance of RHSMClient. If the instance already exist, then existing instance is returned. The confFilePath is used only in the first call of the function. It is just ignored in any other next call.
func (*RHSMClient) Clean ¶
func (rhsmClient *RHSMClient) Clean() error
Clean tries to clean all installed files, but do not try to remove consumer object from candlepin server
func (*RHSMClient) GetConsumerUUID ¶
func (rhsmClient *RHSMClient) GetConsumerUUID() (*string, error)
GetConsumerUUID tries to get consumer UUID from installed consumer certificate
func (*RHSMClient) GetEnvironments ¶
func (rhsmClient *RHSMClient) GetEnvironments( username string, password string, organization string, clientInfo *ClientInfo, ) ([]Environment, error)
GetEnvironments tries to get list of environments from candlepin server
func (*RHSMClient) GetOrgs ¶
func (rhsmClient *RHSMClient) GetOrgs( username string, password string, clientInfo *ClientInfo, ) ([]OrganizationData, error)
GetOrgs tries to get list of available organizations for given username
func (*RHSMClient) GetOwner ¶
func (rhsmClient *RHSMClient) GetOwner() (*string, error)
GetOwner tries to get owner from installed consumer certificate
func (*RHSMClient) GetServerStatus ¶
func (rhsmClient *RHSMClient) GetServerStatus(clientInfo *ClientInfo) (*RHSMStatus, error)
GetServerStatus tries to get status from the server. This method is possible to call, when server is connected or not
func (*RHSMClient) RegisterOrgActivationKeys ¶
func (rhsmClient *RHSMClient) RegisterOrgActivationKeys( org *string, activationKeys []string, options *map[string]string, clientInfo *ClientInfo, ) (*ConsumerData, error)
RegisterOrgActivationKeys tries to register system using organization id and activation keys
func (*RHSMClient) RegisterUsernamePassword ¶
func (rhsmClient *RHSMClient) RegisterUsernamePassword( username *string, password *string, options *map[string]string, clientInfo *ClientInfo, ) (*ConsumerData, error)
RegisterUsernamePassword tries to register system using username and password
func (*RHSMClient) Unregister ¶
func (rhsmClient *RHSMClient) Unregister(clientInfo *ClientInfo) error
Unregister tries to unregister system
type RHSMConf ¶
type RHSMConf struct { // Server represents section [server] Server RHSMConfServer `ini:"server"` // RHSM represents section [rhsm] RHSM RHSMConfRHSM `ini:"rhsm"` // RHSMCertDaemon represents section [rhsmcertd] RHSMCertDaemon RHSMConfRHSMCertDaemon `ini:"rhsmcertd"` // Logging represents section [logging] Logging RHSMConfLogging `ini:"logging"` // contains filtered or unexported fields }
RHSMConf is structure intended for storing configuration that is typically read from /etc/rhsm/rhsm.conf. We try to
func LoadRHSMConf ¶
LoadRHSMConf tries to load given configuration file to RHSMConf structure
type RHSMConfLogging ¶
type RHSMConfLogging struct {
DefaultLogLevel string `ini:"default_log_level" default:"INFO" allowedValues:"ERROR,WARN,INFO,DEBUG"`
}
type RHSMConfRHSM ¶
type RHSMConfRHSM struct { // Directories used for certificates CACertDir string `ini:"ca_cert_dir" default:"/etc/rhsm/ca/"` ConsumerCertDir string `ini:"consumer_cert_dir" default:"/etc/pki/consumer"` // modified EntitlementCertDir string `ini:"entitlement_cert_dir" default:"/etc/pki/entitlement"` // modified ProductCertDir string `ini:"product_cert_dir" default:"/etc/pki/product"` // modified DefaultProductCertDir string `default:"/etc/pki/product-default"` // Configuration options related to RPMs and repositories BaseURL string `ini:"baseurl" default:"https://cdn.redhat.com"` ReportPackageProfile bool `ini:"report_package_profile" default:"true"` RepoCACertificate string `ini:"repo_ca_cert" default:"/etc/rhsm/ca/redhat-uep.pem"` ManageRepos bool `ini:"manage_repos" default:"true"` // Configuration options related to DNF plugins AutoEnableYumPlugins bool `ini:"auto_enable_yum_plugins" default:"true"` PackageProfileOnTrans bool `ini:"package_profile_on_trans" default:"false"` }
RHSMConfRHSM represents section [rhsm] in rhsm.conf
type RHSMConfRHSMCertDaemon ¶
type RHSMConfRHSMCertDaemon struct { AutoRegistration bool `ini:"auto_registration" default:"false"` AutoRegistrationInterval int64 `ini:"auto_registration_interval" default:"60"` Splay bool `ini:"splay" default:"true"` }
RHSMConfRHSMCertDaemon represents section [rhsmcertd] in rhsm.conf
type RHSMConfServer ¶
type RHSMConfServer struct { // Basic settings for connection to candlepin server Hostname string `ini:"hostname" default:"subscription.rhsm.redhat.com"` Prefix string `ini:"prefix" default:"/subscription"` Port string `ini:"port" default:"443"` Insecure bool `ini:"insecure" default:"false"` Timeout int64 `ini:"server_timeout" default:"180"` // Proxy settings ProxyHostname string `ini:"proxy_hostname" default:""` ProxyScheme string `ini:"proxy_scheme" default:"http" allowedValues:"http,https"` ProxyPort string `ini:"proxy_port" default:"3128"` ProxyUser string `ini:"proxy_user" default:""` ProxyPassword string `ini:"proxy_password" default:""` // Comma separated list of hostnames, when connection should not go // through proxy server NoProxy string `ini:"no_proxy" default:""` }
RHSMConfServer represents section [server] in rhsm.conf
type RHSMConnection ¶
type RHSMConnection struct { AuthType AuthType Client *http.Client ServerHostname *string ServerPort *string ServerPrefix *string }
RHSMConnection contains information about connection to server This is typically connection to candlepin server, but it can be also connection to CDN, when we try to get information about release
type RHSMStatus ¶
type RHSMStatus struct { Mode string `json:"mode"` ModeReason interface{} `json:"modeReason"` ModeChangeTime interface{} `json:"modeChangeTime"` Result bool `json:"result"` Version string `json:"version"` Release string `json:"release"` Standalone bool `json:"standalone"` // Note: json module cannot unmarshal timeUTC into time.Time // for this reason: https://github.com/golang/go/issues/47353 // Because we do not need to use timeUTC for anything ATM. // It is parsed as normal string. TimeUTC string `json:"timeUTC"` RulesSource string `json:"rulesSource"` RulesVersion string `json:"rulesVersion"` ManagerCapabilities []string `json:"managerCapabilities"` KeycloakRealm interface{} `json:"keycloakRealm"` KeycloakAuthUrl interface{} `json:"keycloakAuthUrl"` KeycloakResource interface{} `json:"keycloakResource"` DeviceAuthRealm interface{} `json:"deviceAuthRealm"` DeviceAuthUrl interface{} `json:"deviceAuthUrl"` DeviceAuthClientId interface{} `json:"deviceAuthClientId"` DeviceAuthScope interface{} `json:"deviceAuthScope"` }
RHSMStatus is structure used for storing GET response from REST API endpoint "/status". This endpoint can be called using no-auth or consumer-cert-auth connection
type RegisterData ¶
type RegisterData struct { Type string `json:"type"` Name string `json:"name"` Facts *SystemFacts `json:"facts"` InstalledProducts []InstalledProduct `json:"installedProducts"` ContentTags []string `json:"contentTags"` Role string `json:"role"` AddOns []interface{} `json:"addOns"` Usage string `json:"usage"` ServiceLevel string `json:"serviceLevel"` Environments []Environment `json:"environments"` }
RegisterData is structure representing JSON data used for register request
type RegisterError ¶
type RegisterError struct { DisplayMessage string `json:"displayMessage"` RequestUuid string `json:"requestUuid"` }
RegisterError is structure used for parsing JSON document returned by candlepin server, when registration is not successful
type RegisterOptions ¶
type RegisterOptions struct {
// contains filtered or unexported fields
}
RegisterOptions is structure containing various registration options
type SysPurposeJSON ¶
type SysPurposeJSON struct { Role string `json:"role"` ServiceLevelAgreement string `json:"service_level_agreement"` Usage string `json:"usage"` }
SysPurposeJSON is structure holding system purpose attributes
type SystemFacts ¶
type SystemFacts struct {
SystemCertificateVersion string `json:"system.certificate_version"`
}
SystemFacts is collection of system facts necessary during registration
type UnregisterServerError ¶
type UnregisterServerError struct { DisplayMessage string `json:"displayMessage"` RequestUuid string `json:"requestUuid"` StatusCode int ParsingError error }
UnregisterServerError is structure representing error returned from server
func (UnregisterServerError) Error ¶
func (unregisterServerError UnregisterServerError) Error() string
Error interface
type UserAgentInfo ¶
UserAgentInfo holds information about current client connected to candlepin server
func (UserAgentInfo) String ¶
func (userAgent UserAgentInfo) String() string
String returns textual representation of UserAgent