Skip to content

Commit

Permalink
Simplify inteface definition to work with a bare function
Browse files Browse the repository at this point in the history
It turns out that a bare function is not treated the same way as
a struct when it comes to matching it to an interface
  • Loading branch information
errordeveloper committed Apr 24, 2024
1 parent 25baa7e commit 7ead9f9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
9 changes: 5 additions & 4 deletions cmd/timoni/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/stefanprodan/timoni/internal/engine/fetcher"
cueerrors "github.com/stefanprodan/timoni/internal/errors"
"github.com/stefanprodan/timoni/internal/flags"
"github.com/stefanprodan/timoni/internal/logger"
"github.com/stefanprodan/timoni/internal/reconciler"
"github.com/stefanprodan/timoni/internal/runtime"
)
Expand Down Expand Up @@ -240,10 +241,10 @@ func runApplyCmd(cmd *cobra.Command, args []string) error {
OverwriteOwnership: applyArgs.overwriteOwnership,
},
&reconciler.InteractiveOptions{
DryRun: applyArgs.dryrun,
Diff: applyArgs.diff,
DiffOutput: cmd.OutOrStdout(),
// ProgressStart: logger.StartSpinner,
DryRun: applyArgs.dryrun,
Diff: applyArgs.diff,
DiffOutput: cmd.OutOrStdout(),
ProgressStart: logger.StartSpinner,
},
rootArgs.timeout,
)
Expand Down
8 changes: 4 additions & 4 deletions cmd/timoni/bundle_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ func applyBundleInstance(ctx context.Context, cuectx *cue.Context, instance *eng
OverwriteOwnership: bundleApplyArgs.overwriteOwnership,
},
&reconciler.InteractiveOptions{
DryRun: bundleApplyArgs.dryrun,
Diff: bundleApplyArgs.diff,
DiffOutput: diffOutput,
// ProgressStart: logger.StartSpinner,
DryRun: bundleApplyArgs.dryrun,
Diff: bundleApplyArgs.diff,
DiffOutput: diffOutput,
ProgressStart: logger.StartSpinner,
},
rootArgs.timeout,
)
Expand Down
2 changes: 1 addition & 1 deletion internal/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func ColorizeCluster(cluster string) string {
}

// StartSpinner starts a spinner with the given message.
func StartSpinner(msg string) *spinner.Spinner {
func StartSpinner(msg string) interface{ Stop() } {
s := spinner.New(spinner.CharSets[11], 100*time.Millisecond, spinner.WithWriter(os.Stderr))
s.Suffix = " " + msg
s.Start()
Expand Down
9 changes: 2 additions & 7 deletions internal/reconciler/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type InteractiveOptions struct {
Diff bool
DiffOutput io.Writer

ProgressStart ProgressStarter
ProgressStart func(string) interface{ Stop() }
}

type Reconciler struct {
Expand All @@ -61,19 +61,14 @@ type Reconciler struct {
applyOptions ssa.ApplyOptions
waitOptions ssa.WaitOptions

progressStartFn ProgressStarter
progressStartFn func(string) interface{ Stop() }
}

type InteractiveReconciler struct {
*Reconciler
*InteractiveOptions
}

type (
ProgressStarter func(string) ProgressStopper
ProgressStopper interface{ Stop() }
)

type noopProgressStopper struct{}

func (*noopProgressStopper) Stop() {}
Expand Down

0 comments on commit 7ead9f9

Please sign in to comment.