From d947443781457ae3ceb411c18749e0255b100b11 Mon Sep 17 00:00:00 2001 From: Mikhail Swift Date: Mon, 12 Sep 2022 12:53:22 -0400 Subject: [PATCH] chore: linting and copyright adjustments Signed-off-by: Mikhail Swift --- .github/workflows/golangci-lint.yml | 14 ++++++++++++++ .github/workflows/release.yml | 14 ++++++++++++++ .github/workflows/verify-licence.yml | 16 +++++++++++++++- .gitlab-ci.yml | 14 ++++++++++++++ Dockerfile | 14 ++++++++++++++ archivist.resolvers.go | 14 ++++++++++++++ cmd/archivist/main.go | 2 +- cmd/archivistctl/cmd/retrieve.go | 16 +++++++++++++++- cmd/archivistctl/cmd/root.go | 14 ++++++++++++++ cmd/archivistctl/cmd/search.go | 16 +++++++++++++++- cmd/archivistctl/cmd/store.go | 18 ++++++++++++++++-- compose.yml | 14 ++++++++++++++ ent/entc.go | 14 ++++++++++++++ ent/generate.go | 14 ++++++++++++++ ent/schema/attestation.go | 14 ++++++++++++++ ent/schema/attestationcollection.go | 14 ++++++++++++++ ent/schema/dsse.go | 14 ++++++++++++++ ent/schema/payloaddigest.go | 14 ++++++++++++++ ent/schema/signature.go | 14 ++++++++++++++ ent/schema/statement.go | 14 ++++++++++++++ ent/schema/subject.go | 14 ++++++++++++++ ent/schema/subjectdigest.go | 14 ++++++++++++++ gen.go | 14 ++++++++++++++ gqlgen.yml | 14 ++++++++++++++ internal/objectstorage/filestore/file.go | 14 ++++++++++++++ internal/server/server.go | 2 +- resolver.go | 14 ++++++++++++++ 27 files changed, 357 insertions(+), 7 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4327ef98..9673de02 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + name: golangci-lint on: push: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 389fd528..2516719e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + name: release on: [push, pull_request] jobs: diff --git a/.github/workflows/verify-licence.yml b/.github/workflows/verify-licence.yml index 900da732..4b742475 100644 --- a/.github/workflows/verify-licence.yml +++ b/.github/workflows/verify-licence.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + name: Verify License on: workflow_dispatch: @@ -18,4 +32,4 @@ jobs: - name: Check license headers run: | set -e - addlicense --check -l apache -c 'The Archivist Contributors' -v * + addlicense --check -l apache -c 'The Archivist Contributors' -v ./ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9d6c91d..223165d7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + stages: - build diff --git a/Dockerfile b/Dockerfile index abbb96b2..699c4039 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + FROM golang:1.18.1-alpine AS build WORKDIR /src RUN apk update && apk add --no-cache file git diff --git a/archivist.resolvers.go b/archivist.resolvers.go index 52ee6bc0..b0ddbeea 100644 --- a/archivist.resolvers.go +++ b/archivist.resolvers.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 archivist // This file will be automatically regenerated based on the schema, any resolver implementations diff --git a/cmd/archivist/main.go b/cmd/archivist/main.go index fc85053c..535cbb34 100644 --- a/cmd/archivist/main.go +++ b/cmd/archivist/main.go @@ -97,7 +97,7 @@ func main() { log.FromContext(ctx).WithField("duration", time.Since(now)).Infof("completed phase 2: retrieve spiffe svid") grpcOptions := make([]grpc.ServerOption, 0) - if cfg.EnableSPIFFE == true { + if cfg.EnableSPIFFE { opts := initSpiffeConnection(ctx, cfg) grpcOptions = append(grpcOptions, opts...) } else { diff --git a/cmd/archivistctl/cmd/retrieve.go b/cmd/archivistctl/cmd/retrieve.go index c411c17c..cb54c083 100644 --- a/cmd/archivistctl/cmd/retrieve.go +++ b/cmd/archivistctl/cmd/retrieve.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 cmd import ( @@ -35,11 +49,11 @@ var ( var out io.Writer = os.Stdout if len(outFile) > 0 { file, err := os.Create(outFile) - defer file.Close() if err != nil { return err } + defer file.Close() out = file } diff --git a/cmd/archivistctl/cmd/root.go b/cmd/archivistctl/cmd/root.go index 15d81030..e53484b3 100644 --- a/cmd/archivistctl/cmd/root.go +++ b/cmd/archivistctl/cmd/root.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 cmd import ( diff --git a/cmd/archivistctl/cmd/search.go b/cmd/archivistctl/cmd/search.go index 1116b4c6..d1ebd641 100644 --- a/cmd/archivistctl/cmd/search.go +++ b/cmd/archivistctl/cmd/search.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 cmd import ( @@ -35,11 +49,11 @@ Digests are expected to be in the form algorithm:digest, for instance: sha256:45 }, RunE: func(cmd *cobra.Command, args []string) error { conn, err := newConn(archivistUrl) - defer conn.Close() if err != nil { return nil } + defer conn.Close() algo, digest, err := validateDigestString(args[0]) if err != nil { return err diff --git a/cmd/archivistctl/cmd/store.go b/cmd/archivistctl/cmd/store.go index 177c9773..8d56ac96 100644 --- a/cmd/archivistctl/cmd/store.go +++ b/cmd/archivistctl/cmd/store.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 cmd import ( @@ -21,11 +35,11 @@ var ( Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { conn, err := newConn(archivistUrl) - defer conn.Close() if err != nil { return err } + defer conn.Close() for _, filePath := range args { if gitoid, err := storeAttestationByPath(cmd.Context(), archivist.NewCollectorClient(conn), filePath); err != nil { return fmt.Errorf("failed to store %s: %w", filePath, err) @@ -45,11 +59,11 @@ func init() { func storeAttestationByPath(ctx context.Context, client archivist.CollectorClient, path string) (string, error) { file, err := os.Open(path) - defer file.Close() if err != nil { return "", err } + defer file.Close() return storeAttestation(ctx, client, file) } diff --git a/compose.yml b/compose.yml index 4857dbe3..a51227fc 100644 --- a/compose.yml +++ b/compose.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + version: '3.9' services: diff --git a/ent/entc.go b/ent/entc.go index 78742777..552fbc4e 100644 --- a/ent/entc.go +++ b/ent/entc.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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. + //go:build ignore // +build ignore diff --git a/ent/generate.go b/ent/generate.go index e55842a5..79e584dd 100644 --- a/ent/generate.go +++ b/ent/generate.go @@ -1 +1,15 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 ent diff --git a/ent/schema/attestation.go b/ent/schema/attestation.go index feb6969b..295c9739 100644 --- a/ent/schema/attestation.go +++ b/ent/schema/attestation.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/attestationcollection.go b/ent/schema/attestationcollection.go index edf2dd92..ba61074c 100644 --- a/ent/schema/attestationcollection.go +++ b/ent/schema/attestationcollection.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/dsse.go b/ent/schema/dsse.go index 7df7fd54..a8d14648 100644 --- a/ent/schema/dsse.go +++ b/ent/schema/dsse.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/payloaddigest.go b/ent/schema/payloaddigest.go index f6e23953..7086f8a1 100644 --- a/ent/schema/payloaddigest.go +++ b/ent/schema/payloaddigest.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/signature.go b/ent/schema/signature.go index 287a7f70..9936a2f6 100644 --- a/ent/schema/signature.go +++ b/ent/schema/signature.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/statement.go b/ent/schema/statement.go index 099d61ff..5ead652b 100644 --- a/ent/schema/statement.go +++ b/ent/schema/statement.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/subject.go b/ent/schema/subject.go index a9cb215c..0d440c8c 100644 --- a/ent/schema/subject.go +++ b/ent/schema/subject.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/ent/schema/subjectdigest.go b/ent/schema/subjectdigest.go index 04602c26..601250f5 100644 --- a/ent/schema/subjectdigest.go +++ b/ent/schema/subjectdigest.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 import ( diff --git a/gen.go b/gen.go index 25a1567e..58a66f00 100644 --- a/gen.go +++ b/gen.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 archivist //go:generate /bin/sh -c "cd ent && go run -mod=mod ./entc.go" diff --git a/gqlgen.yml b/gqlgen.yml index 6b6cc2fe..946bfac1 100644 --- a/gqlgen.yml +++ b/gqlgen.yml @@ -1,3 +1,17 @@ +# Copyright 2022 The Archivist Contributors +# +# 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. + schema: - archivist.graphql # filters generated by gengql diff --git a/internal/objectstorage/filestore/file.go b/internal/objectstorage/filestore/file.go index 13cadea9..60284d97 100644 --- a/internal/objectstorage/filestore/file.go +++ b/internal/objectstorage/filestore/file.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 filestore import ( diff --git a/internal/server/server.go b/internal/server/server.go index 7e7ae95e..08263ddf 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -147,11 +147,11 @@ func (s *collectorServer) Get(request *archivist.GetRequest, server archivist.Co } objReader, err := s.objectStore.Get(server.Context(), request) - defer objReader.Close() if err != nil { return err } + defer objReader.Close() chunk := &archivist.Chunk{} buf := make([]byte, ChunkSize) r := bufio.NewReaderSize(objReader, ChunkSize) diff --git a/resolver.go b/resolver.go index 6b39f088..2aaaceff 100644 --- a/resolver.go +++ b/resolver.go @@ -1,3 +1,17 @@ +// Copyright 2022 The Archivist Contributors +// +// 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 archivist // This file will not be regenerated automatically.