Skip to content

Commit

Permalink
Merge pull request #830 from jpflueger/validate-copyright-headers
Browse files Browse the repository at this point in the history
Validate copyright headers
  • Loading branch information
Justin Pflueger authored Mar 30, 2020
2 parents c57ebcf + de99987 commit 44df320
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 62 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ delete:
kubectl delete -f config/crd/bases
kustomize build config/default | kubectl delete -f -

# Validate copyright headers
validate-copyright-headers:
@./scripts/validate-copyright-headers.sh

# Generate manifests for helm and package them up
helm-chart-manifests: manifests
kustomize build ./config/default -o ./charts/azure-service-operator/templates
Expand All @@ -128,7 +132,7 @@ fmt:
go fmt ./...

# Run go vet against code
vet:
vet:
go vet ./...

# Generate code
Expand Down
8 changes: 7 additions & 1 deletion devops/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ steps:
# REQUEUE_AFTER: $(REQUEUE_AFTER)
# workingDirectory: '$(MODULE_PATH)'

- script: |
make validate-copyright-headers
continueOnError: 'false'
displayName: 'Validate Copyright Headers'
workingDirectory: '$(MODULE_PATH)'

- script: |
set -e
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0
Expand Down Expand Up @@ -136,7 +142,7 @@ steps:
REQUEUE_AFTER: $(REQUEUE_AFTER)
KUBEBUILDER_ASSETS: $(MODULE_PATH)/bin
BUILD_ID: $(Build.BuildId)
workingDirectory: '$(MODULE_PATH)'
workingDirectory: '$(MODULE_PATH)'

- task: AzureCLI@2
displayName: 'Clean up Azure Resources'
Expand Down
3 changes: 3 additions & 0 deletions pkg/helpers/rand.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// copied from github.com/Azure/open-service-broker-azure/
package helpers

Expand Down
17 changes: 2 additions & 15 deletions pkg/resourcemanager/apim/apimgmt/apimgmt.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package apimgmt

Expand Down
17 changes: 2 additions & 15 deletions pkg/resourcemanager/apim/apimgmt/apimgmt_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
/*
MIT License
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
// +build all apimgmt
package apimgmt

import (
Expand Down
17 changes: 2 additions & 15 deletions pkg/resourcemanager/apim/apimgmt/manager.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package apimgmt

Expand Down
17 changes: 2 additions & 15 deletions pkg/resourcemanager/apim/apimgmt/suite_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
*/
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

package apimgmt

Expand Down
20 changes: 20 additions & 0 deletions scripts/validate-copyright-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.

set -euo pipefail

echo "==> Checking copyright headers <=="

regx="(Copyright.*Microsoft.*Licensed.*MIT)|(generated)"
files=$(find . -type f -iname '*.go' ! -path './vendor/*' ! -path './hack/tools/*' ! -path './test/e2e/vendor/*')
licRes=$(for file in $files; do
head -4 "$file" | tr -d '\n' | grep -Eiq "$regx" || echo "$file";
done)

if [ -n "$licRes" ]; then
echo "Copyright header check failed:";
echo "${licRes}";
exit 1;
fi

0 comments on commit 44df320

Please sign in to comment.