Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dexhorthy committed Jan 7, 2019
1 parent 96eb5b9 commit 1293a41
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func RootCmd() *cobra.Command {
cmd.PersistentFlags().BoolP("navcycle", "", true, "set to false to run ship in v1/non-navigable mode (deprecated)")

cmd.PersistentFlags().String("state-from", "file", "type of resource to use when loading/saving state (currently supported values: 'file', 'secret'")
cmd.PersistentFlags().String("state-file", constants.StatePath, fmt.Sprintf("path to the state file to read from, defaults to %s", constants.StatePath))
cmd.PersistentFlags().String("state-file", "", fmt.Sprintf("path to the state file to read from, defaults to %s", constants.StatePath))
cmd.PersistentFlags().String("secret-namespace", "default", "namespace containing the state secret")
cmd.PersistentFlags().String("secret-name", "", "name of the secret to laod state from")
cmd.PersistentFlags().String("secret-key", "", "name of the key in the secret containing state")
Expand Down
10 changes: 8 additions & 2 deletions pkg/ship/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/replicatedhq/ship/pkg/constants"
"github.com/replicatedhq/ship/pkg/lifecycle/daemon/daemontypes"
"github.com/replicatedhq/ship/pkg/state"
)
Expand All @@ -33,15 +34,20 @@ func (s *Ship) Update(ctx context.Context) error {
return errors.Wrap(err, "load state")
}

uiPrintableStatePath := s.Viper.GetString("state-file")
if uiPrintableStatePath == "" {
uiPrintableStatePath = constants.StatePath
}

if _, noExistingState := existingState.(state.Empty); noExistingState {
debug.Log("event", "state.missing")
return errors.New(`No state file found at ` + s.Viper.GetString("state-file") + `, please run "ship init"`)
return errors.New(fmt.Sprintf(`No state file found at %s please run "ship init"`, uiPrintableStatePath))
}

debug.Log("event", "read.upstream")
upstreamURL := existingState.Upstream()
if upstreamURL == "" {
return errors.New(fmt.Sprintf(`No upstream URL found at %s, please run "ship init"`, s.Viper.GetString("state-file")))
return errors.New(fmt.Sprintf(`No upstream URL found at %s, please run "ship init"`, uiPrintableStatePath))
}

maybeVersionedUpstream, err := s.Resolver.MaybeResolveVersionedUpstream(ctx, upstreamURL, existingState)
Expand Down
9 changes: 8 additions & 1 deletion pkg/ship/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/replicatedhq/ship/pkg/constants"
"github.com/replicatedhq/ship/pkg/state"
)

Expand All @@ -30,9 +31,15 @@ func (s *Ship) Watch(ctx context.Context) error {
return errors.Wrap(err, "load state")
}

// This is duped and should probably be a method on state.Manager or something
uiPrintableStatePath := s.Viper.GetString("state-file")
if uiPrintableStatePath == "" {
uiPrintableStatePath = constants.StatePath
}

if _, noExistingState := existingState.(state.Empty); noExistingState {
debug.Log("event", "state.missing")
return errors.New(`No state found, please run "ship init"`)
return errors.New(fmt.Sprintf(`No state found at %s, please run "ship init"`, uiPrintableStatePath))
}

debug.Log("event", "read.upstream")
Expand Down

0 comments on commit 1293a41

Please sign in to comment.