Skip to content

Commit

Permalink
Fix Function receivers
Browse files Browse the repository at this point in the history
  • Loading branch information
theunrepentantgeek committed Jun 30, 2021
1 parent 6dcbd42 commit d2da249
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions hack/generator/pkg/functions/original_gvk_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ func NewOriginalGVKFunction(originalVersion OriginalVersionKind, idFactory astmo
}

// Name returns the name of this function, which is always OriginalGVK()
func (o OriginalGVKFunction) Name() string {
func (o *OriginalGVKFunction) Name() string {
return "OriginalGVK"
}

// RequiredPackageReferences returns the set of packages required by OriginalGVK()
func (o OriginalGVKFunction) RequiredPackageReferences() *astmodel.PackageReferenceSet {
func (o *OriginalGVKFunction) RequiredPackageReferences() *astmodel.PackageReferenceSet {
return astmodel.NewPackageReferenceSet(astmodel.APIMachinerySchemaReference)
}

// References shows that OriginalGVK() references no other generated types
func (o OriginalGVKFunction) References() astmodel.TypeNameSet {
func (o *OriginalGVKFunction) References() astmodel.TypeNameSet {
return astmodel.NewTypeNameSet()
}

// AsFunc returns the generated code for the OriginalGVK() function
func (o OriginalGVKFunction) AsFunc(
func (o *OriginalGVKFunction) AsFunc(
generationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName) *dst.FuncDecl {
gvkType := astmodel.GroupVersionKindTypeName.AsType(generationContext)
groupVersionPackageGlobal := dst.NewIdent("GroupVersion")
Expand Down Expand Up @@ -103,7 +103,7 @@ func (o OriginalGVKFunction) AsFunc(
}

// Equals returns true if the passed function is equal to us, or false otherwise
func (o OriginalGVKFunction) Equals(f astmodel.Function) bool {
func (o *OriginalGVKFunction) Equals(f astmodel.Function) bool {
_, ok := f.(*OriginalGVKFunction)
// Equality is just based on Type for now
return ok
Expand Down
12 changes: 6 additions & 6 deletions hack/generator/pkg/functions/original_version_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ func NewOriginalVersionFunction(idFactory astmodel.IdentifierFactory) *OriginalV
}

// Name returns the name of this function, which is always OriginalVersion()
func (o OriginalVersionFunction) Name() string {
func (o *OriginalVersionFunction) Name() string {
return "OriginalVersion"
}

// RequiredPackageReferences returns the set of packages required by OriginalVersion()
func (o OriginalVersionFunction) RequiredPackageReferences() *astmodel.PackageReferenceSet {
func (o *OriginalVersionFunction) RequiredPackageReferences() *astmodel.PackageReferenceSet {
return astmodel.NewPackageReferenceSet()
}

// References shows that OriginalVersion() references no other generated types
func (o OriginalVersionFunction) References() astmodel.TypeNameSet {
func (o *OriginalVersionFunction) References() astmodel.TypeNameSet {
return astmodel.NewTypeNameSet()
}

// AsFunc returns the generated code for the OriginalVersion() function
func (o OriginalVersionFunction) AsFunc(
func (o *OriginalVersionFunction) AsFunc(
generationContext *astmodel.CodeGenerationContext, receiver astmodel.TypeName) *dst.FuncDecl {
groupVersionPackageGlobal := dst.NewIdent("GroupVersion")

Expand All @@ -72,13 +72,13 @@ func (o OriginalVersionFunction) AsFunc(
}

// Equals returns true if the passed function is equal to us, or false otherwise
func (o OriginalVersionFunction) Equals(f astmodel.Function) bool {
func (o *OriginalVersionFunction) Equals(f astmodel.Function) bool {
_, ok := f.(*OriginalVersionFunction)
// Equality is just based on Type for now
return ok
}

// ReturnType indicates that this function returns a string
func (o OriginalVersionFunction) ReturnType() astmodel.Type {
func (o *OriginalVersionFunction) ReturnType() astmodel.Type {
return astmodel.StringType
}

0 comments on commit d2da249

Please sign in to comment.