summaryrefslogtreecommitdiff
path: root/generator
diff options
context:
space:
mode:
authorChristoph Blecker <admin@toph.ca>2017-10-24 17:54:29 -0700
committerChristoph Blecker <admin@toph.ca>2017-10-24 23:12:43 -0700
commitc08c4ae2f9c36cd4187b2c03cd0c06c8f310f9d0 (patch)
tree1624e03b3fd198d6a2794807270dd70b1ba5e841 /generator
parent762e5d4e5aa17487a0e04ab28ba04572b3f263d9 (diff)
Don't use docker by default for sig docs generator
Diffstat (limited to 'generator')
-rw-r--r--generator/Dockerfile7
-rw-r--r--generator/README.md8
-rw-r--r--generator/app.go25
-rw-r--r--generator/app_test.go26
-rw-r--r--generator/header.tmpl2
5 files changed, 39 insertions, 29 deletions
diff --git a/generator/Dockerfile b/generator/Dockerfile
deleted file mode 100644
index deffa8a9..00000000
--- a/generator/Dockerfile
+++ /dev/null
@@ -1,7 +0,0 @@
-FROM golang:1.8
-
-WORKDIR /go/src/app
-COPY . .
-
-RUN go-wrapper download
-RUN go-wrapper install
diff --git a/generator/README.md b/generator/README.md
index edef37b8..175d7c8f 100644
--- a/generator/README.md
+++ b/generator/README.md
@@ -24,14 +24,14 @@ sig-list.md
## How to use
-To (re)build documentation for all the SIGs, run these commands:
+To (re)build documentation for all the SIGs in a go environment, run:
```bash
-make
+make generate
```
-or
+or to run this inside a docker container:
```bash
-make generate
+make generate-dockerized
```
To build docs for one SIG, run one of these commands:
diff --git a/generator/app.go b/generator/app.go
index 445a3af9..2aaced3f 100644
--- a/generator/app.go
+++ b/generator/app.go
@@ -29,7 +29,7 @@ import (
"gopkg.in/yaml.v2"
)
-var (
+const (
readmeTemplate = "readme.tmpl"
listTemplate = "list.tmpl"
headerTemplate = "header.tmpl"
@@ -37,11 +37,16 @@ var (
sigsYamlFile = "sigs.yaml"
sigListOutput = "sig-list.md"
indexFilename = "README.md"
- baseOutputDir = "generated"
+
+ beginMarker = "<!-- BEGIN CUSTOM CONTENT -->"
+ endMarker = "<!-- END CUSTOM CONTENT -->"
+)
+
+var (
+ baseGeneratorDir = ""
+ templateDir = "generator"
githubTeamNames = []string{"misc", "test-failures", "bugs", "feature-requests", "proposals", "pr-reviews", "api-reviews"}
- beginMarker = "<!-- BEGIN CUSTOM CONTENT -->"
- endMarker = "<!-- END CUSTOM CONTENT -->"
)
// Lead represents a lead engineer for a particular group. There are usually
@@ -150,7 +155,7 @@ func getExistingContent(path string) (string, error) {
func writeTemplate(templatePath, outputPath string, data interface{}) error {
// set up template
- t, err := template.ParseFiles(templatePath, headerTemplate)
+ t, err := template.ParseFiles(templatePath, filepath.Join(baseGeneratorDir, templateDir, headerTemplate))
if err != nil {
return err
}
@@ -215,7 +220,7 @@ func createGroupReadme(groups []Group, prefix string) error {
fmt.Printf("Generating %s/README.md\n", group.Dir)
- outputDir := filepath.Join(baseOutputDir, group.Dir)
+ outputDir := filepath.Join(baseGeneratorDir, group.Dir)
if err := createDirIfNotExists(outputDir); err != nil {
return err
}
@@ -223,7 +228,7 @@ func createGroupReadme(groups []Group, prefix string) error {
group.SetupGitHubTeams(prefix)
outputPath := filepath.Join(outputDir, indexFilename)
- readmePath := fmt.Sprintf("%s_%s", prefix, readmeTemplate)
+ readmePath := filepath.Join(baseGeneratorDir, templateDir, fmt.Sprintf("%s_%s", prefix, readmeTemplate))
if err := writeTemplate(readmePath, outputPath, group); err != nil {
return err
}
@@ -233,7 +238,7 @@ func createGroupReadme(groups []Group, prefix string) error {
}
func main() {
- yamlData, err := ioutil.ReadFile(filepath.Join(baseOutputDir, sigsYamlFile))
+ yamlData, err := ioutil.ReadFile(filepath.Join(baseGeneratorDir, sigsYamlFile))
if err != nil {
log.Fatal(err)
}
@@ -263,8 +268,8 @@ func main() {
}
fmt.Println("Generating sig-list.md")
- outputPath := filepath.Join(baseOutputDir, sigListOutput)
- err = writeTemplate(listTemplate, outputPath, ctx)
+ outputPath := filepath.Join(baseGeneratorDir, sigListOutput)
+ err = writeTemplate(filepath.Join(baseGeneratorDir, templateDir, listTemplate), outputPath, ctx)
if err != nil {
log.Fatal(err)
}
diff --git a/generator/app_test.go b/generator/app_test.go
index c71471c7..b282a3f2 100644
--- a/generator/app_test.go
+++ b/generator/app_test.go
@@ -83,6 +83,9 @@ func TestGetExistingData(t *testing.T) {
}
func TestWriteTemplate(t *testing.T) {
+ baseGeneratorDir = "generated"
+ templateDir = "../../generator"
+
customContent := `
<!-- BEGIN CUSTOM CONTENT -->
Example
@@ -176,9 +179,12 @@ func TestCustomPrefixSetupGithubTeams(t *testing.T) {
}
func TestCreateGroupReadmes(t *testing.T) {
+ baseGeneratorDir = "generated"
+ templateDir = "../../generator"
+
groups := []Group{
- Group{Name: "Foo"},
- Group{Name: "Bar"},
+ {Name: "Foo"},
+ {Name: "Bar"},
}
err := createGroupReadme(groups, "sig")
@@ -187,7 +193,7 @@ func TestCreateGroupReadmes(t *testing.T) {
}
for _, group := range groups {
- path := filepath.Join(baseOutputDir, group.DirName("sig"), "README.md")
+ path := filepath.Join(baseGeneratorDir, group.DirName("sig"), "README.md")
if !pathExists(path) {
t.Fatalf("%s should exist", path)
}
@@ -195,11 +201,14 @@ func TestCreateGroupReadmes(t *testing.T) {
}
func TestReadmesAreSkipped(t *testing.T) {
+ baseGeneratorDir = "generated"
+ templateDir = "../../generator"
+
os.Setenv("SIG", "sig-foo")
groups := []Group{
- Group{Name: "Foo"},
- Group{Name: "Bar"},
+ {Name: "Foo"},
+ {Name: "Bar"},
}
err := createGroupReadme(groups, "sig")
@@ -208,7 +217,7 @@ func TestReadmesAreSkipped(t *testing.T) {
}
for _, group := range groups[1:] {
- path := filepath.Join(baseOutputDir, group.DirName("sig"), "README.md")
+ path := filepath.Join(baseGeneratorDir, group.DirName("sig"), "README.md")
if !pathExists(path) {
t.Fatalf("%s should exist", path)
}
@@ -232,6 +241,9 @@ func copyFile(src, dst string) error {
}
func TestFullGeneration(t *testing.T) {
+ baseGeneratorDir = "generated"
+ templateDir = "../../generator"
+
err := copyFile("testdata/sigs.yaml", "generated/sigs.yaml")
if err != nil {
t.Fatalf("Error received: %v", err)
@@ -241,7 +253,7 @@ func TestFullGeneration(t *testing.T) {
expectedDirs := []string{"sig-foo", "sig-bar", "wg-baz"}
for _, ed := range expectedDirs {
- path := filepath.Join(baseOutputDir, ed, "README.md")
+ path := filepath.Join(baseGeneratorDir, ed, "README.md")
if !pathExists(path) {
t.Fatalf("%s should exist", path)
}
diff --git a/generator/header.tmpl b/generator/header.tmpl
index 9f53887a..c84f4b7b 100644
--- a/generator/header.tmpl
+++ b/generator/header.tmpl
@@ -5,6 +5,6 @@ This is an autogenerated file!
Please do not edit this file directly, but instead make changes to the
sigs.yaml file in the project root.
-To understand how this file is generated, see generator/README.md.
+To understand how this file is generated, see https://git.k8s.io/community/generator/README.md
-->
{{- end -}}