Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge branch 'staging' into fix-views-badge
Browse files Browse the repository at this point in the history
  • Loading branch information
romanlab authored Apr 19, 2021
2 parents 9a0c56f + 21d3a6c commit a5bdbfe
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bl/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (e *Evaluator) Evaluate(pattern string, cliId string, evaluationConc int) (

res, err := e.cliClient.RequestEvaluation(pattern, files, cliId)
if err != nil {
return nil, fileErrors, fmt.Errorf("RequestEvaluation has failed")
return nil, fileErrors, err
}

results := e.aggregateEvaluationResults(res.Results)
Expand Down
2 changes: 1 addition & 1 deletion bl/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func test_evaluate_failedRequest() *evaluateTestCase {
}{
response: nil,
fileErrors: []propertiesExtractor.FileError{},
err: fmt.Errorf("RequestEvaluation has failed"),
err: fmt.Errorf("error"),
},
}
}
Expand Down
14 changes: 0 additions & 14 deletions install-linux.sh

This file was deleted.

19 changes: 16 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh
#!/bin/bash

osName=$(uname -s)
DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/datreeio/datree/releases/latest" | grep -o "browser_download_url.*\_${osName}_x86_64.zip")

DOWNLOAD_URL=$(curl --silent "https://api.github.com/repos/datreeio/datree/releases/latest" | grep -o "browser_download_url.*\_Darwin_x86_64.zip")
DOWNLOAD_URL=${DOWNLOAD_URL//\"}
DOWNLOAD_URL=${DOWNLOAD_URL/browser_download_url: /}

Expand All @@ -10,4 +12,15 @@ OUTPUT_BASENAME_WITH_POSTFIX=$OUTPUT_BASENAME.zip
curl -L $DOWNLOAD_URL -o $OUTPUT_BASENAME_WITH_POSTFIX
unzip $OUTPUT_BASENAME_WITH_POSTFIX -d $OUTPUT_BASENAME

cp $OUTPUT_BASENAME/datree /usr/local/bin
if [[ $osName == "Linux" ]]
then
sudo cp $OUTPUT_BASENAME/datree /usr/local/bin
mkdir ~/.datree
else
cp $OUTPUT_BASENAME/datree /usr/local/bin
fi

rm $OUTPUT_BASENAME_WITH_POSTFIX
rm -rf $OUTPUT_BASENAME

curl https://get.datree.io/k8s-demo.yaml > ~/.datree/k8s-demo.yaml
196 changes: 196 additions & 0 deletions internal/fixtures/kube/k8s-demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
apiVersion: extensions/v1beta1
kind: Pod
metadata:
name: static-web
namespace: test
labels:
role: .myrole
spec:
serviceAccount: my-service-account
hostPID: true
hostIPC: true
hostNetwork: true
containers:
- name: web
image: nginx:latest
securityContext:
privileged: true
runAsUser: 2000
livenessProbe:
httpGet:
path: /health
port: 8080
httpHeaders:
- name: Custom-Header
value: Awesome
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
cpu: "64Mi"
limits:
memory: "128Mi"
ports:
- name: web
containerPort: 80
protocol: TCP
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: Deployment
metadata:
name: rss-site
namespace: default
labels:
owner: [email protected]
app: web
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
namespace: test
labels:
app: web
spec:
restartPolicy: Never
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
containers:
- name: front-end
image: nginx@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
livenessProbe:
httpGet:
path: /healthz
port: 8080
httpHeaders:
- name: Custom-Header
value: Awesome
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
cpu: "64Mi"
limits:
memory: "128Mi"
ports:
- containerPort: 80
- name: rss-reader
image: nickchase/nginx@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
securityContext:
runAsUser: 100
livenessProbe:
httpGet:
path: /healthz
port: 8080
httpHeaders:
- name: Custom-Header
value: Awesome
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests:
memory: "64Mi"
cpu: "64Mi"
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 88
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-wildcard-host
labels:
owner: [email protected]
environment: prod
spec:
rules:
- host: "*"
http:
paths:
- pathType: Prefix
path: "/bar"
backend:
service:
name: service1
port:
number: 80
---
apiVersion: v1
kind: Service
metadata:
name: my-service
labels:
owner: [email protected]
spec:
type: NodePort
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
namespace: test
labels:
owner: [email protected]
spec:
schedule: "1 * * *"
jobTemplate:
spec:
template:
spec:
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: php-apache
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: php-apache
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
---
apiVersion: rbac.authorization.k8s.io/v1alpha1
kind: InitConfiguration
---
apiVersion: apps/v1beta2
kind: Deployment
6 changes: 6 additions & 0 deletions pkg/httpClient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package httpClient
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -57,6 +58,11 @@ func (c *Client) Request(method string, resourceURI string, body interface{}, he
if err != nil {
return responseBody, err
}

if response.StatusCode > 399 {
return responseBody, fmt.Errorf("Error: %v", string(b))
}

responseBody = Response{
StatusCode: response.StatusCode,
Body: b,
Expand Down

0 comments on commit a5bdbfe

Please sign in to comment.