Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add auto-gen for codegen scripts #47

Merged
merged 2 commits into from Feb 22, 2018
Merged

*: add auto-gen for codegen scripts #47

merged 2 commits into from Feb 22, 2018

Conversation

fanminshi
Copy link
Contributor

@fanminshi fanminshi commented Feb 22, 2018

auto-gen codegen scripts.

@fanminshi
Copy link
Contributor Author

Manual Test:

func TestCodeGen(t *testing.T) {
	buf := &bytes.Buffer{}
	if err := renderBoilerplateFile(buf, "play"); err != nil {
		t.Error(err)
		return
	}
	if err := ioutil.WriteFile("./boilerplate.go.txt", buf.Bytes(), 0744); err != nil {
		t.Error(err)
	}

	buf = &bytes.Buffer{}
	if err := renderUpdateGeneratedFile(buf, "github.com/coreos/play", "play", "v1alpha1"); err != nil {
		t.Error(err)
		return
	}
	if err := ioutil.WriteFile("./update-generated.sh", buf.Bytes(), 0744); err != nil {
		t.Error(err)
	}
}

Output:

// boilerplate.go.txt
/*
Copyright YEAR The play Authors

Commercial software license.
*/
# update-generated.sh
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

DOCKER_REPO_ROOT="/go/src/github.com/coreos/play"
IMAGE=${IMAGE:-"gcr.io/coreos-k8s-scale-testing/codegen"}

docker run --rm \
  -v "$PWD":"$DOCKER_REPO_ROOT" \
  -w "$DOCKER_REPO_ROOT" \
  "$IMAGE" \
  "/go/src/k8s.io/code-generator/generate-groups.sh"  \
  "all" \
  "github.com/coreos/play/pkg/generated" \
  "github.com/coreos/play/pkg/apis" \
  "play:v1alpha1" \
  --go-header-file "./hack/codegen/boilerplate.go.txt" \
  $@
.

@fanminshi
Copy link
Contributor Author

cc/ @hongchaodeng @hasbro17

@fanminshi fanminshi mentioned this pull request Feb 22, 2018
21 tasks
@hongchaodeng
Copy link
Contributor

LGTM

Just to make sure, this build file will not be generated at new, but at generate k8s, right?

@fanminshi
Copy link
Contributor Author

@hongchaodeng depends on how we going to run the script. we can decided that later on when to run this script.

@fanminshi fanminshi merged commit 882cb10 into operator-framework:master Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants