Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
estroz committed Aug 10, 2020
1 parent 4dd9248 commit b3dc147
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
20 changes: 20 additions & 0 deletions changelog/fragments/3-alpha-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
entries:
- description: >
Changed the `go.operator-sdk.io` plugin to only write a `plugins` PROJECT field and
run the OLM integration plugin if the project version is "3-alpha" or above.
kind: change
breaking: true
migration:
header: Upgrade your project from version "2" to "3-alpha"
body: >
The SDK's default Go plugin no longer supports OLM-related project files
nor writes a `plugins` PROJECT field for projects scaffolded previously with
`operator-sdk init --project-version=2`, Please migrate to project version "3-alpha"
for support of these features by adding the following to your `PROJECT` file:
```yaml
version: "3-alpha" # Updated from "2"
layout: go.kubebuilder.io/v2
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
```
2 changes: 1 addition & 1 deletion internal/plugins/golang/v2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Config struct{}

// hasPluginConfig returns true if cfg.Plugins contains an exact match for this plugin's key.
func hasPluginConfig(cfg *config.Config) bool {
if len(cfg.Plugins) == 0 {
if !cfg.IsV3() || len(cfg.Plugins) == 0 {
return false
}
_, hasKey := cfg.Plugins[pluginConfigKey]
Expand Down
21 changes: 11 additions & 10 deletions internal/plugins/golang/v2/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ func (p *initPlugin) Run() error {
return err
}

// Update the scaffolded Makefile with operator-sdk recipes.
// TODO: rewrite this when plugins phase 2 is implemented.
if err := initUpdateMakefile("Makefile"); err != nil {
return fmt.Errorf("error updating Makefile: %v", err)
}

// Update plugin config section with this plugin's configuration.
cfg := Config{}
if err := p.config.EncodePluginConfig(pluginConfigKey, cfg); err != nil {
return fmt.Errorf("error writing plugin config for %s: %v", pluginConfigKey, err)
// Run the Makefile updater and update plugin config section with this plugin's configuration for v3 projects.
if p.config.IsV3() {
// TODO: rewrite this when plugins phase 2 is implemented.
if err := initUpdateMakefile("Makefile"); err != nil {
return fmt.Errorf("error updating Makefile: %v", err)
}

cfg := Config{}
if err := p.config.EncodePluginConfig(pluginConfigKey, cfg); err != nil {
return fmt.Errorf("error writing plugin config for %s: %v", pluginConfigKey, err)
}
}

return nil
Expand Down

0 comments on commit b3dc147

Please sign in to comment.