Skip to content

Commit

Permalink
Merge pull request #76 from inteon/cleanup_imports
Browse files Browse the repository at this point in the history
Prepare for cert-manager v1.15.0: cleanup imports, point to local test package
  • Loading branch information
cert-manager-prow[bot] authored Jun 4, 2024
2 parents 36161d6 + 9ba875c commit bf55968
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.22.0
require (
github.com/cert-manager/cert-manager v1.14.5
github.com/go-logr/logr v1.4.1
github.com/google/gofuzz v1.2.0
github.com/sergi/go-diff v1.3.1
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
Expand Down Expand Up @@ -83,7 +84,6 @@ require (
github.com/google/cel-go v0.17.8 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
Expand Down
12 changes: 11 additions & 1 deletion pkg/inspect/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"text/template"
"time"

apiutil "github.com/cert-manager/cert-manager/pkg/api/util"
cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"
"github.com/cert-manager/cert-manager/pkg/util/pki"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -211,12 +213,20 @@ func describeValidFor(cert *x509.Certificate) (string, error) {
URIs: printSlice(pki.URLsToString(cert.URIs)),
IPAddresses: printSlice(pki.IPAddressesToString(cert.IPAddresses)),
EmailAddresses: printSlice(cert.EmailAddresses),
KeyUsage: printKeyUsage(pki.BuildCertManagerKeyUsages(cert.KeyUsage, cert.ExtKeyUsage)),
KeyUsage: printKeyUsage(buildCertManagerKeyUsages(cert.KeyUsage, cert.ExtKeyUsage)),
})

return b.String(), err
}

func buildCertManagerKeyUsages(ku x509.KeyUsage, eku []x509.ExtKeyUsage) []cmapi.KeyUsage {
var usages []cmapi.KeyUsage
usages = append(usages, apiutil.KeyUsageStrings(ku)...)
usages = append(usages, apiutil.ExtKeyUsageStrings(eku)...)

return usages
}

func describeValidityPeriod(cert *x509.Certificate) (string, error) {
tmpl, err := template.New("validityPeriodTemplate").Parse(validityPeriodTemplate)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/framework/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,24 @@ func StartInformersAndController(t *testing.T, cmFactory cminformers.SharedInfor
}

func StartInformersAndControllers(t *testing.T, cmFactory cminformers.SharedInformerFactory, cs ...controllerpkg.Interface) StopFunc {
stopCh := make(chan struct{})
rootCtx, cancel := context.WithCancel(context.Background())
errCh := make(chan error)

cmFactory.Start(stopCh)
cmFactory.Start(rootCtx.Done())
group, _ := errgroup.WithContext(context.Background())
go func() {
defer close(errCh)
for _, c := range cs {
func(c controllerpkg.Interface) {
group.Go(func() error {
return c.Run(1, stopCh)
return c.Run(1, rootCtx.Done())
})
}(c)
}
errCh <- group.Wait()
}()
return func() {
close(stopCh)
cancel()
err := <-errCh
if err != nil {
t.Fatal(err)
Expand Down
6 changes: 3 additions & 3 deletions test/integration/migrate/ctl_upgrade_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import (
"testing"
"time"

"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/install"
v1 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
v2 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v2"
apiextinstall "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/install"
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -35,6 +32,9 @@ import (

"github.com/cert-manager/cmctl/v2/pkg/upgrade/migrateapiversion"
"github.com/cert-manager/cmctl/v2/test/integration/framework"
"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/install"
v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1"
v2 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v2"
)

// Create a test resource at a given version.
Expand Down
3 changes: 2 additions & 1 deletion test/integration/testdata/apis/testgroup/fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ limitations under the License.
package fuzzer

import (
"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
fuzz "github.com/google/gofuzz"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/utils/ptr"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
)

// Funcs returns the fuzzer functions for the apps api group.
Expand Down
7 changes: 4 additions & 3 deletions test/integration/testdata/apis/testgroup/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ limitations under the License.
package install

import (
"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
v1 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
v2 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v2"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1"
v2 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v2"
)

// Install registers the API group and adds types to a scheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package install
import (
"testing"

"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/fuzzer"
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/fuzzer"
)

func TestRoundTripTypes(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/testdata/apis/testgroup/v1/doc.go
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.
*/

// +k8s:conversion-gen=github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup
// +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta

Expand Down
3 changes: 2 additions & 1 deletion test/integration/testdata/apis/testgroup/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ limitations under the License.
package v1

import (
"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
)

// SchemeGroupVersion is group version used to register these objects
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/integration/testdata/apis/testgroup/v2/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package v2
import (
"unsafe"

"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
"k8s.io/apimachinery/pkg/conversion"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
)

func Convert_v2_TestType_To_testgroup_TestType(in *TestType, out *testgroup.TestType, s conversion.Scope) error {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/testdata/apis/testgroup/v2/doc.go
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.
*/

// +k8s:conversion-gen=github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup
// +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup
// +k8s:deepcopy-gen=package,register
// +k8s:defaulter-gen=TypeMeta

Expand Down
3 changes: 2 additions & 1 deletion test/integration/testdata/apis/testgroup/v2/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ limitations under the License.
package v2

import (
"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
)

// SchemeGroupVersion is group version used to register these objects
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ limitations under the License.
package validation

import (
"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
v1 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
admissionv1 "k8s.io/api/admission/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1"
)

func ValidateTestType(_ *admissionv1.AdmissionRequest, obj runtime.Object) (field.ErrorList, []string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"reflect"
"testing"

"github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup"
v1 "github.com/cert-manager/cert-manager/pkg/webhook/handlers/testdata/apis/testgroup/v1"
"k8s.io/apimachinery/pkg/util/validation/field"

"github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup"
v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1"
)

func TestValidateTestType(t *testing.T) {
Expand Down

0 comments on commit bf55968

Please sign in to comment.