mirror of https://github.com/fluxcd/cli-utils.git
split wirecli into each command wiring
This commit is contained in:
parent
f3ca02a96a
commit
558382635f
|
|
@ -16,13 +16,11 @@ package apply
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
|
||||||
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/cli-experimental/cmd/apply/status"
|
"sigs.k8s.io/cli-experimental/cmd/apply/status"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli"
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireapply"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetApplyCommand returns the `apply` cobra Command
|
// GetApplyCommand returns the `apply` cobra Command
|
||||||
|
|
@ -46,7 +44,7 @@ is used.
|
||||||
|
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
for i := range args {
|
for i := range args {
|
||||||
r, err := wirecli.DoApply(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
r, err := wireapply.DoApply(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirestatus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetApplyStatusCommand returns a new `apply status` command
|
// GetApplyStatusCommand returns a new `apply status` command
|
||||||
|
|
@ -34,7 +34,7 @@ func GetApplyStatusCommand(a util.Args) *cobra.Command {
|
||||||
|
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
for i := range args {
|
for i := range args {
|
||||||
r, err := wirecli.DoStatus(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
r, err := wirestatus.DoStatus(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiredelete"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDeleteCommand returns the `prune` cobra Command
|
// GetDeleteCommand returns the `prune` cobra Command
|
||||||
|
|
@ -40,7 +40,7 @@ as an argument.
|
||||||
|
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
for i := range args {
|
for i := range args {
|
||||||
r, err := wirecli.DoDelete(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
r, err := wiredelete.DoDelete(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireprune"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetPruneCommand returns the `prune` cobra Command
|
// GetPruneCommand returns the `prune` cobra Command
|
||||||
|
|
@ -76,7 +76,7 @@ For more information, see https://github.com/kubernetes-sigs/kustomize/blob/mast
|
||||||
|
|
||||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||||
for i := range args {
|
for i := range args {
|
||||||
r, err := wirecli.DoPrune(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
r, err := wireprune.DoPrune(clik8s.ResourceConfigPath(args[i]), cmd.OutOrStdout(), a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,273 +0,0 @@
|
||||||
// Code generated by Wire. DO NOT EDIT.
|
|
||||||
|
|
||||||
//go:generate wire
|
|
||||||
//+build !wireinject
|
|
||||||
|
|
||||||
package wirecli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
|
||||||
delete2 "sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Injectors from wire.go:
|
|
||||||
|
|
||||||
func InitializeStatus(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (*status.Status, error) {
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
clientset, err := wirek8s.NewKubernetesClientSet(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
statusStatus := &status.Status{
|
|
||||||
Resources: resourceConfigs,
|
|
||||||
Out: writer,
|
|
||||||
Clientset: clientset,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
return statusStatus, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func InitializeApply(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (*apply.Apply, error) {
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
restMapper, err := wirek8s.NewRestMapper(config)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
applyApply := &apply.Apply{
|
|
||||||
DynamicClient: client,
|
|
||||||
Out: writer,
|
|
||||||
Resources: resourceConfigs,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
return applyApply, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoStatus(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (status.Result, error) {
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return status.Result{}, err
|
|
||||||
}
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return status.Result{}, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return status.Result{}, err
|
|
||||||
}
|
|
||||||
clientset, err := wirek8s.NewKubernetesClientSet(config)
|
|
||||||
if err != nil {
|
|
||||||
return status.Result{}, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
statusStatus := &status.Status{
|
|
||||||
Resources: resourceConfigs,
|
|
||||||
Out: writer,
|
|
||||||
Clientset: clientset,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
result, err := NewStatusCommandResult(statusStatus, writer)
|
|
||||||
if err != nil {
|
|
||||||
return status.Result{}, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoApply(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (apply.Result, error) {
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
restMapper, err := wirek8s.NewRestMapper(config)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
applyApply := &apply.Apply{
|
|
||||||
DynamicClient: client,
|
|
||||||
Out: writer,
|
|
||||||
Resources: resourceConfigs,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
result, err := NewApplyCommandResult(applyApply, writer)
|
|
||||||
if err != nil {
|
|
||||||
return apply.Result{}, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoPrune(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (prune.Result, error) {
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
restMapper, err := wirek8s.NewRestMapper(config)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourcePruneConfigs, err := wireconfig.NewResourcePruneConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
prunePrune := &prune.Prune{
|
|
||||||
DynamicClient: client,
|
|
||||||
Out: writer,
|
|
||||||
Resources: resourcePruneConfigs,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
result, err := NewPruneCommandResult(prunePrune, writer)
|
|
||||||
if err != nil {
|
|
||||||
return prune.Result{}, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DoDelete(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (delete2.Result, error) {
|
|
||||||
configFlags, err := wirek8s.NewConfigFlags(args)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
config, err := wirek8s.NewRestConfig(configFlags)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
restMapper, err := wirek8s.NewRestMapper(config)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
pluginConfig := wireconfig.NewPluginConfig()
|
|
||||||
factory := wireconfig.NewResMapFactory(pluginConfig)
|
|
||||||
fileSystem := wireconfig.NewFileSystem()
|
|
||||||
transformerFactory := wireconfig.NewTransformerFactory()
|
|
||||||
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
|
||||||
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
|
||||||
commitIter := wiregit.NewOptionalCommitIter(repository)
|
|
||||||
commit := wiregit.NewOptionalCommit(commitIter)
|
|
||||||
deleteDelete := &delete2.Delete{
|
|
||||||
DynamicClient: client,
|
|
||||||
Out: writer,
|
|
||||||
Resources: resourceConfigs,
|
|
||||||
Commit: commit,
|
|
||||||
}
|
|
||||||
result, err := NewDeleteCommandResult(deleteDelete, writer)
|
|
||||||
if err != nil {
|
|
||||||
return delete2.Result{}, err
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
//+build wireinject
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wireapply
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InitializeApply creates a new *apply.Apply object
|
||||||
|
func InitializeApply(clik8s.ResourceConfigPath, io.Writer, util.Args) (*apply.Apply, error) {
|
||||||
|
panic(wire.Build(ProviderSet))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DoApply creates a new Apply object and runs it
|
||||||
|
func DoApply(clik8s.ResourceConfigPath, io.Writer, util.Args) (apply.Result, error) {
|
||||||
|
panic(wire.Build(ProviderSet))
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:generate wire
|
||||||
|
//+build !wireinject
|
||||||
|
|
||||||
|
package wireapply
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Injectors from wire.go:
|
||||||
|
|
||||||
|
func InitializeApply(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (*apply.Apply, error) {
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
restMapper, err := wirek8s.NewRestMapper(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
applyApply := &apply.Apply{
|
||||||
|
DynamicClient: client,
|
||||||
|
Out: writer,
|
||||||
|
Resources: resourceConfigs,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
return applyApply, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DoApply(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (apply.Result, error) {
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
restMapper, err := wirek8s.NewRestMapper(config)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
applyApply := &apply.Apply{
|
||||||
|
DynamicClient: client,
|
||||||
|
Out: writer,
|
||||||
|
Resources: resourceConfigs,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
result, err := NewApplyCommandResult(applyApply, writer)
|
||||||
|
if err != nil {
|
||||||
|
return apply.Result{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wireapply
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProviderSet defines dependencies for initializing objects
|
||||||
|
var ProviderSet = wire.NewSet(
|
||||||
|
wirek8s.ProviderSet,
|
||||||
|
wiregit.OptionalProviderSet,
|
||||||
|
wire.Struct(new(apply.Apply), "*"),
|
||||||
|
NewApplyCommandResult,
|
||||||
|
wireconfig.ConfigProviderSet,
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewApplyCommandResult returns a new apply.Result
|
||||||
|
func NewApplyCommandResult(a *apply.Apply, out io.Writer) (apply.Result, error) {
|
||||||
|
return a.Do()
|
||||||
|
}
|
||||||
|
|
@ -14,51 +14,15 @@ limitations under the License.
|
||||||
package wirecli
|
package wirecli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
|
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(Liujingfang1): split into per command wire
|
|
||||||
|
|
||||||
// ProviderSet defines dependencies for initializing objects
|
// ProviderSet defines dependencies for initializing objects
|
||||||
var ProviderSet = wire.NewSet(
|
var ProviderSet = wire.NewSet(
|
||||||
wirek8s.ProviderSet,
|
wirek8s.ProviderSet,
|
||||||
wiregit.OptionalProviderSet,
|
wiregit.OptionalProviderSet,
|
||||||
wire.Struct(new(status.Status), "*"),
|
|
||||||
wire.Struct(new(apply.Apply), "*"),
|
|
||||||
wire.Struct(new(prune.Prune), "*"),
|
|
||||||
wire.Struct(new(delete.Delete), "*"),
|
|
||||||
NewStatusCommandResult,
|
|
||||||
NewApplyCommandResult,
|
|
||||||
NewDeleteCommandResult,
|
|
||||||
NewPruneCommandResult,
|
|
||||||
wireconfig.ConfigProviderSet,
|
wireconfig.ConfigProviderSet,
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewStatusCommandResult returns a new status.Result
|
|
||||||
func NewStatusCommandResult(s *status.Status, out io.Writer) (status.Result, error) {
|
|
||||||
return s.Do()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewApplyCommandResult returns a new apply.Result
|
|
||||||
func NewApplyCommandResult(a *apply.Apply, out io.Writer) (apply.Result, error) {
|
|
||||||
return a.Do()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewPruneCommandResult returns a new prune.Result
|
|
||||||
func NewPruneCommandResult(p *prune.Prune, out io.Writer) (prune.Result, error) {
|
|
||||||
return p.Do()
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewDeleteCommandResult returns a new delete.Result
|
|
||||||
func NewDeleteCommandResult(d *delete.Delete, out io.Writer) (delete.Result, error) {
|
|
||||||
return d.Do()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
//+build wireinject
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wiredelete
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DoDelete creates a new Delete object and runs it
|
||||||
|
func DoDelete(clik8s.ResourceConfigPath, io.Writer, util.Args) (delete.Result, error) {
|
||||||
|
panic(wire.Build(ProviderSet))
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:generate wire
|
||||||
|
//+build !wireinject
|
||||||
|
|
||||||
|
package wiredelete
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
delete2 "sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Injectors from wire.go:
|
||||||
|
|
||||||
|
func DoDelete(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (delete2.Result, error) {
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
restMapper, err := wirek8s.NewRestMapper(config)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
deleteDelete := &delete2.Delete{
|
||||||
|
DynamicClient: client,
|
||||||
|
Out: writer,
|
||||||
|
Resources: resourceConfigs,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
result, err := NewDeleteCommandResult(deleteDelete, writer)
|
||||||
|
if err != nil {
|
||||||
|
return delete2.Result{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wiredelete
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProviderSet defines dependencies for initializing objects
|
||||||
|
var ProviderSet = wire.NewSet(
|
||||||
|
wirek8s.ProviderSet,
|
||||||
|
wiregit.OptionalProviderSet,
|
||||||
|
wire.Struct(new(delete.Delete), "*"),
|
||||||
|
NewDeleteCommandResult,
|
||||||
|
wireconfig.ConfigProviderSet,
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewDeleteCommandResult returns a new delete.Result
|
||||||
|
func NewDeleteCommandResult(d *delete.Delete, out io.Writer) (delete.Result, error) {
|
||||||
|
return d.Do()
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
//+build wireinject
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wireprune
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DoPrune creates a new Prune object and runs it
|
||||||
|
func DoPrune(clik8s.ResourceConfigPath, io.Writer, util.Args) (prune.Result, error) {
|
||||||
|
panic(wire.Build(ProviderSet))
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:generate wire
|
||||||
|
//+build !wireinject
|
||||||
|
|
||||||
|
package wireprune
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Injectors from wire.go:
|
||||||
|
|
||||||
|
func DoPrune(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (prune.Result, error) {
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
dynamicInterface, err := wirek8s.NewDynamicClient(config)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
restMapper, err := wirek8s.NewRestMapper(config)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
client, err := wirek8s.NewClient(dynamicInterface, restMapper)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourcePruneConfigs, err := wireconfig.NewResourcePruneConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
prunePrune := &prune.Prune{
|
||||||
|
DynamicClient: client,
|
||||||
|
Out: writer,
|
||||||
|
Resources: resourcePruneConfigs,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
result, err := NewPruneCommandResult(prunePrune, writer)
|
||||||
|
if err != nil {
|
||||||
|
return prune.Result{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wireprune
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProviderSet defines dependencies for initializing objects
|
||||||
|
var ProviderSet = wire.NewSet(
|
||||||
|
wirek8s.ProviderSet,
|
||||||
|
wiregit.OptionalProviderSet,
|
||||||
|
wire.Struct(new(prune.Prune), "*"),
|
||||||
|
NewPruneCommandResult,
|
||||||
|
wireconfig.ConfigProviderSet,
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewPruneCommandResult returns a new prune.Result
|
||||||
|
func NewPruneCommandResult(p *prune.Prune, out io.Writer) (prune.Result, error) {
|
||||||
|
return p.Do()
|
||||||
|
}
|
||||||
|
|
@ -13,19 +13,15 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package wirecli
|
package wirestatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
|
||||||
|
|
||||||
"github.com/google/wire"
|
"github.com/google/wire"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/apply"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/delete"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/prune"
|
|
||||||
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InitializeStatus creates a new *status.Status object
|
// InitializeStatus creates a new *status.Status object
|
||||||
|
|
@ -33,27 +29,7 @@ func InitializeStatus(clik8s.ResourceConfigPath, io.Writer, util.Args) (*status.
|
||||||
panic(wire.Build(ProviderSet))
|
panic(wire.Build(ProviderSet))
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitializeApply creates a new *apply.Apply object
|
|
||||||
func InitializeApply(clik8s.ResourceConfigPath, io.Writer, util.Args) (*apply.Apply, error) {
|
|
||||||
panic(wire.Build(ProviderSet))
|
|
||||||
}
|
|
||||||
|
|
||||||
// DoStatus creates a new Status object and runs it
|
// DoStatus creates a new Status object and runs it
|
||||||
func DoStatus(clik8s.ResourceConfigPath, io.Writer, util.Args) (status.Result, error) {
|
func DoStatus(clik8s.ResourceConfigPath, io.Writer, util.Args) (status.Result, error) {
|
||||||
panic(wire.Build(ProviderSet))
|
panic(wire.Build(ProviderSet))
|
||||||
}
|
}
|
||||||
|
|
||||||
// DoApply creates a new Apply object and runs it
|
|
||||||
func DoApply(clik8s.ResourceConfigPath, io.Writer, util.Args) (apply.Result, error) {
|
|
||||||
panic(wire.Build(ProviderSet))
|
|
||||||
}
|
|
||||||
|
|
||||||
// DoPrune creates a new Prune object and runs it
|
|
||||||
func DoPrune(clik8s.ResourceConfigPath, io.Writer, util.Args) (prune.Result, error) {
|
|
||||||
panic(wire.Build(ProviderSet))
|
|
||||||
}
|
|
||||||
|
|
||||||
// DoDelete creates a new Delete object and runs it
|
|
||||||
func DoDelete(clik8s.ResourceConfigPath, io.Writer, util.Args) (delete.Result, error) {
|
|
||||||
panic(wire.Build(ProviderSet))
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
// Code generated by Wire. DO NOT EDIT.
|
||||||
|
|
||||||
|
//go:generate wire
|
||||||
|
//+build !wireinject
|
||||||
|
|
||||||
|
package wirestatus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/clik8s"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/util"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Injectors from wire.go:
|
||||||
|
|
||||||
|
func InitializeStatus(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (*status.Status, error) {
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
clientset, err := wirek8s.NewKubernetesClientSet(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
statusStatus := &status.Status{
|
||||||
|
Resources: resourceConfigs,
|
||||||
|
Out: writer,
|
||||||
|
Clientset: clientset,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
return statusStatus, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func DoStatus(resourceConfigPath clik8s.ResourceConfigPath, writer io.Writer, args util.Args) (status.Result, error) {
|
||||||
|
pluginConfig := wireconfig.NewPluginConfig()
|
||||||
|
factory := wireconfig.NewResMapFactory(pluginConfig)
|
||||||
|
fileSystem := wireconfig.NewFileSystem()
|
||||||
|
transformerFactory := wireconfig.NewTransformerFactory()
|
||||||
|
kustomizeProvider := wireconfig.NewKustomizeProvider(factory, fileSystem, transformerFactory, pluginConfig)
|
||||||
|
resourceConfigs, err := wireconfig.NewResourceConfig(resourceConfigPath, kustomizeProvider)
|
||||||
|
if err != nil {
|
||||||
|
return status.Result{}, err
|
||||||
|
}
|
||||||
|
configFlags, err := wirek8s.NewConfigFlags(args)
|
||||||
|
if err != nil {
|
||||||
|
return status.Result{}, err
|
||||||
|
}
|
||||||
|
config, err := wirek8s.NewRestConfig(configFlags)
|
||||||
|
if err != nil {
|
||||||
|
return status.Result{}, err
|
||||||
|
}
|
||||||
|
clientset, err := wirek8s.NewKubernetesClientSet(config)
|
||||||
|
if err != nil {
|
||||||
|
return status.Result{}, err
|
||||||
|
}
|
||||||
|
repository := wiregit.NewOptionalRepository(resourceConfigPath)
|
||||||
|
commitIter := wiregit.NewOptionalCommitIter(repository)
|
||||||
|
commit := wiregit.NewOptionalCommit(commitIter)
|
||||||
|
statusStatus := &status.Status{
|
||||||
|
Resources: resourceConfigs,
|
||||||
|
Out: writer,
|
||||||
|
Clientset: clientset,
|
||||||
|
Commit: commit,
|
||||||
|
}
|
||||||
|
result, err := NewStatusCommandResult(statusStatus, writer)
|
||||||
|
if err != nil {
|
||||||
|
return status.Result{}, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package wirestatus
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/google/wire"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/status"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wireconfig"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wiregit"
|
||||||
|
"sigs.k8s.io/cli-experimental/internal/pkg/wirecli/wirek8s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProviderSet defines dependencies for initializing objects
|
||||||
|
var ProviderSet = wire.NewSet(
|
||||||
|
wirek8s.ProviderSet,
|
||||||
|
wiregit.OptionalProviderSet,
|
||||||
|
wire.Struct(new(status.Status), "*"),
|
||||||
|
NewStatusCommandResult,
|
||||||
|
wireconfig.ConfigProviderSet,
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewStatusCommandResult returns a new status.Result
|
||||||
|
func NewStatusCommandResult(s *status.Status, out io.Writer) (status.Result, error) {
|
||||||
|
return s.Do()
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue