Skip to content

Commit

Permalink
Incorporate strideynet feedback
Browse files Browse the repository at this point in the history
- Update copyright year.
- Wrap errors properly in `fmt.Errorf`.
  • Loading branch information
ptgott committed Jan 9, 2025
1 parent 4db59d5 commit 8354407
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.assets/tooling/cmd/resource-ref-generator/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -89,7 +89,7 @@ type GeneratorConfig struct {
// not, returns the first error it encounters.
func (c GeneratorConfig) UnmarshalYAML(value *yaml.Node) error {
if err := value.Decode(&c); err != nil {
return fmt.Errorf("could not parse the configuration file as YAML: %v\n", err)
return fmt.Errorf("parsing the configuration file as YAML: %w\n", err)
}

switch {
Expand Down Expand Up @@ -234,7 +234,7 @@ func (g GenerationError) Error() string {
func Generate(srcFS, destFS afero.Fs, conf GeneratorConfig) error {
sourceData, err := resource.NewSourceData(srcFS, conf.SourcePath)
if err != nil {
return fmt.Errorf("can't load Go source files: %v", err)
return fmt.Errorf("loading Go source files: %w", err)
}

versionKindAssignments, err := resource.VersionKindAssignments(sourceData.PossibleFuncDecls, conf.FieldAssignmentMethodName)
Expand All @@ -259,7 +259,7 @@ func Generate(srcFS, destFS afero.Fs, conf GeneratorConfig) error {
continue
}
if err != nil {
errs.messages = append(errs.messages, fmt.Errorf("issue creating a reference entry for declaration %v.%v in file %v: %v", k.PackageName, k.DeclName, decl.FilePath, err))
errs.messages = append(errs.messages, fmt.Errorf("creating a reference entry for declaration %v.%v in file %v: %w", k.PackageName, k.DeclName, decl.FilePath, err))
}

pc.Resource.ReferenceEntry = entries[k]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -110,7 +110,7 @@ func NewSourceData(fs afero.Fs, rootPath string) (SourceData, error) {
// the resulting docs page know which files to modify.
err := afero.Walk(fs, rootPath, func(currentPath string, info gofs.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("unable to load Go source due to path error: %v", err)
return fmt.Errorf("loading Go source: %w", err)
}

if info.IsDir() {
Expand Down Expand Up @@ -182,7 +182,7 @@ func NewSourceData(fs afero.Fs, rootPath string) (SourceData, error) {
return nil
})
if err != nil {
return SourceData{}, fmt.Errorf("can't load Go source files: %v", err)
return SourceData{}, fmt.Errorf("loading Go source files: %w", err)
}
return SourceData{
TypeDecls: typeDecls,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Teleport
// Copyright (C) 2023 Gravitational, Inc.
// Copyright (C) 2025 Gravitational, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
Expand Down

0 comments on commit 8354407

Please sign in to comment.