Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix typo in controllerbuilder/ #3384

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dev/tools/controllerbuilder/pkg/codegen/generatorbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ func (f *generatedFile) Write(addCopyright bool) error {
return nil
}

func (v *generatorBase) WriteFiles(addCopyright bool) error {
for _, f := range v.generatedFiles {
func (g *generatorBase) WriteFiles(addCopyright bool) error {
for _, f := range g.generatedFiles {
if err := f.Write(addCopyright); err != nil {
return err
}
}
return nil
}

func (g *TypeGenerator) findTypeDeclaration(goTypeName string, srcDir string, skipGenerated bool) (*string, error) {
func (g *generatorBase) findTypeDeclaration(goTypeName string, srcDir string, skipGenerated bool) (*string, error) {
files, err := os.ReadDir(srcDir)
if err != nil {
if os.IsNotExist(err) { // type declaration does not exist
Expand Down Expand Up @@ -165,7 +165,7 @@ func (g *TypeGenerator) findTypeDeclaration(goTypeName string, srcDir string, sk
return nil, nil
}

func (g *TypeGenerator) findTypeDeclarationWithProtoTag(protoTag string, srcDir string, skipGenerated bool) (*string, error) {
func (g *generatorBase) findTypeDeclarationWithProtoTag(protoTag string, srcDir string, skipGenerated bool) (*string, error) {
files, err := os.ReadDir(srcDir)
if err != nil {
return nil, fmt.Errorf("reading directory %q: %w", srcDir, err)
Expand Down
8 changes: 4 additions & 4 deletions dev/tools/controllerbuilder/pkg/codegen/mappergenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func (v *MapperGenerator) GenerateMappers() error {
}
out := v.getOutputFile(k)
out.packageName = lastGoComponent(goPackage)
{

{
pbPackage := pair.ProtoGoPackage
krmPackage := pair.KRMType.GoPackage

Expand Down Expand Up @@ -236,7 +236,7 @@ func (v *MapperGenerator) writeMapFunctionsForPair(out io.Writer, srcDir string,
continue
}

if !v.fieldExistInCounterpartStruct(goType, krmFieldName) && !v.fieldExistInCounterpartStruct(goType, krmFieldName+"Ref") { // special handling for Spec and observedState structs which map to the same proto message.
if !v.fieldExistInCounterpartStruct(goType, krmFieldName) && !v.fieldExistInCounterpartStruct(goType, krmFieldName+"Ref") { // special handling for Spec and ObservedState structs which map to the same proto message.
fmt.Fprintf(out, "\t// MISSING: %s\n", krmFieldName)
}
continue
Expand Down Expand Up @@ -404,7 +404,7 @@ func (v *MapperGenerator) writeMapFunctionsForPair(out io.Writer, srcDir string,
continue
}

if !v.fieldExistInCounterpartStruct(goType, krmFieldName) && !v.fieldExistInCounterpartStruct(goType, krmFieldName+"Ref") { // special handling for spec and state structs which map to the same proto message.
if !v.fieldExistInCounterpartStruct(goType, krmFieldName) && !v.fieldExistInCounterpartStruct(goType, krmFieldName+"Ref") { // special handling for spec and observedState structs which map to the same proto message.
fmt.Fprintf(out, "\t// MISSING: %s\n", krmFieldName)
}
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (o *GenerateBasicReconcilerOptions) BindFlags(cmd *cobra.Command) {
func (o *GenerateBasicReconcilerOptions) InitDefaults() error {
root, err := options.RepoRoot()
if err != nil {
return nil
return err
}
o.APIGoPackagePath = "github.com/GoogleCloudPlatform/k8s-config-connector/apis/"
o.APIDirectory = root + "/apis/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type GenerateMapperOptions struct {
func (o *GenerateMapperOptions) InitDefaults() error {
root, err := options.RepoRoot()
if err != nil {
return nil
return err
}
o.APIGoPackagePath = "github.com/GoogleCloudPlatform/k8s-config-connector/apis/"
o.APIDirectory = root + "/apis/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r *ResourceList) Set(s string) error {
func (o *GenerateCRDOptions) InitDefaults() error {
root, err := options.RepoRoot()
if err != nil {
return nil
return err
}
o.OutputAPIDirectory = root + "/apis/"
return nil
Expand Down Expand Up @@ -168,7 +168,7 @@ func RunGenerateCRD(ctx context.Context, o *GenerateCRDOptions) error {

for _, resource := range o.Resources {
resourceProtoFullName := o.ServiceName + "." + resource.ProtoName
log.Info("visting proto", "name", resourceProtoFullName)
log.Info("visiting proto", "name", resourceProtoFullName)
if err := typeGenerator.VisitProto(resourceProtoFullName); err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type UpdateTypeOptions struct {
func (o *UpdateTypeOptions) InitDefaults() error {
root, err := options.RepoRoot()
if err != nil {
return nil
return err
}
o.apiDirectory = root + "/apis/"
o.goPackagePath = "github.com/GoogleCloudPlatform/k8s-config-connector/apis/"
Expand Down
2 changes: 1 addition & 1 deletion dev/tools/controllerbuilder/pkg/options/generateoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type GenerateOptions struct {
func (o *GenerateOptions) InitDefaults() error {
root, err := RepoRoot()
if err != nil {
return nil
return err
}
o.ProtoSourcePath = root + "/.build/googleapis.pb"
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func findGoTypesFile(directory string) (string, error) {
return "", err
}
if goTypesFile == "" {
return "", fmt.Errorf("did not found Go types file in directory %s", directory)
return "", fmt.Errorf("did not find Go types file in directory %s", directory)
}
return goTypesFile, nil
}
Expand Down
4 changes: 2 additions & 2 deletions dev/tools/controllerbuilder/scaffold/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ func FormatImports(path string, out []byte) error {
Comments: true,
AllErrors: true,
Fragment: true}
formatedOut, err := imports.Process(path, out, importOps)
formattedOut, err := imports.Process(path, out, importOps)
if err != nil {
return fmt.Errorf("format controller file %s: %w", path, err)
}
return WriteToFile(path, formatedOut)
return WriteToFile(path, formattedOut)
}

func WriteToFile(path string, out []byte) error {
Expand Down
Loading