Skip to content

Commit

Permalink
feat: scaffold when lincense type none
Browse files Browse the repository at this point in the history
feat: change the binaryPath when update tutorial

fix: revert const name
  • Loading branch information
yyy1000 committed May 7, 2023
1 parent 8217db9 commit 4324550
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
41 changes: 24 additions & 17 deletions pkg/plugins/golang/v4/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,33 @@ func (s *initScaffolder) Scaffold() error {
machinery.WithConfig(s.config),
)

bpFile := &hack.Boilerplate{
License: s.license,
Owner: s.owner,
}
bpFile.Path = s.boilerplatePath
if err := scaffold.Execute(bpFile); err != nil {
return err
}
if s.license != "none" {
bpFile := &hack.Boilerplate{
License: s.license,
Owner: s.owner,
}
bpFile.Path = s.boilerplatePath
if err := scaffold.Execute(bpFile); err != nil {
return err
}

boilerplate, err := afero.ReadFile(s.fs.FS, s.boilerplatePath)
if err != nil {
return err
boilerplate, err := afero.ReadFile(s.fs.FS, s.boilerplatePath)
if err != nil {
return err
}
// Initialize the machinery.Scaffold that will write the files to disk
scaffold = machinery.NewScaffold(s.fs,
machinery.WithConfig(s.config),
machinery.WithBoilerplate(string(boilerplate)),
)
} else {
s.boilerplatePath = ""
// Initialize the machinery.Scaffold without boilerplate
scaffold = machinery.NewScaffold(s.fs,
machinery.WithConfig(s.config),
)
}

// Initialize the machinery.Scaffold that will write the files to disk
scaffold = machinery.NewScaffold(s.fs,
machinery.WithConfig(s.config),
machinery.WithBoilerplate(string(boilerplate)),
)

// If the KustomizeV2 was used to do the scaffold then
// we need to ensure that we use its supported Kustomize Version
// in order to support it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
{{ if .BoilerplatePath -}}
$(CONTROLLER_GEN) object:headerFile={{printf "%q" .BoilerplatePath}} paths="./..."
{{- else -}}
$(CONTROLLER_GEN) object paths="./..."
{{- end }}
.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down

0 comments on commit 4324550

Please sign in to comment.