Skip to content

Commit

Permalink
Merge pull request #588 from renan-campos/OCM-4783
Browse files Browse the repository at this point in the history
OCM-4783 | feat: display warnings after cluster creation
  • Loading branch information
gdbranco authored Dec 21, 2023
2 parents 6d866ac + 165b90e commit 2114ef6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/ocm/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ func run(cmd *cobra.Command, argv []string) error {
if err != nil {
return err
}
err = c.PrintClusterWarnings(connection, cluster)
if err != nil {
return err
}
}

return nil
Expand Down
15 changes: 15 additions & 0 deletions pkg/cluster/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
sdk "github.com/openshift-online/ocm-sdk-go"
amv1 "github.com/openshift-online/ocm-sdk-go/accountsmgmt/v1"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
slv1 "github.com/openshift-online/ocm-sdk-go/servicelogs/v1"
)

const (
Expand Down Expand Up @@ -345,3 +346,17 @@ func findHyperShiftMgmtSvcClusters(conn *sdk.Connection, cluster *cmv1.Cluster)
// Shouldn't normally happen as every management cluster should have a service cluster
return mgmtClusterName, ""
}

func PrintClusterWarnings(connection *sdk.Connection, cluster *cmv1.Cluster) error {
serviceLogs, err := connection.ServiceLogs().V1().Clusters().ClusterLogs().List().ClusterID(cluster.ID()).Send()
if err != nil {
return err
}
serviceLogs.Items().Each(func(entry *slv1.LogEntry) bool {
if entry.Severity() == slv1.SeverityWarning {
fmt.Printf("⚠️ WARNING:\n%s\n%s\n", entry.Summary(), entry.Description())
}
return true
})
return nil
}

0 comments on commit 2114ef6

Please sign in to comment.