Skip to content

Commit

Permalink
Fix pkger integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pwittrock committed Feb 11, 2021
1 parent da11975 commit 5b5e76e
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 37 deletions.
1 change: 1 addition & 0 deletions config-gen/apis/v1alpha1/cert-generation-filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type CertFilter struct {

// Filter implements kio.Filter
func (c CertFilter) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {

if !c.Spec.Development.GenerateCert {
return input, nil
}
Expand Down
16 changes: 16 additions & 0 deletions config-gen/apis/v1alpha1/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ limitations under the License.
package v1alpha1

import (
"fmt"
"os"

"github.com/markbates/pkger"
"github.com/spf13/cobra"

// import pkged files
_ "sigs.k8s.io/kubebuilder/v3"
"sigs.k8s.io/kustomize/kyaml/fn/framework"
"sigs.k8s.io/kustomize/kyaml/kio"
)
Expand All @@ -27,6 +33,16 @@ import (
func NewCommand() *cobra.Command {
kp := &KubebuilderProject{}

// Eager check to make sure pkged templates are found.
err := pkger.Walk("/config-gen/templates/resources", func(_ string, _ os.FileInfo, err error) error {
return err
})
if err != nil {
// this shouldn't fail it it was compiled correctly
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}

return framework.TemplateCommand{
API: kp,

Expand Down
2 changes: 1 addition & 1 deletion config-gen/apis/v1alpha1/v1alpha1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1_test
import (
"testing"

"sigs.k8s.io/kubebuilder/v2/config-gen/apis/v1alpha1"
"sigs.k8s.io/kubebuilder/v3/config-gen/apis/v1alpha1"
"sigs.k8s.io/kustomize/kyaml/fn/framework/frameworktestutil"
)

Expand Down
4 changes: 2 additions & 2 deletions config-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//go:generate ./pkger.sh
//go:generate go run github.com/markbates/pkger/cmd/pkger
package main

import (
"fmt"
"os"

"github.com/spf13/cobra"
"sigs.k8s.io/kubebuilder/v2/config-gen/apis/v1alpha1"
"sigs.k8s.io/kubebuilder/v3/config-gen/apis/v1alpha1"
)

func main() {
Expand Down
12 changes: 0 additions & 12 deletions config-gen/pkged.go

This file was deleted.

7 changes: 0 additions & 7 deletions config-gen/pkger.sh

This file was deleted.

14 changes: 10 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ go 1.15

require (
github.com/cloudflare/cfssl v1.5.0
github.com/go-logr/logr v0.3.0 // indirect
github.com/gobuffalo/flect v0.2.2
github.com/markbates/pkger v0.17.1
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v1.0.0
github.com/spf13/cobra v1.1.1
github.com/spf13/pflag v1.0.5
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5
k8s.io/apimachinery v0.19.4
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
k8s.io/api v0.20.2 // indirect
k8s.io/apiextensions-apiserver v0.20.1 // indirect
k8s.io/apimachinery v0.20.2
k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 // indirect
sigs.k8s.io/controller-runtime v0.8.2
sigs.k8s.io/controller-tools v0.4.1
sigs.k8s.io/kustomize/kyaml v0.10.2
sigs.k8s.io/yaml v1.2.0
Expand Down
Loading

0 comments on commit 5b5e76e

Please sign in to comment.