Documentation
¶
Index ¶
- func CheckUpdate(currentStr, latestStr string) (bool, error)
- func CheckUpdateSource(packageName string) string
- func Execute()
- func GetServerVersion() string
- func GetServerVersionWithError() (string, error)
- func LatestAgentVersion() string
- func ValidateServerVersionForAPIKey() error
- func ValidateServerVersionForMCP() error
- type Package
- type ServerTransaction
- type ServerVersion
- type ServerVersionError
- type TransactionDetail
- type VerificationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckUpdate ¶ added in v1.10.0
CheckUpdate compares the current version with the latest version. Returns true if the latest version is greater than the current version.
func CheckUpdateSource ¶ added in v1.10.0
CheckUpdateSource checks if updates are available for a given package using DNF. It specifically checks against a predefined repository (`myRepoID`).
packageName: The name of the package to check for updates.
Returns: - "repository" if updates are available for the package from the specified repository. - "manual" if no updates are found via the repository or if an error occurs.
func Execute ¶
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func GetServerVersion ¶ added in v1.5.0
func GetServerVersion() string
GetServerVersion retrieves the server version from the configured server URL. It uses the resty library to make an HTTP GET request to the "/v1/version" endpoint. If authentication is configured (API key or username and password), it sets the appropriate headers. On success, it returns the server version string. On failure (including network errors or invalid server response), it returns "unknown".
func GetServerVersionWithError ¶ added in v1.7.0
GetServerVersionWithError retrieves the server version and returns detailed error information. Returns the version string and any error encountered. If successful, returns version and nil error. If there's an authentication error, returns empty string and ServerVersionError with status code. If there's a network error, returns empty string and the network error.
func LatestAgentVersion ¶ added in v1.4.0
func LatestAgentVersion() string
LatestAgentVersion retrieves the latest agent version from a remote server. It checks the 'agent.check_version' configuration to determine if version checking is enabled. If enabled, it makes an HTTP GET request to "https://txlog.rda.run/docs/agent/version". If the request is successful and returns a 200 status code, the function returns the body of the response as a string, which represents the latest agent version. If there is an error during the request or the status code is not 200, or if version checking is disabled, the function returns an empty string.
func ValidateServerVersionForAPIKey ¶ added in v1.7.0
func ValidateServerVersionForAPIKey() error
ValidateServerVersionForAPIKey checks if the server version supports API key authentication. API key authentication requires server version >= 1.14.0. Returns an error if the server version is too old or cannot be determined.
func ValidateServerVersionForMCP ¶ added in v1.10.0
func ValidateServerVersionForMCP() error
ValidateServerVersionForMCP checks if the server version supports MCP functionality. MCP requires server version >= 1.19.0. Returns an error if the server version is too old or cannot be determined.
Types ¶
type Package ¶
type Package struct {
Action string `json:"action"`
Name string `json:"name"`
Version string `json:"version"`
Release string `json:"release"`
Epoch string `json:"epoch"`
Arch string `json:"arch"`
Repo string `json:"repo"`
FromRepo string `json:"from_repo,omitempty"`
}
Package represents a single package in a transaction entry.
type ServerTransaction ¶ added in v1.9.0
type ServerTransaction struct {
TransactionID string `json:"transaction_id"`
Hostname string `json:"hostname"`
BeginTime string `json:"begin_time"`
EndTime string `json:"end_time"`
Actions string `json:"actions"`
Altered string `json:"altered"`
User string `json:"user"`
ReturnCode string `json:"return_code"`
ReleaseVersion string `json:"release_version"`
CommandLine string `json:"command_line"`
Comment string `json:"comment"`
ScriptletOutput string `json:"scriptlet_output"`
Items []Package `json:"items"`
}
ServerTransaction represents a transaction as stored on the server
type ServerVersion ¶ added in v1.1.1
type ServerVersion struct {
Version string `json:"version"`
}
type ServerVersionError ¶ added in v1.7.0
ServerVersionError represents an error when fetching server version
func (*ServerVersionError) Error ¶ added in v1.7.0
func (e *ServerVersionError) Error() string
type TransactionDetail ¶
type TransactionDetail struct {
TransactionID string `json:"transaction_id"`
BeginTime string `json:"begin_time"`
BeginRPMDB string `json:"begin_rpmdb"`
EndTime string `json:"end_time"`
EndRPMDB string `json:"end_rpmdb"`
User string `json:"user"`
ReturnCode string `json:"return_code"`
Releasever string `json:"releasever"`
CommandLine string `json:"command_line"`
Comment string `json:"comment"`
PackagesAltered []Package `json:"packages_altered"`
ScriptletOutput []string `json:"scriptlet_output"`
}
TransactionDetail represents a detailed transaction entry, as shown in the 'dnf history info' command.