diff --git a/cmd/suseconnect/connectUsage.txt b/cmd/suseconnect/connectUsage.txt index 8e58dbda..fe7248d7 100644 --- a/cmd/suseconnect/connectUsage.txt +++ b/cmd/suseconnect/connectUsage.txt @@ -46,6 +46,8 @@ Manage subscriptions at https://scc.suse.com services installed by SUSEConnect. --rollback Revert the registration state in case of a failed migration. + -i, --info Show the information that will be reported to the + server. --version Print program version. Common options: diff --git a/cmd/suseconnect/suseconnect.go b/cmd/suseconnect/suseconnect.go index 524ed050..cbe2fcc9 100644 --- a/cmd/suseconnect/suseconnect.go +++ b/cmd/suseconnect/suseconnect.go @@ -75,6 +75,7 @@ func main() { email string version bool jsonFlag bool + info bool ) // display help like the ruby SUSEConnect @@ -109,6 +110,8 @@ func main() { flag.Var(&product, "product", "") flag.Var(&product, "p", "") flag.BoolVar(&jsonFlag, "json", false, "") + flag.BoolVar(&info, "info", false, "") + flag.BoolVar(&info, "i", false, "") flag.Parse() if version { @@ -247,6 +250,14 @@ func main() { } err := connect.Rollback() exitOnError(err) + } else if info { + sysInfo, err := connect.FetchSystemInformation() + exitOnError(err) + + out, err := json.Marshal(sysInfo) + exitOnError(err) + + fmt.Print(string(out)) } else { if instanceDataFile != "" && connect.URLDefault() { fmt.Print("Please use --instance-data only in combination ") diff --git a/internal/connect/api.go b/internal/connect/api.go index 87c9cdd8..5905a027 100644 --- a/internal/connect/api.go +++ b/internal/connect/api.go @@ -251,7 +251,7 @@ func makeSysInfoBody(distroTarget, namespace string, instanceData []byte, includ } } - sysinfo, err := fetchSystemInformation() + sysinfo, err := FetchSystemInformation() if err != nil { return nil, err } @@ -277,7 +277,7 @@ var mandatoryCollectors = []collectors.Collector{ collectors.SAP{}, } -func fetchSystemInformation() (collectors.Result, error) { +func FetchSystemInformation() (collectors.Result, error) { arch, err := collectors.DetectArchitecture() if err != nil {