Skip to content

Commit

Permalink
Use a struct for GetStatus to be consistent (#731)
Browse files Browse the repository at this point in the history
Fixes #337

Signed-off-by: John Schnake <jschnake@vmware.com>
  • Loading branch information
johnSchnake committed May 30, 2019
1 parent a07aed2 commit cfd9cfc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion cmd/sonobuoy/app/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/heptio/sonobuoy/pkg/client"
"github.com/heptio/sonobuoy/pkg/errlog"
"github.com/heptio/sonobuoy/pkg/plugin/aggregation"
)
Expand Down Expand Up @@ -64,7 +65,9 @@ func getStatus(cmd *cobra.Command, args []string) {
os.Exit(1)
}

status, err := sbc.GetStatus(statusFlags.namespace)
status, err := sbc.GetStatus(&client.StatusConfig{
Namespace: statusFlags.namespace,
})
if err != nil {
errlog.LogError(errors.Wrap(err, "error attempting to run sonobuoy"))
os.Exit(1)
Expand Down
8 changes: 7 additions & 1 deletion pkg/client/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ type RetrieveConfig struct {
Namespace string
}

// StatusConfig is the input options for retrieving a Sonobuoy run's results.
type StatusConfig struct {
// Namespace is the namespace the sonobuoy aggregator is running in.
Namespace string
}

// PreflightConfig are the options passed to PreflightChecks.
type PreflightConfig struct {
Namespace string
Expand Down Expand Up @@ -155,7 +161,7 @@ type Interface interface {
// RetrieveResults copies results from a sonobuoy run into a Reader in tar format.
RetrieveResults(cfg *RetrieveConfig) (io.Reader, <-chan error)
// GetStatus determines the status of the sonobuoy run in order to assist the user.
GetStatus(namespace string) (*aggregation.Status, error)
GetStatus(cfg *StatusConfig) (*aggregation.Status, error)
// LogReader returns a reader that contains a merged stream of sonobuoy logs.
LogReader(cfg *LogConfig) (*Reader, error)
// Delete removes a sonobuoy run, namespace, and all associated resources.
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *SonobuoyClient) Run(cfg *RunConfig) error {
seenStatus := false
runCondition := func() (bool, error) {
// Get the heptio pod and check if its status is completed or terminated.
status, err := c.GetStatus(cfg.Config.Namespace)
status, err := c.GetStatus(&StatusConfig{cfg.Config.Namespace})
switch {
case err != nil && seenStatus:
return false, errors.Wrap(err, "failed to get status")
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"github.com/heptio/sonobuoy/pkg/plugin/aggregation"
)

func (c *SonobuoyClient) GetStatus(namespace string) (*aggregation.Status, error) {
func (c *SonobuoyClient) GetStatus(cfg *StatusConfig) (*aggregation.Status, error) {
client, err := c.Client()
if err != nil {
return nil, err
}

return aggregation.GetStatus(client, namespace)
return aggregation.GetStatus(client, cfg.Namespace)
}

0 comments on commit cfd9cfc

Please sign in to comment.