Skip to content

Commit ebef24a

Browse files
yevgenypatspull[bot]
authored andcommitted
feat(github): Migrate codegen to transformations (#6428)
#### Summary <!-- Explain what problem this PR addresses --> <!--
1 parent 9815c59 commit ebef24a

51 files changed

Lines changed: 112 additions & 3341 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

plugins/source/github/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ gen-docs:
2626
lint:
2727
golangci-lint run --config ../../.golangci.yml
2828

29-
.PHONY: gen-code
30-
gen-code:
31-
go run codegen/main.go
32-
3329
# All gen targets
3430
.PHONY: gen
35-
gen: gen-code gen-mocks gen-docs
31+
gen: gen-mocks gen-docs
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package client
2+
3+
import (
4+
"reflect"
5+
6+
"github.com/cloudquery/plugin-sdk/schema"
7+
"github.com/cloudquery/plugin-sdk/transformers"
8+
"github.com/google/go-github/v48/github"
9+
)
10+
11+
func SharedTransformers() []transformers.StructTransformerOption {
12+
return []transformers.StructTransformerOption{
13+
transformers.WithUnwrapAllEmbeddedStructs(),
14+
transformers.WithUnwrapStructFields("Spec", "Status"),
15+
transformers.WithTypeTransformer(typeTransformer),
16+
}
17+
}
18+
19+
func typeTransformer(field reflect.StructField) (schema.ValueType, error) {
20+
timestamp := github.Timestamp{}
21+
switch field.Type {
22+
case reflect.TypeOf(timestamp), reflect.TypeOf(&timestamp):
23+
return schema.TypeTimestamp, nil
24+
default:
25+
return schema.TypeInvalid, nil
26+
}
27+
}

plugins/source/github/codegen/main.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

plugins/source/github/codegen/recipes/actions.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

plugins/source/github/codegen/recipes/base.go

Lines changed: 0 additions & 117 deletions
This file was deleted.

plugins/source/github/codegen/recipes/billing.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

plugins/source/github/codegen/recipes/columns.go

Lines changed: 0 additions & 16 deletions
This file was deleted.

plugins/source/github/codegen/recipes/dependabot.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

plugins/source/github/codegen/recipes/external.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

plugins/source/github/codegen/recipes/hooks.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)