Permalink
Browse files

*: add license header checking and tweak Makefile

- move file-finding logic into lint check script
- move lint check script into .tool/ subdirectory (similar to
  opencontainers/runtime-spec)
- add a simple `check-license` script to .tool/ to ensure all Go source
  files have an Apache license header, and wire up to `check-license`
  make target
- invoke this from travis
- add `schema-fs` target to generate schema/fs.go (including header)
- add header everywhere it's missing so far
- add `output/` directory to .gitignore

Signed-off-by: Jonathan Boulle <jonathanboulle@gmail.com>
  • Loading branch information...
1 parent 6b5d048 commit 10e6ff7101c2b0ff76e41a4a213838953e2082d8 @jonboulle jonboulle committed May 19, 2016
Showing with 285 additions and 290 deletions.
  1. +2 −1 .gitignore
  2. +14 −0 .header
  3. +13 −0 .tool/check-license
  4. +23 −0 .tool/lint
  5. +1 −0 .travis.yml
  6. +11 −1 Makefile
  7. +14 −0 cmd/oci-image-tool/main.go
  8. +14 −0 cmd/oci-image-tool/validate.go
  9. +0 −22 lint
  10. +14 −0 schema/doc.go
  11. +121 −265 schema/fs.go
  12. +16 −1 schema/gen.go
  13. +14 −0 schema/schema.go
  14. +14 −0 schema/spec_test.go
  15. +14 −0 schema/validator.go
View
@@ -1,3 +1,4 @@
-oci-validate-examples
code-of-conduct.md
oci-image-tool
+oci-validate-examples
+output
View
@@ -0,0 +1,14 @@
+// Copyright 2016 The Linux Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
View
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+ret=0
+
+for file in $(find . -type f -iname '*.go' ! -path './vendor/*'); do
+ (head -n3 "${file}" | grep -Eq "(Copyright|generated|GENERATED)") || (echo -e "${file}:missing license header" && ret=1)
+done
+
+exit $ret
View
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+if [ ! $(command -v gometalinter) ]; then
+ go get github.com/alecthomas/gometalinter
+ gometalinter --update --install
+fi
+
+for d in $(find . -type d -not -iwholename '*.git*' -a -not -iname '.tool'); do
+ gometalinter \
+ --exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \
+ --exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
+ --exclude='duplicate of.*_test.go.*\(dupl\)$' \
+ --exclude='schema/fs.go' \
+ --disable=aligncheck \
+ --disable=gotype \
+ --cyclo-over=20 \
+ --tests \
+ --deadline=10s "${d}"
+done
View
@@ -18,5 +18,6 @@ install: true
script:
- git-validation -run DCO,short-subject -v -range ${TRAVIS_COMMIT_RANGE}
- make lint
+ - make check-license
- make test
- make oci-image-tool
View
@@ -64,8 +64,17 @@ oci-validate-examples: cmd/oci-validate-examples/main.go
oci-image-tool:
go build ./cmd/oci-image-tool
+schema-fs:
+ @echo "generating schema fs"
+ @cd schema && echo -e "$$(cat ../.header)\n\n$$(go generate)" > fs.go
+
+check-license:
+ @echo "checking license headers"
+ @./.tool/check-license
+
lint:
- for d in $(shell find . -type d -not -iwholename '*.git*'); do echo "$${d}" && ./lint "$${d}"; done
+ @echo "checking lint"
+ @./.tool/lint
test:
go test -race ./...
@@ -78,6 +87,7 @@ media-types.png: media-types.dot
.PHONY: \
validate-examples \
oci-image-tool \
+ check-license \
lint \
docs \
test
@@ -1,3 +1,17 @@
+// Copyright 2016 The Linux Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
@@ -1,3 +1,17 @@
+// Copyright 2016 The Linux Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
package main
import (
View
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-
-set -o errexit
-set -o nounset
-set -o pipefail
-
-if [ ! $(command -v gometalinter) ]
-then
- go get github.com/alecthomas/gometalinter
- gometalinter --update --install
-fi
-
-gometalinter \
- --exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \
- --exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \
- --exclude='duplicate of.*_test.go.*\(dupl\)$' \
- --exclude='schema/fs.go' \
- --disable=aligncheck \
- --disable=gotype \
- --cyclo-over=20 \
- --tests \
- --deadline=10s "${1}"
View
@@ -1,2 +1,16 @@
+// Copyright 2016 The Linux Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
// Package schema defines the OCI image media types, schema definitions and validation functions.
package schema
Oops, something went wrong.

0 comments on commit 10e6ff7

Please sign in to comment.