Skip to content

Commit 3b8d579

Browse files
author
Eric Stroczynski
authored
[v0.19.x] internal/plugins: scaffold a vanilla go.kubebuilder.io/v2 project when --project-version=2 (#3697) (#3716)
1 parent 48929b8 commit 3b8d579

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
entries:
2+
- description: >
3+
Changed the `go.operator-sdk.io` plugin to only write a `plugins` PROJECT field and
4+
run the OLM integration plugin if the project version is "3-alpha" or above.
5+
kind: change
6+
breaking: true
7+
migration:
8+
header: Upgrade your project from version "2" to "3-alpha"
9+
body: >
10+
The SDK's default Go plugin no longer supports OLM-related project files
11+
nor writes a `plugins` PROJECT field for projects scaffolded previously with
12+
`operator-sdk init --project-version=2`, Please migrate to project version "3-alpha"
13+
for support of these features by adding the following to your `PROJECT` file:
14+
15+
```yaml
16+
version: "3-alpha" # Updated from "2"
17+
layout: go.kubebuilder.io/v2
18+
plugins:
19+
go.sdk.operatorframework.io/v2-alpha: {}
20+
```

internal/plugins/golang/v2/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Config struct{}
2121

2222
// hasPluginConfig returns true if cfg.Plugins contains an exact match for this plugin's key.
2323
func hasPluginConfig(cfg *config.Config) bool {
24-
if len(cfg.Plugins) == 0 {
24+
if !cfg.IsV3() || len(cfg.Plugins) == 0 {
2525
return false
2626
}
2727
_, hasKey := cfg.Plugins[pluginConfigKey]

internal/plugins/golang/v2/init.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ func (p *initPlugin) Run() error {
4444
return err
4545
}
4646

47-
// Update the scaffolded Makefile with operator-sdk recipes.
48-
// TODO: rewrite this when plugins phase 2 is implemented.
49-
if err := initUpdateMakefile("Makefile"); err != nil {
50-
return fmt.Errorf("error updating Makefile: %v", err)
51-
}
52-
53-
// Update plugin config section with this plugin's configuration.
54-
cfg := Config{}
55-
if err := p.config.EncodePluginConfig(pluginConfigKey, cfg); err != nil {
56-
return fmt.Errorf("error writing plugin config for %s: %v", pluginConfigKey, err)
47+
// Run the Makefile updater and update plugin config section with this plugin's configuration for v3 projects.
48+
if p.config.IsV3() {
49+
// TODO: rewrite this when plugins phase 2 is implemented.
50+
if err := initUpdateMakefile("Makefile"); err != nil {
51+
return fmt.Errorf("error updating Makefile: %v", err)
52+
}
53+
54+
cfg := Config{}
55+
if err := p.config.EncodePluginConfig(pluginConfigKey, cfg); err != nil {
56+
return fmt.Errorf("error writing plugin config for %s: %v", pluginConfigKey, err)
57+
}
5758
}
5859

5960
return nil

0 commit comments

Comments
 (0)