Skip to content

Commit c0031a9

Browse files
committed
Remove IOStreams from the Applier
1 parent 066fc3b commit c0031a9

File tree

6 files changed

+12
-21
lines changed

6 files changed

+12
-21
lines changed

cmd/apply/cmdapply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
func GetApplyRunner(provider provider.Provider, ioStreams genericclioptions.IOStreams) *ApplyRunner {
2626
r := &ApplyRunner{
27-
Applier: apply.NewApplier(provider, ioStreams),
27+
Applier: apply.NewApplier(provider),
2828
ioStreams: ioStreams,
2929
provider: provider,
3030
}

cmd/destroy/cmddestroy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// GetDestroyRunner creates and returns the DestroyRunner which stores the cobra command.
1818
func GetDestroyRunner(provider provider.Provider, ioStreams genericclioptions.IOStreams) *DestroyRunner {
1919
r := &DestroyRunner{
20-
Destroyer: apply.NewDestroyer(provider, ioStreams),
20+
Destroyer: apply.NewDestroyer(provider),
2121
ioStreams: ioStreams,
2222
provider: provider,
2323
}
@@ -47,7 +47,7 @@ type DestroyRunner struct {
4747
}
4848

4949
func (r *DestroyRunner) RunE(cmd *cobra.Command, args []string) error {
50-
err := r.Destroyer.Initialize(cmd, args)
50+
err := r.Destroyer.Initialize()
5151
if err != nil {
5252
return err
5353
}

cmd/preview/cmdpreview.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ var (
2828
// GetPreviewRunner creates and returns the PreviewRunner which stores the cobra command.
2929
func GetPreviewRunner(provider provider.Provider, ioStreams genericclioptions.IOStreams) *PreviewRunner {
3030
r := &PreviewRunner{
31-
Applier: apply.NewApplier(provider, ioStreams),
32-
Destroyer: apply.NewDestroyer(provider, ioStreams),
31+
Applier: apply.NewApplier(provider),
32+
Destroyer: apply.NewDestroyer(provider),
3333
ioStreams: ioStreams,
3434
provider: provider,
3535
}
@@ -71,7 +71,7 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
7171
return err
7272
}
7373
var ch <-chan event.Event
74-
err = r.Destroyer.Initialize(cmd, args)
74+
err = r.Destroyer.Initialize()
7575
if err != nil {
7676
return err
7777
}

pkg/apply/applier.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/go-errors/errors"
1212
"k8s.io/apimachinery/pkg/api/meta"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
"k8s.io/cli-runtime/pkg/genericclioptions"
1514
"k8s.io/cli-runtime/pkg/resource"
1615
"sigs.k8s.io/cli-utils/pkg/apply/event"
1716
"sigs.k8s.io/cli-utils/pkg/apply/info"
@@ -33,11 +32,10 @@ import (
3332
// the ApplyOptions were responsible for printing progress. This is now
3433
// handled by a separate printer with the KubectlPrinterAdapter bridging
3534
// between the two.
36-
func NewApplier(provider provider.Provider, ioStreams genericclioptions.IOStreams) *Applier {
35+
func NewApplier(provider provider.Provider) *Applier {
3736
a := &Applier{
3837
PruneOptions: prune.NewPruneOptions(),
3938
provider: provider,
40-
ioStreams: ioStreams,
4139
}
4240
a.infoHelperFactoryFunc = a.infoHelperFactory
4341
return a
@@ -54,8 +52,7 @@ func NewApplier(provider provider.Provider, ioStreams genericclioptions.IOStream
5452
// parameters and/or the set of resources that needs to be applied to the
5553
// cluster, different sets of tasks might be needed.
5654
type Applier struct {
57-
provider provider.Provider
58-
ioStreams genericclioptions.IOStreams
55+
provider provider.Provider
5956

6057
PruneOptions *prune.PruneOptions
6158
StatusPoller poller.Poller

pkg/apply/applier_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2323
"k8s.io/apimachinery/pkg/runtime"
2424
"k8s.io/apimachinery/pkg/runtime/schema"
25-
"k8s.io/cli-runtime/pkg/genericclioptions"
2625
"k8s.io/cli-runtime/pkg/resource"
2726
"k8s.io/client-go/rest/fake"
2827
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
@@ -214,9 +213,8 @@ func TestApplier(t *testing.T) {
214213

215214
tf.UnstructuredClient = newFakeRESTClient(t, tc.handlers)
216215

217-
ioStreams, _, _, _ := genericclioptions.NewTestIOStreams() //nolint:dogsled
218-
cf := provider.NewProvider(tf, nil) // nil InventoryFactoryFunc since not needed
219-
applier := NewApplier(cf, ioStreams)
216+
cf := provider.NewProvider(tf, nil) // nil InventoryFactoryFunc since not needed
217+
applier := NewApplier(cf)
220218

221219
err = applier.Initialize()
222220
if !assert.NoError(t, err) {

pkg/apply/destroyer.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
"fmt"
88

99
"github.com/go-errors/errors"
10-
"github.com/spf13/cobra"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211
"k8s.io/apimachinery/pkg/util/sets"
13-
"k8s.io/cli-runtime/pkg/genericclioptions"
1412
"k8s.io/cli-runtime/pkg/resource"
1513
"sigs.k8s.io/cli-utils/pkg/apply/event"
1614
"sigs.k8s.io/cli-utils/pkg/apply/prune"
@@ -25,19 +23,17 @@ import (
2523
// the ApplyOptions were responsible for printing progress. This is now
2624
// handled by a separate printer with the KubectlPrinterAdapter bridging
2725
// between the two.
28-
func NewDestroyer(provider provider.Provider, ioStreams genericclioptions.IOStreams) *Destroyer {
26+
func NewDestroyer(provider provider.Provider) *Destroyer {
2927
return &Destroyer{
3028
PruneOptions: prune.NewPruneOptions(),
3129
provider: provider,
32-
ioStreams: ioStreams,
3330
}
3431
}
3532

3633
// Destroyer performs the step of grabbing all the previous inventory objects and
3734
// prune them. This also deletes all the previous inventory objects
3835
type Destroyer struct {
3936
provider provider.Provider
40-
ioStreams genericclioptions.IOStreams
4137
PruneOptions *prune.PruneOptions
4238
invClient inventory.InventoryClient
4339
DryRunStrategy common.DryRunStrategy
@@ -46,7 +42,7 @@ type Destroyer struct {
4642
// Initialize sets up the Destroyer for actually doing an destroy against
4743
// a cluster. This involves validating command line inputs and configuring
4844
// clients for communicating with the cluster.
49-
func (d *Destroyer) Initialize(cmd *cobra.Command, paths []string) error {
45+
func (d *Destroyer) Initialize() error {
5046
invClient, err := d.provider.InventoryClient()
5147
if err != nil {
5248
return errors.WrapPrefix(err, "error creating inventory client", 1)

0 commit comments

Comments
 (0)