-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(inspector): Created Settings View (#6)
* Init the UI * Created the deployements view * Added Filtering * Added delete code * Created the Proxy * Created Delete inspector function * Completed settings page * Refector the code * Added CI
- Loading branch information
Showing
31 changed files
with
6,038 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: inspector | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'inspector/**' | ||
- 'ui/**' | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/mrsupiri/lazy-koala/inspector | ||
DOCKER_BUILDKIT: 1 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: control-plane | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- run: docker build -t $IMAGE_NAME:latest . | ||
- run: docker tag $IMAGE_NAME:latest $IMAGE_NAME:commit-${GITHUB_SHA:0:8} | ||
- run: docker push $IMAGE_NAME --all-tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/go | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=go | ||
|
||
### Go ### | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
### Go Patch ### | ||
/vendor/ | ||
/Godeps/ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/go | ||
ui/* | ||
!ui/.gitkeep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FROM node as ui-build | ||
|
||
WORKDIR /workspace | ||
|
||
COPY ui/package.json ./ | ||
COPY ui/package-lock.json ./ | ||
RUN npm install --silent | ||
|
||
COPY ui/ . | ||
|
||
RUN npm run build | ||
|
||
|
||
FROM golang:1.17 as go-builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY ./inspector/go.mod go.mod | ||
COPY ./inspector/go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
COPY ./inspector/ ./ | ||
|
||
|
||
# Copy UI build | ||
COPY --from=ui-build /workspace/dist/ ui/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o inspector main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
COPY --from=go-builder /workspace/inspector /usr/local/bin/inspector | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/inspector"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/MrSupiri/LazyKoala/proxy | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/rs/cors v1.8.2 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= | ||
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= | ||
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= | ||
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package main | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
"log" | ||
"net/http" | ||
"net/http/httputil" | ||
"net/url" | ||
"os" | ||
"path" | ||
"strings" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/rs/cors" | ||
) | ||
|
||
//go:embed ui/* | ||
var content embed.FS | ||
|
||
type fsFunc func(name string) (fs.File, error) | ||
|
||
func (f fsFunc) Open(name string) (fs.File, error) { | ||
return f(name) | ||
} | ||
|
||
func clientHandler() http.Handler { | ||
handler := fsFunc(func(name string) (fs.File, error) { | ||
assetPath := path.Join("ui", name) | ||
|
||
// If we can't find the asset, return the default index.html | ||
// content | ||
f, err := content.Open(assetPath) | ||
if os.IsNotExist(err) { | ||
return content.Open("ui/index.html") | ||
} | ||
|
||
// Otherwise assume this is a legitimate request routed | ||
// correctly | ||
return f, err | ||
}) | ||
|
||
return http.FileServer(http.FS(handler)) | ||
} | ||
|
||
func main() { | ||
u, _ := url.Parse("http://127.0.0.1:8001/") | ||
r := mux.NewRouter() | ||
|
||
r.PathPrefix("/k8s").HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
proxy := httputil.NewSingleHostReverseProxy(u) | ||
|
||
r.URL.Path = "/" + strings.Join(strings.Split(r.URL.Path, "/")[2:], "/") | ||
|
||
log.Printf("Proxying Request from %s to KubeAPI on %s\n", r.RemoteAddr, r.URL.Path) | ||
|
||
proxy.ServeHTTP(w, r) | ||
}) | ||
|
||
r.PathPrefix("/").Handler(clientHandler()) | ||
|
||
corsOpts := cors.New(cors.Options{ | ||
AllowedOrigins: []string{"*"}, | ||
AllowedMethods: []string{ | ||
http.MethodGet, | ||
http.MethodDelete, | ||
http.MethodPost, | ||
}, | ||
}) | ||
|
||
log.Println("Client app started on port :8090") | ||
|
||
if err := http.ListenAndServe(":8090", corsOpts.Handler(r)); err != http.ErrServerClosed { | ||
log.Fatal("Receiver webserver crashed: %s", err) | ||
os.Exit(1) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
.env.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite App</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.