-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add go.mod and main.go add main test remove current pattern initial add /backend add /backend change file directories change file directories change file directories change file directories change file directories and fix import issues add frontend template add esentianl pckages Bump github.com/gin-gonic/gin from 1.5.0 to 1.7.0 Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.5.0 to 1.7.0. - [Release notes](https://github.com/gin-gonic/gin/releases) - [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md) - [Commits](gin-gonic/gin@v1.5.0...v1.7.0) --- updated-dependencies: - dependency-name: github.com/gin-gonic/gin dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> ADD CORS, change default App.tsx to React convention serverless and bucket configurstion with go libraries reorder files and directories Update package-lock.json add build for local and prod, move tests change enpoint url of serverless change serveless cunfiguration build cod-infra in order backend to be stable move backend dir remove installation configure netlify and clear README Add makefile and endpoints to backend Add documentation and makefile Configure basic UI and logo add routes generate basic UI with text area add yarn.lock to main project extand api functionallity extand api functionallity move utils to anther directory start interact with kube-neat OS organize go.mod and go.sun download kubernetes write neat yaml wrappper clean functionallty arounf button and converting yaml to neat remove welcode path change name to kubevalid rename all files to validkube add new fetching change routes and endpoint for kubeval change lambda getway + add error on fetching add kubeval wrapper + functionallity in forntend fix scrolling to the side handle errors from front end in go server change documentation change documentation add trivy endpoint run 'go mod tidy' configure image to trivy New brand UI + trivy configuration UI fixes and generate new Dockerfile some we can run Trivy CLI suit application wo mobile out trivy as yaml UI fixes, relative to screen size + LOGO UI improvements and add GitStart small rename Add example and clear button functionallity remove target yaml and add documentation convert kubeval output to yaml try adding githuba actions try adding githuba actions remvoe github actions UI fixes change manifest and kubeval functionallity more UI fixes move kubeval to serverless as image move kubeval to serverless more litlle fixes on UI add styled yaml bump go versions
- Loading branch information
0 parents
commit d3fa081
Showing
66 changed files
with
13,051 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,110 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# Next.js build output | ||
.next | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and *not* Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Local Netlify folder | ||
.netlify | ||
|
||
#deploy | ||
/bin |
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,24 @@ | ||
ARG BUILDER_IMAGE | ||
FROM alpine:3.14 as deps | ||
RUN apk --no-cache add curl | ||
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.22.0 | ||
RUN wget https://github.com/instrumenta/kubeval/releases/latest/download/kubeval-linux-amd64.tar.gz | ||
RUN tar xf kubeval-linux-amd64.tar.gz | ||
RUN cp kubeval /usr/local/bin | ||
|
||
FROM golang:1.17 | ||
|
||
ARG FUNCTION_DIR="/var/task" | ||
RUN mkdir -p ${FUNCTION_DIR} | ||
|
||
COPY /bin/lambda ${FUNCTION_DIR} | ||
|
||
|
||
COPY --from=deps /usr/local/bin/trivy /usr/local/bin/trivy | ||
RUN chmod +x /usr/local/bin/trivy | ||
COPY --from=deps /usr/local/bin/kubeval /usr/local/bin/kubeval | ||
RUN chmod +x /usr/local/bin/kubeval | ||
|
||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "/var/task/lambda" ] |
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,11 @@ | ||
.PHONY: build clean deploy | ||
|
||
clean: | ||
rm -rf ./bin | ||
|
||
build: | ||
rm -f bin/* | ||
env GOOS=linux go build -ldflags="-s -w" -o bin/lambda backend/endpoints/aws/lambda.go | ||
|
||
deploy: clean build | ||
sls deploy --verbose |
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,55 @@ | ||
# validkube | ||
|
||
### Prerequisite | ||
|
||
- aws CLI with access to your AWS | ||
- yarn | ||
- npm | ||
- serverless CLI | ||
|
||
--- | ||
|
||
### Deploy backend server less | ||
|
||
```bash | ||
make deploy | ||
``` | ||
|
||
Serverless endpoint: https://gtgmn58dh9.execute-api.us-east-1.amazonaws.com/production | ||
|
||
Frontend-domain: https://validkube.com | ||
|
||
In order to update web domin: | ||
|
||
```bash | ||
aws ssm put-parameter --name /validkube/config/allowed_origin --type String --value {frontend-domain} --overwrite | ||
``` | ||
|
||
In order to deploy frontend: | ||
|
||
```bash | ||
cd frontend | ||
netlify deploy --prod | ||
``` | ||
|
||
# Local environment | ||
|
||
Set local env of allowed origin, example in Unix-like: | ||
|
||
```bash | ||
export ALLOWED_ORIGIN=http://localhost:3000 | ||
``` | ||
|
||
In order to start backend run: | ||
|
||
```bash | ||
go run backend/development/localdev.go | ||
``` | ||
|
||
In order to start frontend run: | ||
|
||
```bash | ||
cd frontend | ||
yarn insatll | ||
yarn start | ||
``` |
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,17 @@ | ||
package hello | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/komodorio/validkube/backend/internal/routing" | ||
) | ||
|
||
const Path = "/hello" | ||
const Method = routing.GET | ||
|
||
func ProcessRequest(c *gin.Context) { | ||
name := c.Query("name") | ||
c.JSON(http.StatusOK, gin.H{"msg": fmt.Sprintf("Hello %v!", name)}) | ||
} |
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,69 @@ | ||
package kubeneat | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io/ioutil" | ||
"net/http" | ||
"unicode" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/itaysk/kubectl-neat/cmd" | ||
"github.com/komodorio/validkube/backend/api/utils" | ||
"github.com/komodorio/validkube/backend/internal/routing" | ||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
const Path = "/kubeneat" | ||
const Method = routing.POST | ||
|
||
func NeatYAMLOrJSONWrapper(in []byte) (out []byte, errrDescription string, err error) { | ||
var injson, outjson string | ||
|
||
itsYaml := !bytes.HasPrefix(bytes.TrimLeftFunc(in, unicode.IsSpace), []byte{'{'}) | ||
if itsYaml { | ||
injsonbytes, err := yaml.YAMLToJSON(in) | ||
if err != nil { | ||
return nil, "error converting from yaml to json", err | ||
} | ||
injson = string(injsonbytes) | ||
} else { | ||
injson = string(in) | ||
} | ||
|
||
outjson, err = cmd.Neat(injson) | ||
if err != nil { | ||
return nil, "error neating", err | ||
} | ||
|
||
if itsYaml { | ||
out, err = yaml.JSONToYAML([]byte(outjson)) | ||
if err != nil { | ||
return nil, "error converting from json to ymls", err | ||
} | ||
} else { | ||
out = []byte(outjson) | ||
} | ||
return out, "", nil | ||
} | ||
|
||
func ProcessRequest(c *gin.Context) { | ||
body, err := ioutil.ReadAll(c.Request.Body) | ||
if err != nil { | ||
errDescription := fmt.Sprintf("Erorr has with reading request body: %v", err.Error()) | ||
c.JSON(http.StatusPartialContent, gin.H{"data": "", "err": errDescription}) | ||
return | ||
} | ||
bodyAsMap, err := utils.JsonToMap(body) | ||
if err != nil { | ||
c.JSON(http.StatusPartialContent, gin.H{"data": "", "err": err.Error()}) | ||
return | ||
} | ||
yamlAsInterface := bodyAsMap["yaml"] | ||
neatYaml, errDescription, err := NeatYAMLOrJSONWrapper(utils.InterfaceToBytes(yamlAsInterface)) | ||
if err != nil { | ||
fullError := fmt.Sprintf("%v: %v", errDescription, err.Error()) | ||
c.JSON(http.StatusOK, gin.H{"data": "", "err": fullError}) | ||
} | ||
c.JSON(http.StatusOK, gin.H{"data": string(neatYaml), "err": nil}) | ||
} |
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,61 @@ | ||
package kubeval | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
"net/http" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/komodorio/validkube/backend/api/utils" | ||
"github.com/komodorio/validkube/backend/internal/routing" | ||
"sigs.k8s.io/yaml" | ||
) | ||
|
||
const Path = "/kubeval" | ||
const Method = routing.POST | ||
|
||
func kubevalWrapper(inputYaml []byte) ([]byte, error) { | ||
_, err := utils.RunCommand("mkdir", "-p", "/tmp/yaml") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
file, err := os.Create("/tmp/yaml/target_yaml.yaml") | ||
if err != nil { | ||
return nil, err | ||
} else { | ||
file.WriteString(string(inputYaml)) | ||
} | ||
file.Close() | ||
|
||
outputFromKubevalAsJson, _ := exec.Command("kubeval", "-o", "json", "/tmp/yaml/target_yaml.yaml").Output() | ||
|
||
outputFromKubevalAsYaml, err := yaml.JSONToYAML(outputFromKubevalAsJson) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return outputFromKubevalAsYaml, nil | ||
} | ||
|
||
func ProcessRequest(c *gin.Context) { | ||
body, err := ioutil.ReadAll(c.Request.Body) | ||
if err != nil { | ||
fmt.Printf("Erorr has with reading request body: %v", err) | ||
c.JSON(http.StatusOK, gin.H{"data": "", "err": err.Error()}) | ||
return | ||
} | ||
bodyAsMap, err := utils.JsonToMap(body) | ||
if err != nil { | ||
c.JSON(http.StatusOK, gin.H{"data": "", "err": err.Error()}) | ||
return | ||
} | ||
yamlAsInterface := bodyAsMap["yaml"] | ||
kubevalOutput, err := kubevalWrapper(utils.InterfaceToBytes(yamlAsInterface)) | ||
if err != nil { | ||
c.JSON(http.StatusOK, gin.H{"data": "", "err": err.Error()}) | ||
return | ||
} | ||
c.JSON(http.StatusOK, gin.H{"data": string(kubevalOutput), "err": nil}) | ||
} |
Oops, something went wrong.