Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptEULA() error
- func AnnounceSystem(distroTgt string, instanceDataFile string, quiet bool) (string, string, error)
- func AssignAndCreateLabels(labels []string) error
- func Cleanup() error
- func CreatePostSnapshot(preSnapshot int) (int, error)
- func CreatePreSnapshot() (int, error)
- func Deregister(jsonOutput bool) error
- func DeregisterSystem() error
- func FetchSystemInformation() (collectors.Result, error)
- func GetProductStatuses(format string) (string, error)
- func GetShortenedVersion() string
- func InstallerUpdates(product Product) ([]zypper.Repository, error)
- func IsRegistered() bool
- func IsSnapperConfigured() bool
- func MigrationAddService(URL string, serviceName string) error
- func MigrationRemoveService(serviceName string) error
- func Register(jsonOutput bool) error
- func ReloadCertPool() error
- func RenderExtensionTree(outputJson bool) (string, error)
- func Rollback() error
- func SendKeepAlivePing() error
- func SystemActivations() (map[string]Activation, error)
- func UpToDate() bool
- func UpdateCertificates() error
- func UpdateSystem(distroTarget, instanceDataFile string, quiet bool, keepalive bool) error
- type APIError
- type Activation
- type Config
- type JSONError
- type Label
- type MigrationPath
- type Product
- type ProductOut
- type ProductService
- type RegisterOut
- type RegistryAuthConfig
- func (cfg *RegistryAuthConfig) Get(registry string) (string, string, bool)
- func (cfg *RegistryAuthConfig) LoadFrom(path string) error
- func (cfg *RegistryAuthConfig) Remove(registry string)
- func (cfg *RegistryAuthConfig) SaveTo(path string) error
- func (cfg *RegistryAuthConfig) Set(registry string, login string, password string)
- type RegistryAuthentication
- type SearchPackageProduct
- type SearchPackageResult
- type ServerType
- type Service
- type ServiceOut
- type Status
- type StringSet
Constants ¶
const ( DEFAULT_DOCKER_CLIENT_CONFIG = ".docker/config.json" DEFAULT_SUSE_REGISTRY = "https://registry.suse.com" )
const (
UptimeLogFilePath = "/etc/zypp/suse-uptime.log"
)
Variables ¶
var ( ErrSystemNotRegistered = errors.New("System not registered") ErrPingFromUnregistered = errors.New("Keepalive ping not allowed from unregistered system.") ErrBaseProductDeactivation = errors.New("Unable to deactivate base product") ErrListExtensionsUnregistered = errors.New("System not registered") )
export errors that package main needs
var ( // CFG is the global struct for config CFG = NewConfig() )
Functions ¶
func AcceptEULA ¶
func AcceptEULA() error
AcceptEULA handles EULA interactions from the given base product/extensions. If there are no EULAs to be handled, then this function does nothing and returns nil. If the global configuration is set to auto-accept EULAs, then they are accepted without further action. Otherwise, we prompt to users to confirm it and then we proceed accordingly.
func AnnounceSystem ¶
AnnounceSystem announce system via SCC/Registration Proxy
func AssignAndCreateLabels ¶
func CreatePostSnapshot ¶
CreatePostSnapshot creates "post" type snapshot for given preSnapshot
func CreatePreSnapshot ¶
CreatePreSnapshot creates "pre" type snapshot
func DeregisterSystem ¶
func DeregisterSystem() error
DeregisterSystem deletes current system in SMT/SCC
func FetchSystemInformation ¶
func FetchSystemInformation() (collectors.Result, error)
func GetProductStatuses ¶
GetProductStatuses returns statuses of installed products
func GetShortenedVersion ¶
func GetShortenedVersion() string
GetShortenedVersion returns the short program version
func InstallerUpdates ¶
func InstallerUpdates(product Product) ([]zypper.Repository, error)
InstallerUpdates returns an array of Installer-Updates repositories for the given product
func IsRegistered ¶
func IsRegistered() bool
IsRegistered returns true if there is a valid credentials file
func IsSnapperConfigured ¶
func IsSnapperConfigured() bool
IsSnapperConfigured checks if snapper is properly configured
func MigrationAddService ¶
MigrationAddService adds zypper service in migration context
func MigrationRemoveService ¶
MigrationRemoveService removes zypper service in migration context
func Register ¶
Register announces the system, activates the product on SCC and adds the service to the system
func ReloadCertPool ¶
func ReloadCertPool() error
ReloadCertPool triggers reload of internals CA cert pool
func RenderExtensionTree ¶
func SendKeepAlivePing ¶
func SendKeepAlivePing() error
SendKeepAlivePing updates the system information on the server
func SystemActivations ¶
func SystemActivations() (map[string]Activation, error)
SystemActivations returns a map keyed by "Identifier/Version/Arch"
func UpToDate ¶
func UpToDate() bool
UpToDate Checks if API endpoint is up-to-date, useful when dealing with RegistrationProxy errors
func UpdateCertificates ¶
func UpdateCertificates() error
UpdateCertificates runs system certificate update command
Types ¶
type Activation ¶
type Activation struct { Name string `json:"name"` Status string `json:"status"` RegCode string `json:"regcode"` Type string `json:"type"` StartsAt time.Time `json:"starts_at"` ExpiresAt time.Time `json:"expires_at"` Service Service `json:"service"` }
Activation mimics the shape of the json from the api
type Config ¶
type Config struct { Path string BaseURL string `json:"url"` Language string `json:"language"` Insecure bool `json:"insecure"` Namespace string `json:"namespace"` FsRoot string Token string Product Product InstanceDataFile string Email string `json:"email"` AutoAgreeEULA bool EnableSystemUptimeTracking bool ServerType ServerType NoZypperRefresh bool AutoImportRepoKeys bool SkipServiceInstall bool }
Config holds the config!
func (*Config) ChangeBaseURL ¶
Change the base url to be used when talking to the server to the one being provided.
func (*Config) IsScc ¶
Returns true if we detected that the configuration points to SCC.
NOTE: this will be reliable if the configuration file already pointed to SCC, but it might need to be filled in upon HTTP requests to further guess if it's a Glue instance running on localhost or similar developer-only scenarios.
func (*Config) Load ¶
func (c *Config) Load()
Load tries to read and merge the settings from Path. Ignore errors as it's quite normal that Path does not exist.
type MigrationPath ¶
type MigrationPath []Product
MigrationPath holds a list of products
func OfflineProductMigrations ¶
func OfflineProductMigrations(installed []Product, targetBaseProduct Product) ([]MigrationPath, error)
OfflineProductMigrations returns the offline migration paths for the installed products and target
func ProductMigrations ¶
func ProductMigrations(installed []Product) ([]MigrationPath, error)
ProductMigrations returns the online migration paths for the installed products
type Product ¶
type Product struct { Name string `xml:"name,attr" json:"identifier"` Version string `xml:"version,attr" json:"version"` Arch string `xml:"arch,attr" json:"arch"` Release string `xml:"release,attr" json:"-"` Summary string `xml:"summary,attr" json:"summary,omitempty"` IsBase bool `xml:"isbase,attr" json:"isbase"` FriendlyName string `json:"friendly_name,omitempty"` ReleaseType string `xml:"registerrelease,attr" json:"release_type,omitempty"` ProductLine string `xml:"productline,attr"` Available bool `json:"available"` Free bool `json:"free"` Recommended bool `json:"recommended"` // optional extension products Extensions []Product `json:"extensions,omitempty"` // these are used by YaST ID int `json:"-"` // handled by custom unmarshaller/marshaller Description string `xml:"description" json:"description,omitempty"` EULAURL string `json:"eula_url,omitempty"` FormerName string `json:"former_identifier,omitempty"` ProductType string `json:"product_type,omitempty"` ShortName string `json:"shortname,omitempty"` LongName string `json:"name,omitempty"` ReleaseStage string `json:"release_stage,omitempty"` Repositories []zypper.Repository `json:"repositories,omitempty"` }
Product represents an installed product or product information from API
NOTE (FTW epic): some of the things here do not map correctly with SCC's API and it's admittedly quite bananas (e.g. SCC's "identifier" being "Name" but then SCC's "name" being "LongName" and claiming that it's used by Yast (wtf?)).
func ActivatedProducts ¶
ActivatedProducts returns list of products activated in SCC/SMT
func ShowProduct ¶
ShowProduct fetches product details from SCC/SMT
func SplitTriplet ¶
SplitTriplet returns a product from given or error for invalid input
func SyncProducts ¶
SyncProducts synchronizes activated system products to the registration server
func SystemProducts ¶
SystemProducts returns sum of installed and activated products Products from zypper have priority over products from activations as they have summary field which is missing in the latter.
func (*Product) MarshalJSON ¶
MarshalJSON is a custom JSON marshaller that includes the "id" field. This method is needed because the `json:"id"` tag can not be used on Product.ID because the that field requires a custom unmarshaller.
func (*Product) UnmarshalJSON ¶
UnmarshalJSON custom unmarshaller for Product. Special decoding is needed for the Available, IsBase and ID fields.
type ProductOut ¶
type ProductService ¶
type ProductService struct { Product ProductOut `json:"product"` Service ServiceOut `json:"service"` }
type RegisterOut ¶
type RegisterOut struct { Success bool `json:"success"` Products []ProductService `json:"products"` Message string `json:"message"` }
type RegistryAuthConfig ¶
type RegistryAuthConfig struct { AuthConfigs map[string]RegistryAuthentication `json:"auths"` HTTPHeaders map[string]string `json:"HttpHeaders,omitempty"` PsFormat string `json:"psFormat,omitempty"` ImagesFormat string `json:"imagesFormat,omitempty"` NetworksFormat string `json:"networksFormat,omitempty"` PluginsFormat string `json:"pluginsFormat,omitempty"` VolumesFormat string `json:"volumesFormat,omitempty"` StatsFormat string `json:"statsFormat,omitempty"` DetachKeys string `json:"detachKeys,omitempty"` CredentialsStore string `json:"credsStore,omitempty"` CredentialHelpers map[string]string `json:"credHelpers,omitempty"` Filename string `json:"-"` // Note: for internal use only ServiceInspectFormat string `json:"serviceInspectFormat,omitempty"` ServicesFormat string `json:"servicesFormat,omitempty"` TasksFormat string `json:"tasksFormat,omitempty"` SecretFormat string `json:"secretFormat,omitempty"` ConfigFormat string `json:"configFormat,omitempty"` NodesFormat string `json:"nodesFormat,omitempty"` PruneFilters []string `json:"pruneFilters,omitempty"` Proxies map[string]string `json:"proxies,omitempty"` Experimental string `json:"experimental,omitempty"` CurrentContext string `json:"currentContext,omitempty"` CLIPluginsExtraDirs []string `json:"cliPluginsExtraDirs,omitempty"` Plugins map[string]map[string]string `json:"plugins,omitempty"` Aliases map[string]string `json:"aliases,omitempty"` }
func (*RegistryAuthConfig) Get ¶
func (cfg *RegistryAuthConfig) Get(registry string) (string, string, bool)
func (*RegistryAuthConfig) LoadFrom ¶
func (cfg *RegistryAuthConfig) LoadFrom(path string) error
func (*RegistryAuthConfig) Remove ¶
func (cfg *RegistryAuthConfig) Remove(registry string)
func (*RegistryAuthConfig) SaveTo ¶
func (cfg *RegistryAuthConfig) SaveTo(path string) error
type RegistryAuthentication ¶
type SearchPackageProduct ¶
type SearchPackageProduct struct { ID int `json:"id"` Name string `json:"name"` Ident string `json:"identifier"` Type string `json:"type"` Free bool `json:"free"` Edition string `json:"edition"` Arch string `json:"architecture"` }
SearchPackageProduct represents product reference in package search result
type SearchPackageResult ¶
type SearchPackageResult struct { ID int `json:"id"` Name string `json:"name"` Arch string `json:"arch"` Version string `json:"version"` Release string `json:"release"` Products []SearchPackageProduct `json:"products"` }
SearchPackageResult represents package search result
func SearchPackage ¶
func SearchPackage(query string, baseProd Product) ([]SearchPackageResult, error)
SearchPackage returns packages which are available in the extensions tree for given base product
type ServerType ¶
type ServerType uint64
Kinds of servers which are supported by SUSEConnect.
const ( UnknownProvider ServerType = iota SccProvider RmtProvider )
type Service ¶
type Service struct { ID int `json:"id"` URL string `xml:"url,attr" json:"url"` Name string `xml:"name,attr" json:"name"` Product Product `json:"product"` ObsoletedName string `json:"obsoleted_service_name"` }
Service represents an installed service or service information from API
func ActivateProduct ¶
ActivateProduct activates given product in SMT/SCC returns Service to be added to zypper
func DeactivateProduct ¶
DeactivateProduct deactivates given product in SMT/SCC returns Service to be removed from zypper
func UpgradeProduct ¶
UpgradeProduct upgades the records for given product in SCC/SMT The service record for new product is returned
type ServiceOut ¶
type Status ¶
type Status struct { Name string `json:"name,omitempty"` Summary string `json:"-"` Identifier string `json:"identifier"` Version string `json:"version"` Arch string `json:"arch"` Status string `json:"status"` RegCode string `json:"regcode,omitempty"` StartsAt string `json:"starts_at,omitempty"` ExpiresAt string `json:"expires_at,omitempty"` SubStatus string `json:"subscription_status,omitempty"` Type string `json:"type,omitempty"` }
Status is used to create the JSON for `SUSEConnect --status`. And to render the template for `SUSEConnect --status-text`.
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
StringSet is used to implement a set of strings
func NewStringSet ¶
NewStringSet constructor for StringSet. The set can be initialized with zero or more strings.