Skip to content

Commit

Permalink
updated to kubefox v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Dec 8, 2023
1 parent c85dc53 commit f1d8055
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions efs/hello-world/components/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
)

var (
who kit.EnvVar
who kit.EnvVarDep
)

func main() {
k := kit.New()

who = k.EnvVar("who", env.Required())
who = k.EnvVar("who", env.Required)
k.Default(sayWho)

k.Start()
Expand Down
4 changes: 2 additions & 2 deletions efs/hello-world/components/frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import (
)

var (
backend kit.Dependency
backend kit.ComponentDep
)

func main() {
k := kit.New()

backend = k.Component("backend")

k.EnvVar("subPath", env.Unique())
k.EnvVar("subPath", env.Unique)
k.Route("Path(`/{{.Env.subPath}}/hello`)", sayHello)

k.Start()
Expand Down
3 changes: 1 addition & 2 deletions efs/hello-world/go.mod.trim
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ module github.com/xigxog/kubefox/examples/hello-world/kubefox

go 1.21

// TODO update when kubefox is released
require github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37
require github.com/xigxog/kubefox v0.3.0-alpha

require (
github.com/golang/protobuf v1.5.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions efs/hello-world/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37 h1:jgXm3ga62ZnY8oejlI173Z7TfTBtXeOZbJQpArrXiw4=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37/go.mod h1:9qjm+/xmMZUbXct3cf37+rOsEwapMtLORwZWExzZgT0=
github.com/xigxog/kubefox v0.3.0-alpha h1:0vrrMQ5E2yTBqkZocq4wWYzIq8dcEiayXECUhPoLgs0=
github.com/xigxog/kubefox v0.3.0-alpha/go.mod h1:9qjm+/xmMZUbXct3cf37+rOsEwapMtLORwZWExzZgT0=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.17.0
// TODO update when kubefox is released
github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37
github.com/xigxog/kubefox v0.2.5-alpha.0.20231208033510-34928eb203fb
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM
github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37 h1:jgXm3ga62ZnY8oejlI173Z7TfTBtXeOZbJQpArrXiw4=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231206144113-48f17b47cb37/go.mod h1:9qjm+/xmMZUbXct3cf37+rOsEwapMtLORwZWExzZgT0=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231207161131-766472f99055 h1:xZK7obOPCJcH7PrAJUE5f4SxRBka/ujvGJYtpXTCYIM=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231207161131-766472f99055/go.mod h1:9qjm+/xmMZUbXct3cf37+rOsEwapMtLORwZWExzZgT0=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231208033510-34928eb203fb h1:P2u33h2NFOZGbDooJxWlmJKQAgPBv6J3wPaoOG93bVo=
github.com/xigxog/kubefox v0.2.5-alpha.0.20231208033510-34928eb203fb/go.mod h1:9qjm+/xmMZUbXct3cf37+rOsEwapMtLORwZWExzZgT0=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
2 changes: 1 addition & 1 deletion hack/scripts/hello-world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
HELLO_WORLD_SRC="efs/hello-world"

rm -rf "${HELLO_WORLD_SRC}"
cp -r "${KUBEFOX_SRC}/examples/hello-world/kubefox" "${HELLO_WORLD_SRC}"
cp -r "${EXAMPLES_SRC}/go/hello-world/kubefox" "${HELLO_WORLD_SRC}"
mv "${HELLO_WORLD_SRC}/go.mod" "${HELLO_WORLD_SRC}/go.mod.trim"
4 changes: 2 additions & 2 deletions hack/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." &>/dev/null && pwd -P)"
cd "${REPO_ROOT}"

SCRIPTS="hack/scripts"
KUBEFOX_SRC="../kubefox"
EXAMPLES_SRC="../examples"

COMPONENT="fox"
COMPONENT_COMMIT=$(git rev-parse HEAD)
ROOT_COMMIT=${COMPONENT_COMMIT}

HEAD_REF=$(git symbolic-ref -q HEAD)
HEAD_REF=$(git symbolic-ref -q HEAD || true)
TAG_REF=$(git describe --tags --exact-match 2>/dev/null | xargs -I % echo "refs/tags/%")

CONTAINER_REGISTRY=${CONTAINER_REGISTRY:-"ghcr.io/xigxog"}
Expand Down
6 changes: 3 additions & 3 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/xigxog/fox/internal/kubernetes"
"github.com/xigxog/fox/internal/log"
"github.com/xigxog/kubefox/api"
kubefox "github.com/xigxog/kubefox/core"
"github.com/xigxog/kubefox/core"
)

type ProxyServer struct {
Expand Down Expand Up @@ -81,11 +81,11 @@ func (srv *ProxyServer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
req.URL.Scheme = "http"
req.RequestURI = ""

env := kubefox.GetParamOrHeader(req, api.HeaderEnv, api.HeaderAbbrvEnv, api.HeaderShortEnv)
env := core.GetParamOrHeader(req, api.HeaderEnv, api.HeaderAbbrvEnv, api.HeaderShortEnv)
if env == "" && srv.cfg.Flags.VirtEnv != "" {
req.Header.Set(api.HeaderEnv, srv.cfg.Flags.VirtEnv)
}
dep := kubefox.GetParamOrHeader(req, api.HeaderDep, api.HeaderAbbrvDep, api.HeaderShortDep)
dep := core.GetParamOrHeader(req, api.HeaderDep, api.HeaderAbbrvDep, api.HeaderShortDep)
if dep == "" && srv.cfg.Flags.AppDeployment != "" {
req.Header.Set(api.HeaderDep, srv.cfg.Flags.AppDeployment)
}
Expand Down

0 comments on commit f1d8055

Please sign in to comment.