Skip to content

Commit

Permalink
Merge pull request #260 from SUSE/collected-command
Browse files Browse the repository at this point in the history
Add a command to show the info being gathered
  • Loading branch information
mssola authored Oct 2, 2024
2 parents 1a38f57 + 0f25bb3 commit b7159ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/suseconnect/connectUsage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 11 additions & 0 deletions cmd/suseconnect/suseconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func main() {
email string
version bool
jsonFlag bool
info bool
)

// display help like the ruby SUSEConnect
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 ")
Expand Down
4 changes: 2 additions & 2 deletions internal/connect/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func makeSysInfoBody(distroTarget, namespace string, instanceData []byte, includ
}
}

sysinfo, err := fetchSystemInformation()
sysinfo, err := FetchSystemInformation()
if err != nil {
return nil, err
}
Expand All @@ -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 {
Expand Down

0 comments on commit b7159ce

Please sign in to comment.