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

🌱 Export envtest.ReadCRDFiles #3129

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions pkg/envtest/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensio
defaultCRDOptions(&options)

// Read the CRD yamls into options.CRDs
if err := readCRDFiles(&options); err != nil {
if err := ReadCRDFiles(&options); err != nil {
return nil, fmt.Errorf("unable to read CRD files: %w", err)
}

Expand All @@ -115,8 +115,8 @@ func InstallCRDs(config *rest.Config, options CRDInstallOptions) ([]*apiextensio
return options.CRDs, nil
}

// readCRDFiles reads the directories of CRDs in options.Paths and adds the CRD structs to options.CRDs.
func readCRDFiles(options *CRDInstallOptions) error {
// ReadCRDFiles reads the directories of CRDs in options.Paths and adds the CRD structs to options.CRDs.
func ReadCRDFiles(options *CRDInstallOptions) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if I should change the input paramter to only take / return exactly what is needed.

The current input parameter is a bit awkward. On the other side we have the same in WaitForCRDs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion either way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah same :)

if len(options.Paths) > 0 {
crdList, err := renderCRDs(options)
if err != nil {
Expand Down Expand Up @@ -217,7 +217,7 @@ func (p *poller) poll(ctx context.Context) (done bool, err error) {
// UninstallCRDs uninstalls a collection of CRDs by reading the crd yaml files from a directory.
func UninstallCRDs(config *rest.Config, options CRDInstallOptions) error {
// Read the CRD yamls into options.CRDs
if err := readCRDFiles(&options); err != nil {
if err := ReadCRDFiles(&options); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/envtest/crd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var _ = Describe("Test", func() {
"testdata/crdv1_original",
},
}
err := readCRDFiles(&opt)
err := ReadCRDFiles(&opt)
Expect(err).NotTo(HaveOccurred())

expectedCRDs := sets.NewString(
Expand Down
Loading