diff --git a/connect_cmd.go b/connect_cmd.go index ee65cec..89a8a27 100644 --- a/connect_cmd.go +++ b/connect_cmd.go @@ -3,26 +3,35 @@ package main import ( "encoding/json" "fmt" - "github.com/subpop/go-log" - "github.com/urfave/cli/v2" "os" + "strings" "time" + + "github.com/subpop/go-log" + "github.com/urfave/cli/v2" ) +type FeatureResult struct { + Enabled bool `json:"enabled"` + Successful bool `json:"successful"` + Error string `json:"error,omitempty"` +} + // 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"` - 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 + 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"` + Features struct { + Content FeatureResult `json:"content"` + Analytics FeatureResult `json:"analytics"` + RemoteManagement FeatureResult `json:"remote_management"` + } `json:"features"` + format string } // Error implement error interface for structure ConnectResult @@ -56,6 +65,8 @@ func beforeConnectAction(ctx *cli.Context) error { password := ctx.String("password") organization := ctx.String("organization") activationKeys := ctx.StringSlice("activation-key") + enabledFeatures := ctx.StringSlice("enable-feature") + disabledFeatures := ctx.StringSlice("disable-feature") if len(activationKeys) > 0 { if username != "" { @@ -73,6 +84,11 @@ func beforeConnectAction(ctx *cli.Context) error { } } + err = checkFeatureInput(&enabledFeatures, &disabledFeatures) + if err != nil { + return err + } + return checkForUnknownArgs(ctx) } @@ -112,13 +128,44 @@ func connectAction(ctx *cli.Context) error { interactivePrintf("Connecting %v to %v.\nThis might take a few seconds.\n\n", hostname, Provider) + var featuresStr []string + for _, feature := range KnownFeatures { + if feature.Enabled { + if uiSettings.isMachineReadable { + switch feature.ID { + case "content": + connectResult.Features.Content.Enabled = true + case "analytics": + connectResult.Features.Analytics.Enabled = true + case "remote-management": + connectResult.Features.RemoteManagement.Enabled = true + } + } + featuresStr = append(featuresStr, "["+symbolOK+"]"+feature.ID) + } else { + if uiSettings.isMachineReadable { + switch feature.ID { + case "content": + connectResult.Features.Content.Enabled = false + case "analytics": + connectResult.Features.Analytics.Enabled = false + case "remote-management": + connectResult.Features.RemoteManagement.Enabled = false + } + } + featuresStr = append(featuresStr, "[ ]"+feature.ID) + } + } + featuresListStr := strings.Join(featuresStr, ", ") + interactivePrintf("Features preferences: %s\n\n", featuresListStr) + var start time.Time durations := make(map[string]time.Duration) errorMessages := make(map[string]LogMessage) /* 1. Register to RHSM, because we need to get consumer certificate. This blocks following action */ start = time.Now() var returnedMsg string - returnedMsg, err = registerRHSM(ctx) + returnedMsg, err = registerRHSM(ctx, ContentFeature.Enabled) if err != nil { connectResult.RHSMConnected = false errorMessages["rhsm"] = LogMessage{ @@ -127,77 +174,138 @@ func connectAction(ctx *cli.Context) error { err)} if uiSettings.isMachineReadable { connectResult.RHSMConnectError = errorMessages["rhsm"].message.Error() + connectResult.Features.Content.Successful = false } else { fmt.Printf( - "%v Cannot connect to Red Hat Subscription Management\n", + "%s[%v] Cannot connect to Red Hat Subscription Management\n", + smallIndent, + uiSettings.iconError, + ) + fmt.Printf( + "%s[%v] Skipping generation of Red Hat repository file\n", + mediumIndent, uiSettings.iconError, ) } } else { connectResult.RHSMConnected = true - interactivePrintf("%v %v\n", uiSettings.iconOK, returnedMsg) + interactivePrintf("%s[%v] %v\n", smallIndent, uiSettings.iconOK, returnedMsg) + if ContentFeature.Enabled { + if uiSettings.isMachineReadable { + connectResult.Features.Content.Successful = true + } + interactivePrintf( + "%s[%v] Content ... Red Hat repository file generated\n", + mediumIndent, + uiSettings.iconOK, + ) + } else { + if uiSettings.isMachineReadable { + connectResult.Features.Content.Successful = false + } + interactivePrintf("%s[ ] Content ... Red Hat repository file not generated\n", mediumIndent) + } } durations["rhsm"] = time.Since(start) /* 2. Register insights-client */ - if errors, exist := errorMessages["rhsm"]; exist { - if errors.level == log.LevelError { + if AnalyticsFeature.Enabled { + if errors, exist := errorMessages["rhsm"]; exist { + if errors.level == log.LevelError { + interactivePrintf( + "%s[%v] Skipping connection to Red Hat Insights\n", + mediumIndent, + uiSettings.iconError, + ) + } + } else { + start = time.Now() + err = showProgress(" Connecting to Red Hat Insights...", registerInsights, mediumIndent) + if err != nil { + connectResult.Features.Analytics.Successful = false + errorMessages["insights"] = LogMessage{ + level: log.LevelError, + message: fmt.Errorf("cannot connect to Red Hat Insights: %w", err)} + if uiSettings.isMachineReadable { + connectResult.Features.Analytics.Error = errorMessages["insights"].message.Error() + } else { + fmt.Printf( + "%s[%v] Analytics ... Cannot connect to Red Hat Insights\n", + mediumIndent, + uiSettings.iconError, + ) + } + } else { + connectResult.Features.Analytics.Successful = true + interactivePrintf( + "%s[%v] Analytics ... Connected to Red Hat Insights\n", + mediumIndent, + uiSettings.iconOK, + ) + } + durations["insights"] = time.Since(start) + } + } else { + if uiSettings.isMachineReadable { + connectResult.Features.Analytics.Successful = false + } + interactivePrintf("%s[ ] Analytics ... Connecting to Red Hat Insights disabled\n", mediumIndent) + } + + if ManagementFeature.Enabled { + /* 3. Start yggdrasil (rhcd) service */ + if rhsmErrMsg, exist := errorMessages["rhsm"]; exist && rhsmErrMsg.level == log.LevelError { + connectResult.Features.RemoteManagement.Successful = false interactivePrintf( - "%v Skipping connection to Red Hat Insights\n", + "%s[%v] Skipping activation of %v service\n", + mediumIndent, uiSettings.iconError, + ServiceName, ) - } - } else { - start = time.Now() - err = showProgress(" Connecting to Red Hat Insights...", registerInsights) - if err != nil { - connectResult.InsightsConnected = false - errorMessages["insights"] = LogMessage{ - level: log.LevelError, - message: fmt.Errorf("cannot connect to Red Hat Insights: %w", err)} - if uiSettings.isMachineReadable { - connectResult.InsightsError = errorMessages["insights"].message.Error() + } else { + start = time.Now() + progressMessage := fmt.Sprintf(" Activating the %v service", ServiceName) + err = showProgress(progressMessage, activateService, mediumIndent) + if err != nil { + connectResult.Features.RemoteManagement.Successful = false + errorMessages[ServiceName] = LogMessage{ + level: log.LevelError, + message: fmt.Errorf("cannot activate %s service: %w", + ServiceName, err)} + if uiSettings.isMachineReadable { + connectResult.Features.RemoteManagement.Error = errorMessages[ServiceName].message.Error() + } else { + interactivePrintf( + "%s[%v] Remote Management ... Cannot activate the %v service\n", + mediumIndent, + uiSettings.iconError, + ServiceName, + ) + } } else { - fmt.Printf("%v Cannot connect to Red Hat Insights\n", uiSettings.iconError) + connectResult.Features.RemoteManagement.Successful = true + interactivePrintf( + "%s[%v] Remote Management ... Activated the %v service\n", + mediumIndent, + uiSettings.iconOK, + ServiceName, + ) } - } else { - connectResult.InsightsConnected = true - interactivePrintf("%v Connected to Red Hat Insights\n", uiSettings.iconOK) + durations[ServiceName] = time.Since(start) + } + } else { + if uiSettings.isMachineReadable { + connectResult.Features.RemoteManagement.Successful = false } - durations["insights"] = time.Since(start) - } - - /* 3. Start yggdrasil (rhcd) service */ - if rhsmErrMsg, exist := errorMessages["rhsm"]; exist && rhsmErrMsg.level == log.LevelError { - connectResult.YggdrasilStarted = false interactivePrintf( - "%v Skipping activation of %v service\n", - uiSettings.iconError, + "%s[ ] Management .... Starting %s service disabled\n", + mediumIndent, ServiceName, ) - } else { - start = time.Now() - progressMessage := fmt.Sprintf(" Activating the %v service", ServiceName) - err = showProgress(progressMessage, activateService) - if err != nil { - connectResult.YggdrasilStarted = false - errorMessages[ServiceName] = LogMessage{ - level: log.LevelError, - message: fmt.Errorf("cannot activate %s service: %w", - ServiceName, err)} - if uiSettings.isMachineReadable { - connectResult.YggdrasilStartedError = errorMessages[ServiceName].message.Error() - } else { - fmt.Printf("%v Cannot activate the %v service\n", uiSettings.iconError, ServiceName) - } - } else { - connectResult.YggdrasilStarted = true - interactivePrintf("%v Activated the %v service\n", uiSettings.iconOK, ServiceName) - } - durations[ServiceName] = time.Since(start) - interactivePrintf("\nSuccessfully connected to Red Hat!\n") } + interactivePrintf("\nSuccessfully connected to Red Hat!\n") + if !uiSettings.isMachineReadable { /* 5. Show footer message */ fmt.Printf("\nManage your connected systems: https://red.ht/connector\n") diff --git a/constants.go b/constants.go index d131d90..68e33a9 100644 --- a/constants.go +++ b/constants.go @@ -92,3 +92,6 @@ func init() { ServiceName = "yggdrasil" } } + +const smallIndent = " " +const mediumIndent = " " diff --git a/disconnect_cmd.go b/disconnect_cmd.go index f9df4a4..01107bf 100644 --- a/disconnect_cmd.go +++ b/disconnect_cmd.go @@ -3,10 +3,11 @@ package main import ( "encoding/json" "fmt" - "github.com/subpop/go-log" - "github.com/urfave/cli/v2" "os" "time" + + "github.com/subpop/go-log" + "github.com/urfave/cli/v2" ) // DisconnectResult is structure holding information about result of @@ -95,7 +96,7 @@ func disconnectAction(ctx *cli.Context) error { /* 1. Deactivate yggdrasil (rhcd) service */ start = time.Now() progressMessage := fmt.Sprintf(" Deactivating the %v service", ServiceName) - err = showProgress(progressMessage, deactivateService) + err = showProgress(progressMessage, deactivateService, smallIndent) if err != nil { errMsg := fmt.Sprintf("Cannot deactivate %s service: %v", ServiceName, err) errorMessages[ServiceName] = LogMessage{ @@ -103,16 +104,16 @@ func disconnectAction(ctx *cli.Context) error { message: fmt.Errorf("%v", errMsg)} disconnectResult.YggdrasilStopped = false disconnectResult.YggdrasilStoppedError = errMsg - interactivePrintf("%v %v\n", uiSettings.iconError, errMsg) + interactivePrintf(" [%v] %v\n", uiSettings.iconError, errMsg) } else { disconnectResult.YggdrasilStopped = true - interactivePrintf("%v Deactivated the %v service\n", uiSettings.iconOK, ServiceName) + interactivePrintf(" [%v] Deactivated the %v service\n", uiSettings.iconOK, ServiceName) } durations[ServiceName] = time.Since(start) /* 2. Disconnect from Red Hat Insights */ start = time.Now() - err = showProgress(" Disconnecting from Red Hat Insights...", unregisterInsights) + err = showProgress(" Disconnecting from Red Hat Insights...", unregisterInsights, smallIndent) if err != nil { errMsg := fmt.Sprintf("Cannot disconnect from Red Hat Insights: %v", err) errorMessages["insights"] = LogMessage{ @@ -120,16 +121,18 @@ func disconnectAction(ctx *cli.Context) error { message: fmt.Errorf("%v", errMsg)} disconnectResult.InsightsDisconnected = false disconnectResult.InsightsDisconnectedError = errMsg - interactivePrintf("%v %v\n", uiSettings.iconError, errMsg) + interactivePrintf(" [%v] %v\n", uiSettings.iconError, errMsg) } else { disconnectResult.InsightsDisconnected = true - interactivePrintf("%v Disconnected from Red Hat Insights\n", uiSettings.iconOK) + interactivePrintf(" [%v] Disconnected from Red Hat Insights\n", uiSettings.iconOK) } durations["insights"] = time.Since(start) /* 3. Unregister system from Red Hat Subscription Management */ err = showProgress( - " Disconnecting from Red Hat Subscription Management...", unregister, + " Disconnecting from Red Hat Subscription Management...", + unregister, + smallIndent, ) if err != nil { errMsg := fmt.Sprintf("Cannot disconnect from Red Hat Subscription Management: %v", err) @@ -139,10 +142,10 @@ func disconnectAction(ctx *cli.Context) error { disconnectResult.RHSMDisconnected = false disconnectResult.RHSMDisconnectedError = errMsg - interactivePrintf("%v %v\n", uiSettings.iconError, errMsg) + interactivePrintf(" [%v] %v\n", uiSettings.iconError, errMsg) } else { disconnectResult.RHSMDisconnected = true - interactivePrintf("%v Disconnected from Red Hat Subscription Management\n", uiSettings.iconOK) + interactivePrintf(" [%v] Disconnected from Red Hat Subscription Management\n", uiSettings.iconOK) } durations["rhsm"] = time.Since(start) diff --git a/features.go b/features.go new file mode 100644 index 0000000..c896d77 --- /dev/null +++ b/features.go @@ -0,0 +1,155 @@ +package main + +import ( + "fmt" + "strings" + + "github.com/subpop/go-log" + "github.com/urfave/cli/v2" +) + +// RhcFeature manages optional features of rhc. +type RhcFeature struct { + // ID is an identifier of the feature. + ID string + // Description is human-readable description of the feature. + Description string + // Enabled represents the state of feature + Enabled bool + // Requires is a list of IDs of other features that are required for this feature. RhcFeature + // dependencies are not resolved. + Requires []*RhcFeature + // EnableFunc is callback function, and it is called when the feature should transition + // into enabled state. + EnableFunc func(ctx *cli.Context) error + // DisableFunc is also callback function, and it is called when the feature should transition + // into disabled state. + DisableFunc func(ctx *cli.Context) error +} + +func (f *RhcFeature) String() string { + return fmt.Sprintf("Feature{ID:%s}", f.ID) +} + +// KnownFeatures is a sorted list of features, ordered from least to the most dependent. +var KnownFeatures = []*RhcFeature{ + &ContentFeature, + &AnalyticsFeature, + &ManagementFeature, +} + +// listKnownFeatureIds is helper function, and it returns the list of IDs of known feature +func listKnownFeatureIds() []string { + var ids []string + for _, feature := range KnownFeatures { + ids = append(ids, feature.ID) + } + return ids +} + +// ContentFeature allows to enable/disable content provided by Red Hat. It is +// typically set of RPM repositories generated in /etc/yum.repos.d/redhat.repo +var ContentFeature = RhcFeature{ + ID: "content", + Requires: []*RhcFeature{}, + Enabled: func() bool { return true }(), + Description: "Get access to RHEL content", + EnableFunc: func(ctx *cli.Context) error { + log.Debug("enabling 'content' feature not implemented") + return nil + }, + DisableFunc: func(ctx *cli.Context) error { + log.Debug("disabling 'content' feature not implemented") + return nil + }, +} + +// AnalyticsFeature allows to enable/disable collecting data for Red Hat Insights +var AnalyticsFeature = RhcFeature{ + ID: "analytics", + Requires: []*RhcFeature{}, + Enabled: func() bool { return true }(), + Description: "Enable data collection for Red Hat Insights", + EnableFunc: func(ctx *cli.Context) error { + log.Debug("enabling 'analytics' feature not implemented") + return nil + }, + DisableFunc: func(ctx *cli.Context) error { + log.Debug("disabling 'analytics' feature not implemented") + return nil + }, +} + +// ManagementFeature allows to enable/disable remote management of the host +// using yggdrasil service and various workers +var ManagementFeature = RhcFeature{ + ID: "remote-management", + Requires: []*RhcFeature{&ContentFeature, &AnalyticsFeature}, + Enabled: func() bool { return true }(), + Description: "Remote management", + EnableFunc: func(ctx *cli.Context) error { + log.Debug("enabling 'management' feature not implemented") + return nil + }, + DisableFunc: func(ctx *cli.Context) error { + log.Debug("disabling 'management' feature not implemented") + return nil + }, +} + +// checkFeatureInput checks input of enabled and disabled features +func checkFeatureInput(enabledFeatures *[]string, disabledFeatures *[]string) error { + // First check disabled features: check only correctness of IDs + for _, featureId := range *disabledFeatures { + isKnown := false + var disabledFeature *RhcFeature = nil + for _, rhcFeature := range KnownFeatures { + if featureId == rhcFeature.ID { + disabledFeature = rhcFeature + isKnown = true + break + } + } + if !isKnown { + supportedIds := listKnownFeatureIds() + hint := strings.Join(supportedIds, ",") + return fmt.Errorf("cannot disable feature \"%s\": no such feature exists (%s)", featureId, hint) + } + disabledFeature.Enabled = false + } + + // Then check enabled features, and it is more tricky, because: + // 1) you cannot enable feature, which was already disabled + // 2) you cannot enable feature, which depends on disabled feature + for _, featureId := range *enabledFeatures { + isKnown := false + var enabledFeature *RhcFeature = nil + for _, rhcFeature := range KnownFeatures { + if featureId == rhcFeature.ID { + enabledFeature = rhcFeature + isKnown = true + break + } + } + if !isKnown { + supportedIds := listKnownFeatureIds() + hint := strings.Join(supportedIds, ",") + return fmt.Errorf("cannot enable feature \"%s\": no such feature exists (%s)", featureId, hint) + } + for _, disabledFeatureId := range *disabledFeatures { + if featureId == disabledFeatureId { + return fmt.Errorf("cannot enable feature: \"%s\": feature \"%s\" explicitly disabled", + featureId, disabledFeatureId) + } + for _, requiredFeature := range enabledFeature.Requires { + if requiredFeature.ID == disabledFeatureId { + return fmt.Errorf("cannot enable feature: \"%s\": required feature \"%s\" explicitly disabled", + enabledFeature.ID, disabledFeatureId) + } + } + } + enabledFeature.Enabled = true + } + + return nil +} diff --git a/interactive.go b/interactive.go index 47ae1f9..53eefab 100644 --- a/interactive.go +++ b/interactive.go @@ -2,12 +2,13 @@ package main import ( "fmt" - "github.com/briandowns/spinner" - "github.com/subpop/go-log" - "github.com/urfave/cli/v2" "os" "text/tabwriter" "time" + + "github.com/briandowns/spinner" + "github.com/subpop/go-log" + "github.com/urfave/cli/v2" ) const ( @@ -36,6 +37,10 @@ type userInterfaceSettings struct { // It is managed by calling the configureUISettings method. var uiSettings = userInterfaceSettings{} +const symbolOK string = "โœ“" +const symbolInfo string = "โ—" +const symbolError string = "๐„‚" + // configureUISettings is called by the CLI library when it loads up. // It sets up the uiSettings object. func configureUISettings(ctx *cli.Context) { @@ -43,17 +48,17 @@ func configureUISettings(ctx *cli.Context) { uiSettings = userInterfaceSettings{ isRich: false, isMachineReadable: false, - iconOK: "โœ“", - iconInfo: "ยท", - iconError: "๐„‚", + iconOK: symbolOK, + iconInfo: symbolInfo, + iconError: symbolError, } } else { uiSettings = userInterfaceSettings{ isRich: true, isMachineReadable: false, - iconOK: colorGreen + "โ—" + colorReset, - iconInfo: colorYellow + "โ—" + colorReset, - iconError: colorRed + "โ—" + colorReset, + iconOK: colorGreen + symbolOK + colorReset, + iconInfo: colorYellow + symbolInfo + colorReset, + iconError: colorRed + symbolError + colorReset, } } } @@ -63,11 +68,13 @@ func configureUISettings(ctx *cli.Context) { func showProgress( progressMessage string, function func() error, + prefixSpaces string, ) error { var s *spinner.Spinner if uiSettings.isRich { s = spinner.New(spinner.CharSets[9], 100*time.Millisecond) - s.Suffix = progressMessage + s.Prefix = prefixSpaces + "[" + s.Suffix = "]" + progressMessage s.Start() // Stop spinner after running function defer func() { s.Stop() }() diff --git a/main.go b/main.go index 995cc26..f94df6e 100644 --- a/main.go +++ b/main.go @@ -162,6 +162,16 @@ func main() { Usage: "register with `CONTENT_TEMPLATE`", Aliases: []string{"c"}, }, + &cli.StringSliceFlag{ + Name: "enable-feature", + Usage: "enable `FEATURE` during connection", + Aliases: []string{"e"}, + }, + &cli.StringSliceFlag{ + Name: "disable-feature", + Usage: "disable `FEATURE` during connection", + Aliases: []string{"d"}, + }, &cli.StringFlag{ Name: "server", Hidden: true, diff --git a/rhsm.go b/rhsm.go index bc8a31f..64154df 100644 --- a/rhsm.go +++ b/rhsm.go @@ -87,7 +87,7 @@ func unpackOrgs(s string) ([]string, error) { // registerUsernamePassword tries to register system against candlepin server (Red Hat Management Service) // username and password are mandatory. When organization is not obtained, then this method // returns list of available organization and user can select one organization from the list. -func registerUsernamePassword(username, password, organization string, environments []string, serverURL string) ([]string, error) { +func registerUsernamePassword(username, password, organization string, environments []string, serverURL string, enableContent bool) ([]string, error) { var orgs []string if serverURL != "" { if err := configureRHSM(serverURL); err != nil { @@ -140,7 +140,8 @@ func registerUsernamePassword(username, password, organization string, environme options["environment_type"] = EnvTypeContentTemplate } - options["enable_content"] = "true" + + options["enable_content"] = fmt.Sprintf("%v", enableContent) if err := privConn.Object( "com.redhat.RHSM1", @@ -193,7 +194,7 @@ func registerUsernamePassword(username, password, organization string, environme return orgs, nil } -func registerActivationKey(orgID string, activationKeys []string, environments []string, serverURL string) error { +func registerActivationKey(orgID string, activationKeys []string, environments []string, serverURL string, enableContent bool) error { if serverURL != "" { if err := configureRHSM(serverURL); err != nil { return fmt.Errorf("cannot configure RHSM: %w", err) @@ -243,9 +244,10 @@ func registerActivationKey(orgID string, activationKeys []string, environments [ if len(environments) != 0 { options["environment_names"] = strings.Join(environments, ",") options["environment_type"] = EnvTypeContentTemplate - } + options["enable_content"] = fmt.Sprintf("%v", enableContent) + if err := privConn.Object( "com.redhat.RHSM1", "/com/redhat/RHSM1/Register").Call( @@ -412,7 +414,7 @@ func configureRHSM(serverURL string) error { } // registerRHSM tries to register system against Red Hat Subscription Management server (candlepin server) -func registerRHSM(ctx *cli.Context) (string, error) { +func registerRHSM(ctx *cli.Context, enableContent bool) (string, error) { uuid, err := getConsumerUUID() if err != nil { return "Unable to get consumer UUID", cli.Exit(err, 1) @@ -448,7 +450,8 @@ func registerRHSM(ctx *cli.Context) (string, error) { var s *spinner.Spinner if uiSettings.isRich { s = spinner.New(spinner.CharSets[9], 100*time.Millisecond) - s.Suffix = " Connecting to Red Hat Subscription Management..." + s.Prefix = smallIndent + "[" + s.Suffix = "] Connecting to Red Hat Subscription Management..." s.Start() defer s.Stop() } @@ -459,13 +462,14 @@ func registerRHSM(ctx *cli.Context) (string, error) { organization, ctx.StringSlice("activation-key"), contentTemplates, - ctx.String("server")) + ctx.String("server"), + enableContent) } else { var orgs []string if organization != "" { - _, err = registerUsernamePassword(username, password, organization, contentTemplates, ctx.String("server")) + _, err = registerUsernamePassword(username, password, organization, contentTemplates, ctx.String("server"), enableContent) } else { - orgs, err = registerUsernamePassword(username, password, "", contentTemplates, ctx.String("server")) + orgs, err = registerUsernamePassword(username, password, "", contentTemplates, ctx.String("server"), enableContent) /* When organization was not specified using CLI option --organization, and it is required, because user is member of more than one organization, then ask for the organization. */ @@ -500,7 +504,7 @@ func registerRHSM(ctx *cli.Context) (string, error) { } // Try to register once again with given organization - _, err = registerUsernamePassword(username, password, organization, contentTemplates, ctx.String("server")) + _, err = registerUsernamePassword(username, password, organization, contentTemplates, ctx.String("server"), enableContent) } } }