Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 0ae16c9

Browse files
author
Christopher Hein
authored
Merge pull request #96 from christopherhein/chore/94-codegen
Adding Code Gen Into The Project Again
2 parents 26dc13b + 14e2679 commit 0ae16c9

File tree

396 files changed

+196130
-2
lines changed

Some content is hidden

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

396 files changed

+196130
-2
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ tag:
2020

2121
.PHONY: install-aws-codegen
2222
install-aws-codegen:
23-
go get -u github.com/christopherhein/aws-operator-codegen
23+
go install -ldflags "-X main.commit=$(commitSHA) -X main.date=$(dateStr)" ./code-generation/cmd/aws-service-operator-codegen
2424

2525
.PHONY: aws-codegen
2626
aws-codegen:
27-
aws-operator-codegen process
27+
aws-service-operator-codegen process
2828

2929
.PHONY: k8s-codegen
3030
k8s-codegen:

code-generation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/aws-service-operator-codegen

code-generation/Gopkg.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

code-generation/Gopkg.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Gopkg.toml example
2+
#
3+
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
4+
# for detailed Gopkg.toml documentation.
5+
#
6+
# required = ["github.com/user/thing/cmd/thing"]
7+
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8+
#
9+
# [[constraint]]
10+
# name = "github.com/user/project"
11+
# version = "1.0.0"
12+
#
13+
# [[constraint]]
14+
# name = "github.com/user/project2"
15+
# branch = "dev"
16+
# source = "github.com/myfork/project2"
17+
#
18+
# [[override]]
19+
# name = "github.com/x/y"
20+
# version = "2.4.0"
21+
#
22+
# [prune]
23+
# non-go = false
24+
# go-tests = true
25+
# unused-packages = true
26+
27+
28+
[prune]
29+
go-tests = true
30+
unused-packages = true

code-generation/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
commitSHA := $(shell git describe --dirty --always)
2+
dateStr := $(shell date +%s)
3+
4+
.PHONY: build
5+
build:
6+
go build -ldflags "-X main.commit=$(commitSHA) -X main.date=$(dateStr)" ./cmd/aws-service-operator-codegen
7+
8+
.PHONY: install-bindata
9+
install-bindata:
10+
go get -u github.com/jteeuwen/go-bindata/...
11+
12+
.PHONY: update-bindata
13+
update-bindata:
14+
go generate ./pkg/codegen/
15+
16+
.PHONY: rebuild
17+
rebuild: update-bindata build
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
"os"
7+
)
8+
9+
var (
10+
// rootCmd represents the base command when called without any subcommands
11+
rootCmd = &cobra.Command{
12+
Use: "aws-operator-codegen",
13+
Short: "Processes AWS Operator Model files and outputs codegened operators",
14+
Long: `TODO WRITE THIS`,
15+
Run: func(c *cobra.Command, _ []string) {
16+
c.Help()
17+
},
18+
}
19+
)
20+
21+
func main() {
22+
if err := rootCmd.Execute(); err != nil {
23+
fmt.Println(err)
24+
os.Exit(1)
25+
}
26+
}
27+
28+
func init() {
29+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package main
2+
3+
import (
4+
"github.com/christopherhein/aws-operator/code-generation/pkg/codegen"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
var modelPath, rootPath string
9+
10+
var processCmd = &cobra.Command{
11+
Use: "process",
12+
Short: "Process the operator code based on the models files",
13+
Long: ``,
14+
Run: func(cmd *cobra.Command, args []string) {
15+
generation := codegen.New(modelPath, rootPath)
16+
generation.Run()
17+
return
18+
},
19+
}
20+
21+
func init() {
22+
processCmd.Flags().StringVar(&modelPath, "model-path", "models/", "Model path used for regenerating the codebase")
23+
processCmd.Flags().StringVar(&rootPath, "root-path", "./", "Root path used for regenerating the codebase")
24+
rootCmd.AddCommand(processCmd)
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
goVersion "github.com/christopherhein/go-version"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
var (
10+
shortened = false
11+
version = "dev"
12+
commit = "none"
13+
date = "unknown"
14+
versionCmd = &cobra.Command{
15+
Use: "version",
16+
Short: "Version will output the current aws-operator build information",
17+
Long: ``,
18+
Run: func(_ *cobra.Command, _ []string) {
19+
var response string
20+
versionOutput := goVersion.New(version, commit, date)
21+
22+
if shortened {
23+
response = versionOutput.ToShortened()
24+
} else {
25+
response = versionOutput.ToJSON()
26+
}
27+
fmt.Printf("%+v", response)
28+
return
29+
},
30+
}
31+
)
32+
33+
func init() {
34+
versionCmd.Flags().BoolVarP(&shortened, "short", "s", false, "Use shortened output for version information.")
35+
rootCmd.AddCommand(versionCmd)
36+
}

0 commit comments

Comments
 (0)