connect

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_DOCKER_CLIENT_CONFIG = ".docker/config.json"
	DEFAULT_SUSE_REGISTRY        = "https://registry.suse.com"
)
View Source
const (
	UptimeLogFilePath = "/etc/zypp/suse-uptime.log"
)

Variables

View Source
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

View Source
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

func AnnounceSystem(distroTgt string, instanceDataFile string, quiet bool) (string, string, error)

AnnounceSystem announce system via SCC/Registration Proxy

func AssignAndCreateLabels

func AssignAndCreateLabels(labels []string) error

func Cleanup

func Cleanup() error

Cleanup removes system credentials and installed services

func CreatePostSnapshot

func CreatePostSnapshot(preSnapshot int) (int, error)

CreatePostSnapshot creates "post" type snapshot for given preSnapshot

func CreatePreSnapshot

func CreatePreSnapshot() (int, error)

CreatePreSnapshot creates "pre" type snapshot

func Deregister

func Deregister(jsonOutput bool) error

Deregister deregisters the system

func DeregisterSystem

func DeregisterSystem() error

DeregisterSystem deletes current system in SMT/SCC

func FetchSystemInformation

func FetchSystemInformation() (collectors.Result, error)

func GetProductStatuses

func GetProductStatuses(format string) (string, error)

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

func MigrationAddService(URL string, serviceName string) error

MigrationAddService adds zypper service in migration context

func MigrationRemoveService

func MigrationRemoveService(serviceName string) error

MigrationRemoveService removes zypper service in migration context

func Register

func Register(jsonOutput bool) error

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 RenderExtensionTree(outputJson bool) (string, error)

func Rollback

func Rollback() error

Rollback restores system state to before failed migration

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

func UpdateSystem

func UpdateSystem(distroTarget, instanceDataFile string, quiet bool, keepalive bool) error

UpdateSystem resend the system's hardware details on SCC

Types

type APIError

type APIError struct {
	Code    int
	Message string
}

APIError is returned on failed HTTP requests

func (APIError) Error

func (ae APIError) Error() string

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 NewConfig

func NewConfig() Config

NewConfig returns a Config with defaults

func (*Config) ChangeBaseURL

func (c *Config) ChangeBaseURL(baseUrl string)

Change the base url to be used when talking to the server to the one being provided.

func (*Config) IsScc

func (c *Config) IsScc() bool

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.

func (*Config) MergeJSON

func (c *Config) MergeJSON(jsn string) error

MergeJSON merges attributes of jsn that match Config fields

func (Config) Save

func (c Config) Save() error

Save saves the config to Path

type JSONError

type JSONError struct {
	Err error
}

JSONError is returned on failed JSON decoding

func (JSONError) Error

func (je JSONError) Error() string

func (JSONError) Unwrap

func (je JSONError) Unwrap() error

type Label

type Label struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

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

func ActivatedProducts() ([]Product, error)

ActivatedProducts returns list of products activated in SCC/SMT

func ShowProduct

func ShowProduct(productQuery Product) (Product, error)

ShowProduct fetches product details from SCC/SMT

func SplitTriplet

func SplitTriplet(p string) (Product, error)

SplitTriplet returns a product from given or error for invalid input

func SyncProducts

func SyncProducts(products []Product) ([]Product, error)

SyncProducts synchronizes activated system products to the registration server

func SystemProducts

func SystemProducts() ([]Product, error)

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) Edition

func (p Product) Edition() string

Edition returns VERSION[-RELEASE] for product

func (*Product) MarshalJSON

func (p *Product) MarshalJSON() ([]byte, error)

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) ToTriplet

func (p Product) ToTriplet() string

ToTriplet returns <name>/<version>/<arch> string for product

func (*Product) UnmarshalJSON

func (p *Product) UnmarshalJSON(data []byte) error

UnmarshalJSON custom unmarshaller for Product. Special decoding is needed for the Available, IsBase and ID fields.

type ProductOut

type ProductOut struct {
	Name       string `json:"name"`
	Identifier string `json:"identifier"`
	Version    string `json:"version"`
	Arch       string `json:"arch"`
}

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

func (*RegistryAuthConfig) Set

func (cfg *RegistryAuthConfig) Set(registry string, login string, password string)

type RegistryAuthentication

type RegistryAuthentication struct {
	Auth          string `json:"auth,omitempty"`
	IdentityToken string `json:"identitytoken,omitempty"`
}

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

func ActivateProduct(product Product, email string) (Service, error)

ActivateProduct activates given product in SMT/SCC returns Service to be added to zypper

func DeactivateProduct

func DeactivateProduct(product Product) (Service, error)

DeactivateProduct deactivates given product in SMT/SCC returns Service to be removed from zypper

func UpgradeProduct

func UpgradeProduct(product Product) (Service, error)

UpgradeProduct upgades the records for given product in SCC/SMT The service record for new product is returned

type ServiceOut

type ServiceOut struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
	Url  string `json:"url"`
}

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

func NewStringSet(strs ...string) StringSet

NewStringSet constructor for StringSet. The set can be initialized with zero or more strings.

func (StringSet) Add

func (ss StringSet) Add(strs ...string)

Add string(s) to set

func (StringSet) Contains

func (ss StringSet) Contains(s string) bool

Contains returns true if s is in the set

func (StringSet) Delete

func (ss StringSet) Delete(s string)

Delete s from set

func (StringSet) Len

func (ss StringSet) Len() int

Len returns the number of strings in the set

func (StringSet) Strings

func (ss StringSet) Strings() []string

Strings returns all strings from the set as a slice

Jump to

Keyboard shortcuts

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