Skip to content

Commit

Permalink
feat: Remove the RHC Manager status from rhc client
Browse files Browse the repository at this point in the history
Card ID: CCT-698

Remove func getConfProfile and the block of code that had invoked it.
  • Loading branch information
jvlcek committed Oct 3, 2024
1 parent e98351b commit aeb6082
Showing 1 changed file with 0 additions and 87 deletions.
87 changes: 0 additions & 87 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"encoding/json"
"fmt"
"io"
"os"
"strings"
"text/tabwriter"
Expand All @@ -14,7 +13,6 @@ import (
"golang.org/x/term"

"github.com/briandowns/spinner"
"github.com/redhatinsights/rhc/internal/http"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2/altsrc"
)
Expand Down Expand Up @@ -124,55 +122,6 @@ func showErrorMessages(action string, errorMessages map[string]LogMessage) error
return nil
}

// getConfProfile will retrieve the profile the system is configured
func getConfProfile(client *http.Client) (map[string]interface{}, error) {
var profile map[string]interface{}

url, err := GuessAPIURL()
if err != nil {
return nil, err
}

res, err := client.Get(url)
if err != nil {
return nil, err
}
defer res.Body.Close()

if res.StatusCode != 200 {
return nil, fmt.Errorf("cannot get system profile: %s", res.Status)
}
// Read the response body
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}

if err = json.Unmarshal(body, &profile); err != nil {
return nil, fmt.Errorf("cannot unmarshal profile: %s", res.Status)

}

return profile, nil
}

// showConfProfile shows a list of the system profile enabled features gathered from API
// https://github.com/RedHatInsights/config-manager/blob/master/internal/http/v2/openapi.json
func showConfProfile(p *map[string]interface{}) {
services := []string{}
for service, status := range *p {
switch status.(type) {
case bool:
if service == "active" {
service = "remote configuration"
}
services = append(services, service)
}
}
output := strings.Join(services, `, `)
fmt.Printf("%v", output)
}

// registerRHSM tries to register system against Red Hat Subscription Management server (candlepin server)
func registerRHSM(ctx *cli.Context) (string, error) {
uuid, err := getConsumerUUID()
Expand Down Expand Up @@ -424,42 +373,6 @@ func connectAction(ctx *cli.Context) error {
interactivePrintf("%v Activated the %v service\n", uiSettings.iconOK, ServiceName)
}
durations[ServiceName] = time.Since(start)
}

/* 4. Show Configuration Profile */
if len(errorMessages) == 0 {
// Update the configuration file
// Call D-bus to get the CA directory from rhsm
if err = getRHSMConfigOption("rhsm.ca_cert_dir", &config.CADir); err != nil {
errorMessages[ServiceName] = LogMessage{
level: log.LevelWarn,
message: fmt.Errorf("cannot get rhsm configuration: %w",
err)}
}
// Generate a new http client configured with mutual TLS certificate
tlsConfig, err := config.CreateTLSClientConfig()
if err != nil {
errorMessages[ServiceName] = LogMessage{
level: log.LevelWarn,
message: fmt.Errorf("cannot configure TLS: %w",
err)}
}
client := http.NewHTTPClient(tlsConfig)

// Get the user profile
profile, err := getConfProfile(client)
if err != nil {
errorMessages[ServiceName] = LogMessage{
level: log.LevelWarn,
message: fmt.Errorf("cannot get the user profile: %w",
err)}
} else {
if !uiSettings.isMachineReadable {
fmt.Printf("%v Enabled console.redhat.com services: ", uiSettings.iconInfo)
showConfProfile(&profile)
fmt.Printf("\n")
}
}
interactivePrintf("\nSuccessfully connected to Red Hat!\n")
}

Expand Down

0 comments on commit aeb6082

Please sign in to comment.