Skip to content
Merged
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
9 changes: 4 additions & 5 deletions docs/book/src/plugins/available/helm-v1-alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ under the [testdata][testdata] directory on the root directory of the Kubebuilde

### Basic Usage

The Helm plugin is attached to the `init` subcommand and the `edit` subcommand:
The Helm plugin is attached to the `edit` subcommand as the `helm/v1-alpha` plugin
relies on the Go project being scaffolded first.

```sh

# Initialize a new project with helm chart
kubebuilder init --plugins=helm/v1-alpha
# Initialize a new project
kubebuilder init

# Enable or Update the helm chart via the helm plugin to an existing project
# Before run the edit command, run `make manifests` to generate the manifest under `config/`
Expand Down Expand Up @@ -80,8 +81,6 @@ The Helm plugin implements the following subcommands:

- edit (`$ kubebuilder edit [OPTIONS]`)

- init (`$ kubebuilder init [OPTIONS]`)

## Affected files

The following scaffolds will be created or updated by this plugin:
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/optional/helm/v1alpha/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (p *editSubcommand) InjectConfig(c config.Config) error {
}

func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error {
scaffolder := scaffolds.NewInitHelmScaffolder(p.config, p.force)
scaffolder := scaffolds.NewHelmScaffolder(p.config, p.force)
scaffolder.InjectFS(fs)
err := scaffolder.Scaffold()
if err != nil {
Expand Down
59 changes: 0 additions & 59 deletions pkg/plugins/optional/helm/v1alpha/init.go

This file was deleted.

9 changes: 1 addition & 8 deletions pkg/plugins/optional/helm/v1alpha/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,10 @@ var (

// Plugin implements the plugin.Full interface
type Plugin struct {
initSubcommand
editSubcommand
}

var (
_ plugin.Init = Plugin{}
_ plugin.Edit = Plugin{}
)
var _ plugin.Edit = Plugin{}

type pluginConfig struct{}

Expand All @@ -54,9 +50,6 @@ func (Plugin) Version() plugin.Version { return pluginVersion }
// SupportedProjectVersions returns an array with all project versions supported by the plugin
func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }

// GetInitSubcommand will return the subcommand which is responsible for initializing and scaffolding helm manifests
func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }

// GetEditSubcommand will return the subcommand which is responsible for adding and/or edit a helm chart
func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,31 @@ import (
"sigs.k8s.io/kubebuilder/v4/pkg/plugins/optional/helm/v1alpha/scaffolds/internal/templates/github"
)

var _ plugins.Scaffolder = &initScaffolder{}
var _ plugins.Scaffolder = &editScaffolder{}

type initScaffolder struct {
type editScaffolder struct {
config config.Config

fs machinery.Filesystem

force bool
}

// NewInitHelmScaffolder returns a new Scaffolder for HelmPlugin
func NewInitHelmScaffolder(cfg config.Config, force bool) plugins.Scaffolder {
return &initScaffolder{
// NewHelmScaffolder returns a new Scaffolder for HelmPlugin
func NewHelmScaffolder(cfg config.Config, force bool) plugins.Scaffolder {
return &editScaffolder{
config: cfg,
force: force,
}
}

// InjectFS implements cmdutil.Scaffolder
func (s *initScaffolder) InjectFS(fs machinery.Filesystem) {
func (s *editScaffolder) InjectFS(fs machinery.Filesystem) {
s.fs = fs
}

// Scaffold scaffolds the Helm chart with the necessary files.
func (s *initScaffolder) Scaffold() error {
func (s *editScaffolder) Scaffold() error {
log.Println("Generating Helm Chart to distribute project")

imagesEnvVars := s.getDeployImagesEnvVars()
Expand Down Expand Up @@ -132,7 +132,7 @@ func (s *initScaffolder) Scaffold() error {

// getDeployImagesEnvVars will return the values to append the envvars for projects
// which has the APIs scaffolded with DeployImage plugin
func (s *initScaffolder) getDeployImagesEnvVars() map[string]string {
func (s *editScaffolder) getDeployImagesEnvVars() map[string]string {
deployImages := make(map[string]string)

pluginConfig := struct {
Expand All @@ -157,7 +157,7 @@ func (s *initScaffolder) getDeployImagesEnvVars() map[string]string {
// extractWebhooksFromGeneratedFiles parses the files generated by controller-gen under
// config/webhooks and created Mutating and Validating helper structures to
// generate the webhook manifest for the helm-chart
func (s *initScaffolder) extractWebhooksFromGeneratedFiles() (mutatingWebhooks []templateswebhooks.DataWebhook,
func (s *editScaffolder) extractWebhooksFromGeneratedFiles() (mutatingWebhooks []templateswebhooks.DataWebhook,
validatingWebhooks []templateswebhooks.DataWebhook, err error,
) {
manifestFile := "config/webhook/manifests.yaml"
Expand Down Expand Up @@ -227,7 +227,7 @@ func (s *initScaffolder) extractWebhooksFromGeneratedFiles() (mutatingWebhooks [
}

// Helper function to copy files from config/ to dist/chart/templates/
func (s *initScaffolder) copyConfigFiles() error {
func (s *editScaffolder) copyConfigFiles() error {
configDirs := []struct {
SrcDir string
DestDir string
Expand Down
Loading