Skip to content

Commit

Permalink
Added a Docker image with bundled schemas
Browse files Browse the repository at this point in the history
For cases where you don't want to hit the network the new offline images
contain the downloaded schemas.
  • Loading branch information
garethr committed Aug 19, 2017
1 parent 230df46 commit 44d82dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions Dockerfile.offline
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM golang:1.8-alpine as builder
RUN apk --no-cache add make git
RUN mkdir -p /go/src/github.com/garethr/kubeval/
COPY . /go/src/github.com/garethr/kubeval/
WORKDIR /go/src/github.com/garethr/kubeval/
RUN make linux

FROM alpine:latest as schemas
RUN apk --no-cache add git
RUN git clone https://github.com/garethr/kubernetes-json-schema.git
RUN git clone https://github.com/garethr/openshift-json-schema.git

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/src/github.com/garethr/kubeval/bin/linux/amd64/kubeval .
COPY --from=schemas /kubernetes-json-schema /schemas/kubernetes-json-schema/master
COPY --from=schemas /openshift-json-schema /schemas/openshift-json-schema/master
ENV KUBEVAL_SCHEMA_LOCATION=file:///schemas
ENTRYPOINT ["/kubeval"]
CMD ["--help"]
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ docker:
docker build -t garethr/kubeval:$(TAG) .
docker tag garethr/kubeval:$(TAG) garethr/kubeval:latest

publish: docker
docker-offline:
docker build -f Dockerfile.offline -t garethr/kubeval:$(TAG)-offline .
docker tag garethr/kubeval:$(TAG)-offline garethr/kubeval:offline

publish: docker docker-offline
docker push garethr/kubeval:$(TAG)
docker push garethr/kubeval:latest
docker push garethr/kubeval:$(TAG)-offline
docker push garethr/kubeval:offline

vet:
go vet `glide novendor`
Expand Down
2 changes: 1 addition & 1 deletion kubeval/kubeval.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func validateResource(data []byte, fileName string) (ValidationResult, error) {

results, err := gojsonschema.Validate(schemaLoader, documentLoader)
if err != nil {
return result, fmt.Errorf("Problem loading schema from the network at %s", schema)
return result, fmt.Errorf("Problem loading schema from the network at %s: %s", schema, err)
}

if results.Valid() {
Expand Down

0 comments on commit 44d82dc

Please sign in to comment.