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

cleanup: organize templates in the same structure that they are scaffolded #1623

Merged
merged 1 commit into from
Aug 15, 2020
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
17 changes: 10 additions & 7 deletions pkg/plugin/v3/scaffolds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import (
"sigs.k8s.io/kubebuilder/pkg/plugin/internal/machinery"
"sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/controller"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/crd"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/api"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/controller"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/crd"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/rbac"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/samples"
)

var _ scaffold.Scaffolder = &apiScaffolder{}
Expand Down Expand Up @@ -84,11 +87,11 @@ func (s *apiScaffolder) scaffold() error {

if err := machinery.NewScaffold(s.plugins...).Execute(
s.newUniverse(),
&templates.Types{},
&templates.Group{},
&templates.CRDSample{},
&templates.CRDEditorRole{},
&templates.CRDViewerRole{},
&api.Types{},
&api.Group{},
&samples.CRDSample{},
&rbac.CRDEditorRole{},
&rbac.CRDViewerRole{},
&crd.EnableWebhookPatch{},
&crd.EnableCAInjectionPatch{},
); err != nil {
Expand Down
38 changes: 20 additions & 18 deletions pkg/plugin/v3/scaffolds/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
"sigs.k8s.io/kubebuilder/pkg/plugin/internal/machinery"
"sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/certmanager"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/manager"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/metricsauth"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/prometheus"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/webhook"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/certmanager"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/hack"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/kdefault"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/manager"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/prometheus"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/rbac"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/webhook"
)

const (
Expand Down Expand Up @@ -78,7 +80,7 @@ func (s *initScaffolder) Scaffold() error {

// TODO: re-use universe created by s.newUniverse() if possible.
func (s *initScaffolder) scaffold() error {
bpFile := &templates.Boilerplate{}
bpFile := &hack.Boilerplate{}
bpFile.Path = s.boilerplatePath
bpFile.License = s.license
bpFile.Owner = s.owner
Expand All @@ -97,11 +99,11 @@ func (s *initScaffolder) scaffold() error {
return machinery.NewScaffold().Execute(
s.newUniverse(string(boilerplate)),
&templates.GitIgnore{},
&templates.AuthProxyRole{},
&templates.AuthProxyRoleBinding{},
&metricsauth.AuthProxyPatch{},
&metricsauth.AuthProxyService{},
&metricsauth.ClientClusterRole{},
&rbac.AuthProxyRole{},
&rbac.AuthProxyRoleBinding{},
&kdefault.AuthProxyPatch{},
&rbac.AuthProxyService{},
&rbac.ClientClusterRole{},
&manager.Config{Image: imageName},
&templates.Main{},
&templates.GoMod{ControllerRuntimeVersion: ControllerRuntimeVersion},
Expand All @@ -113,17 +115,17 @@ func (s *initScaffolder) scaffold() error {
},
&templates.Dockerfile{},
&templates.DockerignoreFile{},
&templates.Kustomize{},
&templates.ManagerWebhookPatch{},
&templates.ManagerRoleBinding{},
&templates.LeaderElectionRole{},
&templates.LeaderElectionRoleBinding{},
&templates.KustomizeRBAC{},
&kdefault.Kustomize{},
&kdefault.ManagerWebhookPatch{},
&rbac.ManagerRoleBinding{},
&rbac.LeaderElectionRole{},
&rbac.LeaderElectionRoleBinding{},
&rbac.KustomizeRBAC{},
&manager.Kustomization{},
&webhook.Kustomization{},
&webhook.KustomizeConfigWebhook{},
&webhook.Service{},
&webhook.InjectCAPatch{},
&kdefault.InjectCAPatch{},
&prometheus.Kustomization{},
&prometheus.ServiceMonitor{},
&certmanager.CertManager{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package api

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package api

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook
package api

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package hack

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package metricsauth
package kdefault

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook
package kdefault

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package kdefault

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package kdefault

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package metricsauth
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package metricsauth
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package rbac

import (
"path/filepath"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package templates
package samples

import (
"path/filepath"
Expand Down
4 changes: 2 additions & 2 deletions pkg/plugin/v3/scaffolds/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"sigs.k8s.io/kubebuilder/pkg/plugin/internal/machinery"
"sigs.k8s.io/kubebuilder/pkg/plugin/scaffold"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/webhook"
"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/api"
)

var _ scaffold.Scaffolder = &webhookScaffolder{}
Expand Down Expand Up @@ -80,7 +80,7 @@ You need to implement the conversion.Hub and conversion.Convertible interfaces f

if err := machinery.NewScaffold().Execute(
s.newUniverse(),
&webhook.Webhook{Defaulting: s.defaulting, Validating: s.validation},
&api.Webhook{Defaulting: s.defaulting, Validating: s.validation},
&templates.MainUpdater{WireWebhook: true},
); err != nil {
return err
Expand Down