expose

package
v0.15.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:  "expose",
	Usage: "expose local service",

	HideHelpCommand: true,

	Flags: []cli.Flag{
		app.NameFlag,
		app.NamespaceFlag,
		app.KubeconfigFlag,

		&cli.StringSliceFlag{
			Name:     "port",
			Usage:    "local port(s) to expose",
			Required: true,
		},
	},

	Action: func(c *cli.Context) error {
		client := app.MustClient(c)

		name := app.Name(c)
		namespace := app.Namespace(c)

		if namespace == "" {
			namespace = client.Namespace()
		}

		ports := c.StringSlice("port")

		tunnels := map[int]int{}

		for _, p := range ports {
			pair := strings.Split(p, ":")

			if len(pair) > 2 {
				return errors.New("invalid port mapping")
			}

			if len(pair) == 1 {
				pair = []string{pair[0], pair[0]}
			}

			source, err := strconv.Atoi(pair[0])

			if err != nil {
				return err
			}

			target, err := strconv.Atoi(pair[1])

			if err != nil {
				return err
			}

			tunnels[source] = target
		}

		return createTCPTunnel(c.Context, client, namespace, name, tunnels)
	},
}

Functions

This section is empty.

Types

type TunnelOptions

type TunnelOptions struct {
	ServiceType  corev1.ServiceType
	ServicePorts map[int]int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL