From 6680777104f2c1265096cb7e4272439b99309d64 Mon Sep 17 00:00:00 2001 From: Kamil Samigullin Date: Sat, 19 Jan 2019 15:38:43 +0300 Subject: [PATCH] define kubernetes package --- internal/kubernetes/api/contract.go | 1 + internal/kubernetes/api/provider.go | 20 ++++++++++++++++++++ internal/kubernetes/cli/contract.go | 1 + internal/kubernetes/cli/provider.go | 20 ++++++++++++++++++++ internal/kubernetes/interface.go | 22 ++++++++++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 internal/kubernetes/api/contract.go create mode 100644 internal/kubernetes/api/provider.go create mode 100644 internal/kubernetes/cli/contract.go create mode 100644 internal/kubernetes/cli/provider.go create mode 100644 internal/kubernetes/interface.go diff --git a/internal/kubernetes/api/contract.go b/internal/kubernetes/api/contract.go new file mode 100644 index 0000000..778f64e --- /dev/null +++ b/internal/kubernetes/api/contract.go @@ -0,0 +1 @@ +package api diff --git a/internal/kubernetes/api/provider.go b/internal/kubernetes/api/provider.go new file mode 100644 index 0000000..5bf639c --- /dev/null +++ b/internal/kubernetes/api/provider.go @@ -0,0 +1,20 @@ +package api + +import "github.com/kamilsk/forward/internal/kubernetes" + +// New returns new instance of Kubernetes provider above API. +func New() *provider { + return &provider{} +} + +type provider struct{} + +// Find tries to find pods suitable by the pattern. +func (*provider) Find(string) []kubernetes.Pod { + panic("implement me") +} + +// Forward initiates the port forwarding process. +func (*provider) Forward(kubernetes.Pod, kubernetes.Mapping) { + panic("implement me") +} diff --git a/internal/kubernetes/cli/contract.go b/internal/kubernetes/cli/contract.go new file mode 100644 index 0000000..7f1e458 --- /dev/null +++ b/internal/kubernetes/cli/contract.go @@ -0,0 +1 @@ +package cli diff --git a/internal/kubernetes/cli/provider.go b/internal/kubernetes/cli/provider.go new file mode 100644 index 0000000..6169a86 --- /dev/null +++ b/internal/kubernetes/cli/provider.go @@ -0,0 +1,20 @@ +package cli + +import "github.com/kamilsk/forward/internal/kubernetes" + +// New returns new instance of Kubernetes provider above CLI. +func New() *provider { + return &provider{} +} + +type provider struct{} + +// Find tries to find pods suitable by the pattern. +func (*provider) Find(string) []kubernetes.Pod { + panic("implement me") +} + +// Forward initiates the port forwarding process. +func (*provider) Forward(kubernetes.Pod, kubernetes.Mapping) { + panic("implement me") +} diff --git a/internal/kubernetes/interface.go b/internal/kubernetes/interface.go new file mode 100644 index 0000000..088f2f2 --- /dev/null +++ b/internal/kubernetes/interface.go @@ -0,0 +1,22 @@ +package kubernetes + +type ( + // Port is a type for port number. + Port int16 + // Local specifies local ports. + Local Port + // Remote specifies remote ports. + Remote Port + // Pod specifies a fully-qualified pod name. + Pod string + // Mapping specifies port forwarding rules. + Mapping map[Local]Remote +) + +// Interface defines a top-level behavior of Kubernetes provider (API or CLI). +type Interface interface { + // Find tries to find pods suitable by the pattern. + Find(string) []Pod + // Forward initiates the port forwarding process. + Forward(Pod, Mapping) +}