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

Commit

Permalink
Merge pull request #96 from christopherhein/chore/94-codegen
Browse files Browse the repository at this point in the history
Adding Code Gen Into The Project Again
  • Loading branch information
Christopher Hein committed Sep 29, 2018
2 parents 26dc13b + 14e2679 commit 0ae16c9
Show file tree
Hide file tree
Showing 396 changed files with 196,130 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ tag:

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

.PHONY: aws-codegen
aws-codegen:
aws-operator-codegen process
aws-service-operator-codegen process

.PHONY: k8s-codegen
k8s-codegen:
Expand Down
1 change: 1 addition & 0 deletions code-generation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/aws-service-operator-codegen
75 changes: 75 additions & 0 deletions code-generation/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions code-generation/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[prune]
go-tests = true
unused-packages = true
17 changes: 17 additions & 0 deletions code-generation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
commitSHA := $(shell git describe --dirty --always)
dateStr := $(shell date +%s)

.PHONY: build
build:
go build -ldflags "-X main.commit=$(commitSHA) -X main.date=$(dateStr)" ./cmd/aws-service-operator-codegen

.PHONY: install-bindata
install-bindata:
go get -u github.com/jteeuwen/go-bindata/...

.PHONY: update-bindata
update-bindata:
go generate ./pkg/codegen/

.PHONY: rebuild
rebuild: update-bindata build
29 changes: 29 additions & 0 deletions code-generation/cmd/aws-service-operator-codegen/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"fmt"
"github.com/spf13/cobra"
"os"
)

var (
// rootCmd represents the base command when called without any subcommands
rootCmd = &cobra.Command{
Use: "aws-operator-codegen",
Short: "Processes AWS Operator Model files and outputs codegened operators",
Long: `TODO WRITE THIS`,
Run: func(c *cobra.Command, _ []string) {
c.Help()
},
}
)

func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func init() {
}
25 changes: 25 additions & 0 deletions code-generation/cmd/aws-service-operator-codegen/process.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"github.com/christopherhein/aws-operator/code-generation/pkg/codegen"
"github.com/spf13/cobra"
)

var modelPath, rootPath string

var processCmd = &cobra.Command{
Use: "process",
Short: "Process the operator code based on the models files",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
generation := codegen.New(modelPath, rootPath)
generation.Run()
return
},
}

func init() {
processCmd.Flags().StringVar(&modelPath, "model-path", "models/", "Model path used for regenerating the codebase")
processCmd.Flags().StringVar(&rootPath, "root-path", "./", "Root path used for regenerating the codebase")
rootCmd.AddCommand(processCmd)
}
36 changes: 36 additions & 0 deletions code-generation/cmd/aws-service-operator-codegen/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package main

import (
"fmt"
goVersion "github.com/christopherhein/go-version"
"github.com/spf13/cobra"
)

var (
shortened = false
version = "dev"
commit = "none"
date = "unknown"
versionCmd = &cobra.Command{
Use: "version",
Short: "Version will output the current aws-operator build information",
Long: ``,
Run: func(_ *cobra.Command, _ []string) {
var response string
versionOutput := goVersion.New(version, commit, date)

if shortened {
response = versionOutput.ToShortened()
} else {
response = versionOutput.ToJSON()
}
fmt.Printf("%+v", response)
return
},
}
)

func init() {
versionCmd.Flags().BoolVarP(&shortened, "short", "s", false, "Use shortened output for version information.")
rootCmd.AddCommand(versionCmd)
}
Loading

0 comments on commit 0ae16c9

Please sign in to comment.