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

⚠️ *: stabilize project version 3 #1901

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ func main() {
c, err := cli.New(
cli.WithCommandName("kubebuilder"),
cli.WithVersion(versionString()),
cli.WithDefaultProjectVersion(config.Version3Alpha),
cli.WithDefaultProjectVersion(config.Version3),
cli.WithPlugins(
&pluginv2.Plugin{},
&pluginv3.Plugin{},
),
cli.WithDefaultPlugins(config.Version2, &pluginv2.Plugin{}),
cli.WithDefaultPlugins(config.Version3Alpha, &pluginv3.Plugin{}),
cli.WithDefaultPlugins(config.Version3, &pluginv3.Plugin{}),
cli.WithCompletion,
)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function gen_cronjob_tutorial {
mkdir project
cd project
header_text "creating tutorial.kubebuilder.io base ..."
kubebuilder init --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder init --domain=tutorial.kubebuilder.io --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder create api --group batch --version v1 --kind CronJob --resource --controller
kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function gen_cronjob_tutorial {
mkdir project
cd project
header_text "generate base ..."
kubebuilder init --domain=tutorial.kubebuilder.io --project-version=3-alpha --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder init --domain=tutorial.kubebuilder.io --repo=tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors"
kubebuilder create api --group batch --version v1 --kind CronJob --resource --controller --make=false
kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation
kubebuilder create webhook --group batch --version v1 --kind CronJob --conversion --force
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
DefaultPath = "PROJECT"

// DefaultVersion is the version which will be used when the version flag is not provided
DefaultVersion = config.Version3Alpha
DefaultVersion = config.Version3
)

func exists(fs afero.Fs, path string) (bool, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ version: "2"
By("saving config version 3-alpha with plugin config")
cfg = Config{
Config: config.Config{
Version: config.Version3Alpha,
Version: config.Version3,
Repo: "github.com/example/project",
Domain: "example.com",
Plugins: config.PluginConfigs{
Expand Down Expand Up @@ -143,7 +143,7 @@ plugins:
- "plugin value 3"
- "plugin value 4"`
expectedConfig = config.Config{
Version: config.Version3Alpha,
Version: config.Version3,
Repo: "github.com/example/project",
Domain: "example.com",
Plugins: config.PluginConfigs{
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

// Scaffolding versions
const (
Version2 = "2"
Version3Alpha = "3-alpha"
Version2 = "2"
Version3 = "3"
)

// Config is the unmarshalled representation of the configuration file
Expand Down Expand Up @@ -75,7 +75,7 @@ func (c Config) IsV2() bool {

// IsV3 returns true if it is a v3 project
func (c Config) IsV3() bool {
return c.Version == Version3Alpha
return c.Version == Version3
}

// GetResource returns the GKV if the resource is found
Expand Down
16 changes: 8 additions & 8 deletions pkg/model/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ var _ = Describe("PluginConfig", func() {
Expect(config.EncodePluginConfig(key, pluginConfig)).NotTo(Succeed())

By("Using config version 3-alpha")
config = Config{Version: Version3Alpha}
config = Config{Version: Version3}
pluginConfig = PluginConfig{}
expectedConfig = Config{
Version: Version3Alpha,
Version: Version3,
Plugins: PluginConfigs{
"plugin-x": map[string]interface{}{
"data-1": "",
Expand All @@ -94,13 +94,13 @@ var _ = Describe("PluginConfig", func() {
Expect(config).To(Equal(expectedConfig))

By("Using config version 3-alpha with extra fields as struct")
config = Config{Version: Version3Alpha}
config = Config{Version: Version3}
pluginConfig = PluginConfig{
"plugin value 1",
"plugin value 2",
}
expectedConfig = Config{
Version: Version3Alpha,
Version: Version3,
Plugins: PluginConfigs{
"plugin-x": map[string]interface{}{
"data-1": "plugin value 1",
Expand Down Expand Up @@ -134,7 +134,7 @@ var _ = Describe("PluginConfig", func() {

By("Using empty config version 3-alpha")
config = Config{
Version: Version3Alpha,
Version: Version3,
Plugins: PluginConfigs{
"plugin-x": map[string]interface{}{},
},
Expand All @@ -145,15 +145,15 @@ var _ = Describe("PluginConfig", func() {
Expect(pluginConfig).To(Equal(expectedPluginConfig))

By("Using config version 3-alpha")
config = Config{Version: Version3Alpha}
config = Config{Version: Version3}
pluginConfig = PluginConfig{}
expectedPluginConfig = PluginConfig{}
Expect(config.DecodePluginConfig(key, &pluginConfig)).To(Succeed())
Expect(pluginConfig).To(Equal(expectedPluginConfig))

By("Using config version 3-alpha with extra fields as struct")
config = Config{
Version: Version3Alpha,
Version: Version3,
Plugins: PluginConfigs{
"plugin-x": map[string]interface{}{
"data-1": "plugin value 1",
Expand All @@ -173,7 +173,7 @@ var _ = Describe("PluginConfig", func() {
It("should Marshal and Unmarshal a plugin", func() {
By("Using config with extra fields as struct")
cfg := Config{
Version: Version3Alpha,
Version: Version3,
Plugins: PluginConfigs{
"plugin-x": map[string]interface{}{
"data-1": "plugin value 1",
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/resource/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ var _ = Describe("Resource", func() {

resource := options.NewResource(
&config.Config{
Version: config.Version3Alpha,
Version: config.Version3,
Domain: "test.io",
Repo: "test",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/golang/v2/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
const pluginName = "go" + plugins.DefaultNameQualifier

var (
supportedProjectVersions = []string{config.Version2, config.Version3Alpha}
supportedProjectVersions = []string{config.Version2, config.Version3}
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
pluginVersion = plugin.Version{Number: 2}
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/golang/v3/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
const pluginName = "go" + plugins.DefaultNameQualifier

var (
supportedProjectVersions = []string{config.Version3Alpha}
supportedProjectVersions = []string{config.Version3}
pluginVersion = plugin.Version{Number: 3}
)

Expand Down
17 changes: 8 additions & 9 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ EOF

function test_project {
local project_dir=$1
local version=$2
rm -f "$(command -v controller-gen)"
rm -f "$(command -v kustomize)"
header_text "performing tests in dir $project_dir for project version v$version"
header_text "performing tests in dir $project_dir"
cd testdata/$project_dir
make all test
cd -
Expand Down Expand Up @@ -147,14 +146,14 @@ export GO111MODULE=on
go test -race -v ./cmd/... ./pkg/... ./plugins/...

# test project v2
test_project project-v2 2
test_project project-v2-multigroup 2
test_project project-v2-addon 2
test_project project-v2
test_project project-v2-multigroup
test_project project-v2-addon

# test project v3
test_project project-v3 3-alpha
test_project project-v3-multigroup 3-alpha
test_project project-v3-addon 3-alpha
test_project project-v3-config 3-alpha
test_project project-v3
test_project project-v3-multigroup
test_project project-v3-addon
test_project project-v3-config

exit $rc
2 changes: 1 addition & 1 deletion testdata/project-v3-addon/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ resources:
group: crew
kind: Admiral
version: v1
version: 3-alpha
version: "3"
2 changes: 1 addition & 1 deletion testdata/project-v3-config/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ resources:
version: v1
webhooks:
webhookVersion: v1
version: 3-alpha
version: "3"
2 changes: 1 addition & 1 deletion testdata/project-v3-multigroup/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ resources:
version: v1
webhooks:
webhookVersion: v1
version: 3-alpha
version: "3"
2 changes: 1 addition & 1 deletion testdata/project-v3/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ resources:
version: v1
webhooks:
webhookVersion: v1
version: 3-alpha
version: "3"