From 4f04afb0eb7f4409ed75ac730b10357145002ba9 Mon Sep 17 00:00:00 2001 From: tstollin Date: Tue, 20 Oct 2026 13:21:15 +0200 Subject: [PATCH 1/3] chore(renovate): bundle go version updates --- renovate.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/renovate.json b/renovate.json index 7bfe947..aaf8f19 100644 --- a/renovate.json +++ b/renovate.json @@ -34,6 +34,20 @@ ], "semanticCommitType": "chore" }, + { + "description": "Update the go directive in go.mod (Renovate leaves it alone by default unless out of range)", + "matchManagers": ["gomod"], + "matchDepTypes": ["golang"], + "matchDatasources": ["golang-version"], + "rangeStrategy": "bump" + }, + { + "description": "Bundle all Go toolchain bumps (go.mod, mise.toml, Dockerfile base image) into a single PR", + "matchManagers": ["gomod", "mise", "dockerfile"], + "matchPackageNames": ["go", "golang"], + "groupName": "go", + "semanticCommitType": "build" + }, { "matchManagers": ["custom.regex"], "matchPackageNames": ["github.com/golangci/golangci-lint/v2"], From a58ade2f5c918ce76c23b6f67f54a78150036b66 Mon Sep 17 00:00:00 2001 From: tstollin Date: Tue, 20 Oct 2026 13:22:22 +0200 Subject: [PATCH 2/3] build: bump go version in go.mod to 1.27.3 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6ce70c5..7c3aa19 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/Interhyp/git-hubby -go 1.26.3 +go 1.27.3 require ( github.com/PuerkitoBio/rehttp v1.4.0 From 3b78740d854f8dd178d00611ff9e653d4cca5f9d Mon Sep 17 00:00:00 2001 From: tstollin Date: Tue, 20 Oct 2026 13:39:57 +0200 Subject: [PATCH 3/3] chore(linting): fix linting after go 1.27.3 update --- .../controller/inline_presets_crd_test.go | 3 +- .../controller/inline_rulesets_crd_test.go | 7 +- .../controller/organization_controller.go | 7 +- internal/controller/repository_controller.go | 19 +- .../controller/rulesetpreset_index_test.go | 20 +- internal/controller/test_helpers_test.go | 51 +-- .../mapper/github_actions_settings_test.go | 51 ++- internal/mapper/github_hook_mapper_test.go | 33 +- internal/mapper/github_org_mapper_test.go | 57 +--- internal/mapper/github_repo_mapper_test.go | 25 +- internal/mapper/github_team_mapper_test.go | 77 ++--- .../common/rulesets/collect_test.go | 5 +- .../common/rulesets/resolve_test.go | 3 +- internal/reconciler/executor_test.go | 126 +++----- .../orgrec/rec_actions_settings_test.go | 229 +++++--------- .../rec_code_security_configurations_test.go | 71 ++--- .../orgrec/rec_custom_properties_test.go | 13 +- internal/reconciler/orgrec/rec_org_test.go | 7 +- .../reconciler/orgrec/rec_rulesets_test.go | 7 +- internal/reconciler/orgrec/reconciler_test.go | 91 ++---- .../reconcilerfactory/factory_test.go | 289 +++++++---------- .../reporec/rec_actions_settings_test.go | 19 +- .../reporec/rec_autolinks_inline_test.go | 9 +- .../reconciler/reporec/rec_autolinks_test.go | 197 ++++-------- .../reporec/rec_custom_properties_test.go | 7 +- .../reconciler/reporec/rec_deploykeys_test.go | 7 +- internal/reconciler/reporec/rec_repo_test.go | 35 +-- .../reconciler/reporec/rec_rulesets_test.go | 11 +- .../reconciler/reporec/rec_topics_test.go | 7 +- .../reporec/rec_webhooks_inline_test.go | 15 +- .../reconciler/reporec/rec_webhooks_test.go | 293 ++++++------------ .../reconciler_finalize_archive_test.go | 7 +- .../reconciler_finalize_delete_test.go | 7 +- .../reconciler_finalize_ignore_test.go | 7 +- .../reconciler/spreading/spreading_test.go | 6 +- internal/reconciler/stop_test.go | 4 +- internal/reconciler/teamrec/multi_org_test.go | 103 ++---- .../reconciler/teamrec/rec_idpgroup_test.go | 19 +- .../reconciler/teamrec/rec_members_test.go | 39 +-- .../reconciler/teamrec/rec_refcleanup_test.go | 37 +-- .../teamrec/rec_role_assignments_test.go | 7 +- internal/reconciler/teamrec/rec_team_test.go | 7 +- .../reconciler/teamrec/reconciler_test.go | 13 +- .../v1alpha1/organization_webhook_test.go | 13 +- .../v1alpha1/repository_webhook_test.go | 19 +- 45 files changed, 701 insertions(+), 1378 deletions(-) diff --git a/internal/controller/inline_presets_crd_test.go b/internal/controller/inline_presets_crd_test.go index ced7365..f6bd3d5 100644 --- a/internal/controller/inline_presets_crd_test.go +++ b/internal/controller/inline_presets_crd_test.go @@ -6,7 +6,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" githubv1alpha1 "github.com/Interhyp/git-hubby/api/v1alpha1" ) @@ -18,7 +17,7 @@ var _ = Describe("Inline autolinks, webhooks and webhook ignores CRD validation" newRepo := func(name string, mutate func(*githubv1alpha1.RepositorySpec)) *githubv1alpha1.Repository { repo := &githubv1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, + Name: name, Namespace: namespace, Spec: githubv1alpha1.RepositorySpec{ Name: name, OrganizationRef: githubv1alpha1.OrganizationRef{Name: "some-org"}, diff --git a/internal/controller/inline_rulesets_crd_test.go b/internal/controller/inline_rulesets_crd_test.go index 3d5788e..94683fd 100644 --- a/internal/controller/inline_rulesets_crd_test.go +++ b/internal/controller/inline_rulesets_crd_test.go @@ -6,7 +6,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" githubv1alpha1 "github.com/Interhyp/git-hubby/api/v1alpha1" ) @@ -35,7 +34,7 @@ var _ = Describe("Inline rulesets CRD validation", func() { newOrg := func(name string, rulesets []githubv1alpha1.RulesetSpec) *githubv1alpha1.Organization { return &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, + Name: name, Namespace: namespace, Spec: githubv1alpha1.OrganizationSpec{ Name: name, Description: "test", @@ -48,7 +47,7 @@ var _ = Describe("Inline rulesets CRD validation", func() { newRepo := func(name string, rulesets []githubv1alpha1.RulesetSpec) *githubv1alpha1.Repository { return &githubv1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, + Name: name, Namespace: namespace, Spec: githubv1alpha1.RepositorySpec{ Name: name, OrganizationRef: githubv1alpha1.OrganizationRef{Name: "some-org"}, @@ -101,7 +100,7 @@ var _ = Describe("Inline rulesets CRD validation", func() { Context("RulesetPreset extends", func() { newPreset := func(name string, spec githubv1alpha1.RulesetSpec) *githubv1alpha1.RulesetPreset { - return &githubv1alpha1.RulesetPreset{ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, Spec: spec} + return &githubv1alpha1.RulesetPreset{Name: name, Namespace: namespace, Spec: spec} } It("accepts a preset that only sets extends and name", func() { diff --git a/internal/controller/organization_controller.go b/internal/controller/organization_controller.go index 10e7157..f1469ca 100644 --- a/internal/controller/organization_controller.go +++ b/internal/controller/organization_controller.go @@ -9,7 +9,6 @@ import ( "github.com/Interhyp/git-hubby/internal/reconciler/orgrec" "github.com/Interhyp/git-hubby/internal/reconciler/reconcilerfactory" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" @@ -120,10 +119,8 @@ func (r *OrganizationCtl) findOrganizationsForCodeSecurityConfiguration(ctx cont requests := make([]reconcile.Request, 0, len(orgList.Items)) for _, org := range orgList.Items { requests = append(requests, reconcile.Request{ - NamespacedName: types.NamespacedName{ - Name: org.Name, - Namespace: org.Namespace, - }, + Name: org.Name, + Namespace: org.Namespace, }) } diff --git a/internal/controller/repository_controller.go b/internal/controller/repository_controller.go index 2f96fcf..f6392fe 100644 --- a/internal/controller/repository_controller.go +++ b/internal/controller/repository_controller.go @@ -8,7 +8,6 @@ import ( "github.com/Interhyp/git-hubby/internal/reconciler/reconcilerfactory" "github.com/Interhyp/git-hubby/internal/reconciler/reporec" "github.com/google/go-github/v93/github" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -195,10 +194,8 @@ func (r *RepositoryCtl) findRepositoriesForWebhookPreset(ctx context.Context, ob requests := make([]reconcile.Request, 0, len(repoList.Items)) for _, repo := range repoList.Items { requests = append(requests, reconcile.Request{ - NamespacedName: types.NamespacedName{ - Name: repo.Name, - Namespace: repo.Namespace, - }, + Name: repo.Name, + Namespace: repo.Namespace, }) } @@ -217,10 +214,8 @@ func (r *RepositoryCtl) findRepositoriesForWebhookIgnorePreset(ctx context.Conte requests := make([]reconcile.Request, 0, len(repoList.Items)) for _, repo := range repoList.Items { requests = append(requests, reconcile.Request{ - NamespacedName: client.ObjectKey{ - Name: repo.Name, - Namespace: repo.Namespace, - }, + Name: repo.Name, + Namespace: repo.Namespace, }) } @@ -239,10 +234,8 @@ func (r *RepositoryCtl) findRepositoriesForAutolinksPreset(ctx context.Context, requests := make([]reconcile.Request, 0, len(repoList.Items)) for _, repo := range repoList.Items { requests = append(requests, reconcile.Request{ - NamespacedName: types.NamespacedName{ - Name: repo.Name, - Namespace: repo.Namespace, - }, + Name: repo.Name, + Namespace: repo.Namespace, }) } diff --git a/internal/controller/rulesetpreset_index_test.go b/internal/controller/rulesetpreset_index_test.go index f93ce5f..8327a09 100644 --- a/internal/controller/rulesetpreset_index_test.go +++ b/internal/controller/rulesetpreset_index_test.go @@ -6,8 +6,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -27,8 +25,8 @@ var _ = Describe("RulesetPreset watch mapping", func() { preset := func(name, extends string) *githubv1alpha1.RulesetPreset { return &githubv1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, - Spec: githubv1alpha1.RulesetSpec{Name: name, Extends: extends}, + Name: name, Namespace: namespace, + Spec: githubv1alpha1.RulesetSpec{Name: name, Extends: extends}, } } refs := func(names ...string) []corev1.LocalObjectReference { @@ -40,12 +38,12 @@ var _ = Describe("RulesetPreset watch mapping", func() { } repo := func(name string, presets []corev1.LocalObjectReference, inline ...githubv1alpha1.RulesetSpec) *githubv1alpha1.Repository { return &githubv1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, - Spec: githubv1alpha1.RepositorySpec{RulesetPresetList: presets, Rulesets: inline}, + Name: name, Namespace: namespace, + Spec: githubv1alpha1.RepositorySpec{RulesetPresetList: presets, Rulesets: inline}, } } request := func(name string) reconcile.Request { - return reconcile.Request{NamespacedName: types.NamespacedName{Name: name, Namespace: namespace}} + return reconcile.Request{Name: name, Namespace: namespace} } BeforeEach(func() { @@ -59,8 +57,8 @@ var _ = Describe("RulesetPreset watch mapping", func() { preset("cycle-a", "cycle-b"), preset("cycle-b", "cycle-a"), &githubv1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "middle-other-ns", Namespace: "other"}, - Spec: githubv1alpha1.RulesetSpec{Name: "x", Extends: "base"}, + Name: "middle-other-ns", Namespace: "other", + Spec: githubv1alpha1.RulesetSpec{Name: "x", Extends: "base"}, }, } }) @@ -107,8 +105,8 @@ var _ = Describe("RulesetPreset watch mapping", func() { repo("inline-extends-middle", nil, githubv1alpha1.RulesetSpec{Name: "i", Extends: "middle"}), repo("uses-unrelated", refs("unrelated")), &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "org", Namespace: namespace}, - Spec: githubv1alpha1.OrganizationSpec{RulesetPresetList: refs("leaf-b")}, + Name: "org", Namespace: namespace, + Spec: githubv1alpha1.OrganizationSpec{RulesetPresetList: refs("leaf-b")}, }, ) }) diff --git a/internal/controller/test_helpers_test.go b/internal/controller/test_helpers_test.go index f3a262d..a078e5b 100644 --- a/internal/controller/test_helpers_test.go +++ b/internal/controller/test_helpers_test.go @@ -12,7 +12,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/managedfields" "k8s.io/client-go/kubernetes/scheme" - ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -83,18 +82,14 @@ func CreateMockGitHubRepository() *ghclientmock.MockGitHubClientWrapper { func (te *TestEnvironment) SetupTeamTest(_ *testing.T, namespace, teamName string, teamSlug *string, organizationRefs []githubv1alpha1.OrganizationRef) *githubv1alpha1.Team { // Create namespace first ns := &corev1.Namespace{ - ObjectMeta: ctrl.ObjectMeta{ - Name: namespace, - }, + Name: namespace, } _ = te.Client.Create(te.Context, ns) // Ignore error if namespace already exists // Create the Team team := &githubv1alpha1.Team{ - ObjectMeta: ctrl.ObjectMeta{ - Name: teamName, - Namespace: namespace, - }, + Name: teamName, + Namespace: namespace, Spec: githubv1alpha1.TeamSpec{ Name: teamName, OrganizationRefs: organizationRefs, @@ -112,18 +107,14 @@ func (te *TestEnvironment) SetupTeamTest(_ *testing.T, namespace, teamName strin func (te *TestEnvironment) SetupTeamWithMembersTest(_ *testing.T, namespace, teamName, orgName string) *githubv1alpha1.Team { // Create namespace first ns := &corev1.Namespace{ - ObjectMeta: ctrl.ObjectMeta{ - Name: namespace, - }, + Name: namespace, } _ = te.Client.Create(te.Context, ns) // Ignore error if namespace already exists // Create the Team team := &githubv1alpha1.Team{ - ObjectMeta: ctrl.ObjectMeta{ - Name: teamName, - Namespace: namespace, - }, + Name: teamName, + Namespace: namespace, Spec: githubv1alpha1.TeamSpec{ Name: teamName, OrganizationRefs: []githubv1alpha1.OrganizationRef{ @@ -144,18 +135,14 @@ func (te *TestEnvironment) SetupTeamWithMembersTest(_ *testing.T, namespace, tea func (te *TestEnvironment) SetupOrganizationTest(_ *testing.T, namespace, orgName string) *githubv1alpha1.Organization { // Create namespace first ns := &corev1.Namespace{ - ObjectMeta: ctrl.ObjectMeta{ - Name: namespace, - }, + Name: namespace, } _ = te.Client.Create(te.Context, ns) // Ignore error if namespace already exists // Create the Organization org := &githubv1alpha1.Organization{ - ObjectMeta: ctrl.ObjectMeta{ - Name: orgName, - Namespace: namespace, - }, + Name: orgName, + Namespace: namespace, Spec: githubv1alpha1.OrganizationSpec{ Name: orgName, Description: "Test organization for unit tests", @@ -174,18 +161,14 @@ func (te *TestEnvironment) SetupOrganizationTest(_ *testing.T, namespace, orgNam func (te *TestEnvironment) SetupRepositoryTest(_ *testing.T, namespace, repoName, orgName string) *githubv1alpha1.Repository { // Create namespace first ns := &corev1.Namespace{ - ObjectMeta: ctrl.ObjectMeta{ - Name: namespace, - }, + Name: namespace, } _ = te.Client.Create(te.Context, ns) // Ignore error if namespace already exists // Create the repository repo := &githubv1alpha1.Repository{ - ObjectMeta: ctrl.ObjectMeta{ - Name: repoName, - Namespace: namespace, - }, + Name: repoName, + Namespace: namespace, Spec: githubv1alpha1.RepositorySpec{ Name: repoName, OrganizationRef: githubv1alpha1.OrganizationRef{ @@ -218,9 +201,7 @@ func (te *TestEnvironment) SetupRepositoryTest(_ *testing.T, namespace, repoName // CreateTestNamespace creates a namespace for testing func (te *TestEnvironment) CreateTestNamespace(namespaceName string) { namespace := &corev1.Namespace{ - ObjectMeta: ctrl.ObjectMeta{ - Name: namespaceName, - }, + Name: namespaceName, } _ = te.Client.Create(te.Context, namespace) // Ignore error if namespace already exists @@ -236,10 +217,8 @@ func (te *TestEnvironment) CleanupTestResources(resources ...client.Object) { // CreateSecret creates a test GitHub App credentials secret func (te *TestEnvironment) CreateSecret(namespace, secretName string) { secret := &corev1.Secret{ - ObjectMeta: ctrl.ObjectMeta{ - Name: secretName, - Namespace: namespace, - }, + Name: secretName, + Namespace: namespace, Data: map[string][]byte{ "app-id": []byte("12345"), "app-installation-id": []byte("67890"), diff --git a/internal/mapper/github_actions_settings_test.go b/internal/mapper/github_actions_settings_test.go index 1d90382..efa3403 100644 --- a/internal/mapper/github_actions_settings_test.go +++ b/internal/mapper/github_actions_settings_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("GitHub Actions Configuration Mapper", func() { @@ -742,7 +741,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -787,7 +786,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -796,7 +795,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2"}, + Name: "repo2", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -821,7 +820,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -830,7 +829,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2-no-id"}, + Name: "repo2-no-id", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -853,7 +852,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"test-group"}, }, @@ -862,7 +861,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2"}, + Name: "repo2", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"other-group"}, }, @@ -871,7 +870,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo3"}, + Name: "repo3", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: nil, }, @@ -894,7 +893,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"other-group"}, }, @@ -1010,7 +1009,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"production-runners"}, }, @@ -1019,7 +1018,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2"}, + Name: "repo2", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"production-runners", "staging-runners"}, }, @@ -1028,7 +1027,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo3-no-id"}, + Name: "repo3-no-id", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"production-runners"}, }, @@ -1037,7 +1036,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo4"}, + Name: "repo4", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"staging-runners"}, }, @@ -1085,7 +1084,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"all-runners"}, }, @@ -1107,7 +1106,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"private-runners"}, }, @@ -1129,7 +1128,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"no-visibility"}, }, @@ -1153,7 +1152,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"other-runners"}, }, @@ -1175,7 +1174,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"selected-runners"}, }, @@ -1184,7 +1183,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2"}, + Name: "repo2", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"selected-runners"}, }, @@ -1207,7 +1206,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"selected-runners"}, }, @@ -1216,7 +1215,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2-no-id"}, + Name: "repo2-no-id", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"selected-runners"}, }, @@ -1225,7 +1224,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo3"}, + Name: "repo3", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"selected-runners"}, }, @@ -1249,7 +1248,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { } repos := []v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{Name: "repo1"}, + Name: "repo1", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"production-runners", "staging-runners"}, }, @@ -1258,7 +1257,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo2"}, + Name: "repo2", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"staging-runners"}, }, @@ -1267,7 +1266,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{Name: "repo3"}, + Name: "repo3", Spec: v1alpha1.RepositorySpec{ AvailableActionsRunnerGroups: []string{"production-runners"}, }, diff --git a/internal/mapper/github_hook_mapper_test.go b/internal/mapper/github_hook_mapper_test.go index eb49245..d56ff88 100644 --- a/internal/mapper/github_hook_mapper_test.go +++ b/internal/mapper/github_hook_mapper_test.go @@ -4,7 +4,6 @@ import ( "github.com/Interhyp/git-hubby/api/v1alpha1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("GitHub Hook Mapper", func() { @@ -14,9 +13,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset with all fields set", func() { It("should successfully convert to GitHub hook", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-webhook", - }, + Name: "test-webhook", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", ContentType: contentTypeApplicationJSON, @@ -44,9 +41,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset with SSL verification disabled", func() { It("should set InsecureSSL to 0", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "insecure-webhook", - }, + Name: "insecure-webhook", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", SSLVerify: new(false), @@ -64,9 +59,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset without content type", func() { It("should use default content type", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "default-content-type", - }, + Name: "default-content-type", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Active: new(true), @@ -83,9 +76,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset with custom content type", func() { It("should use the custom content type", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "custom-content-type", - }, + Name: "custom-content-type", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", ContentType: "application/x-www-form-urlencoded", @@ -103,9 +94,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset without events", func() { It("should default to push event", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "default-events", - }, + Name: "default-events", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Active: new(true), @@ -122,9 +111,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting an inactive webhook preset", func() { It("should set Active to false", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "inactive-webhook", - }, + Name: "inactive-webhook", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Active: new(false), @@ -141,9 +128,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset with multiple events", func() { It("should include all events", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "multi-event-webhook", - }, + Name: "multi-event-webhook", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Active: new(true), @@ -161,9 +146,7 @@ var _ = Describe("GitHub Hook Mapper", func() { Context("when converting a webhook preset with empty secret", func() { It("should set empty secret", func() { preset := v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "no-secret", - }, + Name: "no-secret", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Active: new(true), diff --git a/internal/mapper/github_org_mapper_test.go b/internal/mapper/github_org_mapper_test.go index cf0c4a1..18fcf27 100644 --- a/internal/mapper/github_org_mapper_test.go +++ b/internal/mapper/github_org_mapper_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("GitHub Org Mapper", func() { @@ -14,9 +13,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with only name field (legacy mode)", func() { It("should use name as both login and display name", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Description: "This is a test organization", @@ -34,9 +31,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with both login and name", func() { It("should use name as display name", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Login: "my-org-login", Name: "My Organization Display Name", @@ -55,9 +50,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with only login field", func() { It("should use login as display name", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Login: "my-org-login", Description: "Test description", @@ -75,9 +68,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with empty description", func() { It("should set empty description", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Description: "", @@ -95,9 +86,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with Location set", func() { It("should set Location in GitHub organization", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Location: "Munich, Germany", @@ -115,9 +104,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with Website set", func() { It("should set Blog in GitHub organization", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Website: "https://example.com", @@ -135,9 +122,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with all fields set", func() { It("should set all fields correctly", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Login: "my-org-login", Name: "My Org Display Name", @@ -160,9 +145,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization with empty optional fields", func() { It("should not set Location and Blog when empty", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Location: "", @@ -183,9 +166,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when converting an organization without MemberPrivileges", func() { It("should not set any member privilege fields on the GitHub organization", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Description: "Test description", @@ -211,9 +192,7 @@ var _ = Describe("GitHub Org Mapper", func() { BeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Description: "Test description", @@ -319,7 +298,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when MemberPrivileges is set with only some fields populated", func() { It("should only set populated fields on the GitHub organization, leaving the rest nil", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", MemberPrivileges: &v1alpha1.OrganizationMemberPrivileges{ @@ -344,7 +323,7 @@ var _ = Describe("GitHub Org Mapper", func() { Context("when organization plan gates MembersCanCreateInternalRepositories", func() { It("should map MembersCanCreateInternalRepositories when Plan is empty (defaults to enterprise)", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", MemberPrivileges: &v1alpha1.OrganizationMemberPrivileges{ @@ -360,7 +339,7 @@ var _ = Describe("GitHub Org Mapper", func() { It("should map MembersCanCreateInternalRepositories when Plan is enterprise", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Plan: v1alpha1.PlanEnterprise, @@ -377,7 +356,7 @@ var _ = Describe("GitHub Org Mapper", func() { It("should map MembersCanCreateInternalRepositories when Plan is team", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Plan: v1alpha1.PlanTeam, @@ -394,7 +373,7 @@ var _ = Describe("GitHub Org Mapper", func() { It("should NOT map MembersCanCreateInternalRepositories when Plan is free", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Plan: v1alpha1.PlanFree, @@ -411,7 +390,7 @@ var _ = Describe("GitHub Org Mapper", func() { It("should still map other MemberPrivileges fields when Plan is free", func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org"}, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Plan: v1alpha1.PlanFree, @@ -435,9 +414,7 @@ var _ = Describe("GitHub Org Mapper", func() { BeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - }, + Name: "test-org", Spec: v1alpha1.OrganizationSpec{ Name: "my-org", Description: "Test organization", diff --git a/internal/mapper/github_repo_mapper_test.go b/internal/mapper/github_repo_mapper_test.go index 3585873..ea297ae 100644 --- a/internal/mapper/github_repo_mapper_test.go +++ b/internal/mapper/github_repo_mapper_test.go @@ -6,7 +6,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("GitHub Repo Mapper", func() { @@ -15,9 +14,7 @@ var _ = Describe("GitHub Repo Mapper", func() { Context("when converting a repository with all fields set", func() { It("should successfully convert to GitHub repository", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - }, + Name: "test-repo", Spec: v1alpha1.RepositorySpec{ Name: "my-repo", Archived: new(false), @@ -44,9 +41,7 @@ var _ = Describe("GitHub Repo Mapper", func() { Context("when converting an archived repository", func() { It("should set Archived to true", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "archived-repo", - }, + Name: "archived-repo", Spec: v1alpha1.RepositorySpec{ Name: "archived-repo", Archived: new(true), @@ -63,9 +58,7 @@ var _ = Describe("GitHub Repo Mapper", func() { Context("when converting a repository", func() { It("should always set visibility to internal", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - }, + Name: "test-repo", Spec: v1alpha1.RepositorySpec{ Name: "my-repo", Archived: new(false), @@ -90,9 +83,7 @@ var _ = Describe("GitHub Repo Mapper", func() { Context("when converting a repository with special characters in name", func() { It("should preserve the name", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - }, + Name: "test-repo", Spec: v1alpha1.RepositorySpec{ Name: "my-special-repo_123", Archived: new(false), @@ -112,9 +103,7 @@ var _ = Describe("GitHub Repo Mapper", func() { BeforeEach(func() { repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - }, + Name: "test-repo", Spec: v1alpha1.RepositorySpec{ Name: "my-repo", Archived: new(false), @@ -518,9 +507,7 @@ var _ = Describe("GitHub Repo Mapper", func() { Context("when repository has nil bool fields", func() { It("should pass nil values through to GitHub repo (no defaults applied in mapper)", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - }, + Name: "test-repo", Spec: v1alpha1.RepositorySpec{ Name: "my-repo", Visibility: "internal", diff --git a/internal/mapper/github_team_mapper_test.go b/internal/mapper/github_team_mapper_test.go index 94f83e3..37183ea 100644 --- a/internal/mapper/github_team_mapper_test.go +++ b/internal/mapper/github_team_mapper_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = Describe("GitHub Team Mapper", func() { @@ -14,9 +13,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team with manual members", func() { It("should successfully convert to GitHub create team request", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "This is a test team", @@ -39,9 +36,7 @@ var _ = Describe("GitHub Team Mapper", func() { It("should use the team description", func() { idpGroup := "engineers" team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "idp-team", Description: "IDP synchronized team", @@ -59,9 +54,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team without description", func() { It("should use empty description", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Members: []string{"user1"}, @@ -78,9 +71,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team with empty description", func() { It("should use empty description", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "", @@ -98,9 +89,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting teams for different organizations", func() { It("should use the same description for both organizations", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "Shared team description", @@ -119,9 +108,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom privacy is specified", func() { It("should use the specified privacy", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Privacy: "secret", @@ -138,9 +125,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom permission is specified", func() { It("should use the specified permission", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Permission: "push", @@ -157,9 +142,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom notification setting is specified", func() { It("should use the specified notification setting", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", NotificationSetting: "notifications_enabled", @@ -176,9 +159,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when all team settings are customized", func() { It("should use all specified values", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "Custom team", @@ -204,9 +185,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team with manual members", func() { It("should successfully convert to GitHub update team request", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "This is a test team", @@ -229,9 +208,7 @@ var _ = Describe("GitHub Team Mapper", func() { It("should use the team description", func() { idpGroup := "engineers" team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "idp-team", Description: "IDP synchronized team", @@ -249,9 +226,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team without description", func() { It("should use empty description", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Members: []string{"user1"}, @@ -268,9 +243,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting a team with empty description", func() { It("should use empty description", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "", @@ -288,9 +261,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when converting teams for different organizations", func() { It("should use the same description for both organizations", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "Shared team description", @@ -309,9 +280,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom privacy is specified", func() { It("should use the specified privacy", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Privacy: "secret", @@ -328,9 +297,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom permission is specified", func() { It("should use the specified permission", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Permission: "push", @@ -347,9 +314,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when custom notification setting is specified", func() { It("should use the specified notification setting", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", NotificationSetting: "notifications_enabled", @@ -366,9 +331,7 @@ var _ = Describe("GitHub Team Mapper", func() { Context("when all team settings are customized", func() { It("should use all specified values", func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "Custom team", @@ -395,9 +358,7 @@ var _ = Describe("GitHub Team Mapper", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - }, + Name: "test-team", Spec: v1alpha1.TeamSpec{ Name: "my-team", Description: "Test team description", diff --git a/internal/reconciler/common/rulesets/collect_test.go b/internal/reconciler/common/rulesets/collect_test.go index 31ec17e..b174fff 100644 --- a/internal/reconciler/common/rulesets/collect_test.go +++ b/internal/reconciler/common/rulesets/collect_test.go @@ -12,7 +12,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/interceptor" ) @@ -53,8 +52,8 @@ var _ = Describe("Collect", func() { newPreset := func(objName string, spec v1alpha1.RulesetSpec) *v1alpha1.RulesetPreset { return &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: objName, Namespace: namespace}, - Spec: spec, + Name: objName, Namespace: namespace, + Spec: spec, } } diff --git a/internal/reconciler/common/rulesets/resolve_test.go b/internal/reconciler/common/rulesets/resolve_test.go index ce7fcdc..1b0fa06 100644 --- a/internal/reconciler/common/rulesets/resolve_test.go +++ b/internal/reconciler/common/rulesets/resolve_test.go @@ -12,7 +12,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -42,7 +41,7 @@ var _ = Describe("Extends resolution", func() { ) preset := func(name string, spec v1alpha1.RulesetSpec) *v1alpha1.RulesetPreset { - return &v1alpha1.RulesetPreset{ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, Spec: spec} + return &v1alpha1.RulesetPreset{Name: name, Namespace: namespace, Spec: spec} } base := v1alpha1.RulesetSpec{ diff --git a/internal/reconciler/executor_test.go b/internal/reconciler/executor_test.go index f1f87fe..2bb2a5c 100644 --- a/internal/reconciler/executor_test.go +++ b/internal/reconciler/executor_test.go @@ -96,10 +96,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { Context("When adding labels to organization", func() { It("Should add default labels to organization with no labels", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -139,12 +137,10 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should preserve existing labels and add missing defaults", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Labels: map[string]string{ - "existing-label": "existing-value", - }, + Name: "test-org", + Namespace: "default", + Labels: map[string]string{ + "existing-label": "existing-value", }, Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", @@ -186,12 +182,10 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should override existing enforced label values", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Labels: map[string]string{ - "app.kubernetes.io/managed-by": "custom-value", - }, + Name: "test-org", + Namespace: "default", + Labels: map[string]string{ + "app.kubernetes.io/managed-by": "custom-value", }, Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", @@ -228,10 +222,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should set organization label to the spec name", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "my-github-org", GitHubAppInstallationId: new(int64(12345)), @@ -267,12 +259,10 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should override already set organization label", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Labels: map[string]string{ - "test-key": "original-org", - }, + Name: "test-org", + Namespace: "default", + Labels: map[string]string{ + "test-key": "original-org", }, Spec: githubv1alpha1.OrganizationSpec{ Name: "new-org", @@ -309,14 +299,12 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should preserve all existing labels", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Labels: map[string]string{ - "label1": "value1", - "label2": "value2", - "label3": "value3", - }, + Name: "test-org", + Namespace: "default", + Labels: map[string]string{ + "label1": "value1", + "label2": "value2", + "label3": "value3", }, Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", @@ -358,10 +346,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should handle organization name with special characters", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "my-org-with-dashes", - Namespace: "default", - }, + Name: "my-org-with-dashes", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "my-org-with-dashes", GitHubAppInstallationId: new(int64(12345)), @@ -397,10 +383,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should apply labels idempotently", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -450,12 +434,10 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should handle labels with multiple enforced labels", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Labels: map[string]string{ - "custom-key": "custom-value", - }, + Name: "test-org", + Namespace: "default", + Labels: map[string]string{ + "custom-key": "custom-value", }, Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", @@ -497,10 +479,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { Context("Parallel Reconciliation Execution", func() { It("Should execute reconciliations in a single group concurrently", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -570,10 +550,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should execute multiple groups sequentially", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -651,10 +629,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should collect errors from all reconciliations without failing fast", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -725,10 +701,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should stop after group has at least on error", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -785,10 +759,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should handle empty reconciliation groups", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -826,10 +798,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should execute groups in order even with different completion times", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -896,10 +866,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { Context("When final status apply fails", func() { It("Should return the status apply error even when reconciliations succeed", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -947,10 +915,8 @@ var _ = Describe("OrganizationReconciler Labels", func() { It("Should still update in-memory conditions even when status apply fails", func() { org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), diff --git a/internal/reconciler/orgrec/rec_actions_settings_test.go b/internal/reconciler/orgrec/rec_actions_settings_test.go index 138821b..74fa02c 100644 --- a/internal/reconciler/orgrec/rec_actions_settings_test.go +++ b/internal/reconciler/orgrec/rec_actions_settings_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -54,10 +53,8 @@ var _ = Describe("ReconcileActionsSettings", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -182,10 +179,8 @@ var _ = Describe("ReconcilePermissions", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -361,10 +356,8 @@ var _ = Describe("ReconcileRetention", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -527,10 +520,8 @@ var _ = Describe("ReconcileAllowedActions", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -798,10 +789,8 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -969,10 +958,8 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -1149,10 +1136,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { JustBeforeEach(func() { // Create organization CR org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -1224,10 +1209,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1238,10 +1221,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", ActionsEnabled: new(true), @@ -1266,10 +1247,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(false), @@ -1296,10 +1275,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1310,10 +1287,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", ActionsEnabled: new(false), @@ -1324,10 +1299,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo3", - Namespace: "default", - }, + Name: "repo3", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo3", ActionsEnabled: new(true), @@ -1352,10 +1325,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1381,10 +1352,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1408,10 +1377,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1450,10 +1417,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1479,10 +1444,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1493,10 +1456,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", ActionsEnabled: new(true), @@ -1521,10 +1482,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1551,10 +1510,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: new(true), @@ -1583,10 +1540,8 @@ var _ = Describe("ReconcileActionsEnabled", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", ActionsEnabled: nil, // should default to true @@ -1765,10 +1720,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { JustBeforeEach(func() { // Create organization CR org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -1926,10 +1879,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2078,10 +2029,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2092,10 +2041,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2128,10 +2075,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2142,10 +2087,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", OrganizationRef: v1alpha1.OrganizationRef{Name: "other-org"}, @@ -2229,10 +2172,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2243,10 +2184,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2312,10 +2251,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2417,10 +2354,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2485,10 +2420,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2532,10 +2465,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2546,10 +2477,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo2", - Namespace: "default", - }, + Name: "repo2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo2", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2595,10 +2524,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2662,10 +2589,8 @@ var _ = Describe("ReconcileRunnerGroups", func() { BeforeEach(func() { repos = []*v1alpha1.Repository{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "repo1", - Namespace: "default", - }, + Name: "repo1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "repo1", OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"}, @@ -2777,10 +2702,8 @@ var _ = Describe("ReconcilePermissions with selected repositories", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), diff --git a/internal/reconciler/orgrec/rec_code_security_configurations_test.go b/internal/reconciler/orgrec/rec_code_security_configurations_test.go index c6784d7..d4ee538 100644 --- a/internal/reconciler/orgrec/rec_code_security_configurations_test.go +++ b/internal/reconciler/orgrec/rec_code_security_configurations_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -72,10 +71,8 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: testOrg, - Namespace: defaultNamespace, - }, + Name: testOrg, + Namespace: defaultNamespace, Spec: v1alpha1.OrganizationSpec{ Name: testOrg, GitHubAppInstallationId: new(int64(12345)), @@ -83,10 +80,8 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() { } csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: testCsc, - Namespace: defaultNamespace, - }, + Name: testCsc, + Namespace: defaultNamespace, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: testCsc, Description: "Test code security configuration", @@ -94,10 +89,8 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: testRepo, - Namespace: defaultNamespace, - }, + Name: testRepo, + Namespace: defaultNamespace, Spec: v1alpha1.RepositorySpec{ Name: testRepo, OrganizationRef: v1alpha1.OrganizationRef{ @@ -566,10 +559,8 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() { BeforeEach(func() { csc2 = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-csc-2", - Namespace: defaultNamespace, - }, + Name: "test-csc-2", + Namespace: defaultNamespace, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "test-csc-2", Description: "Second test code security configuration", @@ -699,10 +690,8 @@ var _ = Describe("UnsetObsoleteDefaults", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: testOrg, - Namespace: defaultNamespace, - }, + Name: testOrg, + Namespace: defaultNamespace, Spec: v1alpha1.OrganizationSpec{ Name: testOrg, GitHubAppInstallationId: new(int64(12345)), @@ -710,10 +699,8 @@ var _ = Describe("UnsetObsoleteDefaults", func() { } csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: testCsc, - Namespace: defaultNamespace, - }, + Name: testCsc, + Namespace: defaultNamespace, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: testCsc, Description: "Test code security configuration", @@ -844,10 +831,8 @@ var _ = Describe("ResolveBypassReviewerNames", func() { BeforeEach(func() { resolver = &mockIdResolver{} csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: testCsc, - Namespace: defaultNamespace, - }, + Name: testCsc, + Namespace: defaultNamespace, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: testCsc, Description: "Test code security configuration", @@ -958,10 +943,8 @@ var _ = Describe("AttachToRepos", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: testOrg, - Namespace: defaultNamespace, - }, + Name: testOrg, + Namespace: defaultNamespace, Spec: v1alpha1.OrganizationSpec{ Name: testOrg, GitHubAppInstallationId: new(int64(12345)), @@ -969,10 +952,8 @@ var _ = Describe("AttachToRepos", func() { } csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: testCsc, - Namespace: defaultNamespace, - }, + Name: testCsc, + Namespace: defaultNamespace, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: testCsc, Description: "Test code security configuration", @@ -980,10 +961,8 @@ var _ = Describe("AttachToRepos", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: testRepo, - Namespace: defaultNamespace, - }, + Name: testRepo, + Namespace: defaultNamespace, Spec: v1alpha1.RepositorySpec{ Name: testRepo, OrganizationRef: v1alpha1.OrganizationRef{ @@ -1324,10 +1303,8 @@ var _ = Describe("GetDesiredAttachmentsForScope", func() { Build() rec.Kubernetes.Client = k8sClient rec.Kubernetes.Resource = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: testOrg, - Namespace: defaultNamespace, - }, + Name: testOrg, + Namespace: defaultNamespace, } result, err := rec.getDesiredAttachmentsForScope(ctx, "selected", testCsc) @@ -1390,7 +1367,7 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() { Kubernetes: reconciler.Kubernetes[*v1alpha1.Organization]{ Client: k8sClient, Resource: &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: testOrg, Namespace: defaultNamespace}, + Name: testOrg, Namespace: defaultNamespace, }, }, } @@ -1505,7 +1482,7 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() { Context("when scope is 'selected'", func() { It("should pass specific repo IDs to attach API", func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: testRepo, Namespace: defaultNamespace}, + Name: testRepo, Namespace: defaultNamespace, Spec: v1alpha1.RepositorySpec{ Name: testRepo, AttachedCodeSecurityConfiguration: &v1alpha1.CodeSecurityConfigurationRef{ diff --git a/internal/reconciler/orgrec/rec_custom_properties_test.go b/internal/reconciler/orgrec/rec_custom_properties_test.go index 9cd37e2..7357763 100644 --- a/internal/reconciler/orgrec/rec_custom_properties_test.go +++ b/internal/reconciler/orgrec/rec_custom_properties_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -52,10 +51,8 @@ var _ = Describe("ReconcileCustomProperties", func() { JustBeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), @@ -679,10 +676,8 @@ var _ = Describe("getGitHubOrgCustomPropertiesByPropertyName", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), diff --git a/internal/reconciler/orgrec/rec_org_test.go b/internal/reconciler/orgrec/rec_org_test.go index affa792..0ce71e7 100644 --- a/internal/reconciler/orgrec/rec_org_test.go +++ b/internal/reconciler/orgrec/rec_org_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -41,10 +40,8 @@ var _ = Describe("ReconcileOrganization", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", Description: "Test Organization", diff --git a/internal/reconciler/orgrec/rec_rulesets_test.go b/internal/reconciler/orgrec/rec_rulesets_test.go index 10a24b1..8328242 100644 --- a/internal/reconciler/orgrec/rec_rulesets_test.go +++ b/internal/reconciler/orgrec/rec_rulesets_test.go @@ -14,7 +14,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -88,15 +87,15 @@ var _ = Describe("ReconcileRulesets", func() { idResolver = &mockIdResolver{} features = config.Features{} org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org", Namespace: "default"}, + Name: "test-org", Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(12345)), }, } preset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "preset-1", Namespace: "default"}, - Spec: rulesetSpec("preset-ruleset"), + Name: "preset-1", Namespace: "default", + Spec: rulesetSpec("preset-ruleset"), } existingRulesets = nil getAllCalled = false diff --git a/internal/reconciler/orgrec/reconciler_test.go b/internal/reconciler/orgrec/reconciler_test.go index 6bcf61b..6edacac 100644 --- a/internal/reconciler/orgrec/reconciler_test.go +++ b/internal/reconciler/orgrec/reconciler_test.go @@ -8,7 +8,6 @@ import ( "github.com/Interhyp/git-hubby/test/mock/ghclientmock" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -34,10 +33,8 @@ var _ = Describe("ReconcileDeletion", func() { Expect(schemeErr).NotTo(HaveOccurred()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", Description: "Test Organization", @@ -90,10 +87,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has repositories", func() { BeforeEach(func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -131,10 +126,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has multiple repositories", func() { BeforeEach(func() { repo1 := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo-1", - Namespace: "default", - }, + Name: "test-repo-1", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo-1", OrganizationRef: v1alpha1.OrganizationRef{ @@ -144,10 +137,8 @@ var _ = Describe("ReconcileDeletion", func() { } repo2 := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo-2", - Namespace: "default", - }, + Name: "test-repo-2", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo-2", OrganizationRef: v1alpha1.OrganizationRef{ @@ -185,10 +176,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has teams", func() { BeforeEach(func() { team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1", "user2"}, @@ -227,10 +216,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has multiple teams", func() { BeforeEach(func() { team1 := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team-1", - Namespace: "default", - }, + Name: "test-team-1", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team-1", Members: []string{"user1"}, @@ -241,10 +228,8 @@ var _ = Describe("ReconcileDeletion", func() { } team2 := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team-2", - Namespace: "default", - }, + Name: "test-team-2", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team-2", Members: []string{"user2"}, @@ -283,10 +268,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has both repositories and teams", func() { BeforeEach(func() { repo := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -296,10 +279,8 @@ var _ = Describe("ReconcileDeletion", func() { } team := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -339,10 +320,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has repositories in a different namespace", func() { BeforeEach(func() { repoInDifferentNamespace := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "other-namespace", - }, + Name: "test-repo", + Namespace: "other-namespace", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -378,10 +357,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has teams in a different namespace", func() { BeforeEach(func() { teamInDifferentNamespace := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "other-namespace", - }, + Name: "test-team", + Namespace: "other-namespace", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -418,10 +395,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has repositories referencing a different organization", func() { BeforeEach(func() { repoForDifferentOrg := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -457,10 +432,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has teams referencing multiple organizations (including this one)", func() { BeforeEach(func() { teamInMultipleOrgs := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -500,10 +473,8 @@ var _ = Describe("ReconcileDeletion", func() { Context("when organization has teams referencing only other organizations", func() { BeforeEach(func() { teamInOtherOrgs := &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -547,10 +518,8 @@ var _ = Describe("RequiredReconciliations", func() { BeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", Description: "Test Organization", diff --git a/internal/reconciler/reconcilerfactory/factory_test.go b/internal/reconciler/reconcilerfactory/factory_test.go index 84e02ab..fb754ce 100644 --- a/internal/reconciler/reconcilerfactory/factory_test.go +++ b/internal/reconciler/reconcilerfactory/factory_test.go @@ -17,7 +17,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -93,10 +92,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, Description: "Test Organization", @@ -232,10 +229,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, Description: "Test Organization", @@ -244,10 +239,8 @@ var _ = Describe("Factory", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: defaultNS, - }, + Name: "test-repo", + Namespace: defaultNS, Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -421,10 +414,8 @@ var _ = Describe("Factory", func() { } org1 = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: defaultNS, - }, + Name: "org1", + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: "org1", Description: "Test Organization 1", @@ -433,10 +424,8 @@ var _ = Describe("Factory", func() { } org2 = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org2", - Namespace: defaultNS, - }, + Name: "org2", + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: "org2", Description: "Test Organization 2", @@ -445,10 +434,8 @@ var _ = Describe("Factory", func() { } team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: defaultNS, - }, + Name: "test-team", + Namespace: defaultNS, Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "Test Team", @@ -703,10 +690,8 @@ var _ = Describe("Factory", func() { namespace = defaultNS org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: orgRef, - Namespace: namespace, - }, + Name: orgRef, + Namespace: namespace, Spec: v1alpha1.OrganizationSpec{ Name: orgRef, Description: "Test Organization", @@ -766,10 +751,8 @@ var _ = Describe("Factory", func() { BeforeEach(func() { org1 = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: defaultNS, - }, + Name: "org1", + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: "org1", GitHubAppInstallationId: new(int64(11111)), @@ -777,10 +760,8 @@ var _ = Describe("Factory", func() { } org2 = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org2", - Namespace: defaultNS, - }, + Name: "org2", + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: "org2", GitHubAppInstallationId: new(int64(22222)), @@ -788,10 +769,8 @@ var _ = Describe("Factory", func() { } team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: defaultNS, - }, + Name: "test-team", + Namespace: defaultNS, Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -920,10 +899,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -976,10 +953,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -988,10 +963,8 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, org)).To(Succeed()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: defaultNS, - }, + Name: "test-repo", + Namespace: defaultNS, Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -1046,10 +1019,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -1058,10 +1029,8 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, org)).To(Succeed()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: defaultNS, - }, + Name: "test-team", + Namespace: defaultNS, Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -1110,10 +1079,8 @@ var _ = Describe("Factory", func() { BeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -1134,11 +1101,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { rulesetPreset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-ruleset", - Namespace: defaultNS, - Generation: 5, - }, + Name: "test-ruleset", + Namespace: defaultNS, + Generation: 5, Spec: v1alpha1.RulesetSpec{ Name: "test-ruleset", }, @@ -1172,8 +1137,8 @@ var _ = Describe("Factory", func() { {"dangling", "missing", 7}, } { Expect(k8sClient.Create(ctx, &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: p.name, Namespace: defaultNS, Generation: p.generation}, - Spec: v1alpha1.RulesetSpec{Name: p.name, Extends: p.extends}, + Name: p.name, Namespace: defaultNS, Generation: p.generation, + Spec: v1alpha1.RulesetSpec{Name: p.name, Extends: p.extends}, })).To(Succeed()) } org.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "child"}, {Name: "dangling"}} @@ -1198,11 +1163,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-csc", - Namespace: defaultNS, - Generation: 3, - }, + Name: "test-csc", + Namespace: defaultNS, + Generation: 3, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "test-csc", Description: "Test CSC", @@ -1234,11 +1197,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { rulesetPreset1 = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ruleset-1", - Namespace: defaultNS, - Generation: 1, - }, + Name: "ruleset-1", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.RulesetSpec{ Name: "ruleset-1", }, @@ -1246,11 +1207,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, rulesetPreset1)).To(Succeed()) rulesetPreset2 = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ruleset-2", - Namespace: defaultNS, - Generation: 1, - }, + Name: "ruleset-2", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.RulesetSpec{ Name: "ruleset-2", }, @@ -1258,11 +1217,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, rulesetPreset2)).To(Succeed()) csc1 = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "csc-1", - Namespace: defaultNS, - Generation: 1, - }, + Name: "csc-1", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "csc-1", Description: "CSC 1", @@ -1271,11 +1228,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, csc1)).To(Succeed()) csc2 = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "csc-2", - Namespace: defaultNS, - Generation: 1, - }, + Name: "csc-2", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "csc-2", Description: "CSC 2", @@ -1322,8 +1277,8 @@ var _ = Describe("Factory", func() { Context("when one of several ruleset presets does not exist", func() { BeforeEach(func() { Expect(k8sClient.Create(ctx, &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "existing", Namespace: defaultNS, Generation: 2}, - Spec: v1alpha1.RulesetSpec{Name: "existing"}, + Name: "existing", Namespace: defaultNS, Generation: 2, + Spec: v1alpha1.RulesetSpec{Name: "existing"}, })).To(Succeed()) org.Spec.RulesetPresetList = []v1.LocalObjectReference{ {Name: "non-existent"}, @@ -1359,10 +1314,8 @@ var _ = Describe("Factory", func() { BeforeEach(func() { repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: defaultNS, - }, + Name: "test-repo", + Namespace: defaultNS, Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -1385,11 +1338,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { rulesetPreset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "repo-ruleset", - Namespace: defaultNS, - Generation: 8, - }, + Name: "repo-ruleset", + Namespace: defaultNS, + Generation: 8, Spec: v1alpha1.RulesetSpec{ Name: "repo-ruleset", }, @@ -1415,11 +1366,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { webhookPreset = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-webhook", - Namespace: defaultNS, - Generation: 6, - }, + Name: "test-webhook", + Namespace: defaultNS, + Generation: 6, Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", }, @@ -1445,11 +1394,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "repo-csc", - Namespace: defaultNS, - Generation: 9, - }, + Name: "repo-csc", + Namespace: defaultNS, + Generation: 9, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "repo-csc", Description: "Repo CSC", @@ -1481,11 +1428,9 @@ var _ = Describe("Factory", func() { BeforeEach(func() { rulesetPreset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "repo-ruleset", - Namespace: defaultNS, - Generation: 11, - }, + Name: "repo-ruleset", + Namespace: defaultNS, + Generation: 11, Spec: v1alpha1.RulesetSpec{ Name: "repo-ruleset", }, @@ -1493,11 +1438,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, rulesetPreset)).To(Succeed()) webhookPreset1 = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-1", - Namespace: defaultNS, - Generation: 13, - }, + Name: "webhook-1", + Namespace: defaultNS, + Generation: 13, Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook1", }, @@ -1505,11 +1448,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, webhookPreset1)).To(Succeed()) webhookPreset2 = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-2", - Namespace: defaultNS, - Generation: 14, - }, + Name: "webhook-2", + Namespace: defaultNS, + Generation: 14, Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook2", }, @@ -1517,11 +1458,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, webhookPreset2)).To(Succeed()) csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "repo-csc", - Namespace: defaultNS, - Generation: 12, - }, + Name: "repo-csc", + Namespace: defaultNS, + Generation: 12, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "repo-csc", Description: "Repo CSC", @@ -1624,11 +1563,9 @@ var _ = Describe("Factory", func() { } rulesetPreset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-ruleset", - Namespace: defaultNS, - Generation: 15, - }, + Name: "integration-ruleset", + Namespace: defaultNS, + Generation: 15, Spec: v1alpha1.RulesetSpec{ Name: "integration-ruleset", }, @@ -1636,11 +1573,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, rulesetPreset)).To(Succeed()) csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-csc", - Namespace: defaultNS, - Generation: 16, - }, + Name: "integration-csc", + Namespace: defaultNS, + Generation: 16, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "integration-csc", Description: "Integration CSC", @@ -1649,10 +1584,8 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, csc)).To(Succeed()) org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -1711,11 +1644,9 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - Generation: 1, - }, + Name: defaultOrgName, + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -1724,11 +1655,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, org)).To(Succeed()) rulesetPreset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-repo-ruleset", - Namespace: defaultNS, - Generation: 1, - }, + Name: "integration-repo-ruleset", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.RulesetSpec{ Name: "integration-repo-ruleset", }, @@ -1736,11 +1665,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, rulesetPreset)).To(Succeed()) webhookPreset = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-webhook", - Namespace: defaultNS, - Generation: 1, - }, + Name: "integration-webhook", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/integration", }, @@ -1748,11 +1675,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, webhookPreset)).To(Succeed()) csc = &v1alpha1.CodeSecurityConfiguration{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-repo-csc", - Namespace: defaultNS, - Generation: 1, - }, + Name: "integration-repo-csc", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.CodeSecurityConfigurationSpec{ Name: "integration-repo-csc", Description: "Integration Repo CSC", @@ -1761,11 +1686,9 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, csc)).To(Succeed()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-repo", - Namespace: defaultNS, - Generation: 1, - }, + Name: "integration-repo", + Namespace: defaultNS, + Generation: 1, Spec: v1alpha1.RepositorySpec{ Name: "integration-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -1828,10 +1751,8 @@ var _ = Describe("Factory", func() { } org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: defaultOrgName, - Namespace: defaultNS, - }, + Name: defaultOrgName, + Namespace: defaultNS, Spec: v1alpha1.OrganizationSpec{ Name: defaultOrgName, GitHubAppInstallationId: &defaultAppID, @@ -1840,10 +1761,8 @@ var _ = Describe("Factory", func() { Expect(k8sClient.Create(ctx, org)).To(Succeed()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "integration-team", - Namespace: defaultNS, - }, + Name: "integration-team", + Namespace: defaultNS, Spec: v1alpha1.TeamSpec{ Name: "integration-team", OrganizationRefs: []v1alpha1.OrganizationRef{ diff --git a/internal/reconciler/reporec/rec_actions_settings_test.go b/internal/reconciler/reporec/rec_actions_settings_test.go index 7b85c4e..63c2dad 100644 --- a/internal/reconciler/reporec/rec_actions_settings_test.go +++ b/internal/reconciler/reporec/rec_actions_settings_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -71,10 +70,8 @@ var _ = Describe("ReconcileActionsSettings", func() { JustBeforeEach(func() { // Create organization CR org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "test-org", ActionsSettings: v1alpha1.ActionsSettings{ @@ -85,10 +82,8 @@ var _ = Describe("ReconcileActionsSettings", func() { // Create repository CR repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -293,10 +288,8 @@ var _ = Describe("ReconcileActionsSettings", func() { It("should return the error", func() { // Create repository CR without organization repoWithoutOrg := &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/reporec/rec_autolinks_inline_test.go b/internal/reconciler/reporec/rec_autolinks_inline_test.go index afea44d..a161d9c 100644 --- a/internal/reconciler/reporec/rec_autolinks_inline_test.go +++ b/internal/reconciler/reporec/rec_autolinks_inline_test.go @@ -11,7 +11,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -40,12 +39,12 @@ var _ = Describe("ReconcileAutolinks with inline autolinks", func() { ctx = context.Background() mockClient = ghclientmock.NewMockGitHubClientWrapper() repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: "test-repo", Namespace: "default"}, - Spec: v1alpha1.RepositorySpec{Name: "test-repo"}, + Name: "test-repo", Namespace: "default", + Spec: v1alpha1.RepositorySpec{Name: "test-repo"}, } preset = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "preset-1", Namespace: "default"}, - Spec: v1alpha1.AutolinksPresetSpec{AutolinkList: []v1alpha1.Autolink{autolink("JIRA-", "https://jira/")}}, + Name: "preset-1", Namespace: "default", + Spec: v1alpha1.AutolinksPresetSpec{AutolinkList: []v1alpha1.Autolink{autolink("JIRA-", "https://jira/")}}, } listCalled = false currentAutolinks = nil diff --git a/internal/reconciler/reporec/rec_autolinks_test.go b/internal/reconciler/reporec/rec_autolinks_test.go index ad4fe04..aee563c 100644 --- a/internal/reconciler/reporec/rec_autolinks_test.go +++ b/internal/reconciler/reporec/rec_autolinks_test.go @@ -14,7 +14,6 @@ import ( . "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -80,20 +79,16 @@ var _ = Describe("ReconcileAutolinks", func() { JustBeforeEach(func() { preset = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-autolinks-preset", - Namespace: "default", - }, + Name: "test-autolinks-preset", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: autolinks, }, } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -417,10 +412,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging two presets with non-overlapping autolinks", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -438,10 +431,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-github", - Namespace: "default", - }, + Name: "preset-github", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -459,10 +450,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -513,10 +502,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging two presets with duplicate autolinks", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-base", - Namespace: "default", - }, + Name: "preset-base", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -534,10 +521,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-duplicate", - Namespace: "default", - }, + Name: "preset-duplicate", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -555,10 +540,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -609,10 +592,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging three presets with partial overlaps", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -630,10 +611,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-github", - Namespace: "default", - }, + Name: "preset-github", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -651,10 +630,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset3 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-custom", - Namespace: "default", - }, + Name: "preset-custom", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -672,10 +649,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -727,10 +702,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging presets and some autolinks already exist in GitHub", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -748,10 +721,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-github", - Namespace: "default", - }, + Name: "preset-github", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -785,10 +756,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -839,10 +808,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging presets with GitHub having extra autolinks not in presets", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -855,10 +822,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-github", - Namespace: "default", - }, + Name: "preset-github", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -899,10 +864,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -947,10 +910,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging presets with full reconciliation (add, remove, keep)", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -968,10 +929,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-github", - Namespace: "default", - }, + Name: "preset-github", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1005,10 +964,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -1063,10 +1020,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when a preset is missing in the cluster", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-jira", - Namespace: "default", - }, + Name: "preset-jira", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1080,10 +1035,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { // preset-missing does not exist in the cluster repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -1125,10 +1078,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging presets with different IsAlphanumeric values for same keyPrefix", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-alpha", - Namespace: "default", - }, + Name: "preset-alpha", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1141,10 +1092,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-nonalpha", - Namespace: "default", - }, + Name: "preset-nonalpha", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1157,10 +1106,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -1207,20 +1154,16 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when merging empty presets", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-empty1", - Namespace: "default", - }, + Name: "preset-empty1", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{}, }, } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-empty2", - Namespace: "default", - }, + Name: "preset-empty2", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{}, }, @@ -1236,10 +1179,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -1284,10 +1225,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { Context("when preset order matters for deduplication", func() { BeforeEach(func() { preset1 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-first", - Namespace: "default", - }, + Name: "preset-first", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1300,10 +1239,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } preset2 = &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "preset-second", - Namespace: "default", - }, + Name: "preset-second", + Namespace: "default", Spec: v1alpha1.AutolinksPresetSpec{ AutolinkList: []v1alpha1.Autolink{ { @@ -1316,10 +1253,8 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", AutolinksPresetList: []v1.LocalObjectReference{ @@ -1382,8 +1317,8 @@ var _ = Describe("collectDesiredAutolinks", func() { } newPreset := func(name string, autolinks ...v1alpha1.Autolink) *v1alpha1.AutolinksPreset { return &v1alpha1.AutolinksPreset{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, - Spec: v1alpha1.AutolinksPresetSpec{AutolinkList: autolinks}, + Name: name, Namespace: namespace, + Spec: v1alpha1.AutolinksPresetSpec{AutolinkList: autolinks}, } } diff --git a/internal/reconciler/reporec/rec_custom_properties_test.go b/internal/reconciler/reporec/rec_custom_properties_test.go index 84ef3bb..30d7833 100644 --- a/internal/reconciler/reporec/rec_custom_properties_test.go +++ b/internal/reconciler/reporec/rec_custom_properties_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -118,10 +117,8 @@ var _ = Describe("ReconcileCustomProperties", func() { JustBeforeEach(func() { repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/reporec/rec_deploykeys_test.go b/internal/reconciler/reporec/rec_deploykeys_test.go index 90698f1..06f7fa2 100644 --- a/internal/reconciler/reporec/rec_deploykeys_test.go +++ b/internal/reconciler/reporec/rec_deploykeys_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -74,10 +73,8 @@ var _ = Describe("ReconcileDeployKeys", func() { JustBeforeEach(func() { repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", DeployKeyList: deployKeys, diff --git a/internal/reconciler/reporec/rec_repo_test.go b/internal/reconciler/reporec/rec_repo_test.go index 319b9dd..11f6fdf 100644 --- a/internal/reconciler/reporec/rec_repo_test.go +++ b/internal/reconciler/reporec/rec_repo_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -43,11 +42,9 @@ var _ = Describe("ReconcileRepository", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - Annotations: map[string]string{}, - }, + Name: "test-repo", + Namespace: "default", + Annotations: map[string]string{}, Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -272,11 +269,9 @@ var _ = Describe("ReconcileRepository", func() { BeforeEach(func() { org = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - Annotations: map[string]string{}, - }, + Name: "test-org", + Namespace: "default", + Annotations: map[string]string{}, Spec: v1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: new(int64(123)), @@ -871,10 +866,8 @@ var _ = Describe("getRepo", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -1146,10 +1139,8 @@ var _ = Describe("updateRepo", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -1238,10 +1229,8 @@ var _ = Describe("updateRecFieldsFromGitHub", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/reporec/rec_rulesets_test.go b/internal/reconciler/reporec/rec_rulesets_test.go index 2b008f7..b54769b 100644 --- a/internal/reconciler/reporec/rec_rulesets_test.go +++ b/internal/reconciler/reporec/rec_rulesets_test.go @@ -13,7 +13,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -99,7 +98,7 @@ var _ = Describe("ReconcileRuleSets", func() { features = config.Features{} orgPlan = v1alpha1.PlanEnterprise repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: "test-repo", Namespace: "default"}, + Name: "test-repo", Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -107,8 +106,8 @@ var _ = Describe("ReconcileRuleSets", func() { }, } preset = &v1alpha1.RulesetPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "preset-1", Namespace: "default"}, - Spec: rulesetSpec("preset-ruleset"), + Name: "preset-1", Namespace: "default", + Spec: rulesetSpec("preset-ruleset"), } existingRulesets = nil getAllCalled = false @@ -124,8 +123,8 @@ var _ = Describe("ReconcileRuleSets", func() { JustBeforeEach(func() { org := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org", Namespace: "default"}, - Spec: v1alpha1.OrganizationSpec{Plan: orgPlan}, + Name: "test-org", Namespace: "default", + Spec: v1alpha1.OrganizationSpec{Plan: orgPlan}, } scheme := runtime.NewScheme() Expect(v1alpha1.AddToScheme(scheme)).To(Succeed()) diff --git a/internal/reconciler/reporec/rec_topics_test.go b/internal/reconciler/reporec/rec_topics_test.go index ad31665..47abeea 100644 --- a/internal/reconciler/reporec/rec_topics_test.go +++ b/internal/reconciler/reporec/rec_topics_test.go @@ -9,7 +9,6 @@ import ( "github.com/Interhyp/git-hubby/test/mock/ghclientmock" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -64,10 +63,8 @@ var _ = Describe("ReconcileTopics", func() { JustBeforeEach(func() { repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", About: v1alpha1.About{ diff --git a/internal/reconciler/reporec/rec_webhooks_inline_test.go b/internal/reconciler/reporec/rec_webhooks_inline_test.go index 199526d..d18daa1 100644 --- a/internal/reconciler/reporec/rec_webhooks_inline_test.go +++ b/internal/reconciler/reporec/rec_webhooks_inline_test.go @@ -12,7 +12,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -49,8 +48,8 @@ var _ = Describe("ReconcileWebhooks with inline webhooks", func() { } secret := func(namespace, name, key, value string) *corev1.Secret { return &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, - Data: map[string][]byte{key: []byte(value)}, + Name: name, Namespace: namespace, + Data: map[string][]byte{key: []byte(value)}, } } @@ -58,14 +57,14 @@ var _ = Describe("ReconcileWebhooks with inline webhooks", func() { ctx = context.Background() mockClient = ghclientmock.NewMockGitHubClientWrapper() repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{Name: "test-repo", Namespace: "default"}, - Spec: v1alpha1.RepositorySpec{Name: "test-repo"}, - Status: v1alpha1.RepositoryStatus{Webhooks: map[string]v1alpha1.WebhookStatus{}}, + Name: "test-repo", Namespace: "default", + Spec: v1alpha1.RepositorySpec{Name: "test-repo"}, + Status: v1alpha1.RepositoryStatus{Webhooks: map[string]v1alpha1.WebhookStatus{}}, } objects = []client.Object{ &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{Name: "preset-1", Namespace: "default"}, - Spec: inlineWebhook("https://preset.example.com/hook"), + Name: "preset-1", Namespace: "default", + Spec: inlineWebhook("https://preset.example.com/hook"), }, } listCalled = false diff --git a/internal/reconciler/reporec/rec_webhooks_test.go b/internal/reconciler/reporec/rec_webhooks_test.go index 0886a2f..e207d7e 100644 --- a/internal/reconciler/reporec/rec_webhooks_test.go +++ b/internal/reconciler/reporec/rec_webhooks_test.go @@ -18,7 +18,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -106,10 +105,8 @@ var _ = Describe("ReconcileWebhooks", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -177,10 +174,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -197,10 +192,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret123", - Namespace: "default", - }, + Name: "secret123", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret123"), }, @@ -229,10 +222,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook1", Secret: &v1alpha1.WebhookSecretSpec{ @@ -246,10 +237,8 @@ var _ = Describe("ReconcileWebhooks", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "slack-webhook", - Namespace: "default", - }, + Name: "slack-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://slack.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -266,19 +255,15 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret1"), }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret2", - Namespace: "default", - }, + Name: "secret2", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret2"), }, @@ -303,10 +288,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { preset = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -323,10 +306,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret123", - Namespace: "default", - }, + Name: "secret123", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret123"), }, @@ -374,10 +355,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -394,10 +373,8 @@ var _ = Describe("ReconcileWebhooks", func() { hash := mapper.HashWebhookConfig("https://example.com/webhook", "application/json", []string{"push", "pull_request"}) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), @@ -416,10 +393,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "newsecret456", - Namespace: "default", - }, + Name: "newsecret456", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("newsecret456"), }, @@ -517,10 +492,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -537,10 +510,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret123", - Namespace: "default", - }, + Name: "secret123", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret123"), }, @@ -660,10 +631,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -680,10 +649,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret123", - Namespace: "default", - }, + Name: "secret123", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret123"), }, @@ -718,10 +685,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -738,10 +703,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret123", - Namespace: "default", - }, + Name: "secret123", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret123"), }, @@ -776,10 +739,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", ContentType: "application/json", @@ -804,10 +765,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook1", Secret: &v1alpha1.WebhookSecretSpec{ @@ -824,10 +783,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret2", - Namespace: "default", - }, + Name: "secret2", + Namespace: "default", Data: map[string][]byte{ "newkey456": []byte("secret2"), }, @@ -847,10 +804,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "ci-webhook", - Namespace: "default", - }, + Name: "ci-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook1", Secret: &v1alpha1.WebhookSecretSpec{ @@ -867,10 +822,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "wrong-key": []byte("secret1"), }, @@ -901,10 +854,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookIgnorePresets = []*v1alpha1.WebhookIgnorePreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "foo-bar-ignore", - Namespace: "default", - }, + Name: "foo-bar-ignore", + Namespace: "default", Spec: v1alpha1.WebhookIgnoreSpec{ IgnoreURLRegex: new("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"), }, @@ -950,19 +901,15 @@ var _ = Describe("ReconcileWebhooks", func() { webhookIgnorePresets = []*v1alpha1.WebhookIgnorePreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "foo-bar-ignore", - Namespace: "default", - }, + Name: "foo-bar-ignore", + Namespace: "default", Spec: v1alpha1.WebhookIgnoreSpec{ IgnoreURLRegex: new("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"), }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "bar-bar-ignore", - Namespace: "default", - }, + Name: "bar-bar-ignore", + Namespace: "default", Spec: v1alpha1.WebhookIgnoreSpec{ IgnoreURLRegex: new("https:\\/\\/bar\\.bar\\.random\\.info\\/webhook\\/.*"), }, @@ -992,10 +939,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookIgnorePresets = []*v1alpha1.WebhookIgnorePreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "foo-bar-ignore", - Namespace: "default", - }, + Name: "foo-bar-ignore", + Namespace: "default", Spec: v1alpha1.WebhookIgnoreSpec{ IgnoreURLRegex: new("("), }, @@ -1014,10 +959,8 @@ var _ = Describe("ReconcileWebhooks", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "templated-webhook", - Namespace: "default", - }, + Name: "templated-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/hooks/{{.SSHURL}}", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1034,10 +977,8 @@ var _ = Describe("ReconcileWebhooks", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-secret", - Namespace: "default", - }, + Name: "webhook-secret", + Namespace: "default", Data: map[string][]byte{ "token": []byte("my-secret-token"), }, @@ -1142,10 +1083,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { } repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", WebhookPresetList: webhookPresetRefs, @@ -1191,10 +1130,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-json", - Namespace: "default", - }, + Name: "webhook-json", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1208,10 +1145,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-form", - Namespace: "default", - }, + Name: "webhook-form", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1228,10 +1163,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("secret123"), }, @@ -1275,10 +1208,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-push", - Namespace: "default", - }, + Name: "webhook-push", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1292,10 +1223,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { }, }, { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-pr", - Namespace: "default", - }, + Name: "webhook-pr", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1312,10 +1241,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("secret123"), }, @@ -1351,10 +1278,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-1", - Namespace: "default", - }, + Name: "webhook-1", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1371,10 +1296,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("secret123"), }, @@ -1452,10 +1375,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-templated", - Namespace: "default", - }, + Name: "webhook-templated", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/hooks/{{.SSHURL}}", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1472,10 +1393,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("secret123"), }, @@ -1566,10 +1485,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { BeforeEach(func() { webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-1", - Namespace: "default", - }, + Name: "webhook-1", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1586,10 +1503,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("new-secret-value"), }, @@ -1650,10 +1565,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { // Only keep the push webhook, remove the pull_request webhook webhookPresets = []*v1alpha1.WebhookPreset{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "webhook-push", - Namespace: "default", - }, + Name: "webhook-push", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", Secret: &v1alpha1.WebhookSecretSpec{ @@ -1670,10 +1583,8 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() { webhookSecrets = []*corev1.Secret{ { - ObjectMeta: metav1.ObjectMeta{ - Name: "secret1", - Namespace: "default", - }, + Name: "secret1", + Namespace: "default", Data: map[string][]byte{ "key1": []byte("secret123"), }, @@ -1776,10 +1687,8 @@ var _ = Describe("cleanupUnusedWebhooks", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -1929,10 +1838,8 @@ var _ = Describe("createMissingWebhooks", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -2108,10 +2015,8 @@ var _ = Describe("updateWebhooksStatus", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: v1alpha1.OrganizationRef{ @@ -2283,10 +2188,8 @@ var _ = Describe("templatePayloadURL", func() { mockClient = ghclientmock.NewMockGitHubClientWrapper() preset = &v1alpha1.WebhookPreset{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-webhook", - Namespace: "default", - }, + Name: "test-webhook", + Namespace: "default", Spec: v1alpha1.WebhookSpec{ PayloadURL: "https://example.com/webhook", ContentType: "application/json", @@ -2573,8 +2476,8 @@ var _ = Describe("collectWebhookIgnoreRegexes", func() { newPreset := func(name string, regex *string) *v1alpha1.WebhookIgnorePreset { return &v1alpha1.WebhookIgnorePreset{ - ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, - Spec: v1alpha1.WebhookIgnoreSpec{IgnoreURLRegex: regex}, + Name: name, Namespace: namespace, + Spec: v1alpha1.WebhookIgnoreSpec{IgnoreURLRegex: regex}, } } diff --git a/internal/reconciler/reporec/reconciler_finalize_archive_test.go b/internal/reconciler/reporec/reconciler_finalize_archive_test.go index 6e73091..31b5c95 100644 --- a/internal/reconciler/reporec/reconciler_finalize_archive_test.go +++ b/internal/reconciler/reporec/reconciler_finalize_archive_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -42,10 +41,8 @@ var _ = Describe("ReconcileArchive", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/reporec/reconciler_finalize_delete_test.go b/internal/reconciler/reporec/reconciler_finalize_delete_test.go index 14b6019..cb6e313 100644 --- a/internal/reconciler/reporec/reconciler_finalize_delete_test.go +++ b/internal/reconciler/reporec/reconciler_finalize_delete_test.go @@ -12,7 +12,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -41,10 +40,8 @@ var _ = Describe("ReconcileDeletion", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/reporec/reconciler_finalize_ignore_test.go b/internal/reconciler/reporec/reconciler_finalize_ignore_test.go index 4ea4831..5e85720 100644 --- a/internal/reconciler/reporec/reconciler_finalize_ignore_test.go +++ b/internal/reconciler/reporec/reconciler_finalize_ignore_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -40,10 +39,8 @@ var _ = Describe("ReconcileIgnore", func() { Expect(schemeErr).NotTo(HaveOccurred()) repo = &v1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: v1alpha1.RepositorySpec{ Name: "test-repo", Archived: new(false), diff --git a/internal/reconciler/spreading/spreading_test.go b/internal/reconciler/spreading/spreading_test.go index 798388f..7ec1e0b 100644 --- a/internal/reconciler/spreading/spreading_test.go +++ b/internal/reconciler/spreading/spreading_test.go @@ -91,10 +91,8 @@ var _ = Describe("Spreading", func() { }} resource = &mockResource{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-resource", - Namespace: "test-namespace", - }, + Name: "test-resource", + Namespace: "test-namespace", generation: 1, observedGeneration: 1, healthy: true, diff --git a/internal/reconciler/stop_test.go b/internal/reconciler/stop_test.go index 23c82fe..234da6d 100644 --- a/internal/reconciler/stop_test.go +++ b/internal/reconciler/stop_test.go @@ -31,8 +31,8 @@ var _ = Describe("Executor condition handling", func() { scheme := runtime.NewScheme() Expect(githubv1alpha1.AddToScheme(scheme)).To(Succeed()) org := &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "test-org", Namespace: "default"}, - Spec: githubv1alpha1.OrganizationSpec{Name: "test-org", GitHubAppInstallationId: new(int64(12345))}, + Name: "test-org", Namespace: "default", + Spec: githubv1alpha1.OrganizationSpec{Name: "test-org", GitHubAppInstallationId: new(int64(12345))}, } k8sClient := fake.NewClientBuilder(). WithScheme(scheme). diff --git a/internal/reconciler/teamrec/multi_org_test.go b/internal/reconciler/teamrec/multi_org_test.go index 34708b0..a966fcc 100644 --- a/internal/reconciler/teamrec/multi_org_test.go +++ b/internal/reconciler/teamrec/multi_org_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -45,10 +44,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when adding a new organization to an existing team", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "Test team description", @@ -159,10 +156,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when adding multiple new organizations at once", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "Test team description", @@ -280,10 +275,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when adding organization and team creation fails", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -378,10 +371,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when removing one organization from a multi-org team", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -467,10 +458,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when removing all organizations except one", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -562,10 +551,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when deletion fails in one of the removed organizations", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -647,10 +634,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when first reconciliation with no previous refs", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -717,10 +702,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when previousOrganizationRefs matches current refs", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -798,10 +781,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when organization order changes but content is same", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -884,10 +865,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when team creation succeeds in first org but fails in second", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -992,10 +971,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when team update succeeds in first org but fails in second", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "New description", @@ -1118,10 +1095,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when deletion succeeds in first removed org but fails in second", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -1218,10 +1193,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when mix of add, keep, and remove operations with partial failure", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -1344,10 +1317,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when deleting team from all organizations successfully", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -1435,10 +1406,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when deletion fails in second organization", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -1531,10 +1500,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when team is already deleted from one organization", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, @@ -1619,10 +1586,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() { Context("when GetTeamBySlug fails during deletion", func() { BeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, diff --git a/internal/reconciler/teamrec/rec_idpgroup_test.go b/internal/reconciler/teamrec/rec_idpgroup_test.go index 180ef19..9ebb3d3 100644 --- a/internal/reconciler/teamrec/rec_idpgroup_test.go +++ b/internal/reconciler/teamrec/rec_idpgroup_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -39,10 +38,8 @@ var _ = Describe("ReconcileIDPGroup", func() { idpGroup := "test-idp-group" team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "IDP Team", @@ -55,20 +52,16 @@ var _ = Describe("ReconcileIDPGroup", func() { // Create Organization objects that the IDP group reconciliation will fetch org1 := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: "default", - }, + Name: "org1", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Plan: v1alpha1.PlanEnterprise, }, } org2 := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org2", - Namespace: "default", - }, + Name: "org2", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Plan: v1alpha1.PlanEnterprise, }, diff --git a/internal/reconciler/teamrec/rec_members_test.go b/internal/reconciler/teamrec/rec_members_test.go index 99ed7cd..0c488ad 100644 --- a/internal/reconciler/teamrec/rec_members_test.go +++ b/internal/reconciler/teamrec/rec_members_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -40,10 +39,8 @@ var _ = Describe("ReconcileTeamMembers", func() { Expect(schemeErr).NotTo(HaveOccurred()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1", "user2"}, @@ -56,10 +53,8 @@ var _ = Describe("ReconcileTeamMembers", func() { // org1 uses legacy mode (no Login): GetLogin() returns Spec.Name == "org1", // which matches githubOrg.Resource set by the factory. org1 = &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: "default", - }, + Name: "org1", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "org1", }, @@ -567,10 +562,8 @@ var _ = Describe("ReconcileTeamMembers", func() { BeforeEach(func() { // Rebuild k8sClient with org1 having a MemberSuffix configured orgWithSuffix := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: "default", - }, + Name: "org1", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "org1", MemberSuffix: "@example.com", @@ -633,10 +626,8 @@ var _ = Describe("ReconcileTeamMembers", func() { // org1 has a different suffix; env var should win orgWithSuffix := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org1", - Namespace: "default", - }, + Name: "org1", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "org1", MemberSuffix: "@example.com", @@ -706,12 +697,12 @@ var _ = Describe("ReconcileTeamMembers", func() { } orgWithSuffix1 := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "org1", Namespace: "default"}, - Spec: v1alpha1.OrganizationSpec{Name: "org1", MemberSuffix: "_suffix1"}, + Name: "org1", Namespace: "default", + Spec: v1alpha1.OrganizationSpec{Name: "org1", MemberSuffix: "_suffix1"}, } orgWithSuffix2 := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{Name: "org2", Namespace: "default"}, - Spec: v1alpha1.OrganizationSpec{Name: "org2", MemberSuffix: "_suffix2"}, + Name: "org2", Namespace: "default", + Spec: v1alpha1.OrganizationSpec{Name: "org2", MemberSuffix: "_suffix2"}, } k8sClient = fake.NewClientBuilder(). WithScheme(scheme). @@ -788,10 +779,8 @@ var _ = Describe("ReconcileTeamMembers", func() { } org2 := &v1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "org2", - Namespace: "default", - }, + Name: "org2", + Namespace: "default", Spec: v1alpha1.OrganizationSpec{ Name: "org2", }, diff --git a/internal/reconciler/teamrec/rec_refcleanup_test.go b/internal/reconciler/teamrec/rec_refcleanup_test.go index 13c02c5..364f6e5 100644 --- a/internal/reconciler/teamrec/rec_refcleanup_test.go +++ b/internal/reconciler/teamrec/rec_refcleanup_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -44,10 +43,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when no organizations have been removed", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -123,10 +120,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when one organization has been removed", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -203,10 +198,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when multiple organizations have been removed", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -289,10 +282,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when team deletion fails", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -363,10 +354,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when team deletion returns 404 (already deleted)", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ @@ -437,10 +426,8 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() { Context("when previousOrganizationRefs is empty (first reconciliation)", func() { JustBeforeEach(func() { team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", OrganizationRefs: []v1alpha1.OrganizationRef{ diff --git a/internal/reconciler/teamrec/rec_role_assignments_test.go b/internal/reconciler/teamrec/rec_role_assignments_test.go index 7fb9347..c25be39 100644 --- a/internal/reconciler/teamrec/rec_role_assignments_test.go +++ b/internal/reconciler/teamrec/rec_role_assignments_test.go @@ -10,7 +10,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -38,10 +37,8 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() { Expect(schemeErr).NotTo(HaveOccurred()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1", "user2"}, diff --git a/internal/reconciler/teamrec/rec_team_test.go b/internal/reconciler/teamrec/rec_team_test.go index 8e9b537..bf86f7d 100644 --- a/internal/reconciler/teamrec/rec_team_test.go +++ b/internal/reconciler/teamrec/rec_team_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -39,10 +38,8 @@ var _ = Describe("ReconcileTeam", func() { Expect(schemeErr).NotTo(HaveOccurred()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "Test team description", diff --git a/internal/reconciler/teamrec/reconciler_test.go b/internal/reconciler/teamrec/reconciler_test.go index fafa7ab..1eccd8d 100644 --- a/internal/reconciler/teamrec/reconciler_test.go +++ b/internal/reconciler/teamrec/reconciler_test.go @@ -11,7 +11,6 @@ import ( "github.com/google/go-github/v93/github" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -39,10 +38,8 @@ var _ = Describe("ReconcileDeletion", func() { Expect(schemeErr).NotTo(HaveOccurred()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Description: "Test team", @@ -527,10 +524,8 @@ var _ = Describe("RequiredReconciliations", func() { Expect(v1alpha1.AddToScheme(scheme)).To(Succeed()) team = &v1alpha1.Team{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-team", - Namespace: "default", - }, + Name: "test-team", + Namespace: "default", Spec: v1alpha1.TeamSpec{ Name: "test-team", Members: []string{"user1"}, diff --git a/internal/webhook/v1alpha1/organization_webhook_test.go b/internal/webhook/v1alpha1/organization_webhook_test.go index e7d6290..0f07657 100644 --- a/internal/webhook/v1alpha1/organization_webhook_test.go +++ b/internal/webhook/v1alpha1/organization_webhook_test.go @@ -7,7 +7,6 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -28,10 +27,8 @@ var _ = Describe("Organization Webhook", func() { BeforeEach(func() { ctx = context.Background() obj = &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: &installationID, @@ -39,10 +36,8 @@ var _ = Describe("Organization Webhook", func() { }, } oldObj = &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppInstallationId: &installationID, diff --git a/internal/webhook/v1alpha1/repository_webhook_test.go b/internal/webhook/v1alpha1/repository_webhook_test.go index b4c4a70..f6f1890 100644 --- a/internal/webhook/v1alpha1/repository_webhook_test.go +++ b/internal/webhook/v1alpha1/repository_webhook_test.go @@ -8,7 +8,6 @@ import ( gogithub "github.com/google/go-github/v93/github" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/client" @@ -84,10 +83,8 @@ var _ = Describe("Repository Webhook", func() { // Set up test organization testOrg = &githubv1alpha1.Organization{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-org", - Namespace: "default", - }, + Name: "test-org", + Namespace: "default", Spec: githubv1alpha1.OrganizationSpec{ Name: "test-org", GitHubAppConfig: &githubv1alpha1.GitHubAppConfig{ @@ -105,10 +102,8 @@ var _ = Describe("Repository Webhook", func() { // Set up test repository obj = &githubv1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: githubv1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: githubv1alpha1.OrganizationRef{ @@ -119,10 +114,8 @@ var _ = Describe("Repository Webhook", func() { } oldObj = &githubv1alpha1.Repository{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-repo", - Namespace: "default", - }, + Name: "test-repo", + Namespace: "default", Spec: githubv1alpha1.RepositorySpec{ Name: "test-repo", OrganizationRef: githubv1alpha1.OrganizationRef{