Skip to content

Commit

Permalink
feat: Added list of enabled/disable features to JSON doc
Browse files Browse the repository at this point in the history
* Card ID: CCT-1005
* When machine readable output is used (JSON format), then
  include list of enabled and list of disabled features
  in JSON document
  • Loading branch information
jirihnidek committed Dec 10, 2024
1 parent eb25fd1 commit 170304e
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions connect_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ import (
// ConnectResult is structure holding information about results
// of connect command. The result could be printed in machine-readable format.
type ConnectResult struct {
Hostname string `json:"hostname"`
HostnameError string `json:"hostname_error,omitempty"`
UID int `json:"uid"`
UIDError string `json:"uid_error,omitempty"`
RHSMConnected bool `json:"rhsm_connected"`
RHSMConnectError string `json:"rhsm_connect_error,omitempty"`
ContentEnabled bool `json:"content_enabled"`
InsightsConnected bool `json:"insights_connected"`
InsightsError string `json:"insights_connect_error,omitempty"`
YggdrasilStarted bool `json:"yggdrasil_started"`
YggdrasilStartedError string `json:"yggdrasil_started_error,omitempty"`
Hostname string `json:"hostname"`
HostnameError string `json:"hostname_error,omitempty"`
UID int `json:"uid"`
UIDError string `json:"uid_error,omitempty"`
EnabledFeatures []string `json:"enabled_features"`
DisabledFeatures []string `json:"disabled_features"`
RHSMConnected bool `json:"rhsm_connected"`
RHSMConnectError string `json:"rhsm_connect_error,omitempty"`
ContentEnabled bool `json:"content_enabled"`
InsightsConnected bool `json:"insights_connected"`
InsightsError string `json:"insights_connect_error,omitempty"`
YggdrasilStarted bool `json:"yggdrasil_started"`
YggdrasilStartedError string `json:"yggdrasil_started_error,omitempty"`
format string
}

Expand Down Expand Up @@ -122,18 +124,22 @@ func connectAction(ctx *cli.Context) error {

interactivePrintf("Connecting %v to %v.\nThis might take a few seconds.\n\n", hostname, Provider)

if !uiSettings.isMachineReadable {
var featuresStr []string
for _, feature := range KnownFeatures {
if feature.Enabled {
featuresStr = append(featuresStr, "["+symbolOK+"]"+feature.ID)
} else {
featuresStr = append(featuresStr, "[ ]"+feature.ID)
var featuresStr []string
for _, feature := range KnownFeatures {
if feature.Enabled {
if uiSettings.isMachineReadable {
connectResult.EnabledFeatures = append(connectResult.EnabledFeatures, feature.ID)
}
featuresStr = append(featuresStr, "["+symbolOK+"]"+feature.ID)
} else {
if uiSettings.isMachineReadable {
connectResult.DisabledFeatures = append(connectResult.EnabledFeatures, feature.ID)
}
featuresStr = append(featuresStr, "[ ]"+feature.ID)
}
featuresListStr := strings.Join(featuresStr, ", ")
interactivePrintf("Features preferences: %s\n\n", featuresListStr)
}
featuresListStr := strings.Join(featuresStr, ", ")
interactivePrintf("Features preferences: %s\n\n", featuresListStr)

var start time.Time
durations := make(map[string]time.Duration)
Expand Down

0 comments on commit 170304e

Please sign in to comment.