-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feat/#661
- Loading branch information
Showing
76 changed files
with
1,293 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package get | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/Kong/kuma/pkg/core/resources/apis/mesh" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/Kong/kuma/app/kumactl/pkg/output" | ||
"github.com/Kong/kuma/app/kumactl/pkg/output/printers" | ||
rest_types "github.com/Kong/kuma/pkg/core/resources/model/rest" | ||
"github.com/Kong/kuma/pkg/core/resources/store" | ||
) | ||
|
||
func newGetDataplaneCmd(pctx *getContext) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "dataplane NAME", | ||
Short: "Show a single Dataplane resource", | ||
Long: `Show a single Dataplane resource.`, | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
rs, err := pctx.CurrentResourceStore() | ||
if err != nil { | ||
return err | ||
} | ||
name := args[0] | ||
currentMesh := pctx.CurrentMesh() | ||
dataplane := &mesh.DataplaneResource{} | ||
if err := rs.Get(context.Background(), dataplane, store.GetByKey(name, currentMesh)); err != nil { | ||
if store.IsResourceNotFound(err) { | ||
return errors.Errorf("No resources found in %s mesh", currentMesh) | ||
} | ||
return errors.Wrapf(err, "failed to get mesh %s", currentMesh) | ||
} | ||
dataplanes := []*mesh.DataplaneResource{dataplane} | ||
switch format := output.Format(pctx.args.outputFormat); format { | ||
case output.TableFormat: | ||
return printDataplanes(dataplanes, cmd.OutOrStdout()) | ||
default: | ||
printer, err := printers.NewGenericPrinter(format) | ||
if err != nil { | ||
return err | ||
} | ||
return printer.Print(rest_types.From.Resource(dataplane), cmd.OutOrStdout()) | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package get | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"github.com/Kong/kuma/pkg/core/resources/apis/mesh" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/Kong/kuma/app/kumactl/pkg/output" | ||
"github.com/Kong/kuma/app/kumactl/pkg/output/printers" | ||
rest_types "github.com/Kong/kuma/pkg/core/resources/model/rest" | ||
"github.com/Kong/kuma/pkg/core/resources/store" | ||
) | ||
|
||
func newGetFaultInjectionCmd(pctx *getContext) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "fault-injection NAME", | ||
Short: "Show a single Fault-Injection resource", | ||
Long: `Show a single Fault-Injection resource.`, | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
rs, err := pctx.CurrentResourceStore() | ||
if err != nil { | ||
return err | ||
} | ||
name := args[0] | ||
currentMesh := pctx.CurrentMesh() | ||
faultInjection := &mesh.FaultInjectionResource{} | ||
if err := rs.Get(context.Background(), faultInjection, store.GetByKey(name, currentMesh)); err != nil { | ||
if store.IsResourceNotFound(err) { | ||
return errors.Errorf("No resources found in %s mesh", currentMesh) | ||
} | ||
return errors.Wrapf(err, "failed to get mesh %s", currentMesh) | ||
} | ||
faultInjections := []*mesh.FaultInjectionResource{faultInjection} | ||
switch format := output.Format(pctx.args.outputFormat); format { | ||
case output.TableFormat: | ||
return printFaultInjections(faultInjections, cmd.OutOrStdout()) | ||
default: | ||
printer, err := printers.NewGenericPrinter(format) | ||
if err != nil { | ||
return err | ||
} | ||
return printer.Print(rest_types.From.Resource(faultInjection), cmd.OutOrStdout()) | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package get | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/Kong/kuma/app/kumactl/pkg/output" | ||
"github.com/Kong/kuma/app/kumactl/pkg/output/printers" | ||
"github.com/Kong/kuma/pkg/core/resources/apis/mesh" | ||
rest_types "github.com/Kong/kuma/pkg/core/resources/model/rest" | ||
"github.com/Kong/kuma/pkg/core/resources/store" | ||
) | ||
|
||
func newGetHealthCheckCmd(pctx *getContext) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "healthcheck NAME", | ||
Short: "Show a single HealthCheck resource", | ||
Long: `Show a single HealthCheck resource.`, | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
rs, err := pctx.CurrentResourceStore() | ||
if err != nil { | ||
return err | ||
} | ||
name := args[0] | ||
currentMesh := pctx.CurrentMesh() | ||
healthcheck := &mesh.HealthCheckResource{} | ||
if err := rs.Get(context.Background(), healthcheck, store.GetByKey(name, currentMesh)); err != nil { | ||
if store.IsResourceNotFound(err) { | ||
return errors.Errorf("No resources found in %s mesh", currentMesh) | ||
} | ||
return errors.Wrapf(err, "failed to get mesh %s", currentMesh) | ||
} | ||
healthchecks := []*mesh.HealthCheckResource{healthcheck} | ||
switch format := output.Format(pctx.args.outputFormat); format { | ||
case output.TableFormat: | ||
return printHealthChecks(healthchecks, cmd.OutOrStdout()) | ||
default: | ||
printer, err := printers.NewGenericPrinter(format) | ||
if err != nil { | ||
return err | ||
} | ||
return printer.Print(rest_types.From.Resource(healthcheck), cmd.OutOrStdout()) | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package get | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
core_mesh "github.com/Kong/kuma/pkg/core/resources/apis/mesh" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/Kong/kuma/app/kumactl/pkg/output" | ||
"github.com/Kong/kuma/app/kumactl/pkg/output/printers" | ||
rest_types "github.com/Kong/kuma/pkg/core/resources/model/rest" | ||
"github.com/Kong/kuma/pkg/core/resources/store" | ||
) | ||
|
||
func newGetMeshCmd(pctx *getContext) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "mesh NAME", | ||
Short: "Show a single Mesh resource", | ||
Long: `Show a single Mesh resource.`, | ||
Args: cobra.MinimumNArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
rs, err := pctx.CurrentResourceStore() | ||
if err != nil { | ||
return err | ||
} | ||
name := args[0] | ||
currentMesh := name | ||
mesh := &core_mesh.MeshResource{} | ||
if err := rs.Get(context.Background(), mesh, store.GetByKey(name, currentMesh)); err != nil { | ||
if store.IsResourceNotFound(err) { | ||
return errors.Errorf("No resources found in %s mesh", currentMesh) | ||
} | ||
return errors.Wrapf(err, "failed to get mesh %s", currentMesh) | ||
} | ||
meshes := []*core_mesh.MeshResource{mesh} | ||
switch format := output.Format(pctx.args.outputFormat); format { | ||
case output.TableFormat: | ||
return printMeshes(meshes, cmd.OutOrStdout()) | ||
default: | ||
printer, err := printers.NewGenericPrinter(format) | ||
if err != nil { | ||
return err | ||
} | ||
return printer.Print(rest_types.From.Resource(mesh), cmd.OutOrStdout()) | ||
} | ||
}, | ||
} | ||
return cmd | ||
} |
Oops, something went wrong.