Skip to content

Commit 49646e0

Browse files
committed
📦 release prepare 0.1.6
1 parent 791526f commit 49646e0

File tree

15 files changed

+62
-19
lines changed

15 files changed

+62
-19
lines changed

Diff for: .github/workflows/release.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88

9-
releases-matrix:
9+
releases-matrix-launcher:
1010
name: Release Capsule (Launcher) Binary
1111
runs-on: ubuntu-latest
1212
strategy:
@@ -106,7 +106,7 @@ jobs:
106106
goos: ${{ matrix.goos }}
107107
goarch: ${{ matrix.goarch }}
108108
project_path: "./capsule-ctl"
109-
binary_name: "cc"
109+
binary_name: "caps"
110110
ldflags: "-s -w"
111111
#extra_files: ./capsulectl/README.md
112112
goversion: "https://dl.google.com/go/go1.18.4.linux-amd64.tar.gz"

Diff for: README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# 💊 Capsule
2+
> 🖐 I'm learning Go
23
34
What is **Capsule**?
45

@@ -9,7 +10,7 @@ What is **Capsule**?
910

1011
🖐 The functions are developed with GoLang and compiled to wasm with TinyGo
1112

12-
📦 Before executing or running a function, you need to download the last release of **Capsule**: https://github.com/bots-garden/capsule/releases/tag/0.1.5 (`v0.1.5 🦐`)
13+
📦 Before executing or running a function, you need to download the last release of **Capsule**: https://github.com/bots-garden/capsule/releases/tag/0.1.6 (`v0.1.6 🦐`)
1314

1415
There are 5 components in the **Capsule** project:
1516
- `capsule`: the wasm module launcher (executor)

Diff for: capsule-registry/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/bots-garden/capsule/capsule-registry
33
go 1.18
44

55
require (
6-
github.com/bots-garden/capsule v0.0.0-20220815053639-8f472197bb5e
6+
github.com/bots-garden/capsule v0.0.0-20220815132744-791526f0745d
77
github.com/gin-gonic/gin v1.8.1
88
)
99

Diff for: capsule-registry/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/bots-garden/capsule v0.0.0-20220815053639-8f472197bb5e h1:pI50OYuPU5uKR93VGsVp7tNisiwvoYBvVUH9X7kwiaQ=
2-
github.com/bots-garden/capsule v0.0.0-20220815053639-8f472197bb5e/go.mod h1:PBhXY24j6vjuYghjEt+9mXzDb2ZwD9m9PAh9e6FTXck=
1+
github.com/bots-garden/capsule v0.0.0-20220815132744-791526f0745d h1:xf+TLqAUfN+kQPK2CJ2XUUyfpZ/J7i1zOegNFlnsKjo=
2+
github.com/bots-garden/capsule v0.0.0-20220815132744-791526f0745d/go.mod h1:PBhXY24j6vjuYghjEt+9mXzDb2ZwD9m9PAh9e6FTXck=
33
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
44
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

Diff for: capsule-registry/registry/registry.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ import (
1515
// TODO: add a route to delete a module
1616
// TODO: add a route to get the list of the module (and information)
1717

18+
func CheckRegistryAdminToken(c *gin.Context, registryAdminToken string) bool {
19+
if c.GetHeader("CAPSULE_REGISTRY_ADMIN_TOKEN") == registryAdminToken ||
20+
c.GetHeader("Capsule_Registry_Admin_Token") == registryAdminToken ||
21+
c.GetHeader("capsule_registry_admin_token") == registryAdminToken {
22+
return true
23+
} else {
24+
return false
25+
}
26+
}
27+
28+
// See: https://github.com/gin-gonic/gin/issues/1079
29+
1830
func Serve(httpPort, filesPath, crt, key string) {
1931
/*
2032
You need to use a header with this key: CAPSULE_REGISTRY_ADMIN_TOKEN
@@ -138,7 +150,7 @@ func Serve(httpPort, filesPath, crt, key string) {
138150
*/
139151
router.POST("/upload/:user_org/:wasm_module/:tag", func(c *gin.Context) {
140152
//TODO: check if there is a better practice to handle authentication token
141-
if len(registryAdminToken) == 0 || c.GetHeader("CAPSULE_REGISTRY_ADMIN_TOKEN") == registryAdminToken {
153+
if len(registryAdminToken) == 0 || CheckRegistryAdminToken(c, registryAdminToken) {
142154
userOrg := c.Param("user_org")
143155
wasmModule := c.Param("wasm_module") // without extension
144156
tag := c.Param("tag")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package reverse_proxy_memory_routes
2+
3+
import "github.com/gin-gonic/gin"
4+
5+
func CheckReverseProxyAdminToken(c *gin.Context, reverseProxyAdminToken string) bool {
6+
if c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken ||
7+
c.GetHeader("Capsule_Reverse_Proxy_Admin_Token") == reverseProxyAdminToken ||
8+
c.GetHeader("capsule_reverse_proxy_admin_token") == reverseProxyAdminToken {
9+
return true
10+
} else {
11+
return false
12+
}
13+
}
14+
15+
// See: https://github.com/gin-gonic/gin/issues/1079

Diff for: capsule-reverse-proxy/reverse-proxy/routes/routes-functions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func DefineFunctionsRoutes(router *gin.Engine, functions map[interface{}]map[int
4444

4545
router.POST("memory/functions/registration", func(c *gin.Context) {
4646
//TODO: check if there is a better practice to handle authentication token
47-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
47+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
4848

4949
jsonMap := make(map[string]interface{})
5050
if err := c.Bind(&jsonMap); err != nil {
@@ -102,7 +102,7 @@ func DefineFunctionsRoutes(router *gin.Engine, functions map[interface{}]map[int
102102
*/
103103
router.DELETE("memory/functions/registration", func(c *gin.Context) {
104104
//TODO: check if there is a better practice to handle authentication token
105-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
105+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
106106

107107
jsonMap := make(map[string]interface{})
108108
if err := c.Bind(&jsonMap); err != nil {

Diff for: capsule-reverse-proxy/reverse-proxy/routes/routes-revisions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func DefineRevisionsRoutes(router *gin.Engine, functions map[interface{}]map[int
2424
*/
2525
router.POST("memory/functions/:function_name/revision", func(c *gin.Context) {
2626
//TODO: check if there is a better practice to handle authentication token
27-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
27+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
2828

2929
functionName := c.Param("function_name")
3030

@@ -88,7 +88,7 @@ func DefineRevisionsRoutes(router *gin.Engine, functions map[interface{}]map[int
8888
*/
8989
router.DELETE("memory/functions/:function_name/revision", func(c *gin.Context) {
9090
//TODO: check if there is a better practice to handle authentication token
91-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
91+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
9292

9393
functionName := c.Param("function_name")
9494

Diff for: capsule-reverse-proxy/reverse-proxy/routes/routes-urls.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func DefineUrlsRoutes(router *gin.Engine, functions map[interface{}]map[interfac
2525
*/
2626
router.POST("memory/functions/:function_name/:function_revision/url", func(c *gin.Context) {
2727
//TODO: check if there is a better practice to handle authentication token
28-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
28+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
2929

3030
functionName := c.Param("function_name")
3131
revisionName := c.Param("function_revision")
@@ -93,7 +93,7 @@ func DefineUrlsRoutes(router *gin.Engine, functions map[interface{}]map[interfac
9393
*/
9494
router.DELETE("memory/functions/:function_name/:function_revision/url", func(c *gin.Context) {
9595
//TODO: check if there is a better practice to handle authentication token
96-
if len(reverseProxyAdminToken) == 0 || c.GetHeader("CAPSULE_REVERSE_PROXY_ADMIN_TOKEN") == reverseProxyAdminToken {
96+
if len(reverseProxyAdminToken) == 0 || CheckReverseProxyAdminToken(c, reverseProxyAdminToken) {
9797

9898
functionName := c.Param("function_name")
9999
revisionName := c.Param("function_revision")

Diff for: capsule-worker/worker/routes/check-headers.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package routes
2+
3+
import "github.com/gin-gonic/gin"
4+
5+
func CheckWorkerAdminToken(c *gin.Context, workerAdminToken string) bool {
6+
if c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken ||
7+
c.GetHeader("Capsule_Worker_Admin_Token") == workerAdminToken ||
8+
c.GetHeader("capsule_worker_admin_token") == workerAdminToken {
9+
return true
10+
} else {
11+
return false
12+
}
13+
}
14+
15+
// See: https://github.com/gin-gonic/gin/issues/1079

Diff for: capsule-worker/worker/routes/route-downscale-revision-deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func DefineDownscaleRevisionDeploymentRoute(router *gin.Engine, functions map[st
4747
// and kill the associated processes
4848
router.DELETE("functions/revisions/downscale", func(c *gin.Context) {
4949
//TODO: check if there is a better practice to handle authentication token
50-
if len(workerAdminToken) == 0 || c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken {
50+
if len(workerAdminToken) == 0 || CheckWorkerAdminToken(c, workerAdminToken) {
5151

5252
// check json payload parameters
5353
jsonMap := make(map[string]interface{})

Diff for: capsule-worker/worker/routes/route-remove-revision-deployment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func DefineRemoveRevisionDeploymentRoute(router *gin.Engine, functions map[strin
4545
// and kill the associated processes
4646
router.DELETE("functions/revisions/deployments", func(c *gin.Context) {
4747
//TODO: check if there is a better practice to handle authentication token
48-
if len(workerAdminToken) == 0 || c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken {
48+
if len(workerAdminToken) == 0 || CheckWorkerAdminToken(c, workerAdminToken) {
4949

5050
// check json payload parameters
5151
jsonMap := make(map[string]interface{})

Diff for: capsule-worker/worker/routes/routes-deploy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func DefineDeployRoute(router *gin.Engine, functions map[string]models.Function,
190190
*/
191191
router.POST("functions/deploy", func(c *gin.Context) {
192192
//TODO: check if there is a better practice to handle authentication token
193-
if len(workerAdminToken) == 0 || c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken {
193+
if len(workerAdminToken) == 0 || CheckWorkerAdminToken(c, workerAdminToken) {
194194

195195
// check json payload parameters
196196
jsonMap := make(map[string]interface{})

Diff for: capsule-worker/worker/routes/routes-revision-switch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func DefineSwitchRoutes(router *gin.Engine, functions map[string]models.Function
170170
//Delete on the reverse-proxy-side
171171
router.DELETE("functions/remove_default_revision", func(c *gin.Context) {
172172
//TODO: check if there is a better practice to handle authentication token
173-
if len(workerAdminToken) == 0 || c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken {
173+
if len(workerAdminToken) == 0 || CheckWorkerAdminToken(c, workerAdminToken) {
174174
// check json payload parameters
175175
jsonMap := make(map[string]interface{})
176176
if err := c.Bind(&jsonMap); err != nil {
@@ -201,7 +201,7 @@ func DefineSwitchRoutes(router *gin.Engine, functions map[string]models.Function
201201

202202
router.POST("functions/set_default_revision", func(c *gin.Context) {
203203
//TODO: check if there is a better practice to handle authentication token
204-
if len(workerAdminToken) == 0 || c.GetHeader("CAPSULE_WORKER_ADMIN_TOKEN") == workerAdminToken {
204+
if len(workerAdminToken) == 0 || CheckWorkerAdminToken(c, workerAdminToken) {
205205

206206
// check json payload parameters
207207
jsonMap := make(map[string]interface{})

Diff for: commons/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package commons
22

33
func CapsuleVersion() string {
4-
return "v0.1.5 🦐" // shrimp
4+
return "v0.1.6 🦞" // lobster
55
}

0 commit comments

Comments
 (0)