Skip to content

Commit

Permalink
updated fox docs, hello-world; added SendAccepts to kit
Browse files Browse the repository at this point in the history
  • Loading branch information
xadhatter committed Dec 6, 2023
1 parent 2a8bc03 commit 48f17b4
Show file tree
Hide file tree
Showing 27 changed files with 113 additions and 242 deletions.
1 change: 0 additions & 1 deletion docs/fox/fox.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ and release your KubeFox Apps.
* [fox release](fox_release.md) - Release specified AppDeployment and VirtualEnvironment
* [fox version](fox_version.md) - Show version information of 🦊 Fox

###### Auto generated by spf13/cobra on 6-Dec-2023
13 changes: 6 additions & 7 deletions docs/fox/fox_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ Build and optionally push an OCI image of component

### Synopsis


The build command will use Docker to build the specified component. By default
components are built using a KubeFox defined Dockerfile. A custom Dockerfile can
be provided my placing it in the root directory of the component. Please note
that the build working directory is the root of the repository, not the
component directory.

Examples:

# Build and push OCI image for my-component.
fox build my-component --publish
```
fox build (NAME) [flags]
```

### Examples

```
fox build (NAME) [flags]
# Build and push OCI image for my-component.
fox build my-component --publish
```

### Options
Expand All @@ -45,4 +45,3 @@ fox build (NAME) [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ See each sub-command's help for details on how to use the generated script.
* [fox completion powershell](fox_completion_powershell.md) - Generate the autocompletion script for powershell
* [fox completion zsh](fox_completion_zsh.md) - Generate the autocompletion script for zsh

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_completion_bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ fox completion bash

* [fox completion](fox_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_completion_fish.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ fox completion fish [flags]

* [fox completion](fox_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_completion_powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ fox completion powershell [flags]

* [fox completion](fox_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_completion_zsh.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ fox completion zsh [flags]

* [fox completion](fox_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ Use the config subcommand to help setup your local environment.
* [fox config setup](fox_config_setup.md) - Run setup to configure 🦊 Fox
* [fox config show](fox_config_show.md) - Show the current configuration

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_config_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ fox config setup [flags]

* [fox config](fox_config.md) - Configure 🦊 Fox

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_config_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ fox config show [flags]

* [fox config](fox_config.md) - Configure 🦊 Fox

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ fox deploy [NAME] [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
3 changes: 0 additions & 3 deletions docs/fox/fox_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ Generate docs for 🦊 Fox

### Synopsis


Run this command to automatically generate 🦊 Fox documentation. Output is
placed in the subdirectory docs of the working directory.


```
fox docs [flags]
```
Expand All @@ -33,4 +31,3 @@ fox docs [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
3 changes: 0 additions & 3 deletions docs/fox/fox_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Initialize a KubeFox App

### Synopsis


The init command creates the skelton of a KubeFox App and ensures a Git
repository is present. It will optionally create simple 'hello-world' app to get
you started.


```
fox init [flags]
```
Expand All @@ -35,4 +33,3 @@ fox init [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
25 changes: 12 additions & 13 deletions docs/fox/fox_proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Port forward local port to broker's HTTP server adapter

### Synopsis


The proxy command will inspect the Kubernetes cluster and find an available
broker to proxy a local port to. This port can then be used to make HTTP
requests to the broker's HTTP server adapter. This is especially useful during
Expand All @@ -15,21 +14,22 @@ automatically inject the values as context to requests sent through the proxy.
The context can still be overridden manually by setting the header or query
param on the original request.

Examples:
```
fox proxy (PORT) [flags]
```

# Port forward local port 8080 and wait if no brokers are available.
fox proxy 8080 --wait 5m
### Examples

# Port forward local port 8080 and inject 'my-env' and 'my-dep' context.
fox proxy 8080 --virtual-env my-env --app-deployment my-dep

http://127.0.0.1:8080/hello # uses my-env and my-deployment
http://127.0.0.1:8080/hello?kf-env=your-env # uses your-env and my-dep
http://127.0.0.1:8080/hello?kf-dep=your-dep # uses my-env and your-dep
```
# Port forward local port 8080 and wait if no brokers are available.
fox proxy 8080 --wait 5m
# Port forward local port 8080 and inject 'my-env' and 'my-dep' context.
fox proxy 8080 --virtual-env my-env --app-deployment my-dep
```
fox proxy (PORT) [flags]
http://127.0.0.1:8080/hello # uses my-env and my-deployment
http://127.0.0.1:8080/hello?kf-env=your-env # uses your-env and my-dep
http://127.0.0.1:8080/hello?kf-dep=your-dep # uses my-env and your-dep
```

### Options
Expand Down Expand Up @@ -58,4 +58,3 @@ fox proxy (PORT) [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ fox publish [NAME] [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
21 changes: 10 additions & 11 deletions docs/fox/fox_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Release specified AppDeployment and VirtualEnvironment

### Synopsis


The release command activates the routes of the components belonging to the
specified AppDeployment. This causes genesis events matching components' routes
to be automatically sent to the component with the specified environment being
Expand All @@ -15,18 +14,19 @@ characters), version, Git tag, or Git branch. 🦊 Fox will inspect the Kubernet
cluster to find a matching AppDeployment. If more than one AppDeployment is
found you will be prompted to select the desired AppDeployment.

Examples:

# Release the AppDeployment named 'main' using the 'dev' Virtual Environment.
fox release main --virtual-env dev

# Release the AppDeployment with version 'v1.2.3' using the 'prod'
# VirtualEnvironment, creating an VirtualEnvironmentSnapshot if needed.
fox release v1.2.3 --virtual-env prod --create-snapshot
```
fox release (NAME | COMMIT | SHORT COMMIT | VERSION | TAG | BRANCH) [flags]
```

### Examples

```
fox release (NAME | COMMIT | SHORT COMMIT | VERSION | TAG | BRANCH) [flags]
# Release the AppDeployment named 'main' using the 'dev' Virtual Environment.
fox release main --virtual-env dev
# Release the AppDeployment with version 'v1.2.3' using the 'prod'
# VirtualEnvironment, creating an VirtualEnvironmentSnapshot if needed.
fox release v1.2.3 --virtual-env prod --create-snapshot
```

### Options
Expand Down Expand Up @@ -55,4 +55,3 @@ fox release (NAME | COMMIT | SHORT COMMIT | VERSION | TAG | BRANCH) [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
1 change: 0 additions & 1 deletion docs/fox/fox_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ fox version [flags]

* [fox](fox.md) - CLI for interacting with KubeFox

###### Auto generated by spf13/cobra on 6-Dec-2023
21 changes: 7 additions & 14 deletions examples/hello-world/kubefox/components/frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"fmt"
"strings"

"github.com/xigxog/kubefox/kit"
"github.com/xigxog/kubefox/kit/env"
)

var (
Expand All @@ -15,7 +15,8 @@ func main() {
k := kit.New()

backend = k.Component("backend")
// TODO mark env var as unique

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

k.Start()
Expand All @@ -30,20 +31,12 @@ func sayHello(k kit.Kontext) error {
msg := fmt.Sprintf("👋 Hello %s!", r.Str())
k.Log().Debug(msg)

a := strings.ToLower(k.Header("accept"))
switch {
case strings.Contains(a, "application/json"):
return k.Resp().SendJSON(map[string]any{"msg": msg})

case strings.Contains(a, "text/html"):
return k.Resp().SendHTML(fmt.Sprintf(html, msg))

default:
return k.Resp().SendStr(msg)
}
json := map[string]any{"msg": msg}
html := fmt.Sprintf(htmlTmpl, msg)
return k.Resp().SendAccepts(json, html, msg)
}

const html = `
const htmlTmpl = `
<!DOCTYPE html>
<html>
<head>
Expand Down
8 changes: 4 additions & 4 deletions examples/hello-world/kubefox/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ require (
github.com/google/uuid v1.4.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
20 changes: 10 additions & 10 deletions examples/hello-world/kubefox/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -18,15 +18,15 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand Down
6 changes: 5 additions & 1 deletion examples/hello-world/kubefox/hack/environments/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apiVersion: kubefox.xigxog.io/v1alpha1
kind: VirtualEnvironment
kind: VirtualEnv
metadata:
name: prod
spec:
releasePolicy:
appDeploymentPolicy: VersionRequired
virtualEnvPolicy: SnapshotRequired
data:
vars:
subPath: prod
who: Universe
6 changes: 5 additions & 1 deletion examples/hello-world/kubefox/hack/environments/qa.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apiVersion: kubefox.xigxog.io/v1alpha1
kind: VirtualEnvironment
kind: VirtualEnv
metadata:
name: qa
spec:
releasePolicy:
appDeploymentPolicy: VersionOptional
virtualEnvPolicy: SnapshotOptional
data:
vars:
subPath: qa
who: World
15 changes: 7 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/google/uuid v1.4.0
github.com/hashicorp/vault/api v1.10.0
github.com/hashicorp/vault/api/auth/kubernetes v0.5.0
github.com/hasura/go-graphql-client v0.10.0
github.com/lestrrat-go/jwx v1.2.26
github.com/hasura/go-graphql-client v0.10.1
github.com/lestrrat-go/jwx v1.2.27
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/nats-io/nats.go v1.31.0
github.com/vulcand/predicate v1.2.0
Expand Down Expand Up @@ -79,15 +79,14 @@ require (
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.2 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -105,14 +104,14 @@ require (
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.10 // indirect
github.com/shirou/gopsutil/v3 v3.23.11 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.13 // indirect
github.com/tklauser/numcpus v0.7.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
Expand All @@ -133,7 +132,7 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/component-base v0.28.4 // indirect
k8s.io/kube-openapi v0.0.0-20231113174909-778a5567bc1e // indirect
k8s.io/kube-openapi v0.0.0-20231129212854-f0671cc7e66a // indirect
k8s.io/utils v0.0.0-20231127182322-b307cd553661 // indirect
nhooyr.io/websocket v1.8.10 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
Loading

0 comments on commit 48f17b4

Please sign in to comment.