add automated copyright header check (#1696)

Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
This commit is contained in:
Oleksandr Levchenkov 2024-06-03 16:49:36 +03:00 committed by GitHub
parent ab9c995064
commit 5a161c8bcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
85 changed files with 306 additions and 55 deletions

View File

@ -13,6 +13,9 @@ project {
# files or folders should be ignored
header_ignore = [
"**/*.tf",
"**/*.tftest.hcl",
"testing/equivalence-tests/**/.terraform.lock.hcl",
"website/docs/**/examples/**",
"**/testdata/**",
"**/*.pb.go",
"**/*_string.go",

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package main
import (

View File

@ -214,6 +214,14 @@ jobs:
with:
version: v1.58
only-new-issues: true
- name: "Copyright headers"
run: |
go run github.com/hashicorp/copywrite headers --plan
if [[ $? != 0 ]]; then
echo >&2 "ERROR: some files are missing required copyright headers. Run `scripts/add-copyright-headers.sh` locally and then commit the updated files."
exit 1
fi
license-checks:
name: "License Checks"

View File

@ -1,3 +1,8 @@
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
run:
timeout: 30m

View File

@ -1,15 +0,0 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build tools
// +build tools
package main
import (
_ "github.com/hashicorp/copywrite"
)
//go:generate go run github.com/hashicorp/copywrite headers

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package addrs
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package collections
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package collections_test
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package e2etest
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package e2etest
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package command
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package command
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package hcl2shim
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package configs
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aws_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package keyprovider
import "fmt"

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package gcp_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package gcp_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package gcp_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package gcp_kms
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package openbao
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package openbao
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package openbao
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package openbao
import "github.com/opentofu/opentofu/internal/encryption/keyprovider"

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package openbao
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package keyprovider
import "github.com/zclconf/go-cty/cty"

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm_test
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm_test
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm_test
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm
import "fmt"

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package aesgcm
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package method
import "fmt"

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package unencrypted
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package blocktoattr
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package convert
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package convert
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tofu
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tofu
import (

View File

@ -1,3 +1,8 @@
// Copyright (c) The OpenTofu Authors
// SPDX-License-Identifier: MPL-2.0
// Copyright (c) 2023 HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package tofu
import (

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
go run github.com/hashicorp/copywrite headers

View File

@ -13,6 +13,7 @@ package tools
// Go toolchain to see that we need to include them in go.mod and go.sum.
import (
_ "github.com/hashicorp/copywrite"
_ "github.com/nishanths/exhaustive/cmd/exhaustive"
_ "golang.org/x/tools/cmd/stringer"
_ "honnef.co/go/tools/cmd/staticcheck"

View File

@ -33,3 +33,7 @@ To update the sidebar navigation, you must edit the appropriate `nav-data.json`
Currently, you can preview your changes through the [opentofu/opentofu.org](https://github.com/opentofu/opentofu.org/blob/main/README.md) repository.
Follow the [Getting Started](https://github.com/opentofu/opentofu.org/blob/main/README.md#getting-started) guide.
## Copyright headers for code examples
In order to not include copyright headers for code examples used in docs, please, add the files under `examples` folder. This way, it will be ignored on automated copyright headers check.

View File

@ -1,2 +0,0 @@
Please do not add license headers and end-of-file line breaks to the examples in this folder.
They are embedded in the website, and it makes for really hard reading to have license headers 5-6 times in a page.

View File

@ -8,8 +8,8 @@ description: |-
import CodeBlock from '@theme/CodeBlock';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import ApkConvenienceScript from '!!raw-loader!./alpine-convenience.sh'
import ApkManualScript from '!!raw-loader!./alpine-manual.sh'
import ApkConvenienceScript from '!!raw-loader!./examples/alpine-convenience.sh'
import ApkManualScript from '!!raw-loader!./examples/alpine-manual.sh'
# Installing OpenTofu on Alpine Linux

View File

@ -1,13 +1,18 @@
#!/bin/sh
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
set -e
apk add curl
if [ "$1" = "--convenience" ]; then
sh -x alpine-convenience.sh
sh -x examples/alpine-convenience.sh
else
sh -x alpine-manual.sh
sh -x examples/alpine-manual.sh
fi
tofu --version

View File

@ -1,4 +1,9 @@
#!/bin/bash
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
set -ex
@ -10,6 +15,6 @@ apt-get install -y curl git build-essential gcc procps curl file
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /root/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
bash -x brew-install.sh
bash -x examples/brew-install.sh
tofu --version

View File

@ -8,8 +8,8 @@ description: |-
import CodeBlock from '@theme/CodeBlock';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import ApkConvenienceScript from '!!raw-loader!./alpine-convenience.sh'
import ApkManualScript from '!!raw-loader!./alpine-manual.sh'
import ApkConvenienceScript from '!!raw-loader!./examples/alpine-convenience.sh'
import ApkManualScript from '!!raw-loader!./examples/alpine-manual.sh'
# Installing OpenTofu on FreeBSD

View File

@ -6,11 +6,11 @@ description: |-
---
import CodeBlock from '@theme/CodeBlock';
import DebConvenienceScript from '!!raw-loader!./deb-convenience.sh'
import DebStep1Script from '!!raw-loader!./deb-step1.sh'
import DebStep2Script from '!!raw-loader!./deb-step2.sh'
import DebStep3Script from '!!raw-loader!./deb-step3.sh'
import DebStep4Script from '!!raw-loader!./deb-step4.sh'
import DebConvenienceScript from '!!raw-loader!./examples/deb-convenience.sh'
import DebStep1Script from '!!raw-loader!./examples/deb-step1.sh'
import DebStep2Script from '!!raw-loader!./examples/deb-step2.sh'
import DebStep3Script from '!!raw-loader!./examples/deb-step3.sh'
import DebStep4Script from '!!raw-loader!./examples/deb-step4.sh'
import Buildkite from './buildkite'
# Installing OpenTofu on .deb-based Linux (Debian, Ubuntu, etc.)

View File

@ -1,4 +1,9 @@
#!/bin/bash
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
set -e
@ -6,12 +11,12 @@ apt update
apt install -y sudo curl
if [ "$1" = "--convenience" ]; then
bash -ex deb-convenience.sh
bash -ex examples/deb-convenience.sh
else
bash -ex deb-step1.sh
bash -ex deb-step2.sh
bash -ex deb-step3.sh
bash -ex deb-step4.sh
bash -ex examples/deb-step1.sh
bash -ex examples/deb-step2.sh
bash -ex examples/deb-step3.sh
bash -ex examples/deb-step4.sh
fi
tofu --version

View File

@ -6,8 +6,8 @@ description: |-
---
import CodeBlock from '@theme/CodeBlock';
import DockerPullScript from '!!raw-loader!./docker-pull.sh'
import DockerRunScript from '!!raw-loader!./docker-run.sh'
import DockerPullScript from '!!raw-loader!./examples/docker-pull.sh'
import DockerRunScript from '!!raw-loader!./examples/docker-run.sh'
# Use OpenTofu as Docker Image

View File

@ -6,7 +6,7 @@ description: |-
---
import CodeBlock from '@theme/CodeBlock';
import BrewScript from '!!raw-loader!./brew-install.sh'
import BrewScript from '!!raw-loader!./examples/brew-install.sh'
# Installing OpenTofu via Homebrew

View File

@ -8,11 +8,11 @@ description: |-
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import RpmConvenienceScript from '!!raw-loader!./rpm-convenience.sh'
import YumRepoScript from '!!raw-loader!./repo-yum.sh'
import ZypperRepoScript from '!!raw-loader!./repo-zypper.sh'
import YumInstallScript from '!!raw-loader!./install-yum.sh'
import ZypperInstallScript from '!!raw-loader!./install-zypper.sh'
import RpmConvenienceScript from '!!raw-loader!./examples/rpm-convenience.sh'
import YumRepoScript from '!!raw-loader!./examples/repo-yum.sh'
import ZypperRepoScript from '!!raw-loader!./examples/repo-zypper.sh'
import YumInstallScript from '!!raw-loader!./examples/install-yum.sh'
import ZypperInstallScript from '!!raw-loader!./examples/install-zypper.sh'
import Buildkite from "./buildkite";
# Installing OpenTofu on RHEL, openSUSE, AlmaLinux and other RPM-based distributions

View File

@ -1,22 +1,27 @@
#!/bin/bash
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
set -e
if [ -f /usr/bin/zypper ]; then
zypper install -y sudo
if [ "$1" = "--convenience" ]; then
bash -ex rpm-convenience.sh
bash -ex examples/rpm-convenience.sh
else
bash -ex repo-zypper.sh
bash -ex install-zypper.sh
bash -ex examples/repo-zypper.sh
bash -ex examples/install-zypper.sh
fi
else
yum install -y sudo
if [ "$1" = "--convenience" ]; then
bash -ex rpm-convenience.sh
bash -ex examples/rpm-convenience.sh
else
bash -ex repo-yum.sh
bash -ex install-yum.sh
bash -ex examples/repo-yum.sh
bash -ex examples/install-yum.sh
fi
fi

View File

@ -8,13 +8,13 @@ description: |-
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import CodeBlock from '@theme/CodeBlock';
import LinuxScript from '!!raw-loader!./standalone-install.sh'
import WindowsScript from '!!raw-loader!./standalone-install.ps1'
import VerifyChecksumPS1 from '!!raw-loader!./verify-checksum.ps1'
import VerifyChecksumLinux from '!!raw-loader!./verify-checksum-linux.sh'
import VerifyChecksumMacOS from '!!raw-loader!./verify-checksum-macos.sh'
import VerifyCosignLinux from '!!raw-loader!./verify-cosign.sh'
import VerifyCosignWindows from '!!raw-loader!./verify-cosign.ps1'
import LinuxScript from '!!raw-loader!./examples/standalone-install.sh'
import WindowsScript from '!!raw-loader!./examples/standalone-install.ps1'
import VerifyChecksumPS1 from '!!raw-loader!./examples/verify-checksum.ps1'
import VerifyChecksumLinux from '!!raw-loader!./examples/verify-checksum-linux.sh'
import VerifyChecksumMacOS from '!!raw-loader!./examples/verify-checksum-macos.sh'
import VerifyCosignLinux from '!!raw-loader!./examples/verify-cosign.sh'
import VerifyCosignWindows from '!!raw-loader!./examples/verify-cosign.ps1'
import Admonition from '@theme/Admonition';
# Installing OpenTofu from GitHub Releases

View File

@ -1,4 +1,9 @@
#!/bin/bash
# Copyright (c) The OpenTofu Authors
# SPDX-License-Identifier: MPL-2.0
# Copyright (c) 2023 HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
# This script tests the installation instructions on all relevant Linux operating systems listed in docker-compose.yaml.