diff --git a/Dockerfile b/Dockerfile
index f784d8d..2915722 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,5 @@
# Build the manager binary
-FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
+FROM --platform=$BUILDPLATFORM golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH
diff --git a/README.md b/README.md
index 7deadfe..fae7d27 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,8 @@ A Kubernetes operator for managing GitHub organizations and repositories as code
- **Declarative GitHub Management**: Define organizations and repositories as Kubernetes resources
- **GitHub App Integration**: Secure authentication using GitHub App credentials
-- **Advanced Features**: Manage repository rulesets, webhooks, and organization custom properties
+- **Multi-Plan Support**: Works with GitHub `free`, `team`, and `enterprise` plans — plan-gated features are automatically skipped when not available
+- **Advanced Features**: Manage repository rulesets, webhooks, organization custom properties, and code security configurations
- **Rate Limit Awareness**: Built-in GitHub API rate limit handling with intelligent backoff
- **Startup Spreading**: Distributes reconciliations over time during pod startup to prevent API thundering herd
- **Webhook Validation**: Comprehensive validation of resource specifications
@@ -28,7 +29,7 @@ A Kubernetes operator for managing GitHub organizations and repositories as code
### Prerequisites
-- A **GitHub Enterprise Cloud** organization — the operator relies on Enterprise-only APIs (organization rulesets, code security configurations, IDP group sync). Repository and team management works on all plans, but full organization reconciliation requires Enterprise Cloud.
+- A GitHub organization on any plan (`free`, `team`, or `enterprise`). Set `spec.plan` on the `Organization` resource to match your GitHub plan — defaults to `enterprise` for backward compatibility. Feature availability varies by plan (see [GitHub Plan Compatibility](#github-plan-compatibility) below).
- Go 1.25.5 or later
- Kubernetes cluster (v1.34+ recommended)
- kubectl configured to access your cluster
@@ -50,6 +51,22 @@ Edit `.env` to configure local settings such as `LOG_LEVEL`, `LOG_FORMAT`, and `
For the full development setup, make targets, testing, and code conventions, see [CONTRIBUTING.md](CONTRIBUTING.md).
+## GitHub Plan Compatibility
+
+The operator supports GitHub organizations on all billing plans. Feature availability is automatically gated by the `spec.plan` field on the `Organization` resource:
+
+| Feature | free | team | enterprise |
+|---|---|---|---|
+| Repository & organization settings | ✓ | ✓ | ✓ |
+| Repository rulesets (public repos) | ✓ | ✓ | ✓ |
+| Repository rulesets (private/internal repos) | ✗ | ✓ | ✓ |
+| Organization rulesets | ✗ | ✓ | ✓ |
+| Code security configurations | ✗ | ✗ | ✓ |
+| IDP group sync (Teams) | ✗ | ✗ | ✓ |
+| Internal repository visibility | ✗ | ✗ | ✓ |
+
+Invalid plan and feature combinations are rejected during resource validation (admission webhook). Plan defaults to `enterprise` for backward compatibility.
+
## Configuration
### Logging
diff --git a/api/v1alpha1/applyconfiguration/api/v1alpha1/organizationspec.go b/api/v1alpha1/applyconfiguration/api/v1alpha1/organizationspec.go
index c5040ae..7dbefc7 100644
--- a/api/v1alpha1/applyconfiguration/api/v1alpha1/organizationspec.go
+++ b/api/v1alpha1/applyconfiguration/api/v1alpha1/organizationspec.go
@@ -55,6 +55,9 @@ type OrganizationSpecApplyConfiguration struct {
// Description is a human-readable description of the organization.
// This appears on the organization's GitHub profile page.
Description *string `json:"description,omitempty"`
+ // Plan indicates the GitHub plan tier for this organization (enterprise, team, or free).
+ // Determines whether Enterprise-only features (e.g., custom properties, runner groups) are reconciled or skipped.
+ Plan *string `json:"plan,omitempty"`
}
// OrganizationSpecApplyConfiguration constructs a declarative configuration of the OrganizationSpec type for use with
@@ -130,3 +133,11 @@ func (b *OrganizationSpecApplyConfiguration) WithDescription(value string) *Orga
b.Description = &value
return b
}
+
+// WithPlan sets the Plan field in the declarative configuration to the given value
+// and returns the receiver, so that objects can be built by chaining "With" function invocations.
+// If called multiple times, the Plan field is set to the value of the last call.
+func (b *OrganizationSpecApplyConfiguration) WithPlan(value string) *OrganizationSpecApplyConfiguration {
+ b.Plan = &value
+ return b
+}
diff --git a/api/v1alpha1/organization_methods.go b/api/v1alpha1/organization_methods.go
index 8c1ae87..982bde7 100644
--- a/api/v1alpha1/organization_methods.go
+++ b/api/v1alpha1/organization_methods.go
@@ -6,6 +6,22 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
+const (
+ // PlanFree represents the GitHub free plan
+ PlanFree = "free"
+ // PlanTeam represents the GitHub team plan
+ PlanTeam = "team"
+ // PlanEnterprise represents the GitHub enterprise plan
+ PlanEnterprise = "enterprise"
+
+ // VisibilityPublic represents a public repository visible to everyone
+ VisibilityPublic = "public"
+ // VisibilityPrivate represents a private repository visible only to explicit collaborators
+ VisibilityPrivate = "private"
+ // VisibilityInternal represents an internal repository visible to organization members (Enterprise only)
+ VisibilityInternal = "internal"
+)
+
func (in *Organization) GetTypeRepresentation() string {
return "Organization"
}
@@ -43,6 +59,25 @@ func (in *Organization) GetObservedSubResourceGenerations() map[string]int64 {
return in.Status.ObservedSubResourceGenerations
}
+func (in *Organization) GetPlan() string {
+ if in == nil {
+ return ""
+ }
+ if in.Spec.Plan == "" {
+ return PlanEnterprise
+ }
+ return in.Spec.Plan
+}
+
+// HasEnterpriseFeatures returns true if the organization has enterprise-level features.
+// Returns false for free plan, true for enterprise and other plans.
+func (in *Organization) HasEnterpriseFeatures() bool {
+ if in == nil {
+ return false
+ }
+ return in.GetPlan() != PlanFree
+}
+
func (in *Organization) SetObservedSubResourceGeneration(new map[string]int64) {
if in == nil {
return
diff --git a/api/v1alpha1/organization_types.go b/api/v1alpha1/organization_types.go
index fea4e4d..9e4b346 100644
--- a/api/v1alpha1/organization_types.go
+++ b/api/v1alpha1/organization_types.go
@@ -319,6 +319,13 @@ type OrganizationSpec struct {
// Description is a human-readable description of the organization.
// This appears on the organization's GitHub profile page.
Description string `json:"description"`
+
+ // Plan indicates the GitHub plan tier for this organization (enterprise, team, or free).
+ // Determines whether Enterprise-only features (e.g., custom properties, runner groups) are reconciled or skipped.
+ // +kubebuilder:validation:Enum=enterprise;team;free
+ // +kubebuilder:default=enterprise
+ // +optional
+ Plan string `json:"plan,omitempty"`
}
// OrganizationStatus defines the observed state of Organization.
diff --git a/config/crd/bases/github.interhyp.de_organizations.yaml b/config/crd/bases/github.interhyp.de_organizations.yaml
index 061254a..3a1d0e2 100644
--- a/config/crd/bases/github.interhyp.de_organizations.yaml
+++ b/config/crd/bases/github.interhyp.de_organizations.yaml
@@ -333,6 +333,16 @@ spec:
minLength: 1
pattern: ^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,99}$
type: string
+ plan:
+ default: enterprise
+ description: |-
+ Plan indicates the GitHub plan tier for this organization (enterprise, team, or free).
+ Determines whether Enterprise-only features (e.g., custom properties, runner groups) are reconciled or skipped.
+ enum:
+ - enterprise
+ - team
+ - free
+ type: string
rulesetPresets:
description: |-
RulesetPresetList references RulesetPreset CRDs that define repository rulesets for this organization.
diff --git a/docs/techdocs/crds.md b/docs/techdocs/crds.md
index 9021e91..dac5e81 100644
--- a/docs/techdocs/crds.md
+++ b/docs/techdocs/crds.md
@@ -599,6 +599,7 @@ _Appears in:_
| `codeSecurityConfigurations` _[AttachableCodeSecurityConfigurationRef](#attachablecodesecurityconfigurationref) array_ | CodeSecurityConfigurations lists code security configurations to create and optionally attach to repositories.
Each configuration defines security features like dependency scanning, secret scanning, and code scanning.
See: https://docs.github.com/en/rest/code-security/configurations | | |
| `rulesetPresets` _[LocalObjectReference](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#localobjectreference-v1-core) array_ | RulesetPresetList references RulesetPreset CRDs that define repository rulesets for this organization.
Rulesets enforce policies like branch protection, required reviews, and status checks.
See: https://docs.github.com/en/rest/orgs/rules | | |
| `description` _string_ | Description is a human-readable description of the organization.
This appears on the organization's GitHub profile page. | | |
+| `plan` _string_ | Plan indicates the GitHub plan tier for this organization (enterprise, team, or free).
Determines whether Enterprise-only features (e.g., custom properties, runner groups) are reconciled or skipped. | enterprise | Enum: [enterprise team free]
Optional: \{\}
|
#### OrganizationStatus
diff --git a/go.mod b/go.mod
index c96287f..cb5483a 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/Interhyp/git-hubby
-go 1.25.7
+go 1.26.3
require (
github.com/PuerkitoBio/rehttp v1.4.0
diff --git a/internal/controller/organization_controller.go b/internal/controller/organization_controller.go
index 2000f65..ae70d1e 100644
--- a/internal/controller/organization_controller.go
+++ b/internal/controller/organization_controller.go
@@ -26,7 +26,6 @@ import (
"github.com/Interhyp/git-hubby/internal/reconciler/reconcilerfactory"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/workqueue"
- "k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -125,7 +124,7 @@ func (r *OrganizationCtl) SetupWithManager(mgr ctrl.Manager) error {
).
WithEventFilter(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{})).
WithOptions(controller.Options{
- UsePriorityQueue: ptr.To[bool](true),
+ UsePriorityQueue: new(true),
RateLimiter: workqueue.NewTypedMaxOfRateLimiter(
workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](
1*time.Second, // base delay
diff --git a/internal/controller/organization_controller_test.go b/internal/controller/organization_controller_test.go
index df3d5bf..ba6e1f6 100644
--- a/internal/controller/organization_controller_test.go
+++ b/internal/controller/organization_controller_test.go
@@ -80,7 +80,7 @@ var _ = Describe("Organization Controller - Integration Tests", func() {
return &github.Organization{
Login: github.Ptr(orgName),
Name: github.Ptr(orgName),
- Description: github.Ptr("Test organization for unit tests"),
+ Description: new("Test organization for unit tests"),
}, nil
}
mockClient.GetAllOrganizationCustomPropertiesFunc = func(ctx context.Context, org string) ([]*github.CustomProperty, error) {
@@ -108,7 +108,7 @@ var _ = Describe("Organization Controller - Integration Tests", func() {
return &github.Organization{
Login: github.Ptr(orgName),
Name: github.Ptr(orgName),
- Description: github.Ptr("Test organization for unit tests"),
+ Description: new("Test organization for unit tests"),
}, nil
}
mockClient.GetAllOrganizationCustomPropertiesFunc = func(ctx context.Context, org string) ([]*github.CustomProperty, error) {
@@ -148,7 +148,7 @@ var _ = Describe("Organization Controller - Integration Tests", func() {
return &github.Organization{
Login: github.Ptr(orgName),
Name: github.Ptr(orgName),
- Description: github.Ptr("Test organization for unit tests"),
+ Description: new("Test organization for unit tests"),
}, nil
}
mockClient.GetAllOrganizationCustomPropertiesFunc = func(ctx context.Context, org string) ([]*github.CustomProperty, error) {
@@ -194,7 +194,7 @@ var _ = Describe("Organization Controller - Integration Tests", func() {
return &github.Organization{
Login: github.Ptr(orgName),
Name: github.Ptr(orgName),
- Description: github.Ptr("Test organization"),
+ Description: new("Test organization"),
}, nil
}
mockClient.GetAllOrganizationCustomPropertiesFunc = func(ctx context.Context, org string) ([]*github.CustomProperty, error) {
diff --git a/internal/controller/repository_controller.go b/internal/controller/repository_controller.go
index 22bdec1..093dd34 100644
--- a/internal/controller/repository_controller.go
+++ b/internal/controller/repository_controller.go
@@ -27,7 +27,6 @@ import (
"github.com/google/go-github/v86/github"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/workqueue"
- "k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
@@ -189,7 +188,7 @@ func (r *RepositoryCtl) SetupWithManager(mgr ctrl.Manager) error {
).
WithEventFilter(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{})).
WithOptions(controller.Options{
- UsePriorityQueue: ptr.To[bool](true),
+ UsePriorityQueue: new(true),
MaxConcurrentReconciles: 20,
RateLimiter: workqueue.NewTypedMaxOfRateLimiter(
workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](
diff --git a/internal/controller/repository_controller_test.go b/internal/controller/repository_controller_test.go
index 78e7467..a21a7e5 100644
--- a/internal/controller/repository_controller_test.go
+++ b/internal/controller/repository_controller_test.go
@@ -62,7 +62,7 @@ var _ = Describe("Repository Controller - Integration Tests", func() {
testEnv.CreateTestNamespace(namespaceName)
testEnv.CreateSecret(namespaceName, secretName)
organization = testEnv.SetupOrganizationTest(nil, namespaceName, orgName)
- organization.Spec.ActionsSettings.EnabledRepositories = github.Ptr("all")
+ organization.Spec.ActionsSettings.EnabledRepositories = new("all")
Expect(testEnv.Client.Update(testEnv.Context, organization)).To(Succeed())
})
@@ -94,12 +94,12 @@ var _ = Describe("Repository Controller - Integration Tests", func() {
By("Setting up mock to return existing repository")
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repo string) (*github.Repository, error) {
return &github.Repository{
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
Name: github.Ptr(repoName),
- FullName: github.Ptr(owner + "/" + repo),
- Owner: &github.User{Login: github.Ptr(owner)},
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ FullName: new(owner + "/" + repo),
+ Owner: &github.User{Login: new(owner)},
+ Archived: new(false),
+ Visibility: new("internal"),
}, nil
}
@@ -189,27 +189,27 @@ var _ = Describe("Repository Controller - Integration Tests", func() {
By("Setting up mock to return repository with ID")
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repo string) (*github.Repository, error) {
return &github.Repository{
- ID: github.Ptr(int64(99999)),
+ ID: new(int64(99999)),
Name: github.Ptr(repoName),
- FullName: github.Ptr(owner + "/" + repo),
- Owner: &github.User{Login: github.Ptr(owner)},
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
- AllowRebaseMerge: github.Ptr(false),
- AllowMergeCommit: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(true),
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: github.Ptr(""),
- Description: github.Ptr(""),
- DefaultBranch: github.Ptr(""),
+ FullName: new(owner + "/" + repo),
+ Owner: &github.User{Login: new(owner)},
+ Archived: new(false),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
+ AllowRebaseMerge: new(false),
+ AllowMergeCommit: new(false),
+ DeleteBranchOnMerge: new(true),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: new(""),
+ Description: new(""),
+ DefaultBranch: new(""),
}, nil
}
diff --git a/internal/controller/team_controller.go b/internal/controller/team_controller.go
index 520005f..add0f04 100644
--- a/internal/controller/team_controller.go
+++ b/internal/controller/team_controller.go
@@ -26,7 +26,6 @@ import (
"github.com/Interhyp/git-hubby/internal/reconciler/reconcilerfactory"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/util/workqueue"
- "k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -99,7 +98,7 @@ func (r *TeamCtl) SetupWithManager(mgr ctrl.Manager) error {
For(&githubv1alpha1.Team{}).
WithEventFilter(predicate.Or(predicate.GenerationChangedPredicate{}, predicate.AnnotationChangedPredicate{})).
WithOptions(controller.Options{
- UsePriorityQueue: ptr.To[bool](true),
+ UsePriorityQueue: new(true),
MaxConcurrentReconciles: 20,
RateLimiter: workqueue.NewTypedMaxOfRateLimiter(
workqueue.NewTypedItemExponentialFailureRateLimiter[reconcile.Request](
diff --git a/internal/controller/team_controller_test.go b/internal/controller/team_controller_test.go
index 5bf3b1e..f16b582 100644
--- a/internal/controller/team_controller_test.go
+++ b/internal/controller/team_controller_test.go
@@ -152,10 +152,10 @@ var _ = Describe("TeamController", func() {
return &github.Team{
Name: github.Ptr(teamName),
Slug: github.Ptr(teamName),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -181,21 +181,21 @@ var _ = Describe("TeamController", func() {
return &github.Team{
Name: github.Ptr(teamName),
Slug: github.Ptr(teamName),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
mockClient.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("new-member_memberSuffix")},
- {Login: github.Ptr("existing-member_memberSuffix")},
+ {Login: new("new-member_memberSuffix")},
+ {Login: new("existing-member_memberSuffix")},
}, nil
}
mockClient.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("existing-member_memberSuffix")},
+ {Login: new("existing-member_memberSuffix")},
}, nil
}
diff --git a/internal/controller/test_helpers_test.go b/internal/controller/test_helpers_test.go
index d0c3c81..1237fff 100644
--- a/internal/controller/test_helpers_test.go
+++ b/internal/controller/test_helpers_test.go
@@ -7,7 +7,6 @@ import (
"github.com/Interhyp/git-hubby/internal/reconciler"
"github.com/Interhyp/git-hubby/test/mock/ghclientmock"
- "github.com/google/go-github/v86/github"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
@@ -133,7 +132,7 @@ func (te *TestEnvironment) SetupTeamWithMembersTest(_ *testing.T, namespace, tea
Members: []string{"new-member", "existing-member"},
},
Status: githubv1alpha1.TeamStatus{
- Slug: github.Ptr(teamName),
+ Slug: new(teamName),
},
}
@@ -189,14 +188,14 @@ func (te *TestEnvironment) SetupRepositoryTest(_ *testing.T, namespace, repoName
Name: orgName,
},
// Default value for tests
- Archived: github.Ptr(false),
+ Archived: new(false),
Visibility: "internal",
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(true),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ DeleteBranchOnMerge: new(true),
MergeCommitMessage: "PR_TITLE",
MergeCommitTitle: "MERGE_MESSAGE",
diff --git a/internal/ghclient/wrapper.go b/internal/ghclient/wrapper.go
index 36ea4dc..4db9538 100644
--- a/internal/ghclient/wrapper.go
+++ b/internal/ghclient/wrapper.go
@@ -486,7 +486,7 @@ func (g *GitHubClientWrapper) GetActionsRetentionForOrg(ctx context.Context, org
return result, _handleErrorResponse(response, err)
}
func (g *GitHubClientWrapper) SetActionsRetentionForOrg(ctx context.Context, org string, retentionInDays int) error {
- response, err := g.client.Actions.UpdateArtifactAndLogRetentionPeriodInOrganization(ctx, org, github.ArtifactPeriodOpt{Days: github.Ptr(retentionInDays)})
+ response, err := g.client.Actions.UpdateArtifactAndLogRetentionPeriodInOrganization(ctx, org, github.ArtifactPeriodOpt{Days: new(retentionInDays)})
defer _closeBody(response)
return _handleErrorResponse(response, err)
}
diff --git a/internal/mapper/github_actions_settings.go b/internal/mapper/github_actions_settings.go
index e88a978..6f98bfb 100644
--- a/internal/mapper/github_actions_settings.go
+++ b/internal/mapper/github_actions_settings.go
@@ -62,7 +62,7 @@ func EqualRunnerGroup(k8sGroup v1alpha1.RunnerGroup, ghGroup *github.RunnerGroup
func MapRunnerGroupToCreateRequest(group v1alpha1.RunnerGroup, repos []v1alpha1.Repository) github.CreateRunnerGroupRequest {
selectedRepositoryIDs := GetSelectedRepositoryIDsForRunnerGroup(group, repos)
return github.CreateRunnerGroupRequest{
- Name: github.Ptr(group.Name),
+ Name: new(group.Name),
Visibility: group.Visibility,
SelectedRepositoryIDs: selectedRepositoryIDs,
RestrictedToWorkflows: group.RestrictedToWorkflows,
@@ -89,7 +89,7 @@ func GetSelectedRepositoryIDsForRunnerGroup(group v1alpha1.RunnerGroup, repos []
func MapRunnerGroupToUpdateRequest(group v1alpha1.RunnerGroup) github.UpdateRunnerGroupRequest {
return github.UpdateRunnerGroupRequest{
- Name: github.Ptr(group.Name),
+ Name: new(group.Name),
Visibility: group.Visibility,
RestrictedToWorkflows: group.RestrictedToWorkflows,
SelectedWorkflows: group.SelectedWorkflows,
diff --git a/internal/mapper/github_actions_settings_test.go b/internal/mapper/github_actions_settings_test.go
index 0bd1c87..6fa5d8e 100644
--- a/internal/mapper/github_actions_settings_test.go
+++ b/internal/mapper/github_actions_settings_test.go
@@ -21,7 +21,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only configuration is nil", func() {
It("should return false", func() {
current := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}
result := EqualActionsPermissions(nil, current)
Expect(result).To(BeFalse())
@@ -31,7 +31,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only current is nil", func() {
It("should return false", func() {
configuration := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}
result := EqualActionsPermissions(configuration, nil)
Expect(result).To(BeFalse())
@@ -41,14 +41,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when both are equal", func() {
It("should return true for identical permissions", func() {
configuration := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(true),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(true),
}
current := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(true),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(true),
}
result := EqualActionsPermissions(configuration, current)
Expect(result).To(BeTrue())
@@ -65,10 +65,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when SHAPinningRequired differs", func() {
It("should return false", func() {
configuration := &github.ActionsPermissions{
- SHAPinningRequired: github.Ptr(true),
+ SHAPinningRequired: new(true),
}
current := &github.ActionsPermissions{
- SHAPinningRequired: github.Ptr(false),
+ SHAPinningRequired: new(false),
}
result := EqualActionsPermissions(configuration, current)
Expect(result).To(BeFalse())
@@ -76,7 +76,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
configuration := &github.ActionsPermissions{
- SHAPinningRequired: github.Ptr(true),
+ SHAPinningRequired: new(true),
}
current := &github.ActionsPermissions{
SHAPinningRequired: nil,
@@ -89,10 +89,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when AllowedActions differs", func() {
It("should return false", func() {
configuration := &github.ActionsPermissions{
- AllowedActions: github.Ptr("all"),
+ AllowedActions: new("all"),
}
current := &github.ActionsPermissions{
- AllowedActions: github.Ptr("selected"),
+ AllowedActions: new("selected"),
}
result := EqualActionsPermissions(configuration, current)
Expect(result).To(BeFalse())
@@ -100,7 +100,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
configuration := &github.ActionsPermissions{
- AllowedActions: github.Ptr("all"),
+ AllowedActions: new("all"),
}
current := &github.ActionsPermissions{
AllowedActions: nil,
@@ -113,10 +113,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when EnabledRepositories differs", func() {
It("should return false", func() {
configuration := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}
current := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("selected"),
+ EnabledRepositories: new("selected"),
}
result := EqualActionsPermissions(configuration, current)
Expect(result).To(BeFalse())
@@ -124,7 +124,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
configuration := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}
current := &github.ActionsPermissions{
EnabledRepositories: nil,
@@ -137,14 +137,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when multiple fields differ", func() {
It("should return false", func() {
configuration := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(true),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(true),
}
current := &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("selected"),
- AllowedActions: github.Ptr("selected"),
- SHAPinningRequired: github.Ptr(false),
+ EnabledRepositories: new("selected"),
+ AllowedActions: new("selected"),
+ SHAPinningRequired: new(false),
}
result := EqualActionsPermissions(configuration, current)
Expect(result).To(BeFalse())
@@ -163,7 +163,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only actions is nil", func() {
It("should return false", func() {
current := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
}
result := EqualActionsAllowed(nil, current)
Expect(result).To(BeFalse())
@@ -173,7 +173,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only current is nil", func() {
It("should return false", func() {
actions := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
}
result := EqualActionsAllowed(actions, nil)
Expect(result).To(BeFalse())
@@ -183,13 +183,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when both are equal", func() {
It("should return true for identical actions", func() {
actions := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"org/*", "user/repo@*"},
}
current := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"org/*", "user/repo@*"},
}
result := EqualActionsAllowed(actions, current)
@@ -218,10 +218,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when GithubOwnedAllowed differs", func() {
It("should return false", func() {
actions := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
}
current := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
}
result := EqualActionsAllowed(actions, current)
Expect(result).To(BeFalse())
@@ -229,7 +229,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
actions := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
}
current := &github.ActionsAllowed{
GithubOwnedAllowed: nil,
@@ -242,10 +242,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when VerifiedAllowed differs", func() {
It("should return false", func() {
actions := &github.ActionsAllowed{
- VerifiedAllowed: github.Ptr(true),
+ VerifiedAllowed: new(true),
}
current := &github.ActionsAllowed{
- VerifiedAllowed: github.Ptr(false),
+ VerifiedAllowed: new(false),
}
result := EqualActionsAllowed(actions, current)
Expect(result).To(BeFalse())
@@ -253,7 +253,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
actions := &github.ActionsAllowed{
- VerifiedAllowed: github.Ptr(true),
+ VerifiedAllowed: new(true),
}
current := &github.ActionsAllowed{
VerifiedAllowed: nil,
@@ -323,13 +323,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when multiple fields differ", func() {
It("should return false", func() {
actions := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"org/*"},
}
current := &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
- VerifiedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
+ VerifiedAllowed: new(false),
PatternsAllowed: []string{"user/*"},
}
result := EqualActionsAllowed(actions, current)
@@ -349,7 +349,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only expected is nil", func() {
It("should return false", func() {
current := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
+ DefaultWorkflowPermissions: new("read"),
}
result := EqualDefaultWorkflowPermissions(nil, current)
Expect(result).To(BeFalse())
@@ -359,7 +359,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when only current is nil", func() {
It("should return false", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
+ DefaultWorkflowPermissions: new("read"),
}
result := EqualDefaultWorkflowPermissions(expected, nil)
Expect(result).To(BeFalse())
@@ -369,12 +369,12 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when both are equal", func() {
It("should return true for identical permissions", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
- CanApprovePullRequestReviews: github.Ptr(true),
+ DefaultWorkflowPermissions: new("read"),
+ CanApprovePullRequestReviews: new(true),
}
current := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
- CanApprovePullRequestReviews: github.Ptr(true),
+ DefaultWorkflowPermissions: new("read"),
+ CanApprovePullRequestReviews: new(true),
}
result := EqualDefaultWorkflowPermissions(expected, current)
Expect(result).To(BeTrue())
@@ -391,10 +391,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when DefaultWorkflowPermissions differs", func() {
It("should return false for different values", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
+ DefaultWorkflowPermissions: new("read"),
}
current := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("write"),
+ DefaultWorkflowPermissions: new("write"),
}
result := EqualDefaultWorkflowPermissions(expected, current)
Expect(result).To(BeFalse())
@@ -402,7 +402,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
+ DefaultWorkflowPermissions: new("read"),
}
current := &github.DefaultWorkflowPermissionOrganization{
DefaultWorkflowPermissions: nil,
@@ -415,10 +415,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when CanApprovePullRequestReviews differs", func() {
It("should return false for different values", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- CanApprovePullRequestReviews: github.Ptr(true),
+ CanApprovePullRequestReviews: new(true),
}
current := &github.DefaultWorkflowPermissionOrganization{
- CanApprovePullRequestReviews: github.Ptr(false),
+ CanApprovePullRequestReviews: new(false),
}
result := EqualDefaultWorkflowPermissions(expected, current)
Expect(result).To(BeFalse())
@@ -426,7 +426,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- CanApprovePullRequestReviews: github.Ptr(true),
+ CanApprovePullRequestReviews: new(true),
}
current := &github.DefaultWorkflowPermissionOrganization{
CanApprovePullRequestReviews: nil,
@@ -439,12 +439,12 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
Context("when both fields differ", func() {
It("should return false", func() {
expected := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
- CanApprovePullRequestReviews: github.Ptr(true),
+ DefaultWorkflowPermissions: new("read"),
+ CanApprovePullRequestReviews: new(true),
}
current := &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("write"),
- CanApprovePullRequestReviews: github.Ptr(false),
+ DefaultWorkflowPermissions: new("write"),
+ CanApprovePullRequestReviews: new(false),
}
result := EqualDefaultWorkflowPermissions(expected, current)
Expect(result).To(BeFalse())
@@ -457,14 +457,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true for identical runner groups", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -474,14 +474,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when RestrictedToWorkflows is false and SelectedWorkflows differ", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: []string{"org/repo/.github/workflows/deploy.yaml@refs/heads/main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("test-group"),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: []string{"different/workflow@refs/heads/main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -491,14 +491,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when RestrictedToWorkflows is true and SelectedWorkflows are identical", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -508,14 +508,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when RestrictedToWorkflows is true and SelectedWorkflows are in different order", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/a.yaml@main", "org/repo/.github/workflows/b.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/b.yaml@main", "org/repo/.github/workflows/a.yaml@main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -525,14 +525,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when RestrictedToWorkflows is nil in k8s and false in GitHub", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
RestrictedToWorkflows: nil,
SelectedWorkflows: nil,
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -544,13 +544,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("different-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("different-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
Expect(result).To(BeFalse())
@@ -561,13 +561,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("test-group"),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(false),
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
Expect(result).To(BeFalse())
@@ -576,13 +576,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one visibility is nil", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
+ Name: new("test-group"),
Visibility: nil,
- RestrictedToWorkflows: github.Ptr(false),
+ RestrictedToWorkflows: new(false),
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
Expect(result).To(BeFalse())
@@ -593,14 +593,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when values are different", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -610,13 +610,13 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one is nil", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
+ Name: new("test-group"),
+ Visibility: new("all"),
RestrictedToWorkflows: nil,
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
@@ -629,14 +629,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when workflows are different", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/deploy.yaml@main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -646,14 +646,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when number of workflows differs", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main", "org/repo/.github/workflows/deploy.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -663,14 +663,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when one has nil workflows and other has workflows", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: nil,
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -680,14 +680,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when both have empty workflows", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -699,14 +699,14 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false", func() {
k8sGroup := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
ghGroup := &github.RunnerGroup{
- Name: github.Ptr("different-group"),
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(false),
+ Name: new("different-group"),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: []string{"org/repo/.github/workflows/deploy.yaml@main"},
}
result := EqualRunnerGroup(k8sGroup, ghGroup)
@@ -720,17 +720,17 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should create request without selected repositories", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
repos := []v1alpha1.Repository{}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("all")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("all")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(false)))
Expect(result.SelectedWorkflows).To(BeNil())
Expect(result.SelectedRepositoryIDs).To(BeNil())
})
@@ -738,7 +738,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should not include repositories even if they reference the runner group", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
}
repos := []v1alpha1.Repository{
{
@@ -747,7 +747,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
},
}
@@ -762,17 +762,17 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should create request without selected repositories", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
repos := []v1alpha1.Repository{}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("private")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("private")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(false)))
Expect(result.SelectedWorkflows).To(BeNil())
Expect(result.SelectedRepositoryIDs).To(BeNil())
})
@@ -782,8 +782,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should include repositories that reference the runner group with ID", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(false),
}
repos := []v1alpha1.Repository{
{
@@ -792,7 +792,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
},
{
@@ -801,15 +801,15 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(456)),
+ ID: new(int64(456)),
},
},
}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("selected")))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("selected")))
Expect(result.SelectedRepositoryIDs).To(HaveLen(2))
Expect(result.SelectedRepositoryIDs).To(ContainElements(int64(123), int64(456)))
})
@@ -817,7 +817,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should exclude repositories without ID", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -826,7 +826,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
},
{
@@ -849,7 +849,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should exclude repositories that don't reference the runner group", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -858,7 +858,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
},
{
@@ -867,7 +867,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"other-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(456)),
+ ID: new(int64(456)),
},
},
{
@@ -876,7 +876,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: nil,
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(789)),
+ ID: new(int64(789)),
},
},
}
@@ -890,7 +890,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return empty slice when no repositories match", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -899,7 +899,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"other-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
},
}
@@ -913,7 +913,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should initialize empty slice when no repos provided", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{}
@@ -928,24 +928,24 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should include selected workflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"},
}
repos := []v1alpha1.Repository{}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(Equal([]string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"}))
})
It("should include multiple selected workflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo/.github/workflows/ci.yaml@refs/heads/main",
"org/repo/.github/workflows/deploy.yaml@refs/tags/v1.0.0",
@@ -955,7 +955,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(HaveLen(2))
Expect(result.SelectedWorkflows).To(ContainElements(
"org/repo/.github/workflows/ci.yaml@refs/heads/main",
@@ -968,15 +968,15 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should not include selected workflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"},
}
repos := []v1alpha1.Repository{}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(false)))
Expect(result.SelectedWorkflows).To(Equal([]string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"}))
})
})
@@ -985,7 +985,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should pass nil RestrictedToWorkflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
RestrictedToWorkflows: nil,
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@refs/heads/main"},
}
@@ -1002,8 +1002,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle selected visibility with workflows and matching repos", func() {
group := v1alpha1.RunnerGroup{
Name: "production-runners",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo1/.github/workflows/deploy.yaml@refs/heads/main",
},
@@ -1015,7 +1015,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"production-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -1024,7 +1024,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"production-runners", "staging-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
{
@@ -1042,16 +1042,16 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"staging-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(400)),
+ ID: new(int64(400)),
},
},
}
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("production-runners")))
- Expect(result.Visibility).To(Equal(github.Ptr("selected")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("production-runners")))
+ Expect(result.Visibility).To(Equal(new("selected")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(Equal([]string{
"org/repo1/.github/workflows/deploy.yaml@refs/heads/main",
}))
@@ -1067,7 +1067,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
result := MapRunnerGroupToCreateRequest(group, repos)
- Expect(result.Name).To(Equal(github.Ptr("minimal-group")))
+ Expect(result.Name).To(Equal(new("minimal-group")))
Expect(result.Visibility).To(BeNil())
Expect(result.RestrictedToWorkflows).To(BeNil())
Expect(result.SelectedWorkflows).To(BeNil())
@@ -1081,7 +1081,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return nil for 'all' visibility", func() {
group := v1alpha1.RunnerGroup{
Name: "all-runners",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
}
repos := []v1alpha1.Repository{
{
@@ -1090,7 +1090,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"all-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
@@ -1103,7 +1103,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return nil for 'private' visibility", func() {
group := v1alpha1.RunnerGroup{
Name: "private-runners",
- Visibility: github.Ptr("private"),
+ Visibility: new("private"),
}
repos := []v1alpha1.Repository{
{
@@ -1112,7 +1112,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"private-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
@@ -1134,7 +1134,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"no-visibility"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
@@ -1149,7 +1149,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return empty slice when no repos match", func() {
group := v1alpha1.RunnerGroup{
Name: "selected-runners",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -1158,7 +1158,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"other-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
@@ -1171,7 +1171,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return IDs of matching repos", func() {
group := v1alpha1.RunnerGroup{
Name: "selected-runners",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -1180,7 +1180,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"selected-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -1189,7 +1189,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"selected-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
}
@@ -1203,7 +1203,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should skip repos without IDs (not yet reconciled)", func() {
group := v1alpha1.RunnerGroup{
Name: "selected-runners",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -1212,7 +1212,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"selected-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -1230,7 +1230,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"selected-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(300)),
+ ID: new(int64(300)),
},
},
}
@@ -1245,7 +1245,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle repos with multiple runner groups", func() {
group := v1alpha1.RunnerGroup{
Name: "production-runners",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{
{
@@ -1254,7 +1254,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"production-runners", "staging-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -1263,7 +1263,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"staging-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
{
@@ -1272,7 +1272,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
AvailableActionsRunnerGroups: []string{"production-runners"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(300)),
+ ID: new(int64(300)),
},
},
}
@@ -1287,7 +1287,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return empty slice when repos list is empty", func() {
group := v1alpha1.RunnerGroup{
Name: "selected-runners",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
}
repos := []v1alpha1.Repository{}
@@ -1303,8 +1303,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should map all fields correctly", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo/.github/workflows/ci.yaml@refs/heads/main",
"org/repo/.github/workflows/deploy.yaml@refs/heads/main",
@@ -1313,9 +1313,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("selected")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("selected")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(HaveLen(2))
Expect(result.SelectedWorkflows).To(ContainElements(
"org/repo/.github/workflows/ci.yaml@refs/heads/main",
@@ -1326,32 +1326,32 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should map with visibility 'all'", func() {
group := v1alpha1.RunnerGroup{
Name: "all-runners",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("all-runners")))
- Expect(result.Visibility).To(Equal(github.Ptr("all")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(result.Name).To(Equal(new("all-runners")))
+ Expect(result.Visibility).To(Equal(new("all")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(false)))
Expect(result.SelectedWorkflows).To(BeNil())
})
It("should map with visibility 'private'", func() {
group := v1alpha1.RunnerGroup{
Name: "private-runners",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("private-runners")))
- Expect(result.Visibility).To(Equal(github.Ptr("private")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("private-runners")))
+ Expect(result.Visibility).To(Equal(new("private")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(Equal([]string{"org/repo/.github/workflows/ci.yaml@main"}))
})
})
@@ -1361,30 +1361,30 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
Visibility: nil,
- RestrictedToWorkflows: github.Ptr(true),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
+ Expect(result.Name).To(Equal(new("test-group")))
Expect(result.Visibility).To(BeNil())
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(Equal([]string{"org/repo/.github/workflows/ci.yaml@main"}))
})
It("should handle nil RestrictedToWorkflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
RestrictedToWorkflows: nil,
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("all")))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("all")))
Expect(result.RestrictedToWorkflows).To(BeNil())
Expect(result.SelectedWorkflows).To(Equal([]string{"org/repo/.github/workflows/ci.yaml@main"}))
})
@@ -1392,32 +1392,32 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle nil SelectedWorkflows", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(false),
SelectedWorkflows: nil,
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("selected")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("selected")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(false)))
Expect(result.SelectedWorkflows).To(BeNil())
})
It("should handle empty SelectedWorkflows slice", func() {
group := v1alpha1.RunnerGroup{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{},
}
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("test-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("selected")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("test-group")))
+ Expect(result.Visibility).To(Equal(new("selected")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(BeEmpty())
})
})
@@ -1433,7 +1433,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("minimal-group")))
+ Expect(result.Name).To(Equal(new("minimal-group")))
Expect(result.Visibility).To(BeNil())
Expect(result.RestrictedToWorkflows).To(BeNil())
Expect(result.SelectedWorkflows).To(BeNil())
@@ -1444,8 +1444,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should preserve workflow restrictions when enabled", func() {
group := v1alpha1.RunnerGroup{
Name: "restricted-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo1/.github/workflows/ci.yaml@refs/heads/main",
"org/repo2/.github/workflows/deploy.yaml@refs/tags/v1.0.0",
@@ -1455,9 +1455,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
result := MapRunnerGroupToUpdateRequest(group)
- Expect(result.Name).To(Equal(github.Ptr("restricted-group")))
- Expect(result.Visibility).To(Equal(github.Ptr("all")))
- Expect(result.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(result.Name).To(Equal(new("restricted-group")))
+ Expect(result.Visibility).To(Equal(new("all")))
+ Expect(result.RestrictedToWorkflows).To(Equal(new(true)))
Expect(result.SelectedWorkflows).To(HaveLen(3))
Expect(result.SelectedWorkflows).To(ContainElements(
"org/repo1/.github/workflows/ci.yaml@refs/heads/main",
@@ -1493,8 +1493,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when expected has more items", func() {
expectedIDs := []int64{100, 200, 300}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1505,9 +1505,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when current has more items", func() {
expectedIDs := []int64{100, 200}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
- {ID: github.Ptr(int64(300))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
+ {ID: new(int64(300))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1518,7 +1518,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when expected is empty but current is not", func() {
expectedIDs := []int64{}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
+ {ID: new(int64(100))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1540,9 +1540,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when all IDs match", func() {
expectedIDs := []int64{100, 200, 300}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
- {ID: github.Ptr(int64(300))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
+ {ID: new(int64(300))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1553,9 +1553,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when all IDs match regardless of order", func() {
expectedIDs := []int64{300, 100, 200}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
- {ID: github.Ptr(int64(300))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
+ {ID: new(int64(300))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1566,9 +1566,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when some IDs differ", func() {
expectedIDs := []int64{100, 200, 300}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
- {ID: github.Ptr(int64(400))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
+ {ID: new(int64(400))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1579,9 +1579,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when all IDs are different", func() {
expectedIDs := []int64{100, 200, 300}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(400))},
- {ID: github.Ptr(int64(500))},
- {ID: github.Ptr(int64(600))},
+ {ID: new(int64(400))},
+ {ID: new(int64(500))},
+ {ID: new(int64(600))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1594,7 +1594,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true when single ID matches", func() {
expectedIDs := []int64{100}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
+ {ID: new(int64(100))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1605,7 +1605,7 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return false when single ID differs", func() {
expectedIDs := []int64{100}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(200))},
+ {ID: new(int64(200))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1618,8 +1618,8 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle duplicates in expected list", func() {
expectedIDs := []int64{100, 100, 200}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1633,9 +1633,9 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle large repository IDs", func() {
expectedIDs := []int64{9223372036854775807, 1000000000000, 999999999999}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(9223372036854775807))},
- {ID: github.Ptr(int64(1000000000000))},
- {ID: github.Ptr(int64(999999999999))},
+ {ID: new(int64(9223372036854775807))},
+ {ID: new(int64(1000000000000))},
+ {ID: new(int64(999999999999))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1648,10 +1648,10 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should handle mixed matching and non-matching IDs", func() {
expectedIDs := []int64{100, 200, 300, 400}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(200))},
- {ID: github.Ptr(int64(300))},
- {ID: github.Ptr(int64(400))},
+ {ID: new(int64(100))},
+ {ID: new(int64(200))},
+ {ID: new(int64(300))},
+ {ID: new(int64(400))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
@@ -1662,16 +1662,16 @@ var _ = Describe("GitHub Actions Configuration Mapper", func() {
It("should return true for matching unordered large list", func() {
expectedIDs := []int64{10, 20, 30, 40, 50, 60, 70, 80, 90, 100}
currentRepos := []*github.Repository{
- {ID: github.Ptr(int64(100))},
- {ID: github.Ptr(int64(90))},
- {ID: github.Ptr(int64(80))},
- {ID: github.Ptr(int64(70))},
- {ID: github.Ptr(int64(60))},
- {ID: github.Ptr(int64(50))},
- {ID: github.Ptr(int64(40))},
- {ID: github.Ptr(int64(30))},
- {ID: github.Ptr(int64(20))},
- {ID: github.Ptr(int64(10))},
+ {ID: new(int64(100))},
+ {ID: new(int64(90))},
+ {ID: new(int64(80))},
+ {ID: new(int64(70))},
+ {ID: new(int64(60))},
+ {ID: new(int64(50))},
+ {ID: new(int64(40))},
+ {ID: new(int64(30))},
+ {ID: new(int64(20))},
+ {ID: new(int64(10))},
}
result := EqualRepositoryIDs(expectedIDs, currentRepos)
diff --git a/internal/mapper/github_autolink_mapper.go b/internal/mapper/github_autolink_mapper.go
index 03661a0..920648a 100644
--- a/internal/mapper/github_autolink_mapper.go
+++ b/internal/mapper/github_autolink_mapper.go
@@ -15,8 +15,8 @@ func HashAutolink(keyPrefix, urlTemplate string, isAlphanumeric bool) string {
func KubernetesAutolinkToGitHubAutolink(preset v1alpha1.Autolink) *github.AutolinkOptions {
return &github.AutolinkOptions{
- KeyPrefix: github.Ptr(preset.KeyPrefix),
- URLTemplate: github.Ptr(preset.URLTemplate),
- IsAlphanumeric: github.Ptr(preset.IsAlphanumeric),
+ KeyPrefix: new(preset.KeyPrefix),
+ URLTemplate: new(preset.URLTemplate),
+ IsAlphanumeric: new(preset.IsAlphanumeric),
}
}
diff --git a/internal/mapper/github_code_security_configuration_mapper_test.go b/internal/mapper/github_code_security_configuration_mapper_test.go
index c350a82..45a5310 100644
--- a/internal/mapper/github_code_security_configuration_mapper_test.go
+++ b/internal/mapper/github_code_security_configuration_mapper_test.go
@@ -13,12 +13,12 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
Description: "Test description",
- AdvancedSecurity: github.Ptr("enabled"),
+ AdvancedSecurity: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
Description: "Test description",
- AdvancedSecurity: github.Ptr("enabled"),
+ AdvancedSecurity: new("enabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -29,26 +29,26 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
Description: "Test description",
- AdvancedSecurity: github.Ptr("enabled"),
- DependencyGraph: github.Ptr("enabled"),
- DependabotAlerts: github.Ptr("enabled"),
- SecretScanning: github.Ptr("enabled"),
- SecretScanningPushProtection: github.Ptr("enabled"),
- PrivateVulnerabilityReporting: github.Ptr("enabled"),
- Enforcement: github.Ptr("active"),
- CodeSecurity: github.Ptr("enabled"),
+ AdvancedSecurity: new("enabled"),
+ DependencyGraph: new("enabled"),
+ DependabotAlerts: new("enabled"),
+ SecretScanning: new("enabled"),
+ SecretScanningPushProtection: new("enabled"),
+ PrivateVulnerabilityReporting: new("enabled"),
+ Enforcement: new("active"),
+ CodeSecurity: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
Description: "Test description",
- AdvancedSecurity: github.Ptr("enabled"),
- DependencyGraph: github.Ptr("enabled"),
- DependabotAlerts: github.Ptr("enabled"),
- SecretScanning: github.Ptr("enabled"),
- SecretScanningPushProtection: github.Ptr("enabled"),
- PrivateVulnerabilityReporting: github.Ptr("enabled"),
- Enforcement: github.Ptr("active"),
- CodeSecurity: github.Ptr("enabled"),
+ AdvancedSecurity: new("enabled"),
+ DependencyGraph: new("enabled"),
+ DependabotAlerts: new("enabled"),
+ SecretScanning: new("enabled"),
+ SecretScanningPushProtection: new("enabled"),
+ PrivateVulnerabilityReporting: new("enabled"),
+ Enforcement: new("active"),
+ CodeSecurity: new("enabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -88,11 +88,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different advanced security", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- AdvancedSecurity: github.Ptr("enabled"),
+ AdvancedSecurity: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- AdvancedSecurity: github.Ptr("disabled"),
+ AdvancedSecurity: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -102,11 +102,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different dependency graph", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependencyGraph: github.Ptr("enabled"),
+ DependencyGraph: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependencyGraph: github.Ptr("disabled"),
+ DependencyGraph: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -116,11 +116,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different dependency graph autosubmit action", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependencyGraphAutosubmitAction: github.Ptr("enabled"),
+ DependencyGraphAutosubmitAction: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependencyGraphAutosubmitAction: github.Ptr("disabled"),
+ DependencyGraphAutosubmitAction: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -131,13 +131,13 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
DependencyGraphAutosubmitActionOptions: &github.DependencyGraphAutosubmitActionOptions{
- LabeledRunners: github.Ptr(true),
+ LabeledRunners: new(true),
},
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
DependencyGraphAutosubmitActionOptions: &github.DependencyGraphAutosubmitActionOptions{
- LabeledRunners: github.Ptr(false),
+ LabeledRunners: new(false),
},
}
@@ -149,7 +149,7 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
DependencyGraphAutosubmitActionOptions: &github.DependencyGraphAutosubmitActionOptions{
- LabeledRunners: github.Ptr(true),
+ LabeledRunners: new(true),
},
}
second := &github.CodeSecurityConfiguration{
@@ -163,11 +163,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different dependabot alerts", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependabotAlerts: github.Ptr("enabled"),
+ DependabotAlerts: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependabotAlerts: github.Ptr("disabled"),
+ DependabotAlerts: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -177,11 +177,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different dependabot security updates", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependabotSecurityUpdates: github.Ptr("enabled"),
+ DependabotSecurityUpdates: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- DependabotSecurityUpdates: github.Ptr("disabled"),
+ DependabotSecurityUpdates: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -191,11 +191,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different code scanning default setup", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeScanningDefaultSetup: github.Ptr("enabled"),
+ CodeScanningDefaultSetup: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeScanningDefaultSetup: github.Ptr("disabled"),
+ CodeScanningDefaultSetup: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -207,14 +207,14 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "labeled",
- RunnerLabel: github.Ptr("runner-1"),
+ RunnerLabel: new("runner-1"),
},
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "labeled",
- RunnerLabel: github.Ptr("runner-2"),
+ RunnerLabel: new("runner-2"),
},
}
@@ -240,11 +240,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different code scanning delegated alert dismissal", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeScanningDelegatedAlertDismissal: github.Ptr("enabled"),
+ CodeScanningDelegatedAlertDismissal: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeScanningDelegatedAlertDismissal: github.Ptr("disabled"),
+ CodeScanningDelegatedAlertDismissal: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -255,13 +255,13 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningOptions: &github.CodeScanningOptions{
- AllowAdvanced: github.Ptr(true),
+ AllowAdvanced: new(true),
},
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningOptions: &github.CodeScanningOptions{
- AllowAdvanced: github.Ptr(false),
+ AllowAdvanced: new(false),
},
}
@@ -273,7 +273,7 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningOptions: &github.CodeScanningOptions{
- AllowAdvanced: github.Ptr(true),
+ AllowAdvanced: new(true),
},
}
second := &github.CodeSecurityConfiguration{
@@ -287,11 +287,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different code security", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeSecurity: github.Ptr("enabled"),
+ CodeSecurity: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- CodeSecurity: github.Ptr("disabled"),
+ CodeSecurity: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -301,11 +301,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanning: github.Ptr("enabled"),
+ SecretScanning: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanning: github.Ptr("disabled"),
+ SecretScanning: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -315,11 +315,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning push protection", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningPushProtection: github.Ptr("enabled"),
+ SecretScanningPushProtection: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningPushProtection: github.Ptr("disabled"),
+ SecretScanningPushProtection: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -329,11 +329,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning validity checks", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningValidityChecks: github.Ptr("enabled"),
+ SecretScanningValidityChecks: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningValidityChecks: github.Ptr("disabled"),
+ SecretScanningValidityChecks: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -343,11 +343,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning non provider patterns", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningNonProviderPatterns: github.Ptr("enabled"),
+ SecretScanningNonProviderPatterns: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningNonProviderPatterns: github.Ptr("disabled"),
+ SecretScanningNonProviderPatterns: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -357,11 +357,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning generic secrets", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningGenericSecrets: github.Ptr("enabled"),
+ SecretScanningGenericSecrets: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningGenericSecrets: github.Ptr("disabled"),
+ SecretScanningGenericSecrets: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -371,11 +371,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret scanning delegated alert dismissal", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningDelegatedAlertDismissal: github.Ptr("enabled"),
+ SecretScanningDelegatedAlertDismissal: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretScanningDelegatedAlertDismissal: github.Ptr("disabled"),
+ SecretScanningDelegatedAlertDismissal: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -385,11 +385,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different secret protection", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretProtection: github.Ptr("enabled"),
+ SecretProtection: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- SecretProtection: github.Ptr("disabled"),
+ SecretProtection: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -399,11 +399,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different private vulnerability reporting", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- PrivateVulnerabilityReporting: github.Ptr("enabled"),
+ PrivateVulnerabilityReporting: new("enabled"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- PrivateVulnerabilityReporting: github.Ptr("disabled"),
+ PrivateVulnerabilityReporting: new("disabled"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -413,11 +413,11 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
It("should return true for different enforcement", func() {
first := &github.CodeSecurityConfiguration{
Name: "test-config",
- Enforcement: github.Ptr("active"),
+ Enforcement: new("active"),
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
- Enforcement: github.Ptr("inactive"),
+ Enforcement: new("inactive"),
}
result := CodeSecurityConfigurationsDiffer(first, second)
@@ -473,14 +473,14 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "labeled",
- RunnerLabel: github.Ptr("my-runner"),
+ RunnerLabel: new("my-runner"),
},
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "labeled",
- RunnerLabel: github.Ptr("my-runner"),
+ RunnerLabel: new("my-runner"),
},
}
@@ -493,14 +493,14 @@ var _ = Describe("CodeSecurityConfigurationsDiffer", func() {
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "labeled",
- RunnerLabel: github.Ptr("my-runner"),
+ RunnerLabel: new("my-runner"),
},
}
second := &github.CodeSecurityConfiguration{
Name: "test-config",
CodeScanningDefaultSetupOptions: &github.CodeScanningDefaultSetupOptions{
RunnerType: "unlabeled",
- RunnerLabel: github.Ptr("my-runner"),
+ RunnerLabel: new("my-runner"),
},
}
diff --git a/internal/mapper/github_custom_property_mapper_test.go b/internal/mapper/github_custom_property_mapper_test.go
index c73d00a..e10f253 100644
--- a/internal/mapper/github_custom_property_mapper_test.go
+++ b/internal/mapper/github_custom_property_mapper_test.go
@@ -19,9 +19,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
desired = v1alpha1.OrgCustomProperty{
PropertyName: "test-property",
ValueType: "string",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("default")},
- Description: github.Ptr("test description"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("default")},
+ Description: new("test description"),
AllowedValues: nil,
ValuesEditableBy: "org_actors",
}
@@ -38,9 +38,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when current property is not organization type", func() {
BeforeEach(func() {
current = &github.CustomProperty{
- PropertyName: github.Ptr("test-property"),
+ PropertyName: new("test-property"),
ValueType: "string",
- SourceType: github.Ptr("repository"),
+ SourceType: new("repository"),
}
})
@@ -54,14 +54,14 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when current property is organization type and matches", func() {
BeforeEach(func() {
current = &github.CustomProperty{
- PropertyName: github.Ptr("test-property"),
+ PropertyName: new("test-property"),
ValueType: "string",
- SourceType: github.Ptr(CustomPropertySourceTypeOrganization),
- Required: github.Ptr(true),
+ SourceType: new(CustomPropertySourceTypeOrganization),
+ Required: new(true),
DefaultValue: "default",
- Description: github.Ptr("test description"),
+ Description: new("test description"),
AllowedValues: []string{},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
}
})
@@ -75,14 +75,14 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when current property is organization type but does not match", func() {
BeforeEach(func() {
current = &github.CustomProperty{
- PropertyName: github.Ptr("test-property"),
+ PropertyName: new("test-property"),
ValueType: "string",
- SourceType: github.Ptr(CustomPropertySourceTypeOrganization),
- Required: github.Ptr(false),
+ SourceType: new(CustomPropertySourceTypeOrganization),
+ Required: new(false),
DefaultValue: "different",
- Description: github.Ptr("different description"),
+ Description: new("different description"),
AllowedValues: []string{},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
}
})
@@ -99,7 +99,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when property is organization type", func() {
It("should return true", func() {
property := &github.CustomProperty{
- SourceType: github.Ptr(CustomPropertySourceTypeOrganization),
+ SourceType: new(CustomPropertySourceTypeOrganization),
}
result := IsK8sOrgCustomProperty(property)
Expect(result).To(BeTrue())
@@ -109,7 +109,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when property is repository type", func() {
It("should return false", func() {
property := &github.CustomProperty{
- SourceType: github.Ptr("repository"),
+ SourceType: new("repository"),
}
result := IsK8sOrgCustomProperty(property)
Expect(result).To(BeFalse())
@@ -129,7 +129,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when property has empty source type", func() {
It("should return false", func() {
property := &github.CustomProperty{
- SourceType: github.Ptr(""),
+ SourceType: new(""),
}
result := IsK8sOrgCustomProperty(property)
Expect(result).To(BeFalse())
@@ -141,13 +141,13 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when converting valid GitHub custom property", func() {
It("should successfully convert string property", func() {
githubProperty := &github.CustomProperty{
- PropertyName: github.Ptr("test-string"),
+ PropertyName: new("test-string"),
ValueType: "string",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "default-value",
- Description: github.Ptr("test description"),
+ Description: new("test description"),
AllowedValues: []string{},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
}
result, err := ToK8sOrgCustomProperty(githubProperty)
@@ -164,13 +164,13 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should successfully convert single_select property", func() {
githubProperty := &github.CustomProperty{
- PropertyName: github.Ptr("test-select"),
+ PropertyName: new("test-select"),
ValueType: "single_select",
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "option1",
- Description: github.Ptr("select description"),
+ Description: new("select description"),
AllowedValues: []string{"option1", "option2", "option3"},
- ValuesEditableBy: github.Ptr("org_and_repo_actors"),
+ ValuesEditableBy: new("org_and_repo_actors"),
}
result, err := ToK8sOrgCustomProperty(githubProperty)
@@ -186,13 +186,13 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should successfully convert multi_select property", func() {
githubProperty := &github.CustomProperty{
- PropertyName: github.Ptr("test-multi"),
+ PropertyName: new("test-multi"),
ValueType: "multi_select",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: []string{"option1", "option2"},
- Description: github.Ptr("multi select description"),
+ Description: new("multi select description"),
AllowedValues: []string{"option1", "option2", "option3", "option4"},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
}
result, err := ToK8sOrgCustomProperty(githubProperty)
@@ -208,13 +208,13 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should successfully convert true_false property", func() {
githubProperty := &github.CustomProperty{
- PropertyName: github.Ptr("test-boolean"),
+ PropertyName: new("test-boolean"),
ValueType: "true_false",
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "true",
Description: nil,
AllowedValues: []string{},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
}
result, err := ToK8sOrgCustomProperty(githubProperty)
@@ -229,7 +229,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should handle property with nil values", func() {
githubProperty := &github.CustomProperty{
- PropertyName: github.Ptr("minimal-property"),
+ PropertyName: new("minimal-property"),
ValueType: "string",
Required: nil,
DefaultValue: nil,
@@ -258,9 +258,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
k8sProperty := v1alpha1.OrgCustomProperty{
PropertyName: "test-string",
ValueType: "string",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("default-value")},
- Description: github.Ptr("test description"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("default-value")},
+ Description: new("test description"),
AllowedValues: []string{},
ValuesEditableBy: "org_actors",
}
@@ -281,9 +281,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
k8sProperty := v1alpha1.OrgCustomProperty{
PropertyName: "test-select",
ValueType: "single_select",
- Required: github.Ptr(false),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")},
- Description: github.Ptr("select description"),
+ Required: new(false),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")},
+ Description: new("select description"),
AllowedValues: []string{"option1", "option2", "option3"},
ValuesEditableBy: "org_and_repo_actors",
}
@@ -302,9 +302,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
k8sProperty := v1alpha1.OrgCustomProperty{
PropertyName: "test-multi",
ValueType: "multi_select",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Values: []string{"option1", "option2"}},
- Description: github.Ptr("multi select description"),
+ Description: new("multi select description"),
AllowedValues: []string{"option1", "option2", "option3", "option4"},
ValuesEditableBy: "org_actors",
}
@@ -323,8 +323,8 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
k8sProperty := v1alpha1.OrgCustomProperty{
PropertyName: "test-boolean",
ValueType: "true_false",
- Required: github.Ptr(false),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("false")},
+ Required: new(false),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("false")},
Description: nil,
AllowedValues: []string{},
ValuesEditableBy: "org_actors",
@@ -343,7 +343,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
k8sProperty := v1alpha1.OrgCustomProperty{
PropertyName: "minimal-property",
ValueType: "string",
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: nil,
Description: nil,
AllowedValues: nil,
@@ -394,10 +394,10 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when converting valid property values", func() {
It("should successfully convert all supported types", func() {
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: stringProp, Value: github.Ptr("test-value")},
- {PropertyName: selectProp, Value: github.Ptr("option1")},
+ {PropertyName: stringProp, Value: new("test-value")},
+ {PropertyName: selectProp, Value: new("option1")},
{PropertyName: multiProp, Values: []string{"option1", "option2"}},
- {PropertyName: boolProp, Value: github.Ptr("true")},
+ {PropertyName: boolProp, Value: new("true")},
}
result, err := ToGitHubCustomPropertyValues(raw, definitions)
@@ -438,7 +438,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should handle nil values", func() {
raw := []v1alpha1.CustomPropertyValue{
{PropertyName: stringProp, Value: nil},
- {PropertyName: selectProp, Value: github.Ptr("option1")},
+ {PropertyName: selectProp, Value: new("option1")},
}
result, err := ToGitHubCustomPropertyValues(raw, definitions)
@@ -462,7 +462,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when property is not defined", func() {
It("should return error for undefined property", func() {
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: "undefined-prop", Value: github.Ptr("value")},
+ {PropertyName: "undefined-prop", Value: new("value")},
}
result, err := ToGitHubCustomPropertyValues(raw, definitions)
@@ -477,9 +477,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should return multiple errors for multiple undefined properties", func() {
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: "undefined-prop1", Value: github.Ptr("value1")},
- {PropertyName: "undefined-prop2", Value: github.Ptr("value2")},
- {PropertyName: stringProp, Value: github.Ptr("valid-value")},
+ {PropertyName: "undefined-prop1", Value: new("value1")},
+ {PropertyName: "undefined-prop2", Value: new("value2")},
+ {PropertyName: stringProp, Value: new("valid-value")},
}
result, err := ToGitHubCustomPropertyValues(raw, definitions)
// No longer errors - undefined properties are ignored
@@ -501,7 +501,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when definitions are empty", func() {
It("should return error for any property", func() {
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: "any-prop", Value: github.Ptr("value")},
+ {PropertyName: "any-prop", Value: new("value")},
}
result, err := ToGitHubCustomPropertyValues(raw, []*github.CustomProperty{})
// No longer errors - empty definitions means nothing to process
@@ -513,7 +513,7 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
Context("when definitions are nil", func() {
It("should return error for any property", func() {
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: "any-prop", Value: github.Ptr("value")},
+ {PropertyName: "any-prop", Value: new("value")},
}
result, err := ToGitHubCustomPropertyValues(raw, nil)
// No longer errors - nil definitions means nothing to process
@@ -526,9 +526,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should use default value for required string property", func() {
definitions := []*github.CustomProperty{
{
- PropertyName: github.Ptr("required-string"),
+ PropertyName: new("required-string"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "default-value",
},
}
@@ -544,9 +544,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should use default value for required single_select property", func() {
definitions := []*github.CustomProperty{
{
- PropertyName: github.Ptr("required-select"),
+ PropertyName: new("required-select"),
ValueType: github.PropertyValueTypeSingleSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "option1",
},
}
@@ -562,9 +562,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should use default values for required multi_select property", func() {
definitions := []*github.CustomProperty{
{
- PropertyName: github.Ptr("required-multi"),
+ PropertyName: new("required-multi"),
ValueType: github.PropertyValueTypeMultiSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: []any{"option1", "option2"},
},
}
@@ -580,9 +580,9 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should set nil for optional property not in raw input", func() {
definitions := []*github.CustomProperty{
{
- PropertyName: github.Ptr("optional-string"),
+ PropertyName: new("optional-string"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "default-value",
},
}
@@ -598,25 +598,25 @@ var _ = Describe("GitHub Custom Property Mapper", func() {
It("should handle mix of required and optional properties", func() {
definitions := []*github.CustomProperty{
{
- PropertyName: github.Ptr("required-prop"),
+ PropertyName: new("required-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "required-default",
},
{
- PropertyName: github.Ptr("optional-prop"),
+ PropertyName: new("optional-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "optional-default",
},
{
- PropertyName: github.Ptr("provided-prop"),
+ PropertyName: new("provided-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
},
}
raw := []v1alpha1.CustomPropertyValue{
- {PropertyName: "provided-prop", Value: github.Ptr("user-value")},
+ {PropertyName: "provided-prop", Value: new("user-value")},
}
result, err := ToGitHubCustomPropertyValues(raw, definitions)
diff --git a/internal/mapper/github_deploykey_mapper.go b/internal/mapper/github_deploykey_mapper.go
index 5916d17..900e5b0 100644
--- a/internal/mapper/github_deploykey_mapper.go
+++ b/internal/mapper/github_deploykey_mapper.go
@@ -16,8 +16,8 @@ func HashDeployKey(key, title string, readonly bool) string {
func DeployKeyPresetToGitHubDeployKey(preset v1alpha1.DeployKey) *github.Key {
return &github.Key{
- Key: github.Ptr(preset.Key),
+ Key: new(preset.Key),
ReadOnly: utils.WithDefaultAsPtr(preset.ReadOnly, true),
- Title: github.Ptr(preset.Title),
+ Title: new(preset.Title),
}
}
diff --git a/internal/mapper/github_deploykey_mapper_test.go b/internal/mapper/github_deploykey_mapper_test.go
index 4993d04..f01a20e 100644
--- a/internal/mapper/github_deploykey_mapper_test.go
+++ b/internal/mapper/github_deploykey_mapper_test.go
@@ -158,7 +158,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should convert all fields correctly", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "production-deploy-key",
}
@@ -176,7 +176,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle read-write deploy key", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "write-access-key",
}
@@ -189,7 +189,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle empty key", func() {
preset := v1alpha1.DeployKey{
Key: "",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "empty-key",
}
@@ -202,7 +202,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle empty title", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "",
}
@@ -215,7 +215,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should create proper GitHub Key type", func() {
preset := v1alpha1.DeployKey{
Key: "test-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "test-title",
}
@@ -227,7 +227,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle all fields as pointers", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "deploy-key",
}
@@ -241,7 +241,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle special characters in key", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...+/=",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "special-key",
}
@@ -253,7 +253,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle unicode in title", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "部署密钥-デプロイキー",
}
@@ -265,12 +265,12 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should preserve readonly flag exactly", func() {
presetTrue := v1alpha1.DeployKey{
Key: "key1",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "readonly-key",
}
presetFalse := v1alpha1.DeployKey{
Key: "key2",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "readwrite-key",
}
@@ -286,7 +286,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle RSA keys", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "rsa-key",
}
@@ -298,7 +298,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle Ed25519 keys", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "ed25519-key",
}
@@ -310,7 +310,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle ECDSA keys", func() {
preset := v1alpha1.DeployKey{
Key: "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTY...",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "ecdsa-key",
}
@@ -322,7 +322,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle keys with comments", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3... user@host",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: "key-with-comment",
}
@@ -337,7 +337,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
longTitle := string(make([]byte, 1000))
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: longTitle,
}
@@ -349,7 +349,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle whitespace in key", func() {
preset := v1alpha1.DeployKey{
Key: " ssh-rsa AAAAB3... ",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
Title: "whitespace-key",
}
@@ -361,7 +361,7 @@ var _ = Describe("DeployKeyPresetToGitHubDeployKey", func() {
It("should handle whitespace in title", func() {
preset := v1alpha1.DeployKey{
Key: "ssh-rsa AAAAB3...",
- ReadOnly: github.Ptr(true),
+ ReadOnly: new(true),
Title: " deploy key ",
}
diff --git a/internal/mapper/github_hook_mapper.go b/internal/mapper/github_hook_mapper.go
index c969ea6..e6dc66c 100644
--- a/internal/mapper/github_hook_mapper.go
+++ b/internal/mapper/github_hook_mapper.go
@@ -40,7 +40,7 @@ func WebhookPresetToGithubHook(preset v1alpha1.WebhookPreset) *github.Hook {
}
conf.InsecureSSL = &sslVerify
hook := &github.Hook{
- Name: github.Ptr("web"),
+ Name: new("web"),
Active: utils.WithDefaultAsPtr(preset.Spec.Active, true),
Config: conf,
}
diff --git a/internal/mapper/github_hook_mapper_test.go b/internal/mapper/github_hook_mapper_test.go
index 4a8c061..38f19f3 100644
--- a/internal/mapper/github_hook_mapper_test.go
+++ b/internal/mapper/github_hook_mapper_test.go
@@ -21,9 +21,9 @@ var _ = Describe("GitHub Hook Mapper", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
ContentType: contentTypeApplicationJSON,
- SecretValue: github.Ptr("secret123"),
- SSLVerify: github.Ptr(true),
- Active: github.Ptr(true),
+ SecretValue: new("secret123"),
+ SSLVerify: new(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
},
}
@@ -31,13 +31,13 @@ var _ = Describe("GitHub Hook Mapper", func() {
hook := WebhookPresetToGithubHook(preset)
Expect(hook).NotTo(BeNil())
- Expect(hook.Name).To(Equal(github.Ptr("web")))
- Expect(hook.Active).To(Equal(github.Ptr(true)))
+ Expect(hook.Name).To(Equal(new("web")))
+ Expect(hook.Active).To(Equal(new(true)))
Expect(hook.Config).NotTo(BeNil())
- Expect(hook.Config.URL).To(Equal(github.Ptr("https://example.com/webhook")))
+ Expect(hook.Config.URL).To(Equal(new("https://example.com/webhook")))
Expect(hook.Config.ContentType).To(Equal(github.Ptr(contentTypeApplicationJSON)))
- Expect(hook.Config.Secret).To(Equal(github.Ptr("secret123")))
- Expect(hook.Config.InsecureSSL).To(Equal(github.Ptr("1")))
+ Expect(hook.Config.Secret).To(Equal(new("secret123")))
+ Expect(hook.Config.InsecureSSL).To(Equal(new("1")))
Expect(hook.Events).To(ConsistOf("push", "pull_request"))
})
})
@@ -50,15 +50,15 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- SSLVerify: github.Ptr(false),
- Active: github.Ptr(true),
+ SSLVerify: new(false),
+ Active: new(true),
},
}
hook := WebhookPresetToGithubHook(preset)
Expect(hook).NotTo(BeNil())
- Expect(hook.Config.InsecureSSL).To(Equal(github.Ptr("0")))
+ Expect(hook.Config.InsecureSSL).To(Equal(new("0")))
})
})
@@ -70,7 +70,7 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- Active: github.Ptr(true),
+ Active: new(true),
},
}
@@ -90,14 +90,14 @@ var _ = Describe("GitHub Hook Mapper", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
ContentType: "application/x-www-form-urlencoded",
- Active: github.Ptr(true),
+ Active: new(true),
},
}
hook := WebhookPresetToGithubHook(preset)
Expect(hook).NotTo(BeNil())
- Expect(hook.Config.ContentType).To(Equal(github.Ptr("application/x-www-form-urlencoded")))
+ Expect(hook.Config.ContentType).To(Equal(new("application/x-www-form-urlencoded")))
})
})
@@ -109,7 +109,7 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- Active: github.Ptr(true),
+ Active: new(true),
},
}
@@ -128,14 +128,14 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- Active: github.Ptr(false),
+ Active: new(false),
},
}
hook := WebhookPresetToGithubHook(preset)
Expect(hook).NotTo(BeNil())
- Expect(hook.Active).To(Equal(github.Ptr(false)))
+ Expect(hook.Active).To(Equal(new(false)))
})
})
@@ -147,7 +147,7 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request", "issues", "release"},
},
}
@@ -167,7 +167,7 @@ var _ = Describe("GitHub Hook Mapper", func() {
},
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
- Active: github.Ptr(true),
+ Active: new(true),
},
}
diff --git a/internal/mapper/github_org_mapper_test.go b/internal/mapper/github_org_mapper_test.go
index 561a2a5..8859fc7 100644
--- a/internal/mapper/github_org_mapper_test.go
+++ b/internal/mapper/github_org_mapper_test.go
@@ -26,8 +26,8 @@ var _ = Describe("GitHub Org Mapper", func() {
githubOrg := OrgToGithubOrg(org)
Expect(githubOrg).NotTo(BeNil())
- Expect(githubOrg.Name).To(Equal(github.Ptr("my-org")))
- Expect(githubOrg.Description).To(Equal(github.Ptr("This is a test organization")))
+ Expect(githubOrg.Name).To(Equal(new("my-org")))
+ Expect(githubOrg.Description).To(Equal(new("This is a test organization")))
})
})
@@ -46,8 +46,8 @@ var _ = Describe("GitHub Org Mapper", func() {
githubOrg := OrgToGithubOrg(org)
Expect(githubOrg).NotTo(BeNil())
- Expect(githubOrg.Name).To(Equal(github.Ptr("my-org")))
- Expect(githubOrg.Description).To(Equal(github.Ptr("")))
+ Expect(githubOrg.Name).To(Equal(new("my-org")))
+ Expect(githubOrg.Description).To(Equal(new("")))
})
})
@@ -70,8 +70,8 @@ var _ = Describe("GitHub Org Mapper", func() {
githubOrg := OrgToGithubOrg(org)
Expect(githubOrg).NotTo(BeNil())
- Expect(githubOrg.Name).To(Equal(github.Ptr("my-org")))
- Expect(githubOrg.Description).To(Equal(github.Ptr(longDesc)))
+ Expect(githubOrg.Name).To(Equal(new("my-org")))
+ Expect(githubOrg.Description).To(Equal(new(longDesc)))
})
})
@@ -92,7 +92,7 @@ var _ = Describe("GitHub Org Mapper", func() {
githubOrg := OrgToGithubOrg(org)
Expect(githubOrg).NotTo(BeNil())
- Expect(githubOrg.Description).To(Equal(github.Ptr(specialDesc)))
+ Expect(githubOrg.Description).To(Equal(new(specialDesc)))
})
})
})
@@ -115,8 +115,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when organizations match exactly", func() {
It("should return false", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr("Test organization"),
+ Name: new("my-org"),
+ Description: new("Test organization"),
}
differs := OrgDiffers(org, githubOrg)
@@ -128,8 +128,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when name differs", func() {
It("should return true", func() {
githubOrg := github.Organization{
- Name: github.Ptr("different-org"),
- Description: github.Ptr("Test organization"),
+ Name: new("different-org"),
+ Description: new("Test organization"),
}
differs := OrgDiffers(org, githubOrg)
@@ -141,8 +141,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when description differs", func() {
It("should return true", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr("Different description"),
+ Name: new("my-org"),
+ Description: new("Different description"),
}
differs := OrgDiffers(org, githubOrg)
@@ -154,8 +154,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when both name and description differ", func() {
It("should return true", func() {
githubOrg := github.Organization{
- Name: github.Ptr("different-org"),
- Description: github.Ptr("Different description"),
+ Name: new("different-org"),
+ Description: new("Different description"),
}
differs := OrgDiffers(org, githubOrg)
@@ -168,7 +168,7 @@ var _ = Describe("GitHub Org Mapper", func() {
It("should return true", func() {
githubOrg := github.Organization{
Name: nil,
- Description: github.Ptr("Test organization"),
+ Description: new("Test organization"),
}
differs := OrgDiffers(org, githubOrg)
@@ -180,7 +180,7 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when GitHub organization has nil description", func() {
It("should return true", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
+ Name: new("my-org"),
Description: nil,
}
@@ -194,8 +194,8 @@ var _ = Describe("GitHub Org Mapper", func() {
It("should return false", func() {
org.Spec.Description = ""
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr(""),
+ Name: new("my-org"),
+ Description: new(""),
}
differs := OrgDiffers(org, githubOrg)
@@ -208,8 +208,8 @@ var _ = Describe("GitHub Org Mapper", func() {
It("should return true", func() {
org.Spec.Description = ""
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr("Some description"),
+ Name: new("my-org"),
+ Description: new("Some description"),
}
differs := OrgDiffers(org, githubOrg)
@@ -221,8 +221,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when K8s has description but GitHub description is empty", func() {
It("should return true", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr(""),
+ Name: new("my-org"),
+ Description: new(""),
}
differs := OrgDiffers(org, githubOrg)
@@ -234,8 +234,8 @@ var _ = Describe("GitHub Org Mapper", func() {
Context("when checking whitespace differences", func() {
It("should detect trailing whitespace differences", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr("Test organization "),
+ Name: new("my-org"),
+ Description: new("Test organization "),
}
differs := OrgDiffers(org, githubOrg)
@@ -245,8 +245,8 @@ var _ = Describe("GitHub Org Mapper", func() {
It("should detect leading whitespace differences", func() {
githubOrg := github.Organization{
- Name: github.Ptr("my-org"),
- Description: github.Ptr(" Test organization"),
+ Name: new("my-org"),
+ Description: new(" Test organization"),
}
differs := OrgDiffers(org, githubOrg)
diff --git a/internal/mapper/github_repo_mapper.go b/internal/mapper/github_repo_mapper.go
index 90e1e46..b9a7c89 100644
--- a/internal/mapper/github_repo_mapper.go
+++ b/internal/mapper/github_repo_mapper.go
@@ -23,9 +23,9 @@ func RepoToGithubRepo(repo *v1alpha1.Repository) *github.Repository {
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
MergeCommitTitle: &repo.Spec.MergeCommitTitle,
MergeCommitMessage: &repo.Spec.MergeCommitMessage,
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: github.Ptr(repo.Spec.DefaultBranch),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: new(repo.Spec.DefaultBranch),
}
}
@@ -114,8 +114,8 @@ func RepoDiffers(repo *v1alpha1.Repository, githubRepo github.Repository) bool {
func getMergeStrategy(repo *v1alpha1.Repository, strategy string) *bool {
for _, s := range repo.Spec.AllowedMergeStrategies {
if s.Type == strategy {
- return github.Ptr(true)
+ return new(true)
}
}
- return github.Ptr(false)
+ return new(false)
}
diff --git a/internal/mapper/github_repo_mapper_test.go b/internal/mapper/github_repo_mapper_test.go
index 0ae7ab9..37ea48f 100644
--- a/internal/mapper/github_repo_mapper_test.go
+++ b/internal/mapper/github_repo_mapper_test.go
@@ -20,13 +20,13 @@ var _ = Describe("GitHub Repo Mapper", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "my-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
Visibility: "internal",
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
MergeCommitMessage: "PR_TITLE",
MergeCommitTitle: "MERGE_MESSAGE",
},
@@ -35,9 +35,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
githubRepo := RepoToGithubRepo(repo)
Expect(githubRepo).NotTo(BeNil())
- Expect(githubRepo.Name).To(Equal(github.Ptr("my-repo")))
- Expect(githubRepo.Archived).To(Equal(github.Ptr(false)))
- Expect(githubRepo.Visibility).To(Equal(github.Ptr("internal")))
+ Expect(githubRepo.Name).To(Equal(new("my-repo")))
+ Expect(githubRepo.Archived).To(Equal(new(false)))
+ Expect(githubRepo.Visibility).To(Equal(new("internal")))
})
})
@@ -49,14 +49,14 @@ var _ = Describe("GitHub Repo Mapper", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "archived-repo",
- Archived: github.Ptr(true),
+ Archived: new(true),
},
}
githubRepo := RepoToGithubRepo(repo)
Expect(githubRepo).NotTo(BeNil())
- Expect(githubRepo.Archived).To(Equal(github.Ptr(true)))
+ Expect(githubRepo.Archived).To(Equal(new(true)))
})
})
@@ -68,13 +68,13 @@ var _ = Describe("GitHub Repo Mapper", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "my-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
Visibility: "internal",
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
MergeCommitMessage: "PR_TITLE",
MergeCommitTitle: "MERGE_MESSAGE",
},
@@ -83,7 +83,7 @@ var _ = Describe("GitHub Repo Mapper", func() {
githubRepo := RepoToGithubRepo(repo)
Expect(githubRepo).NotTo(BeNil())
- Expect(githubRepo.Visibility).To(Equal(github.Ptr("internal")))
+ Expect(githubRepo.Visibility).To(Equal(new("internal")))
})
})
@@ -95,14 +95,14 @@ var _ = Describe("GitHub Repo Mapper", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "my-special-repo_123",
- Archived: github.Ptr(false),
+ Archived: new(false),
},
}
githubRepo := RepoToGithubRepo(repo)
Expect(githubRepo).NotTo(BeNil())
- Expect(githubRepo.Name).To(Equal(github.Ptr("my-special-repo_123")))
+ Expect(githubRepo.Name).To(Equal(new("my-special-repo_123")))
})
})
})
@@ -117,14 +117,14 @@ var _ = Describe("GitHub Repo Mapper", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "my-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
Visibility: "internal",
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(true),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ DeleteBranchOnMerge: new(true),
MergeCommitMessage: "PR_TITLE",
MergeCommitTitle: "MERGE_MESSAGE",
},
@@ -134,24 +134,24 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when repositories match exactly", func() {
It("should return false", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -163,9 +163,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when name differs", func() {
It("should return true", func() {
githubRepo := github.Repository{
- Name: github.Ptr("different-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ Name: new("different-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -178,8 +178,8 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should return true", func() {
githubRepo := github.Repository{
Name: nil,
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ Archived: new(false),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -190,11 +190,11 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when archived status differs", func() {
It("should return true when K8s is archived but GitHub is not", func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -203,11 +203,11 @@ var _ = Describe("GitHub Repo Mapper", func() {
})
It("should return true when K8s is not archived but GitHub is", func() {
- repo.Spec.Archived = github.Ptr(false)
+ repo.Spec.Archived = new(false)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(true),
- Visibility: github.Ptr("internal"),
+ Name: new("my-repo"),
+ Archived: new(true),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -218,11 +218,11 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when GitHub repository has nil Archived field", func() {
It("should return true if K8s Archived is true", func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
+ Name: new("my-repo"),
Archived: nil,
- Visibility: github.Ptr("internal"),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -231,26 +231,26 @@ var _ = Describe("GitHub Repo Mapper", func() {
})
It("should return false if K8s Archived is false", func() {
- repo.Spec.Archived = github.Ptr(false)
+ repo.Spec.Archived = new(false)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
+ Name: new("my-repo"),
Archived: nil,
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -262,9 +262,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when visibility differs", func() {
It("should return true for public visibility", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("public"),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("public"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -274,23 +274,23 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should return true for private visibility", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("private"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("private"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -300,8 +300,8 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should return true when visibility is nil", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false),
Visibility: nil,
}
@@ -312,24 +312,24 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should return false for internal visibility", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -341,9 +341,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when multiple fields differ", func() {
It("should return true", func() {
githubRepo := github.Repository{
- Name: github.Ptr("different-repo"),
- Archived: github.Ptr(true),
- Visibility: github.Ptr("public"),
+ Name: new("different-repo"),
+ Archived: new(true),
+ Visibility: new("public"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -354,26 +354,26 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when checking archived repositories", func() {
It("should not differ if both are archived with internal visibility", func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(true),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(true),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -382,11 +382,11 @@ var _ = Describe("GitHub Repo Mapper", func() {
})
It("should differ if archived but visibility is not internal", func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(true),
- Visibility: github.Ptr("public"),
+ Name: new("my-repo"),
+ Archived: new(true),
+ Visibility: new("public"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -398,9 +398,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
Context("when checking edge cases", func() {
It("should handle empty name string", func() {
githubRepo := github.Repository{
- Name: github.Ptr(""),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ Name: new(""),
+ Archived: new(false),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -410,9 +410,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should handle name with whitespace", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo "),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
+ Name: new("my-repo "),
+ Archived: new(false),
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
@@ -435,24 +435,24 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should not differ when GitHub matches defaults (HasIssues=true, others=false)", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false), // default
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true), // default
- HasProjects: github.Ptr(false), // default
- HasWiki: github.Ptr(false), // default
- HasDownloads: github.Ptr(false), // default
- IsTemplate: github.Ptr(false), // default
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false), // default
+ Visibility: new("internal"),
+ HasIssues: new(true), // default
+ HasProjects: new(false), // default
+ HasWiki: new(false), // default
+ HasDownloads: new(false), // default
+ IsTemplate: new(false), // default
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
- DeleteBranchOnMerge: github.Ptr(true), // default
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ DeleteBranchOnMerge: new(true), // default
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -462,10 +462,10 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should differ when GitHub HasIssues differs from default", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(false), // differs from default (true)
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
+ HasIssues: new(false), // differs from default (true)
}
differs := RepoDiffers(repo, githubRepo)
@@ -475,24 +475,24 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should differ when GitHub DeleteBranchOnMerge differs from default", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(false),
- Visibility: github.Ptr("internal"),
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
+ Name: new("my-repo"),
+ Archived: new(false),
+ Visibility: new("internal"),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
AllowRebaseMerge: getMergeStrategy(repo, "rebase"),
AllowMergeCommit: getMergeStrategy(repo, "merge"),
- DeleteBranchOnMerge: github.Ptr(false), // differs from default (true)
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Website), ""),
- Description: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.About.Description), ""),
- DefaultBranch: utils.WithDefaultAsPtr(github.Ptr(repo.Spec.DefaultBranch), ""),
+ DeleteBranchOnMerge: new(false), // differs from default (true)
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: utils.WithDefaultAsPtr(new(repo.Spec.About.Website), ""),
+ Description: utils.WithDefaultAsPtr(new(repo.Spec.About.Description), ""),
+ DefaultBranch: utils.WithDefaultAsPtr(new(repo.Spec.DefaultBranch), ""),
}
differs := RepoDiffers(repo, githubRepo)
@@ -502,9 +502,9 @@ var _ = Describe("GitHub Repo Mapper", func() {
It("should differ when GitHub Archived is true but K8s defaults to false", func() {
githubRepo := github.Repository{
- Name: github.Ptr("my-repo"),
- Archived: github.Ptr(true), // differs from default (false)
- Visibility: github.Ptr("internal"),
+ Name: new("my-repo"),
+ Archived: new(true), // differs from default (false)
+ Visibility: new("internal"),
}
differs := RepoDiffers(repo, githubRepo)
diff --git a/internal/mapper/github_ruleset_mapper.go b/internal/mapper/github_ruleset_mapper.go
index 021be2b..01a45c0 100644
--- a/internal/mapper/github_ruleset_mapper.go
+++ b/internal/mapper/github_ruleset_mapper.go
@@ -19,7 +19,7 @@ func RulesetPresetToGithubRuleset(preset githubv1alpha1.RulesetPreset) (*github.
ruleset := &github.RepositoryRuleset{
Name: preset.Spec.Name,
Enforcement: github.RulesetEnforcement(preset.Spec.Enforcement),
- Target: github.Ptr(github.RulesetTarget(preset.Spec.Target)),
+ Target: new(github.RulesetTarget(preset.Spec.Target)),
}
ruleset.Conditions = mapConditions(preset.Spec.Conditions)
diff --git a/internal/mapper/github_ruleset_mapper_test.go b/internal/mapper/github_ruleset_mapper_test.go
index ce56e8e..b96e4f3 100644
--- a/internal/mapper/github_ruleset_mapper_test.go
+++ b/internal/mapper/github_ruleset_mapper_test.go
@@ -26,50 +26,50 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
BypassActors: []githubv1alpha1.RulesetBypassActor{
{
- ActorID: github.Ptr(int64(123)),
+ ActorID: new(int64(123)),
ActorType: "Team",
BypassMode: "always",
},
},
Rules: githubv1alpha1.RulesetRules{
- Creation: github.Ptr(true),
- Update: github.Ptr(false),
- Deletion: github.Ptr(true),
- RequiredLinearHistory: github.Ptr(true),
- RequiredSignatures: github.Ptr(false),
- NonFastForward: github.Ptr(true),
+ Creation: new(true),
+ Update: new(false),
+ Deletion: new(true),
+ RequiredLinearHistory: new(true),
+ RequiredSignatures: new(false),
+ NonFastForward: new(true),
PullRequest: &githubv1alpha1.PullRequestRule{
- DismissStaleReviewsOnPush: github.Ptr(true),
- RequireCodeOwnerReviews: github.Ptr(true),
- RequireLastPushApproval: github.Ptr(false),
+ DismissStaleReviewsOnPush: new(true),
+ RequireCodeOwnerReviews: new(true),
+ RequireLastPushApproval: new(false),
RequiredApprovingReviewCount: 2,
- RequiredReviewThreadResolution: github.Ptr(true),
+ RequiredReviewThreadResolution: new(true),
},
RequiredStatusChecks: &githubv1alpha1.RequiredStatusChecks{
Checks: []githubv1alpha1.StatusCheck{
{
Context: "ci/build",
- IntegrationID: github.Ptr(int64(456)),
+ IntegrationID: new(int64(456)),
},
{
Context: "ci/test",
},
},
- StrictPolicy: github.Ptr(true),
+ StrictPolicy: new(true),
},
CopilotReview: &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
},
CommitMessagePattern: &githubv1alpha1.PatternRule{
Pattern: "^(feat|fix|docs):",
Operator: "regex",
- Negate: github.Ptr(false),
+ Negate: new(false),
},
BranchNamePattern: &githubv1alpha1.PatternRule{
Pattern: "hotfix/",
Operator: "starts_with",
- Negate: github.Ptr(true),
+ Negate: new(true),
},
},
},
@@ -129,7 +129,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Expect(githubRuleset.Rules.CommitMessagePattern.Pattern).To(Equal("^(feat|fix|docs):"))
Expect(hasRule(githubRuleset.Rules, "branch_name_pattern")).To(BeTrue())
- Expect(githubRuleset.Rules.BranchNamePattern.Negate).To(Equal(github.Ptr(true)))
+ Expect(githubRuleset.Rules.BranchNamePattern.Negate).To(Equal(new(true)))
})
It("should convert CopilotCodeReview rule", func() {
@@ -144,8 +144,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: githubv1alpha1.RulesetRules{
CopilotReview: &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
},
},
},
@@ -172,8 +172,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: githubv1alpha1.RulesetRules{
CopilotReview: &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(true),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(true),
},
},
},
@@ -198,7 +198,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -220,7 +220,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -268,11 +268,11 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
RepositoryName: &githubv1alpha1.RepositoryNameCondition{
Include: []string{"backend-*", "frontend-*"},
Exclude: []string{"legacy-*"},
- Protected: github.Ptr(true),
+ Protected: new(true),
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -285,7 +285,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Expect(githubRuleset.Conditions.RepositoryName).NotTo(BeNil())
Expect(githubRuleset.Conditions.RepositoryName.Include).To(Equal([]string{"backend-*", "frontend-*"}))
Expect(githubRuleset.Conditions.RepositoryName.Exclude).To(Equal([]string{"legacy-*"}))
- Expect(githubRuleset.Conditions.RepositoryName.Protected).To(Equal(github.Ptr(true)))
+ Expect(githubRuleset.Conditions.RepositoryName.Protected).To(Equal(new(true)))
Expect(githubRuleset.Conditions.RepositoryProperty).To(BeNil())
})
@@ -301,7 +301,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &githubv1alpha1.RepositoryPropertyCondition{
Include: []githubv1alpha1.RepositoryPropertyTarget{
- {Name: "environment", PropertyValues: []string{"production", "staging"}, Source: github.Ptr("custom")},
+ {Name: "environment", PropertyValues: []string{"production", "staging"}, Source: new("custom")},
},
Exclude: []githubv1alpha1.RepositoryPropertyTarget{
{Name: "archived", PropertyValues: []string{"true"}},
@@ -309,7 +309,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -323,7 +323,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Expect(githubRuleset.Conditions.RepositoryProperty.Include).To(HaveLen(1))
Expect(githubRuleset.Conditions.RepositoryProperty.Include[0].Name).To(Equal("environment"))
Expect(githubRuleset.Conditions.RepositoryProperty.Include[0].PropertyValues).To(Equal([]string{"production", "staging"}))
- Expect(githubRuleset.Conditions.RepositoryProperty.Include[0].Source).To(Equal(github.Ptr("custom")))
+ Expect(githubRuleset.Conditions.RepositoryProperty.Include[0].Source).To(Equal(new("custom")))
Expect(githubRuleset.Conditions.RepositoryProperty.Exclude).To(HaveLen(1))
Expect(githubRuleset.Conditions.RepositoryProperty.Exclude[0].Name).To(Equal("archived"))
Expect(githubRuleset.Conditions.RepositoryProperty.Exclude[0].PropertyValues).To(Equal([]string{"true"}))
@@ -341,7 +341,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -374,7 +374,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -401,7 +401,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -435,7 +435,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -465,7 +465,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -488,7 +488,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredSignatures: github.Ptr(true),
+ RequiredSignatures: new(true),
},
},
}
@@ -511,7 +511,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
}
@@ -534,7 +534,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
}
@@ -558,13 +558,13 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- Creation: github.Ptr(true),
- Deletion: github.Ptr(true),
- RequiredSignatures: github.Ptr(true),
+ Creation: new(true),
+ Deletion: new(true),
+ RequiredSignatures: new(true),
TagNamePattern: &githubv1alpha1.PatternRule{
Pattern: "^v[0-9]+\\.[0-9]+\\.[0-9]+$",
Operator: "regex",
- Negate: github.Ptr(false),
+ Negate: new(false),
},
},
},
@@ -592,7 +592,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Enforcement: githubv1alpha1.RulesetEnforcementActive,
Target: TargetTypeBranch, // Set default target type
BypassActors: []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: "Team"},
+ {ActorID: new(int64(123)), ActorType: "Team"},
},
Conditions: &githubv1alpha1.RulesetConditions{
RefName: &githubv1alpha1.RefNameCondition{
@@ -600,7 +600,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
},
Rules: githubv1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
PullRequest: &githubv1alpha1.PullRequestRule{
RequiredApprovingReviewCount: 2,
},
@@ -623,7 +623,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch), // Set target type
BypassActors: []*github.BypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: &actorType},
+ {ActorID: new(int64(123)), ActorType: &actorType},
},
Conditions: &github.RepositoryRulesetConditions{
RefName: &github.RepositoryRulesetRefConditionParameters{
@@ -709,8 +709,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return false when CopilotCodeReview rules match", func() {
rulesetPreset.Spec.Rules.CopilotReview = &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
}
githubRuleset.Rules.CopilotCodeReview = &github.CopilotCodeReviewRuleParameters{
ReviewOnPush: true,
@@ -723,8 +723,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return true when CopilotCodeReview ReviewOnPush differs", func() {
rulesetPreset.Spec.Rules.CopilotReview = &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
}
githubRuleset.Rules.CopilotCodeReview = &github.CopilotCodeReviewRuleParameters{
ReviewOnPush: false, // Different
@@ -737,8 +737,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return true when CopilotCodeReview ReviewDraftPullRequests differs", func() {
rulesetPreset.Spec.Rules.CopilotReview = &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
}
githubRuleset.Rules.CopilotCodeReview = &github.CopilotCodeReviewRuleParameters{
ReviewOnPush: true,
@@ -751,8 +751,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return true when CopilotCodeReview is present in preset but missing in GitHub", func() {
rulesetPreset.Spec.Rules.CopilotReview = &githubv1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
}
githubRuleset.Rules.CopilotCodeReview = nil
@@ -1136,7 +1136,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &githubv1alpha1.RepositoryPropertyCondition{
Include: []githubv1alpha1.RepositoryPropertyTarget{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("custom")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("custom")},
},
},
}
@@ -1146,7 +1146,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &github.RepositoryRulesetRepositoryPropertyConditionParameters{
Include: []*github.RepositoryRulesetRepositoryPropertyTargetParameters{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("system")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("system")},
},
},
}
@@ -1162,7 +1162,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &githubv1alpha1.RepositoryPropertyCondition{
Include: []githubv1alpha1.RepositoryPropertyTarget{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("custom")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("custom")},
},
},
}
@@ -1172,7 +1172,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &github.RepositoryRulesetRepositoryPropertyConditionParameters{
Include: []*github.RepositoryRulesetRepositoryPropertyTargetParameters{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("custom")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("custom")},
},
},
}
@@ -1198,7 +1198,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &github.RepositoryRulesetRepositoryPropertyConditionParameters{
Include: []*github.RepositoryRulesetRepositoryPropertyTargetParameters{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("custom")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("custom")},
},
},
}
@@ -1224,7 +1224,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
RepositoryProperty: &github.RepositoryRulesetRepositoryPropertyConditionParameters{
Include: []*github.RepositoryRulesetRepositoryPropertyTargetParameters{
- {Name: "environment", PropertyValues: []string{"production"}, Source: github.Ptr("system")},
+ {Name: "environment", PropertyValues: []string{"production"}, Source: new("system")},
},
},
}
@@ -1314,11 +1314,11 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
teamType := github.BypassActorTypeTeam
deployKeyType := github.BypassActorTypeDeployKey
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: "Team", BypassMode: "always"},
+ {ActorID: new(int64(123)), ActorType: "Team", BypassMode: "always"},
{ActorType: "DeployKey", BypassMode: "always"},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
+ {ActorID: new(int64(123)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
{ActorType: &deployKeyType, BypassMode: github.Ptr(github.BypassMode("always"))},
}
@@ -1336,13 +1336,13 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
{ActorType: "DeployKey", BypassMode: "always"},
{ActorType: "OrganizationAdmin", BypassMode: "pull_request"},
{ActorType: "EnterpriseOwner", BypassMode: "always"},
- {ActorID: github.Ptr(int64(456)), ActorType: "Team", BypassMode: "always"},
+ {ActorID: new(int64(456)), ActorType: "Team", BypassMode: "always"},
}
githubRuleset.BypassActors = []*github.BypassActor{
{ActorType: &deployKeyType, BypassMode: github.Ptr(github.BypassMode("always"))},
{ActorType: &orgAdminType, BypassMode: github.Ptr(github.BypassMode("pull_request"))},
{ActorType: &enterpriseOwnerType, BypassMode: github.Ptr(github.BypassMode("always"))},
- {ActorID: github.Ptr(int64(456)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
+ {ActorID: new(int64(456)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1366,10 +1366,10 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return true when actors with same type but different ActorIDs", func() {
teamType := github.BypassActorTypeTeam
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: "Team", BypassMode: "always"},
+ {ActorID: new(int64(123)), ActorType: "Team", BypassMode: "always"},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(456)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
+ {ActorID: new(int64(456)), ActorType: &teamType, BypassMode: github.Ptr(github.BypassMode("always"))},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1379,10 +1379,10 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return false when Integration actors match with same ActorID", func() {
integrationType := github.BypassActorTypeIntegration
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(789)), ActorType: "Integration", BypassMode: "always"},
+ {ActorID: new(int64(789)), ActorType: "Integration", BypassMode: "always"},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(789)), ActorType: &integrationType, BypassMode: github.Ptr(github.BypassMode("always"))},
+ {ActorID: new(int64(789)), ActorType: &integrationType, BypassMode: github.Ptr(github.BypassMode("always"))},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1392,10 +1392,10 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return false when RepositoryRole actors match with same ActorID", func() {
roleType := github.BypassActorTypeRepositoryRole
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(321)), ActorType: "RepositoryRole", BypassMode: "pull_request"},
+ {ActorID: new(int64(321)), ActorType: "RepositoryRole", BypassMode: "pull_request"},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(321)), ActorType: &roleType, BypassMode: github.Ptr(github.BypassMode("pull_request"))},
+ {ActorID: new(int64(321)), ActorType: &roleType, BypassMode: github.Ptr(github.BypassMode("pull_request"))},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1405,10 +1405,10 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should handle empty bypass mode correctly", func() {
teamType := github.BypassActorTypeTeam
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: "Team", BypassMode: ""},
+ {ActorID: new(int64(123)), ActorType: "Team", BypassMode: ""},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: &teamType, BypassMode: nil},
+ {ActorID: new(int64(123)), ActorType: &teamType, BypassMode: nil},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1418,10 +1418,10 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
It("should return true when bypass mode differs between empty and set", func() {
teamType := github.BypassActorTypeTeam
rulesetPreset.Spec.BypassActors = []githubv1alpha1.RulesetBypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: "Team", BypassMode: "always"},
+ {ActorID: new(int64(123)), ActorType: "Team", BypassMode: "always"},
}
githubRuleset.BypassActors = []*github.BypassActor{
- {ActorID: github.Ptr(int64(123)), ActorType: &teamType, BypassMode: nil},
+ {ActorID: new(int64(123)), ActorType: &teamType, BypassMode: nil},
}
differs := RulesetsDiffer(rulesetPreset, githubRuleset)
@@ -1545,7 +1545,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1577,7 +1577,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42)), Ref: github.Ptr("refs/heads/main")},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42)), Ref: new("refs/heads/main")},
},
},
},
@@ -1593,7 +1593,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42)), Ref: github.Ptr("refs/heads/main")},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42)), Ref: new("refs/heads/main")},
},
},
},
@@ -1615,7 +1615,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1631,7 +1631,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(99))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(99))},
},
},
},
@@ -1653,7 +1653,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42)), Ref: github.Ptr("refs/heads/main")},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42)), Ref: new("refs/heads/main")},
},
},
},
@@ -1669,7 +1669,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42)), Ref: github.Ptr("refs/heads/develop")},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42)), Ref: new("refs/heads/develop")},
},
},
},
@@ -1690,9 +1690,9 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
- DoNotEnforceOnCreate: github.Ptr(true),
+ DoNotEnforceOnCreate: new(true),
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1707,9 +1707,9 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
- DoNotEnforceOnCreate: github.Ptr(false),
+ DoNotEnforceOnCreate: new(false),
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42))},
},
},
},
@@ -1730,9 +1730,9 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
- DoNotEnforceOnCreate: github.Ptr(true),
+ DoNotEnforceOnCreate: new(true),
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1747,9 +1747,9 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
- DoNotEnforceOnCreate: github.Ptr(true),
+ DoNotEnforceOnCreate: new(true),
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42))},
},
},
},
@@ -1772,7 +1772,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Workflows: &githubv1alpha1.WorkflowsRule{
DoNotEnforceOnCreate: nil,
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "my-repo", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1787,9 +1787,9 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
- DoNotEnforceOnCreate: github.Ptr(false),
+ DoNotEnforceOnCreate: new(false),
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42))},
},
},
},
@@ -1811,7 +1811,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-a", ResolvedRepositoryID: github.Ptr(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-a", ResolvedRepositoryID: new(int64(42))},
},
},
},
@@ -1827,7 +1827,7 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(99))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(99))},
},
},
},
@@ -1849,8 +1849,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
Workflows: []githubv1alpha1.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-a", ResolvedRepositoryID: github.Ptr(int64(42))},
- {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-b", ResolvedRepositoryID: github.Ptr(int64(99))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-a", ResolvedRepositoryID: new(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryName: "repo-b", ResolvedRepositoryID: new(int64(99))},
},
},
},
@@ -1866,8 +1866,8 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
Rules: &github.RepositoryRulesetRules{
Workflows: &github.WorkflowsRuleParameters{
Workflows: []*github.RuleWorkflow{
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(42))},
- {Path: ".github/workflows/ci.yaml", RepositoryID: github.Ptr(int64(99))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(42))},
+ {Path: ".github/workflows/ci.yaml", RepositoryID: new(int64(99))},
},
},
},
@@ -1891,13 +1891,13 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
},
Rules: githubv1alpha1.RulesetRules{
Workflows: &githubv1alpha1.WorkflowsRule{
- DoNotEnforceOnCreate: github.Ptr(true),
+ DoNotEnforceOnCreate: new(true),
Workflows: []githubv1alpha1.RuleWorkflow{
{
Path: ".github/workflows/ci.yaml",
RepositoryName: "my-repo",
- ResolvedRepositoryID: github.Ptr(int64(42)),
- Ref: github.Ptr("refs/heads/main"),
+ ResolvedRepositoryID: new(int64(42)),
+ Ref: new("refs/heads/main"),
},
},
},
@@ -1908,11 +1908,11 @@ var _ = Describe("GitHub Ruleset Mapper", func() {
ruleset, err := RulesetPresetToGithubRuleset(preset)
Expect(err).NotTo(HaveOccurred())
Expect(ruleset.Rules.Workflows).NotTo(BeNil())
- Expect(ruleset.Rules.Workflows.DoNotEnforceOnCreate).To(Equal(github.Ptr(true)))
+ Expect(ruleset.Rules.Workflows.DoNotEnforceOnCreate).To(Equal(new(true)))
Expect(ruleset.Rules.Workflows.Workflows).To(HaveLen(1))
Expect(ruleset.Rules.Workflows.Workflows[0].Path).To(Equal(".github/workflows/ci.yaml"))
- Expect(ruleset.Rules.Workflows.Workflows[0].RepositoryID).To(Equal(github.Ptr(int64(42))))
- Expect(ruleset.Rules.Workflows.Workflows[0].Ref).To(Equal(github.Ptr("refs/heads/main")))
+ Expect(ruleset.Rules.Workflows.Workflows[0].RepositoryID).To(Equal(new(int64(42))))
+ Expect(ruleset.Rules.Workflows.Workflows[0].Ref).To(Equal(new("refs/heads/main")))
})
})
diff --git a/internal/mapper/github_team_mapper.go b/internal/mapper/github_team_mapper.go
index 2063a3c..87cbaef 100644
--- a/internal/mapper/github_team_mapper.go
+++ b/internal/mapper/github_team_mapper.go
@@ -39,10 +39,10 @@ func teamNotificationSetting(team *v1alpha1.Team) string {
func TeamToNewGitHubTeam(team *v1alpha1.Team) *github.NewTeam {
return &github.NewTeam{
Name: team.Spec.Name,
- Description: github.Ptr(team.Spec.Description),
- Privacy: github.Ptr(teamPrivacy(team)),
- Permission: github.Ptr(teamPermission(team)),
- NotificationSetting: github.Ptr(teamNotificationSetting(team)),
+ Description: new(team.Spec.Description),
+ Privacy: new(teamPrivacy(team)),
+ Permission: new(teamPermission(team)),
+ NotificationSetting: new(teamNotificationSetting(team)),
}
}
@@ -108,5 +108,5 @@ func TeamNameToSlug(name string) *string {
// Trim leading/trailing hyphens
cleanedSlug = strings.Trim(cleanedSlug, "-")
- return github.Ptr(cleanedSlug)
+ return new(cleanedSlug)
}
diff --git a/internal/mapper/github_team_mapper_test.go b/internal/mapper/github_team_mapper_test.go
index 8476729..579d3ac 100644
--- a/internal/mapper/github_team_mapper_test.go
+++ b/internal/mapper/github_team_mapper_test.go
@@ -28,10 +28,10 @@ var _ = Describe("GitHub Team Mapper", func() {
Expect(newTeam).NotTo(BeNil())
Expect(newTeam.Name).To(Equal("my-team"))
- Expect(newTeam.Description).To(Equal(github.Ptr("This is a test team")))
- Expect(newTeam.Privacy).To(Equal(github.Ptr("closed")))
- Expect(newTeam.Permission).To(Equal(github.Ptr("pull"))) //nolint:staticcheck
- Expect(newTeam.NotificationSetting).To(Equal(github.Ptr("notifications_disabled")))
+ Expect(newTeam.Description).To(Equal(new("This is a test team")))
+ Expect(newTeam.Privacy).To(Equal(new("closed")))
+ Expect(newTeam.Permission).To(Equal(new("pull"))) //nolint:staticcheck
+ Expect(newTeam.NotificationSetting).To(Equal(new("notifications_disabled")))
})
})
@@ -52,7 +52,7 @@ var _ = Describe("GitHub Team Mapper", func() {
newTeam := TeamToNewGitHubTeam(team)
Expect(newTeam).NotTo(BeNil())
- Expect(newTeam.Description).To(Equal(github.Ptr("IDP synchronized team")))
+ Expect(newTeam.Description).To(Equal(new("IDP synchronized team")))
})
})
@@ -131,7 +131,7 @@ var _ = Describe("GitHub Team Mapper", func() {
newTeam := TeamToNewGitHubTeam(team)
- Expect(newTeam.Privacy).To(Equal(github.Ptr("secret")))
+ Expect(newTeam.Privacy).To(Equal(new("secret")))
})
})
@@ -150,7 +150,7 @@ var _ = Describe("GitHub Team Mapper", func() {
newTeam := TeamToNewGitHubTeam(team)
- Expect(newTeam.Permission).To(Equal(github.Ptr("push"))) //nolint:staticcheck
+ Expect(newTeam.Permission).To(Equal(new("push"))) //nolint:staticcheck
})
})
@@ -169,7 +169,7 @@ var _ = Describe("GitHub Team Mapper", func() {
newTeam := TeamToNewGitHubTeam(team)
- Expect(newTeam.NotificationSetting).To(Equal(github.Ptr("notifications_enabled")))
+ Expect(newTeam.NotificationSetting).To(Equal(new("notifications_enabled")))
})
})
@@ -192,10 +192,10 @@ var _ = Describe("GitHub Team Mapper", func() {
newTeam := TeamToNewGitHubTeam(team)
Expect(newTeam.Name).To(Equal("my-team"))
- Expect(newTeam.Description).To(Equal(github.Ptr("Custom team")))
- Expect(newTeam.Privacy).To(Equal(github.Ptr("secret")))
- Expect(newTeam.Permission).To(Equal(github.Ptr("push"))) //nolint:staticcheck
- Expect(newTeam.NotificationSetting).To(Equal(github.Ptr("notifications_enabled")))
+ Expect(newTeam.Description).To(Equal(new("Custom team")))
+ Expect(newTeam.Privacy).To(Equal(new("secret")))
+ Expect(newTeam.Permission).To(Equal(new("push"))) //nolint:staticcheck
+ Expect(newTeam.NotificationSetting).To(Equal(new("notifications_enabled")))
})
})
})
@@ -219,11 +219,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when teams match exactly", func() {
It("should return false", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -235,7 +235,7 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when K8s team is nil", func() {
It("should return true", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
+ Name: new("my-team"),
}
differs := TeamDiffers(nil, githubTeam, "my-org")
@@ -255,11 +255,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when name differs", func() {
It("should return true", func() {
githubTeam := &github.Team{
- Name: github.Ptr("different-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("different-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -271,11 +271,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when description differs", func() {
It("should return true", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Different description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Different description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -287,11 +287,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when description is nil on GitHub", func() {
It("should return true", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
+ Name: new("my-team"),
Description: nil,
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -303,11 +303,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when privacy differs", func() {
It("should return true for secret privacy", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("secret"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("secret"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -317,11 +317,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return true when privacy is nil", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
Privacy: nil,
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -333,11 +333,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when permission differs", func() {
It("should return true for push permission", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("push"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("push"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -347,11 +347,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return true when permission is nil", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
Permission: nil,
- NotificationSetting: github.Ptr("notifications_disabled"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -363,11 +363,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when notification setting differs", func() {
It("should return true for notifications enabled", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_enabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_enabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -377,10 +377,10 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return true when notification setting is nil", func() {
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
NotificationSetting: nil,
}
@@ -394,11 +394,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should compare against empty description", func() {
team.Spec.Description = ""
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -410,11 +410,11 @@ var _ = Describe("GitHub Team Mapper", func() {
Context("when multiple fields differ", func() {
It("should return true", func() {
githubTeam := &github.Team{
- Name: github.Ptr("different-team"),
- Description: github.Ptr("Different description"),
- Privacy: github.Ptr("secret"),
- Permission: github.Ptr("admin"),
- NotificationSetting: github.Ptr("notifications_enabled"),
+ Name: new("different-team"),
+ Description: new("Different description"),
+ Privacy: new("secret"),
+ Permission: new("admin"),
+ NotificationSetting: new("notifications_enabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -427,11 +427,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return false when GitHub matches", func() {
team.Spec.Privacy = "secret"
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("secret"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("secret"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -442,11 +442,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return true when GitHub has different privacy", func() {
team.Spec.Privacy = "secret"
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -459,11 +459,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return false when GitHub matches", func() {
team.Spec.Permission = "push"
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("push"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("push"),
+ NotificationSetting: new("notifications_disabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -476,11 +476,11 @@ var _ = Describe("GitHub Team Mapper", func() {
It("should return false when GitHub matches", func() {
team.Spec.NotificationSetting = "notifications_enabled"
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_enabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_enabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
@@ -495,11 +495,11 @@ var _ = Describe("GitHub Team Mapper", func() {
team.Spec.Permission = "push"
team.Spec.NotificationSetting = "notifications_enabled"
githubTeam := &github.Team{
- Name: github.Ptr("my-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("secret"),
- Permission: github.Ptr("push"),
- NotificationSetting: github.Ptr("notifications_enabled"),
+ Name: new("my-team"),
+ Description: new("Test team description"),
+ Privacy: new("secret"),
+ Permission: new("push"),
+ NotificationSetting: new("notifications_enabled"),
}
differs := TeamDiffers(team, githubTeam, "my-org")
diff --git a/internal/reconciler/orgrec/rec_actions_settings.go b/internal/reconciler/orgrec/rec_actions_settings.go
index 9a01aad..8bbab7b 100644
--- a/internal/reconciler/orgrec/rec_actions_settings.go
+++ b/internal/reconciler/orgrec/rec_actions_settings.go
@@ -55,7 +55,7 @@ func (o *GitHubOrgReconciler) disableActionsForGHOrg(ctx context.Context) error
return err
}
if current.GetEnabledRepositories() != enabledReposNone {
- _, err = o.GitHub.Client.SetActionsPermissionsForOrg(ctx, o.GitHub.Resource, github.ActionsPermissions{EnabledRepositories: github.Ptr(enabledReposNone)})
+ _, err = o.GitHub.Client.SetActionsPermissionsForOrg(ctx, o.GitHub.Resource, github.ActionsPermissions{EnabledRepositories: new(enabledReposNone)})
return err
}
return nil
@@ -206,19 +206,27 @@ func (o *GitHubOrgReconciler) reconcileRetention(ctx context.Context) error {
}
func (o *GitHubOrgReconciler) reconcileAllowedActions(ctx context.Context) error {
+ log := logPkg.FromContext(ctx)
+
if reconciler.IsActionsDisabledForOrgSpec(o.Kubernetes.Resource) {
// If Actions are disabled for all repositories, skip reconciling allowed actions
return nil
}
+ allowedActions := o.Kubernetes.Resource.Spec.ActionsSettings.AllowedActions
+ if allowedActions == nil || *allowedActions != "selected" {
+ log.V(1).Info("AllowedActions is not in mode selected, skipping reconciliation of allowed actions")
+ return nil
+ }
+
current, err := o.GitHub.Client.GetActionsAllowedForOrg(ctx, o.GitHub.Resource)
if err != nil {
return err
}
expected := github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
- VerifiedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
+ VerifiedAllowed: new(false),
PatternsAllowed: make([]string, 0),
}
if o.Kubernetes.Resource.Spec.ActionsSettings.SelectedAllowedActions != nil {
@@ -263,7 +271,7 @@ func (o *GitHubOrgReconciler) reconcileSelfHostedRunnerSettings(ctx context.Cont
if current.GetEnabledRepositories() != enabledReposNone {
err = o.GitHub.Client.SetSelfHostedRunnersSettingsForOrg(ctx, o.GitHub.Resource, github.SelfHostedRunnersSettingsOrganizationOpt{
- EnabledRepositories: github.Ptr(enabledReposNone),
+ EnabledRepositories: new(enabledReposNone),
})
if err != nil {
return err
diff --git a/internal/reconciler/orgrec/rec_actions_settings_test.go b/internal/reconciler/orgrec/rec_actions_settings_test.go
index d7d6399..a8bae9c 100644
--- a/internal/reconciler/orgrec/rec_actions_settings_test.go
+++ b/internal/reconciler/orgrec/rec_actions_settings_test.go
@@ -97,7 +97,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
return &github.ActionsPermissions{}, nil
}
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
- return &github.ArtifactPeriod{Days: github.Ptr(400)}, nil
+ return &github.ArtifactPeriod{Days: new(400)}, nil
}
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{}, nil
@@ -107,7 +107,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
}
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("none"),
+ EnabledRepositories: new("none"),
}, nil
}
})
@@ -123,30 +123,30 @@ var _ = Describe("ReconcileActionsSettings", func() {
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("none"),
- AllowedActions: github.Ptr("selected"),
- SHAPinningRequired: github.Ptr(false),
+ EnabledRepositories: new("none"),
+ AllowedActions: new("selected"),
+ SHAPinningRequired: new(false),
}, nil
}
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
- return &github.ArtifactPeriod{Days: github.Ptr(400)}, nil
+ return &github.ArtifactPeriod{Days: new(400)}, nil
}
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
- VerifiedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
+ VerifiedAllowed: new(false),
PatternsAllowed: []string{},
}, nil
}
mockClient.GetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.DefaultWorkflowPermissionOrganization, error) {
return &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
- CanApprovePullRequestReviews: github.Ptr(false),
+ DefaultWorkflowPermissions: new("read"),
+ CanApprovePullRequestReviews: new(false),
}, nil
}
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("none"),
+ EnabledRepositories: new("none"),
}, nil
}
})
@@ -215,15 +215,15 @@ var _ = Describe("ReconcilePermissions", func() {
Context("when permissions match current state", func() {
BeforeEach(func() {
- actionsSettings.EnabledRepositories = github.Ptr("all")
- actionsSettings.AllowedActions = github.Ptr("all")
- actionsSettings.ShaPinningRequired = github.Ptr(true)
+ actionsSettings.EnabledRepositories = new("all")
+ actionsSettings.AllowedActions = new("all")
+ actionsSettings.ShaPinningRequired = new(true)
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(true),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(true),
}, nil
}
})
@@ -245,15 +245,15 @@ var _ = Describe("ReconcilePermissions", func() {
BeforeEach(func() {
setPermissionsCalled = false
- actionsSettings.EnabledRepositories = github.Ptr("selected")
- actionsSettings.AllowedActions = github.Ptr("local_only")
- actionsSettings.ShaPinningRequired = github.Ptr(true)
+ actionsSettings.EnabledRepositories = new("selected")
+ actionsSettings.AllowedActions = new("local_only")
+ actionsSettings.ShaPinningRequired = new(true)
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(false),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(false),
}, nil
}
mockClient.SetActionsPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.ActionsPermissions) (*github.ActionsPermissions, error) {
@@ -266,9 +266,9 @@ var _ = Describe("ReconcilePermissions", func() {
It("should update permissions", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setPermissionsCalled).To(BeTrue())
- Expect(capturedPermissions.EnabledRepositories).To(Equal(github.Ptr("selected")))
- Expect(capturedPermissions.AllowedActions).To(Equal(github.Ptr("local_only")))
- Expect(capturedPermissions.SHAPinningRequired).To(Equal(github.Ptr(true)))
+ Expect(capturedPermissions.EnabledRepositories).To(Equal(new("selected")))
+ Expect(capturedPermissions.AllowedActions).To(Equal(new("local_only")))
+ Expect(capturedPermissions.SHAPinningRequired).To(Equal(new(true)))
})
})
@@ -278,14 +278,14 @@ var _ = Describe("ReconcilePermissions", func() {
BeforeEach(func() {
// Only set EnabledRepositories to trigger reconciliation and defaults are used for everything else
actionsSettings = v1alpha1.ActionsSettings{
- EnabledRepositories: github.Ptr("selected"),
+ EnabledRepositories: new("selected"),
}
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
- AllowedActions: github.Ptr("all"),
- SHAPinningRequired: github.Ptr(true),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("all"),
+ SHAPinningRequired: new(true),
}, nil
}
mockClient.SetActionsPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.ActionsPermissions) (*github.ActionsPermissions, error) {
@@ -296,9 +296,9 @@ var _ = Describe("ReconcilePermissions", func() {
It("should use default values (, selected, false)", func() {
Expect(err).NotTo(HaveOccurred())
- Expect(capturedPermissions.EnabledRepositories).To(Equal(github.Ptr("selected")))
- Expect(capturedPermissions.AllowedActions).To(Equal(github.Ptr("selected")))
- Expect(capturedPermissions.SHAPinningRequired).To(Equal(github.Ptr(false)))
+ Expect(capturedPermissions.EnabledRepositories).To(Equal(new("selected")))
+ Expect(capturedPermissions.AllowedActions).To(Equal(new("selected")))
+ Expect(capturedPermissions.SHAPinningRequired).To(Equal(new(false)))
})
})
@@ -317,11 +317,11 @@ var _ = Describe("ReconcilePermissions", func() {
Context("when GitHub API returns error on set", func() {
BeforeEach(func() {
- actionsSettings.EnabledRepositories = github.Ptr("selected")
+ actionsSettings.EnabledRepositories = new("selected")
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}, nil
}
mockClient.SetActionsPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.ActionsPermissions) (*github.ActionsPermissions, error) {
@@ -394,11 +394,11 @@ var _ = Describe("ReconcileRetention", func() {
Context("when retention matches current state", func() {
BeforeEach(func() {
- actionsSettings.ArtifactAndLogRetentionDays = github.Ptr(90)
+ actionsSettings.ArtifactAndLogRetentionDays = new(90)
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
return &github.ArtifactPeriod{
- Days: github.Ptr(90),
+ Days: new(90),
}, nil
}
})
@@ -420,11 +420,11 @@ var _ = Describe("ReconcileRetention", func() {
BeforeEach(func() {
setRetentionCalled = false
- actionsSettings.ArtifactAndLogRetentionDays = github.Ptr(30)
+ actionsSettings.ArtifactAndLogRetentionDays = new(30)
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
return &github.ArtifactPeriod{
- Days: github.Ptr(90),
+ Days: new(90),
}, nil
}
mockClient.SetActionsRetentionForOrgFunc = func(ctx context.Context, org string, retentionInDays int) error {
@@ -450,7 +450,7 @@ var _ = Describe("ReconcileRetention", func() {
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
return &github.ArtifactPeriod{
- Days: github.Ptr(90),
+ Days: new(90),
}, nil
}
mockClient.SetActionsRetentionForOrgFunc = func(ctx context.Context, org string, retentionInDays int) error {
@@ -480,11 +480,11 @@ var _ = Describe("ReconcileRetention", func() {
Context("when GitHub API returns error on set", func() {
BeforeEach(func() {
- actionsSettings.ArtifactAndLogRetentionDays = github.Ptr(30)
+ actionsSettings.ArtifactAndLogRetentionDays = new(30)
mockClient.GetActionsRetentionForOrgFunc = func(ctx context.Context, org string) (*github.ArtifactPeriod, error) {
return &github.ArtifactPeriod{
- Days: github.Ptr(90),
+ Days: new(90),
}, nil
}
mockClient.SetActionsRetentionForOrgFunc = func(ctx context.Context, org string, retentionInDays int) error {
@@ -520,7 +520,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
Expect(schemeErr).NotTo(HaveOccurred())
actionsSettings = v1alpha1.ActionsSettings{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
+ AllowedActions: new("selected"),
}
})
@@ -557,6 +558,66 @@ var _ = Describe("ReconcileAllowedActions", func() {
err = rec.reconcileAllowedActions(ctx)
})
+ Context("when allowedActions is all", func() {
+ BeforeEach(func() {
+ actionsSettings.AllowedActions = new("all")
+ })
+
+ It("should skip reconciling and not call GitHub API", func() {
+ Expect(err).NotTo(HaveOccurred())
+
+ calls := mockClient.GetActionsCalls()
+ for _, call := range calls {
+ Expect(call.Method).NotTo(Equal("GetActionsAllowedForOrg"))
+ Expect(call.Method).NotTo(Equal("SetActionsAllowedForOrg"))
+ }
+ })
+ })
+
+ Context("when allowedActions is nil", func() {
+ BeforeEach(func() {
+ actionsSettings.AllowedActions = nil
+ })
+
+ It("should skip reconciling and not call GitHub API", func() {
+ Expect(err).NotTo(HaveOccurred())
+
+ calls := mockClient.GetActionsCalls()
+ for _, call := range calls {
+ Expect(call.Method).NotTo(Equal("GetActionsAllowedForOrg"))
+ Expect(call.Method).NotTo(Equal("SetActionsAllowedForOrg"))
+ }
+ })
+ })
+
+ Context("when allowedActions is selected in K8s", func() {
+ BeforeEach(func() {
+ actionsSettings.AllowedActions = new("selected")
+
+ mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
+ return &github.ActionsAllowed{
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
+ PatternsAllowed: []string{},
+ }, nil
+ }
+ })
+
+ It("should proceed to reconcile and call GetActionsAllowedForOrg", func() {
+ Expect(err).NotTo(HaveOccurred())
+
+ calls := mockClient.GetActionsCalls()
+ foundGetCall := false
+ for _, call := range calls {
+ if call.Method == "GetActionsAllowedForOrg" {
+ foundGetCall = true
+ break
+ }
+ }
+ Expect(foundGetCall).To(BeTrue(), "Expected GetActionsAllowedForOrg to be called")
+ })
+ })
+
Context("when SelectedAllowedActions is nil", func() {
var capturedAllowedActions github.ActionsAllowed
@@ -565,8 +626,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"some/pattern@*"},
}, nil
}
@@ -578,8 +639,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
It("should set all flags to false and empty patterns", func() {
Expect(err).NotTo(HaveOccurred())
- Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(github.Ptr(false)))
- Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(github.Ptr(false)))
+ Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(new(false)))
+ Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(new(false)))
Expect(capturedAllowedActions.PatternsAllowed).To(BeEmpty())
})
})
@@ -591,15 +652,15 @@ var _ = Describe("ReconcileAllowedActions", func() {
BeforeEach(func() {
setAllowedCalled = false
actionsSettings.SelectedAllowedActions = &v1alpha1.SelectedAllowedActions{
- GitHubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GitHubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"org/action@*", "another/action@v1"},
}
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
- VerifiedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
+ VerifiedAllowed: new(false),
PatternsAllowed: []string{},
}, nil
}
@@ -613,8 +674,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
It("should update allowed actions with specified values", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAllowedCalled).To(BeTrue())
- Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(github.Ptr(true)))
- Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(github.Ptr(true)))
+ Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(new(true)))
+ Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(new(true)))
Expect(capturedAllowedActions.PatternsAllowed).To(ConsistOf("org/action@*", "another/action@v1"))
})
})
@@ -622,15 +683,15 @@ var _ = Describe("ReconcileAllowedActions", func() {
Context("when allowed actions match current state", func() {
BeforeEach(func() {
actionsSettings.SelectedAllowedActions = &v1alpha1.SelectedAllowedActions{
- GitHubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(false),
+ GitHubOwnedAllowed: new(true),
+ VerifiedAllowed: new(false),
PatternsAllowed: []string{"org/action@*"},
}
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(false),
PatternsAllowed: []string{"org/action@*"},
}, nil
}
@@ -657,8 +718,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(true),
- VerifiedAllowed: github.Ptr(true),
+ GithubOwnedAllowed: new(true),
+ VerifiedAllowed: new(true),
PatternsAllowed: []string{"some/pattern@*"},
}, nil
}
@@ -670,8 +731,8 @@ var _ = Describe("ReconcileAllowedActions", func() {
It("should use default values (false, false, empty)", func() {
Expect(err).NotTo(HaveOccurred())
- Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(github.Ptr(false)))
- Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(github.Ptr(false)))
+ Expect(capturedAllowedActions.GithubOwnedAllowed).To(Equal(new(false)))
+ Expect(capturedAllowedActions.VerifiedAllowed).To(Equal(new(false)))
Expect(capturedAllowedActions.PatternsAllowed).To(BeEmpty())
})
})
@@ -692,12 +753,12 @@ var _ = Describe("ReconcileAllowedActions", func() {
Context("when GitHub API returns error on set", func() {
BeforeEach(func() {
actionsSettings.SelectedAllowedActions = &v1alpha1.SelectedAllowedActions{
- GitHubOwnedAllowed: github.Ptr(true),
+ GitHubOwnedAllowed: new(true),
}
mockClient.GetActionsAllowedForOrgFunc = func(ctx context.Context, org string) (*github.ActionsAllowed, error) {
return &github.ActionsAllowed{
- GithubOwnedAllowed: github.Ptr(false),
+ GithubOwnedAllowed: new(false),
}, nil
}
mockClient.SetActionsAllowedForOrgFunc = func(ctx context.Context, org string, allowedActions github.ActionsAllowed) (*github.ActionsAllowed, error) {
@@ -770,13 +831,13 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
Context("when workflow permissions match current state", func() {
BeforeEach(func() {
- actionsSettings.DefaultWorkflowPermissions = github.Ptr("write")
- actionsSettings.CanApprovePullRequestReviews = github.Ptr(true)
+ actionsSettings.DefaultWorkflowPermissions = new("write")
+ actionsSettings.CanApprovePullRequestReviews = new(true)
mockClient.GetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.DefaultWorkflowPermissionOrganization, error) {
return &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("write"),
- CanApprovePullRequestReviews: github.Ptr(true),
+ DefaultWorkflowPermissions: new("write"),
+ CanApprovePullRequestReviews: new(true),
}, nil
}
})
@@ -798,13 +859,13 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
BeforeEach(func() {
setPermissionsCalled = false
- actionsSettings.DefaultWorkflowPermissions = github.Ptr("write")
- actionsSettings.CanApprovePullRequestReviews = github.Ptr(true)
+ actionsSettings.DefaultWorkflowPermissions = new("write")
+ actionsSettings.CanApprovePullRequestReviews = new(true)
mockClient.GetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.DefaultWorkflowPermissionOrganization, error) {
return &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
- CanApprovePullRequestReviews: github.Ptr(false),
+ DefaultWorkflowPermissions: new("read"),
+ CanApprovePullRequestReviews: new(false),
}, nil
}
mockClient.SetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.DefaultWorkflowPermissionOrganization) (*github.DefaultWorkflowPermissionOrganization, error) {
@@ -817,8 +878,8 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
It("should update workflow permissions", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setPermissionsCalled).To(BeTrue())
- Expect(capturedPermissions.DefaultWorkflowPermissions).To(Equal(github.Ptr("write")))
- Expect(capturedPermissions.CanApprovePullRequestReviews).To(Equal(github.Ptr(true)))
+ Expect(capturedPermissions.DefaultWorkflowPermissions).To(Equal(new("write")))
+ Expect(capturedPermissions.CanApprovePullRequestReviews).To(Equal(new(true)))
})
})
@@ -832,8 +893,8 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
mockClient.GetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.DefaultWorkflowPermissionOrganization, error) {
return &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("write"),
- CanApprovePullRequestReviews: github.Ptr(true),
+ DefaultWorkflowPermissions: new("write"),
+ CanApprovePullRequestReviews: new(true),
}, nil
}
mockClient.SetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.DefaultWorkflowPermissionOrganization) (*github.DefaultWorkflowPermissionOrganization, error) {
@@ -844,8 +905,8 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
It("should use default values (read, false)", func() {
Expect(err).NotTo(HaveOccurred())
- Expect(capturedPermissions.DefaultWorkflowPermissions).To(Equal(github.Ptr("read")))
- Expect(capturedPermissions.CanApprovePullRequestReviews).To(Equal(github.Ptr(false)))
+ Expect(capturedPermissions.DefaultWorkflowPermissions).To(Equal(new("read")))
+ Expect(capturedPermissions.CanApprovePullRequestReviews).To(Equal(new(false)))
})
})
@@ -864,11 +925,11 @@ var _ = Describe("ReconcileDefaultWorkflowPermissions", func() {
Context("when GitHub API returns error on set", func() {
BeforeEach(func() {
- actionsSettings.DefaultWorkflowPermissions = github.Ptr("write")
+ actionsSettings.DefaultWorkflowPermissions = new("write")
mockClient.GetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.DefaultWorkflowPermissionOrganization, error) {
return &github.DefaultWorkflowPermissionOrganization{
- DefaultWorkflowPermissions: github.Ptr("read"),
+ DefaultWorkflowPermissions: new("read"),
}, nil
}
mockClient.SetActionsDefaultWorkflowPermissionsForOrgFunc = func(ctx context.Context, org string, permissions github.DefaultWorkflowPermissionOrganization) (*github.DefaultWorkflowPermissionOrganization, error) {
@@ -943,7 +1004,7 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() {
BeforeEach(func() {
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("none"),
+ EnabledRepositories: new("none"),
}, nil
}
})
@@ -968,7 +1029,7 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() {
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}, nil
}
mockClient.SetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string, settings github.SelfHostedRunnersSettingsOrganizationOpt) error {
@@ -981,7 +1042,7 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() {
It("should update settings to none", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setSettingsCalled).To(BeTrue())
- Expect(capturedSettings.EnabledRepositories).To(Equal(github.Ptr("none")))
+ Expect(capturedSettings.EnabledRepositories).To(Equal(new("none")))
})
})
@@ -993,7 +1054,7 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() {
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("selected"),
+ EnabledRepositories: new("selected"),
}, nil
}
mockClient.SetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string, settings github.SelfHostedRunnersSettingsOrganizationOpt) error {
@@ -1025,7 +1086,7 @@ var _ = Describe("ReconcileSelfHostedRunnerSettings", func() {
BeforeEach(func() {
mockClient.GetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string) (*github.SelfHostedRunnersSettingsOrganization, error) {
return &github.SelfHostedRunnersSettingsOrganization{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}, nil
}
mockClient.SetSelfHostedRunnersSettingsForOrgFunc = func(ctx context.Context, org string, settings github.SelfHostedRunnersSettingsOrganizationOpt) error {
@@ -1096,7 +1157,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
Name: "test-org",
GitHubAppInstallationId: 12345,
ActionsSettings: v1alpha1.ActionsSettings{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
},
},
}
@@ -1148,7 +1209,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
BeforeEach(func() {
repos = []*v1alpha1.Repository{}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(999))},
+ {ID: new(int64(999))},
}
})
@@ -1169,11 +1230,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
{
@@ -1183,11 +1244,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo2",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(222)),
+ ID: new(int64(222)),
},
},
}
@@ -1211,16 +1272,16 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(false),
+ ActionsEnabled: new(false),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(111))},
+ {ID: new(int64(111))},
}
})
@@ -1241,11 +1302,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
{
@@ -1255,11 +1316,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo2",
- ActionsEnabled: github.Ptr(false),
+ ActionsEnabled: new(false),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(222)),
+ ID: new(int64(222)),
},
},
{
@@ -1269,11 +1330,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo3",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(333)),
+ ID: new(int64(333)),
},
},
}
@@ -1297,16 +1358,16 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(111))},
+ {ID: new(int64(111))},
}
})
@@ -1326,7 +1387,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
@@ -1353,7 +1414,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
@@ -1362,7 +1423,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(999))},
+ {ID: new(int64(999))},
}
})
@@ -1395,11 +1456,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
@@ -1424,11 +1485,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
{
@@ -1438,11 +1499,11 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo2",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "other-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(222)),
+ ID: new(int64(222)),
},
},
}
@@ -1466,16 +1527,16 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(222))}, // Different repo enabled
+ {ID: new(int64(222))}, // Different repo enabled
}
})
@@ -1496,18 +1557,18 @@ var _ = Describe("ReconcileActionsEnabled", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "repo1",
- ActionsEnabled: github.Ptr(true),
+ ActionsEnabled: new(true),
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
currentEnabledRepos = []*github.Repository{
- {ID: github.Ptr(int64(111))},
- {ID: github.Ptr(int64(222))},
- {ID: github.Ptr(int64(333))},
+ {ID: new(int64(111))},
+ {ID: new(int64(222))},
+ {ID: new(int64(333))},
}
})
@@ -1532,7 +1593,7 @@ var _ = Describe("ReconcileActionsEnabled", func() {
OrganizationRef: v1alpha1.OrganizationRef{Name: "test-org"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(111)),
+ ID: new(int64(111)),
},
},
}
@@ -1550,8 +1611,8 @@ var _ = Describe("ReconcileActionsEnabled", func() {
var _ = Describe("containsSameIDs", func() {
It("should return true for matching IDs", func() {
current := []*github.Repository{
- {ID: github.Ptr(int64(111))},
- {ID: github.Ptr(int64(222))},
+ {ID: new(int64(111))},
+ {ID: new(int64(222))},
}
desired := map[int64]any{
111: nil,
@@ -1562,7 +1623,7 @@ var _ = Describe("containsSameIDs", func() {
It("should return false for different counts", func() {
current := []*github.Repository{
- {ID: github.Ptr(int64(111))},
+ {ID: new(int64(111))},
}
desired := map[int64]any{
111: nil,
@@ -1573,8 +1634,8 @@ var _ = Describe("containsSameIDs", func() {
It("should return false for different IDs", func() {
current := []*github.Repository{
- {ID: github.Ptr(int64(111))},
- {ID: github.Ptr(int64(333))},
+ {ID: new(int64(111))},
+ {ID: new(int64(333))},
}
desired := map[int64]any{
111: nil,
@@ -1599,7 +1660,7 @@ var _ = Describe("containsSameIDs", func() {
It("should return false when desired is empty but current is not", func() {
current := []*github.Repository{
- {ID: github.Ptr(int64(111))},
+ {ID: new(int64(111))},
}
desired := map[int64]any{}
Expect(containsSameIDs(current, desired)).To(BeFalse())
@@ -1662,7 +1723,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
return nil, createRunnerGroupError
}
return &github.RunnerGroup{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: createRequest.Name,
Visibility: createRequest.Visibility,
RestrictedToWorkflows: createRequest.RestrictedToWorkflows,
@@ -1679,7 +1740,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
return nil, updateRunnerGroupError
}
return &github.RunnerGroup{
- ID: github.Ptr(groupID),
+ ID: new(groupID),
Name: updateRequest.Name,
Visibility: updateRequest.Visibility,
RestrictedToWorkflows: updateRequest.RestrictedToWorkflows,
@@ -1764,8 +1825,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
},
}
currentRunnerGroups = []*github.RunnerGroup{}
@@ -1774,8 +1835,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should create the runner group", func() {
Expect(err).NotTo(HaveOccurred())
Expect(createRunnerGroupCalls).To(HaveLen(1))
- Expect(createRunnerGroupCalls[0].Name).To(Equal(github.Ptr("test-group")))
- Expect(createRunnerGroupCalls[0].Visibility).To(Equal(github.Ptr("all")))
+ Expect(createRunnerGroupCalls[0].Name).To(Equal(new("test-group")))
+ Expect(createRunnerGroupCalls[0].Visibility).To(Equal(new("all")))
Expect(deleteRunnerGroupCalls).To(BeEmpty())
})
})
@@ -1785,10 +1846,10 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("old-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ ID: new(int64(111)),
+ Name: new("old-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
},
}
})
@@ -1806,16 +1867,16 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
},
}
})
@@ -1832,17 +1893,17 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("selected"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
- RestrictedToWorkflows: github.Ptr(false),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("all"),
+ RestrictedToWorkflows: new(false),
},
}
})
@@ -1853,9 +1914,9 @@ var _ = Describe("ReconcileRunnerGroups", func() {
Expect(createRunnerGroupCalls).To(BeEmpty())
Expect(updateRunnerGroupCalls).To(HaveLen(1))
Expect(updateRunnerGroupCalls[0].GroupID).To(Equal(int64(111)))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Name).To(Equal(github.Ptr("test-group")))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(github.Ptr("selected")))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Name).To(Equal(new("test-group")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(new("selected")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.RestrictedToWorkflows).To(Equal(new(true)))
// Repository IDs are equal (both empty: current via mock default, desired has no repos), so no SetSelectedRepositories call
Expect(setSelectedRepositoriesCalls).To(BeEmpty())
})
@@ -1875,24 +1936,24 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"group1"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "group1",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
{
Name: "group2",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(222)),
- Name: github.Ptr("old-group"),
+ ID: new(int64(222)),
+ Name: new("old-group"),
},
}
})
@@ -1926,8 +1987,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("old-group"),
+ ID: new(int64(111)),
+ Name: new("old-group"),
},
}
deleteRunnerGroupError = errors.New("API error: failed to delete runner group")
@@ -1945,7 +2006,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
},
}
currentRunnerGroups = []*github.RunnerGroup{}
@@ -1964,14 +2025,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "new-name",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("old-name"),
- Visibility: github.Ptr("all"),
+ ID: new(int64(111)),
+ Name: new("old-name"),
+ Visibility: new("all"),
},
}
})
@@ -1981,7 +2042,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
Expect(deleteRunnerGroupCalls).To(HaveLen(1))
Expect(deleteRunnerGroupCalls[0]).To(Equal(int64(111)))
Expect(createRunnerGroupCalls).To(HaveLen(1))
- Expect(createRunnerGroupCalls[0].Name).To(Equal(github.Ptr("new-name")))
+ Expect(createRunnerGroupCalls[0].Name).To(Equal(new("new-name")))
})
})
@@ -1990,8 +2051,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "restricted-group",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo/.github/workflows/deploy.yaml@refs/heads/main",
"org/repo/.github/workflows/test.yaml@refs/tags/v1.0.0",
@@ -2004,8 +2065,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should create runner group with workflow restrictions", func() {
Expect(err).NotTo(HaveOccurred())
Expect(createRunnerGroupCalls).To(HaveLen(1))
- Expect(createRunnerGroupCalls[0].Name).To(Equal(github.Ptr("restricted-group")))
- Expect(createRunnerGroupCalls[0].RestrictedToWorkflows).To(Equal(github.Ptr(true)))
+ Expect(createRunnerGroupCalls[0].Name).To(Equal(new("restricted-group")))
+ Expect(createRunnerGroupCalls[0].RestrictedToWorkflows).To(Equal(new(true)))
Expect(createRunnerGroupCalls[0].SelectedWorkflows).To(ConsistOf(
"org/repo/.github/workflows/deploy.yaml@refs/heads/main",
"org/repo/.github/workflows/test.yaml@refs/tags/v1.0.0",
@@ -2027,7 +2088,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"selected-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -2041,14 +2102,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"selected-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "selected-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{}
@@ -2057,8 +2118,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should create runner group with selected repositories", func() {
Expect(err).NotTo(HaveOccurred())
Expect(createRunnerGroupCalls).To(HaveLen(1))
- Expect(createRunnerGroupCalls[0].Name).To(Equal(github.Ptr("selected-group")))
- Expect(createRunnerGroupCalls[0].Visibility).To(Equal(github.Ptr("selected")))
+ Expect(createRunnerGroupCalls[0].Name).To(Equal(new("selected-group")))
+ Expect(createRunnerGroupCalls[0].Visibility).To(Equal(new("selected")))
Expect(createRunnerGroupCalls[0].SelectedRepositoryIDs).To(ConsistOf(int64(100), int64(200)))
})
})
@@ -2077,7 +2138,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"my-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -2091,14 +2152,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"my-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "my-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{}
@@ -2116,31 +2177,31 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "group-keep",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
},
{
Name: "group-update",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
{
Name: "group-new",
- Visibility: github.Ptr("private"),
+ Visibility: new("private"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("group-keep"),
- Visibility: github.Ptr("all"),
+ ID: new(int64(111)),
+ Name: new("group-keep"),
+ Visibility: new("all"),
},
{
- ID: github.Ptr(int64(222)),
- Name: github.Ptr("group-update"),
- Visibility: github.Ptr("all"), // Different visibility
+ ID: new(int64(222)),
+ Name: new("group-update"),
+ Visibility: new("all"), // Different visibility
},
{
- ID: github.Ptr(int64(333)),
- Name: github.Ptr("group-delete"),
+ ID: new(int64(333)),
+ Name: new("group-delete"),
},
}
})
@@ -2153,11 +2214,11 @@ var _ = Describe("ReconcileRunnerGroups", func() {
// Should update: group-update
Expect(updateRunnerGroupCalls).To(HaveLen(1))
Expect(updateRunnerGroupCalls[0].GroupID).To(Equal(int64(222)))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Name).To(Equal(github.Ptr("group-update")))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(github.Ptr("selected")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Name).To(Equal(new("group-update")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(new("selected")))
// Should create: group-new
Expect(createRunnerGroupCalls).To(HaveLen(1))
- Expect(createRunnerGroupCalls[0].Name).To(Equal(github.Ptr("group-new")))
+ Expect(createRunnerGroupCalls[0].Name).To(Equal(new("group-new")))
// Repository IDs are equal (both empty) for group-update, so no SetSelectedRepositories call
// group-keep has visibility='all' so it also skips repository operations
Expect(setSelectedRepositoriesCalls).To(BeEmpty())
@@ -2178,7 +2239,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -2192,21 +2253,21 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
})
@@ -2227,14 +2288,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("all"),
},
}
updateRunnerGroupError = errors.New("API error: failed to update runner group")
@@ -2261,21 +2322,21 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("all"),
},
}
setSelectedRepositoriesError = errors.New("API error: failed to set repositories")
@@ -2294,8 +2355,8 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(true),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo/.github/workflows/ci.yaml@main",
"org/repo/.github/workflows/deploy.yaml@main",
@@ -2304,10 +2365,10 @@ var _ = Describe("ReconcileRunnerGroups", func() {
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(true),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{
"org/repo/.github/workflows/ci.yaml@main",
},
@@ -2330,16 +2391,16 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(false),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(false),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("private"),
- RestrictedToWorkflows: github.Ptr(true),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("private"),
+ RestrictedToWorkflows: new(true),
SelectedWorkflows: []string{"org/repo/.github/workflows/ci.yaml@main"},
},
}
@@ -2348,7 +2409,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should update the runner group", func() {
Expect(err).NotTo(HaveOccurred())
Expect(updateRunnerGroupCalls).To(HaveLen(1))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.RestrictedToWorkflows).To(Equal(github.Ptr(false)))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.RestrictedToWorkflows).To(Equal(new(false)))
})
})
@@ -2366,21 +2427,21 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("all"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("all"),
},
}
})
@@ -2388,7 +2449,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should update visibility and set selected repositories", func() {
Expect(err).NotTo(HaveOccurred())
Expect(updateRunnerGroupCalls).To(HaveLen(1))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(github.Ptr("selected")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(new("selected")))
Expect(setSelectedRepositoriesCalls).To(HaveLen(1))
Expect(setSelectedRepositoriesCalls[0].RepositoryIDs).To(ConsistOf(int64(100)))
})
@@ -2399,14 +2460,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("all"),
+ Visibility: new("all"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
})
@@ -2414,7 +2475,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
It("should update visibility but not set repositories", func() {
Expect(err).NotTo(HaveOccurred())
Expect(updateRunnerGroupCalls).To(HaveLen(1))
- Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(github.Ptr("all")))
+ Expect(updateRunnerGroupCalls[0].UpdateRequest.Visibility).To(Equal(new("all")))
// When visibility is 'all', SetSelectedRepositories should not be called
Expect(setSelectedRepositoriesCalls).To(BeEmpty())
})
@@ -2434,27 +2495,27 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
// Mock GetSelectedRepositories to return the same repo that's desired
mockClient.GetSelectedRepositoriesForRunnerGroupFunc = func(ctx context.Context, org string, groupID int64) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(100))},
+ {ID: new(int64(100))},
}, nil
}
})
@@ -2481,7 +2542,7 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
{
@@ -2495,27 +2556,27 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
// Mock GetSelectedRepositories to return different repos
mockClient.GetSelectedRepositoriesForRunnerGroupFunc = func(ctx context.Context, org string, groupID int64) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(300))}, // Different repo
+ {ID: new(int64(300))}, // Different repo
}, nil
}
})
@@ -2544,21 +2605,21 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("private"),
+ Visibility: new("private"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("private"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("private"),
},
}
})
@@ -2576,14 +2637,14 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
mockClient.GetSelectedRepositoriesForRunnerGroupFunc = func(ctx context.Context, org string, groupID int64) ([]*github.Repository, error) {
@@ -2611,21 +2672,21 @@ var _ = Describe("ReconcileRunnerGroups", func() {
AvailableActionsRunnerGroups: []string{"test-group"},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
},
},
}
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
// Current has no repositories
@@ -2651,20 +2712,20 @@ var _ = Describe("ReconcileRunnerGroups", func() {
actionsSettings.RunnerGroups = []v1alpha1.RunnerGroup{
{
Name: "test-group",
- Visibility: github.Ptr("selected"),
+ Visibility: new("selected"),
},
}
currentRunnerGroups = []*github.RunnerGroup{
{
- ID: github.Ptr(int64(111)),
- Name: github.Ptr("test-group"),
- Visibility: github.Ptr("selected"),
+ ID: new(int64(111)),
+ Name: new("test-group"),
+ Visibility: new("selected"),
},
}
// Current has a repository
mockClient.GetSelectedRepositoriesForRunnerGroupFunc = func(ctx context.Context, org string, groupID int64) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(100))},
+ {ID: new(int64(100))},
}, nil
}
})
@@ -2703,9 +2764,9 @@ var _ = Describe("ReconcilePermissions with selected repositories", func() {
mockClient.GetActionsPermissionsForOrgFunc = func(ctx context.Context, org string) (*github.ActionsPermissions, error) {
return &github.ActionsPermissions{
- EnabledRepositories: github.Ptr("selected"),
- AllowedActions: github.Ptr("selected"),
- SHAPinningRequired: github.Ptr(false),
+ EnabledRepositories: new("selected"),
+ AllowedActions: new("selected"),
+ SHAPinningRequired: new(false),
}, nil
}
@@ -2760,7 +2821,7 @@ var _ = Describe("ReconcilePermissions with selected repositories", func() {
Context("when enabled repositories is 'selected'", func() {
BeforeEach(func() {
actionsSettings = v1alpha1.ActionsSettings{
- EnabledRepositories: github.Ptr("selected"),
+ EnabledRepositories: new("selected"),
}
})
@@ -2782,7 +2843,7 @@ var _ = Describe("ReconcilePermissions with selected repositories", func() {
Context("when enabled repositories is not 'selected'", func() {
BeforeEach(func() {
actionsSettings = v1alpha1.ActionsSettings{
- EnabledRepositories: github.Ptr("all"),
+ EnabledRepositories: new("all"),
}
})
diff --git a/internal/reconciler/orgrec/rec_code_security_configurations.go b/internal/reconciler/orgrec/rec_code_security_configurations.go
index 8dfad02..e79aec4 100644
--- a/internal/reconciler/orgrec/rec_code_security_configurations.go
+++ b/internal/reconciler/orgrec/rec_code_security_configurations.go
@@ -30,6 +30,11 @@ func (o *GitHubOrgReconciler) reconcileCodeSecurityConfigurations(ctx context.Co
return err
}
+ if !o.Kubernetes.Resource.HasEnterpriseFeatures() {
+ log.V(1).Info("Skipping code security configurations reconciliation for free plan")
+ return nil
+ }
+
type attachable struct {
k8sName string
scope *string
@@ -255,12 +260,12 @@ func (o *GitHubOrgReconciler) getDesiredAttachmentsForScope(ctx context.Context,
}
doInclude := false
switch attachmentScope {
- case "public":
- if repo.GetVisibility() == "public" {
+ case githubv1alpha1.VisibilityPublic:
+ if repo.GetVisibility() == githubv1alpha1.VisibilityPublic {
doInclude = true
}
case "private_or_internal":
- if repo.GetVisibility() == "private" || repo.GetVisibility() == "internal" {
+ if repo.GetVisibility() == githubv1alpha1.VisibilityPrivate || repo.GetVisibility() == githubv1alpha1.VisibilityInternal {
doInclude = true
}
case "all":
diff --git a/internal/reconciler/orgrec/rec_code_security_configurations_test.go b/internal/reconciler/orgrec/rec_code_security_configurations_test.go
index 47b5b2c..308c06e 100644
--- a/internal/reconciler/orgrec/rec_code_security_configurations_test.go
+++ b/internal/reconciler/orgrec/rec_code_security_configurations_test.go
@@ -80,7 +80,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
}
})
@@ -111,6 +111,36 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
})
+ Context("when plan is 'free'", func() {
+ BeforeEach(func() {
+ org.Spec.Plan = "free"
+ mockClient.GetDefaultCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfigurationWithDefaultForNewRepos, error) {
+ return []*github.CodeSecurityConfigurationWithDefaultForNewRepos{}, nil
+ }
+ mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
+ return []*github.CodeSecurityConfiguration{}, nil
+ }
+ })
+
+ JustBeforeEach(func() {
+ err = rec.reconcileCodeSecurityConfigurations(ctx)
+ })
+
+ It("should skip reconciliation and return no error", func() {
+ Expect(err).NotTo(HaveOccurred())
+ })
+
+ It("should not call any modifying GitHub API methods", func() {
+ Expect(err).NotTo(HaveOccurred())
+ calls := mockClient.GetCodeSecurityConfigurationCalls()
+ for _, call := range calls {
+ Expect(call.Method).NotTo(Equal("CreateCodeSecurityConfigurationForOrg"))
+ Expect(call.Method).NotTo(Equal("UpdateCodeSecurityConfigurationForOrg"))
+ Expect(call.Method).NotTo(Equal("DeleteCodeSecurityConfigurationForOrg"))
+ }
+ })
+ })
+
Context("when no code security configurations are referenced", func() {
BeforeEach(func() {
mockClient.GetDefaultCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfigurationWithDefaultForNewRepos, error) {
@@ -146,7 +176,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
createdConfig = &config
- createdConfig.ID = github.Ptr(int64(999))
+ createdConfig.ID = new(int64(999))
return createdConfig, nil
}
})
@@ -168,7 +198,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
var defaultScope string
BeforeEach(func() {
- csc.Spec.DefaultForNewRepos = github.Ptr("all")
+ csc.Spec.DefaultForNewRepos = new("all")
org.Spec.CodeSecurityConfigurations = []v1alpha1.AttachableCodeSecurityConfigurationRef{
{Name: testCsc},
}
@@ -181,7 +211,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
return &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: config.Name,
Description: config.Description,
}, nil
@@ -219,16 +249,16 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
Description: "Old description",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
mockClient.UpdateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, configId int64, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
updatedConfig = &config
- updatedConfig.ID = github.Ptr(configId)
+ updatedConfig.ID = new(configId)
return updatedConfig, nil
}
})
@@ -256,10 +286,10 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
Description: "Test code security configuration",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
@@ -295,9 +325,9 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: "orphaned-csc",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
@@ -362,9 +392,9 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
var defaultScope string
BeforeEach(func() {
- csc.Spec.DefaultForNewRepos = github.Ptr("selected")
+ csc.Spec.DefaultForNewRepos = new("selected")
org.Spec.CodeSecurityConfigurations = []v1alpha1.AttachableCodeSecurityConfigurationRef{
- {Name: testCsc, AttachmentScope: github.Ptr("selected")},
+ {Name: testCsc, AttachmentScope: new("selected")},
}
mockClient.GetDefaultCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfigurationWithDefaultForNewRepos, error) {
@@ -375,7 +405,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
return &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: config.Name,
Description: config.Description,
}, nil
@@ -406,7 +436,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
Context("when SetCodeSecurityConfigurationAsDefaultForOrg fails during creation", func() {
BeforeEach(func() {
- csc.Spec.DefaultForNewRepos = github.Ptr("all")
+ csc.Spec.DefaultForNewRepos = new("all")
org.Spec.CodeSecurityConfigurations = []v1alpha1.AttachableCodeSecurityConfigurationRef{
{Name: testCsc},
}
@@ -419,7 +449,7 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
return &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: config.Name,
Description: config.Description,
}, nil
@@ -452,10 +482,10 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
Description: "Old description",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
@@ -484,9 +514,9 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: "orphaned-csc",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
@@ -531,16 +561,16 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
mockClient.GetCodeSecurityConfigurationsForOrgFunc = func(ctx context.Context, org string) ([]*github.CodeSecurityConfiguration, error) {
return []*github.CodeSecurityConfiguration{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
Description: "Test code security configuration",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}, nil
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
return &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(1000)),
+ ID: new(int64(1000)),
Name: config.Name,
Description: config.Description,
}, nil
@@ -594,13 +624,13 @@ var _ = Describe("ReconcileCodeSecurityConfigurations", func() {
}
mockClient.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- ID: github.Ptr(int64(12345)),
- Slug: github.Ptr("security-team"),
+ ID: new(int64(12345)),
+ Slug: new("security-team"),
}, nil
}
mockClient.CreateCodeSecurityConfigurationForOrgFunc = func(ctx context.Context, org string, config github.CodeSecurityConfiguration) (*github.CodeSecurityConfiguration, error) {
return &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: config.Name,
Description: config.Description,
}, nil
@@ -686,7 +716,7 @@ var _ = Describe("UnsetObsoleteDefaults", func() {
BeforeEach(func() {
// CSC is not marked as default (or is set to "none")
- csc.Spec.DefaultForNewRepos = github.Ptr("none")
+ csc.Spec.DefaultForNewRepos = new("none")
org.Spec.CodeSecurityConfigurations = []v1alpha1.AttachableCodeSecurityConfigurationRef{
{Name: testCsc},
}
@@ -695,9 +725,9 @@ var _ = Describe("UnsetObsoleteDefaults", func() {
return []*github.CodeSecurityConfigurationWithDefaultForNewRepos{
{
Configuration: &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
},
}, nil
@@ -716,7 +746,7 @@ var _ = Describe("UnsetObsoleteDefaults", func() {
Context("when a default config is still marked as default in k8s", func() {
BeforeEach(func() {
- csc.Spec.DefaultForNewRepos = github.Ptr("all")
+ csc.Spec.DefaultForNewRepos = new("all")
org.Spec.CodeSecurityConfigurations = []v1alpha1.AttachableCodeSecurityConfigurationRef{
{Name: testCsc},
}
@@ -725,9 +755,9 @@ var _ = Describe("UnsetObsoleteDefaults", func() {
return []*github.CodeSecurityConfigurationWithDefaultForNewRepos{
{
Configuration: &github.CodeSecurityConfiguration{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: testCsc,
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
},
}, nil
@@ -857,14 +887,14 @@ var _ = Describe("ResolveBypassReviewerNames", func() {
mockClient.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- ID: github.Ptr(int64(12345)),
- Slug: github.Ptr(testTeam),
+ ID: new(int64(12345)),
+ Slug: new(testTeam),
}, nil
}
mockClient.GetRoleByNameFunc = func(ctx context.Context, org string, roleName string) (*github.CustomOrgRole, error) {
return &github.CustomOrgRole{
- ID: github.Ptr(int64(67890)),
- Name: github.Ptr(testRole),
+ ID: new(int64(67890)),
+ Name: new(testRole),
}, nil
}
})
@@ -908,14 +938,14 @@ var _ = Describe("ResolveBypassReviewerNames", func() {
mockClient.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- ID: github.Ptr(int64(12345)),
- Slug: github.Ptr(testTeam),
+ ID: new(int64(12345)),
+ Slug: new(testTeam),
}, nil
}
mockClient.GetRoleByNameFunc = func(ctx context.Context, org string, roleName string) (*github.CustomOrgRole, error) {
return &github.CustomOrgRole{
- ID: github.Ptr(int64(67890)),
- Name: github.Ptr(testRole),
+ ID: new(int64(67890)),
+ Name: new(testRole),
}, nil
}
})
@@ -1031,7 +1061,7 @@ var _ = Describe("AttachToRepos", func() {
},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
}
})
@@ -1073,8 +1103,8 @@ var _ = Describe("AttachToRepos", func() {
}
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
}, nil
}
mockClient.AttachCodeSecurityConfigurationsFunc = func(ctx context.Context, org string, cscID int64, scope string, repoIDs []int64) error {
@@ -1146,8 +1176,8 @@ var _ = Describe("AttachToRepos", func() {
}
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repoName string) (*github.Repository, error) {
return &github.Repository{
- ID: github.Ptr(int64(54321)),
- Name: github.Ptr(testRepo),
+ ID: new(int64(54321)),
+ Name: new(testRepo),
}, nil
}
mockClient.AttachCodeSecurityConfigurationsFunc = func(ctx context.Context, org string, cscID int64, scope string, repoIDs []int64) error {
@@ -1191,7 +1221,7 @@ var _ = Describe("AttachToRepos", func() {
}
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
}, nil
}
mockClient.AttachCodeSecurityConfigurationsFunc = func(ctx context.Context, org string, cscID int64, scope string, repoIDs []int64) error {
@@ -1211,7 +1241,7 @@ var _ = Describe("AttachmentsDiffer", func() {
Context("when attachments have different counts", func() {
It("should return true", func() {
current := []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}},
+ {Repository: &github.Repository{Name: new("repo1")}},
}
desired := map[string]int64{
"repo1": 1,
@@ -1224,8 +1254,8 @@ var _ = Describe("AttachmentsDiffer", func() {
Context("when all current attachments exist in desired", func() {
It("should return false (no difference when repos match)", func() {
current := []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}},
- {Repository: &github.Repository{Name: github.Ptr("repo2")}},
+ {Repository: &github.Repository{Name: new("repo1")}},
+ {Repository: &github.Repository{Name: new("repo2")}},
}
desired := map[string]int64{
"repo1": 1,
@@ -1238,7 +1268,7 @@ var _ = Describe("AttachmentsDiffer", func() {
Context("when a current attachment is not in desired", func() {
It("should return true (counts differ)", func() {
current := []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo3")}},
+ {Repository: &github.Repository{Name: new("repo3")}},
}
desired := map[string]int64{
"repo1": 1,
@@ -1262,8 +1292,8 @@ var _ = Describe("AttachmentsDiffer", func() {
Context("when current attachments match desired exactly", func() {
It("should return false", func() {
current := []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1"), ID: github.Ptr(int64(1))}},
- {Repository: &github.Repository{Name: github.Ptr("repo2"), ID: github.Ptr(int64(2))}},
+ {Repository: &github.Repository{Name: new("repo1"), ID: new(int64(1))}},
+ {Repository: &github.Repository{Name: new("repo2"), ID: new(int64(2))}},
}
desired := map[string]int64{
"repo1": 1,
@@ -1296,9 +1326,9 @@ var _ = Describe("GetDesiredAttachmentsForScope", func() {
It("should return all repositories", func() {
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
- {ID: github.Ptr(int64(3)), Name: github.Ptr("repo3"), Visibility: github.Ptr("internal")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
+ {ID: new(int64(3)), Name: new("repo3"), Visibility: new("internal")},
}, nil
}
@@ -1315,9 +1345,9 @@ var _ = Describe("GetDesiredAttachmentsForScope", func() {
It("should return only public repositories", func() {
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
- {ID: github.Ptr(int64(3)), Name: github.Ptr("repo3"), Visibility: github.Ptr("internal")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
+ {ID: new(int64(3)), Name: new("repo3"), Visibility: new("internal")},
}, nil
}
@@ -1332,9 +1362,9 @@ var _ = Describe("GetDesiredAttachmentsForScope", func() {
It("should return only private and internal repositories", func() {
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
- {ID: github.Ptr(int64(3)), Name: github.Ptr("repo3"), Visibility: github.Ptr("internal")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
+ {ID: new(int64(3)), Name: new("repo3"), Visibility: new("internal")},
}, nil
}
@@ -1392,9 +1422,9 @@ var _ = Describe("GetDesiredAttachmentsForScope", func() {
It("should skip that repository", func() {
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: nil, Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
- {ID: github.Ptr(int64(3)), Name: nil, Visibility: github.Ptr("internal")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: nil, Name: new("repo2"), Visibility: new("private")},
+ {ID: new(int64(3)), Name: nil, Visibility: new("internal")},
}, nil
}
@@ -1458,19 +1488,19 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
{
- Repository: &github.Repository{Name: github.Ptr("repo1"), ID: github.Ptr(int64(1))},
- Status: github.Ptr("attached"),
+ Repository: &github.Repository{Name: new("repo1"), ID: new(int64(1))},
+ Status: new("attached"),
},
{
- Repository: &github.Repository{Name: github.Ptr("repo2"), ID: github.Ptr(int64(2))},
- Status: github.Ptr("attached"),
+ Repository: &github.Repository{Name: new("repo2"), ID: new(int64(2))},
+ Status: new("attached"),
},
}, nil
}
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
}, nil
}
@@ -1491,15 +1521,15 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
{
- Repository: &github.Repository{Name: github.Ptr("repo1"), ID: github.Ptr(int64(1))},
- Status: github.Ptr("attached"),
+ Repository: &github.Repository{Name: new("repo1"), ID: new(int64(1))},
+ Status: new("attached"),
},
}, nil
}
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
}, nil
}
@@ -1522,8 +1552,8 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() {
}
mockClient.GetOrgRepositoriesFunc = func(ctx context.Context, org string) ([]*github.Repository, error) {
return []*github.Repository{
- {ID: github.Ptr(int64(1)), Name: github.Ptr("repo1"), Visibility: github.Ptr("public")},
- {ID: github.Ptr(int64(2)), Name: github.Ptr("repo2"), Visibility: github.Ptr("private")},
+ {ID: new(int64(1)), Name: new("repo1"), Visibility: new("public")},
+ {ID: new(int64(2)), Name: new("repo2"), Visibility: new("private")},
}, nil
}
@@ -1553,7 +1583,7 @@ var _ = Describe("AttachCSC - Comprehensive Scenarios", func() {
},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
}
@@ -1636,8 +1666,8 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return attachments", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("attached")},
- {Repository: &github.Repository{Name: github.Ptr("repo2")}, Status: github.Ptr("attached")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("attached")},
+ {Repository: &github.Repository{Name: new("repo2")}, Status: new("attached")},
}, nil
}
@@ -1651,7 +1681,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return attachments", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("enforced")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("enforced")},
}, nil
}
@@ -1665,7 +1695,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return attachments", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("removed_by_enterprise")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("removed_by_enterprise")},
}, nil
}
@@ -1679,8 +1709,8 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return nil without error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("attached")},
- {Repository: &github.Repository{Name: github.Ptr("repo2")}, Status: github.Ptr("attaching")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("attached")},
+ {Repository: &github.Repository{Name: new("repo2")}, Status: new("attaching")},
}, nil
}
@@ -1694,7 +1724,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return nil without error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("updating")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("updating")},
}, nil
}
@@ -1708,7 +1738,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return nil without error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("failed")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("failed")},
}, nil
}
@@ -1722,7 +1752,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("failed")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("failed")},
}, nil
}
@@ -1738,7 +1768,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return nil without error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("detached")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("detached")},
}, nil
}
@@ -1752,7 +1782,7 @@ var _ = Describe("GetAttachmentsIfAllAttached", func() {
It("should return nil without error", func() {
mockClient.GetRepositoriesAttachedToCodeSecurityConfigurationFunc = func(ctx context.Context, org string, cscID int64) ([]*github.RepositoryAttachment, error) {
return []*github.RepositoryAttachment{
- {Repository: &github.Repository{Name: github.Ptr("repo1")}, Status: github.Ptr("removed")},
+ {Repository: &github.Repository{Name: new("repo1")}, Status: new("removed")},
}, nil
}
@@ -1782,11 +1812,11 @@ var _ = Describe("ByName", func() {
configs := []*github.CodeSecurityConfiguration{
{
Name: "org-config",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
{
Name: "enterprise-config",
- TargetType: github.Ptr("enterprise"),
+ TargetType: new("enterprise"),
},
}
@@ -1806,15 +1836,15 @@ var _ = Describe("ByName", func() {
configs := []*github.CodeSecurityConfiguration{
{
Name: "org-config-1",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
{
Name: "enterprise-config",
- TargetType: github.Ptr("enterprise"),
+ TargetType: new("enterprise"),
},
{
Name: "org-config-excluded",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}
@@ -1853,15 +1883,15 @@ var _ = Describe("ByName", func() {
configs := []*github.CodeSecurityConfiguration{
{
Name: "org-config-1",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
{
Name: "enterprise-config",
- TargetType: github.Ptr("enterprise"),
+ TargetType: new("enterprise"),
},
{
Name: "org-config-excluded",
- TargetType: github.Ptr(targetTypeOrganization),
+ TargetType: new(targetTypeOrganization),
},
}
diff --git a/internal/reconciler/orgrec/rec_custom_properties.go b/internal/reconciler/orgrec/rec_custom_properties.go
index 19edffb..6f8d116 100644
--- a/internal/reconciler/orgrec/rec_custom_properties.go
+++ b/internal/reconciler/orgrec/rec_custom_properties.go
@@ -22,7 +22,7 @@ func (o *GitHubOrgReconciler) reconcileCustomProperties(ctx context.Context) err
hasNewOrUpdatedProps := false
for _, desired := range desiredOrgCustomProps {
if desired.Required == nil {
- desired.Required = github.Ptr(false)
+ desired.Required = new(false)
}
desiredGhRep := mapper.ToGitHubCustomProperty(desired)
// always add to apply list, we will only apply if update is needed
diff --git a/internal/reconciler/orgrec/rec_custom_properties_test.go b/internal/reconciler/orgrec/rec_custom_properties_test.go
index fc0eb16..09d9270 100644
--- a/internal/reconciler/orgrec/rec_custom_properties_test.go
+++ b/internal/reconciler/orgrec/rec_custom_properties_test.go
@@ -121,9 +121,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("dev")},
- Description: github.Ptr("Environment type"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("dev")},
+ Description: new("Environment type"),
AllowedValues: []string{"dev", "staging", "prod"},
ValuesEditableBy: "org_actors",
},
@@ -148,15 +148,15 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "team",
ValueType: "string",
- Required: github.Ptr(false),
- Description: github.Ptr("Team name"),
+ Required: new(false),
+ Description: new("Team name"),
ValuesEditableBy: "org_and_repo_actors",
},
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("dev")},
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("dev")},
AllowedValues: []string{"dev", "staging", "prod"},
ValuesEditableBy: "org_actors",
},
@@ -185,13 +185,13 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: github.PropertyValueTypeSingleSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "dev",
- Description: github.Ptr("Old description"),
+ Description: new("Old description"),
AllowedValues: []string{"dev", "prod"},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -202,9 +202,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("staging")},
- Description: github.Ptr("Updated environment description"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("staging")},
+ Description: new("Updated environment description"),
AllowedValues: []string{"dev", "staging", "prod"},
ValuesEditableBy: "org_actors",
},
@@ -225,13 +225,13 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: github.PropertyValueTypeSingleSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "dev",
- Description: github.Ptr("Environment type"),
+ Description: new("Environment type"),
AllowedValues: []string{"dev", "staging", "prod"},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -241,9 +241,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("dev")},
- Description: github.Ptr("Environment type"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("dev")},
+ Description: new("Environment type"),
AllowedValues: []string{"dev", "staging", "prod"},
ValuesEditableBy: "org_actors",
},
@@ -263,19 +263,19 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: github.PropertyValueTypeSingleSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "dev",
AllowedValues: []string{"dev", "prod"},
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("team"),
+ PropertyName: new("team"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
- ValuesEditableBy: github.Ptr("org_actors"),
+ Required: new(false),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -286,8 +286,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("dev")},
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("dev")},
AllowedValues: []string{"dev", "prod"},
ValuesEditableBy: "org_actors",
},
@@ -308,9 +308,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "tags",
ValueType: "multi_select",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Values: []string{"backend", "api"}},
- Description: github.Ptr("Repository tags"),
+ Description: new("Repository tags"),
AllowedValues: []string{"frontend", "backend", "api", "database"},
ValuesEditableBy: "org_actors",
},
@@ -337,9 +337,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "is_production",
ValueType: "true_false",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("false")},
- Description: github.Ptr("Is production repository"),
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("false")},
+ Description: new("Is production repository"),
ValuesEditableBy: "org_actors",
},
}
@@ -364,8 +364,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "optional_tag",
ValueType: "string",
- Required: github.Ptr(false),
- Description: github.Ptr("Optional tag"),
+ Required: new(false),
+ Description: new("Optional tag"),
ValuesEditableBy: "org_and_repo_actors",
},
}
@@ -439,10 +439,10 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("broken"),
+ PropertyName: new("broken"),
ValueType: github.PropertyValueTypeMultiSelect,
DefaultValue: "not-a-slice", // Invalid type for multi_select
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -471,17 +471,17 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("org_property"),
+ PropertyName: new("org_property"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false), // Must match default
- ValuesEditableBy: github.Ptr("org_actors"),
+ Required: new(false), // Must match default
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("repo_property"),
+ PropertyName: new("repo_property"),
ValueType: github.PropertyValueTypeString,
- ValuesEditableBy: github.Ptr("org_actors"),
- SourceType: github.Ptr("repository"), // This should be filtered out
+ ValuesEditableBy: new("org_actors"),
+ SourceType: new("repository"), // This should be filtered out
},
}, nil
}
@@ -490,7 +490,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "org_property",
ValueType: "string",
- Required: github.Ptr(false), // Must be explicit
+ Required: new(false), // Must be explicit
ValuesEditableBy: "org_actors",
},
}
@@ -508,12 +508,12 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: github.PropertyValueTypeSingleSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "dev",
AllowedValues: []string{"prod", "dev", "staging"}, // Different order
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -523,8 +523,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "environment",
ValueType: "single_select",
- Required: github.Ptr(true),
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("dev")},
+ Required: new(true),
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("dev")},
AllowedValues: []string{"dev", "staging", "prod"}, // Different order
ValuesEditableBy: "org_actors",
},
@@ -543,9 +543,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("team"),
+ PropertyName: new("team"),
ValueType: github.PropertyValueTypeString,
- ValuesEditableBy: github.Ptr("org_actors"),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -572,10 +572,10 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("team"),
+ PropertyName: new("team"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
- ValuesEditableBy: github.Ptr("org_actors"),
+ Required: new(false),
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -585,8 +585,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
{
PropertyName: "team",
ValueType: "string",
- Required: github.Ptr(true), // Changed to required
- DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("default-team")},
+ Required: new(true), // Changed to required
+ DefaultValue: &v1alpha1.OrgCustomPropertyDefaultValue{Value: new("default-team")},
ValuesEditableBy: "org_actors",
},
}
@@ -630,10 +630,10 @@ var _ = Describe("ReconcileCustomProperties", func() {
getCurrentProps = func(_ context.Context, _ string) ([]*github.CustomProperty, error) {
return []*github.CustomProperty{
{
- PropertyName: github.Ptr("existing_property"),
+ PropertyName: new("existing_property"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false), // GitHub has default
- ValuesEditableBy: github.Ptr("org_actors"),
+ Required: new(false), // GitHub has default
+ ValuesEditableBy: new("org_actors"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}, nil
@@ -732,12 +732,12 @@ var _ = Describe("getGitHubOrgCustomPropertiesByPropertyName", func() {
BeforeEach(func() {
allProps = []*github.CustomProperty{
{
- PropertyName: github.Ptr("prop1"),
+ PropertyName: new("prop1"),
ValueType: github.PropertyValueTypeString,
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("prop2"),
+ PropertyName: new("prop2"),
ValueType: github.PropertyValueTypeString,
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
@@ -756,14 +756,14 @@ var _ = Describe("getGitHubOrgCustomPropertiesByPropertyName", func() {
BeforeEach(func() {
allProps = []*github.CustomProperty{
{
- PropertyName: github.Ptr("org_prop"),
+ PropertyName: new("org_prop"),
ValueType: github.PropertyValueTypeString,
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("repo_prop"),
+ PropertyName: new("repo_prop"),
ValueType: github.PropertyValueTypeString,
- SourceType: github.Ptr("repository"),
+ SourceType: new("repository"),
},
}
})
@@ -780,12 +780,12 @@ var _ = Describe("getGitHubOrgCustomPropertiesByPropertyName", func() {
BeforeEach(func() {
allProps = []*github.CustomProperty{
{
- PropertyName: github.Ptr(""),
+ PropertyName: new(""),
ValueType: github.PropertyValueTypeString,
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("valid_prop"),
+ PropertyName: new("valid_prop"),
ValueType: github.PropertyValueTypeString,
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
@@ -835,11 +835,11 @@ var _ = Describe("retainOnlyOrgProperties", func() {
It("should return all properties", func() {
input := []*github.CustomProperty{
{
- PropertyName: github.Ptr("prop1"),
+ PropertyName: new("prop1"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("prop2"),
+ PropertyName: new("prop2"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}
@@ -852,12 +852,12 @@ var _ = Describe("retainOnlyOrgProperties", func() {
It("should return empty slice", func() {
input := []*github.CustomProperty{
{
- PropertyName: github.Ptr("prop1"),
- SourceType: github.Ptr("repository"),
+ PropertyName: new("prop1"),
+ SourceType: new("repository"),
},
{
- PropertyName: github.Ptr("prop2"),
- SourceType: github.Ptr("repository"),
+ PropertyName: new("prop2"),
+ SourceType: new("repository"),
},
}
result := retainOnlyOrgProperties(input)
@@ -869,15 +869,15 @@ var _ = Describe("retainOnlyOrgProperties", func() {
It("should only return organization-sourced properties", func() {
input := []*github.CustomProperty{
{
- PropertyName: github.Ptr("org1"),
+ PropertyName: new("org1"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("repo1"),
- SourceType: github.Ptr("repository"),
+ PropertyName: new("repo1"),
+ SourceType: new("repository"),
},
{
- PropertyName: github.Ptr("org2"),
+ PropertyName: new("org2"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
}
@@ -892,11 +892,11 @@ var _ = Describe("retainOnlyOrgProperties", func() {
It("should not include properties with nil source type", func() {
input := []*github.CustomProperty{
{
- PropertyName: github.Ptr("org1"),
+ PropertyName: new("org1"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("unknown"),
+ PropertyName: new("unknown"),
SourceType: nil,
},
}
@@ -910,12 +910,12 @@ var _ = Describe("retainOnlyOrgProperties", func() {
It("should not include properties with unexpected source type", func() {
input := []*github.CustomProperty{
{
- PropertyName: github.Ptr("org1"),
+ PropertyName: new("org1"),
SourceType: github.Ptr(mapper.CustomPropertySourceTypeOrganization),
},
{
- PropertyName: github.Ptr("unknown"),
- SourceType: github.Ptr("unknown_source"),
+ PropertyName: new("unknown"),
+ SourceType: new("unknown_source"),
},
}
result := retainOnlyOrgProperties(input)
diff --git a/internal/reconciler/orgrec/rec_org_test.go b/internal/reconciler/orgrec/rec_org_test.go
index 396b8c0..f529f75 100644
--- a/internal/reconciler/orgrec/rec_org_test.go
+++ b/internal/reconciler/orgrec/rec_org_test.go
@@ -57,9 +57,9 @@ var _ = Describe("ReconcileOrganization", func() {
// Default: current GitHub org matches desired state
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -105,9 +105,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when organization name differs", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -122,9 +122,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when organization description differs", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Old Description"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Old Description"),
+ Login: new("test-org"),
}
})
@@ -139,9 +139,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when both name and description differ", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Old Description"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Old Description"),
+ Login: new("test-org"),
}
})
@@ -158,9 +158,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Description = ""
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Old Description"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Old Description"),
+ Login: new("test-org"),
}
})
@@ -175,9 +175,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when current description is empty and desired is not", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr(""),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new(""),
+ Login: new("test-org"),
}
org.Spec.Description = "New Description"
})
@@ -253,9 +253,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
editErr = errors.New("GitHub API error during update")
})
@@ -279,9 +279,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when EditOrganization returns 403 Forbidden", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -308,9 +308,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when EditOrganization returns 422 Unprocessable Entity", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -338,9 +338,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Description = "Test & Special \"quotes\" 'apostrophes' 日本語"
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Old Description"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Old Description"),
+ Login: new("test-org"),
}
})
@@ -360,9 +360,9 @@ var _ = Describe("ReconcileOrganization", func() {
}
org.Spec.Description = longDesc.String()
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Short"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Short"),
+ Login: new("test-org"),
}
})
@@ -378,9 +378,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Description = "Line 1\nLine 2\nLine 3"
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Old Description"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Old Description"),
+ Login: new("test-org"),
}
})
@@ -408,9 +408,9 @@ var _ = Describe("ReconcileOrganization", func() {
// Update the mock to return the already-updated org
mockClient.GetOrganizationFunc = func(ctx context.Context, orgName string) (*github.Organization, error) {
return &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}, nil
}
@@ -421,9 +421,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
// Start with different state
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -442,9 +442,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Description = "Test Organization"
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -459,9 +459,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Description = " Test Organization "
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
})
@@ -475,9 +475,9 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when EditOrganization succeeds but returns nil", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
}
mockClient.EditOrganizationFunc = func(ctx context.Context, orgName string, organization *github.Organization) (*github.Organization, error) {
@@ -496,9 +496,9 @@ var _ = Describe("ReconcileOrganization", func() {
BeforeEach(func() {
org.Spec.Name = "actual-org-name"
currentGHOrg = &github.Organization{
- Name: github.Ptr("old-name"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("actual-org-name"),
+ Name: new("old-name"),
+ Description: new("Test Organization"),
+ Login: new("actual-org-name"),
}
})
@@ -512,14 +512,14 @@ var _ = Describe("ReconcileOrganization", func() {
Context("when GitHub organization has additional fields not in spec", func() {
BeforeEach(func() {
currentGHOrg = &github.Organization{
- Name: github.Ptr("test-org"),
- Description: github.Ptr("Test Organization"),
- Login: github.Ptr("test-org"),
+ Name: new("test-org"),
+ Description: new("Test Organization"),
+ Login: new("test-org"),
// Additional fields that aren't in our spec
- Company: github.Ptr("Test Company"),
- Blog: github.Ptr("https://example.com"),
- Location: github.Ptr("Test Location"),
- Email: github.Ptr("test@example.com"),
+ Company: new("Test Company"),
+ Blog: new("https://example.com"),
+ Location: new("Test Location"),
+ Email: new("test@example.com"),
}
})
diff --git a/internal/reconciler/orgrec/rec_rulesets.go b/internal/reconciler/orgrec/rec_rulesets.go
index 97bf43d..a65ed2b 100644
--- a/internal/reconciler/orgrec/rec_rulesets.go
+++ b/internal/reconciler/orgrec/rec_rulesets.go
@@ -15,6 +15,12 @@ import (
func (o *GitHubOrgReconciler) reconcileRulesetPresets(ctx context.Context) error {
log := logPkg.FromContext(ctx)
+ // Org rulesets are not supported on the free plan
+ if !o.Kubernetes.Resource.HasEnterpriseFeatures() {
+ log.V(1).Info("Skipping organization rulesets reconciliation for non-public repository on free plan")
+ return nil
+ }
+
existingRulesets, err := o.GitHub.Client.GetAllOrganizationRulesets(ctx, o.GitHub.Resource, false)
if err != nil {
log.Error(err, "failed to get existing organization rulesets")
@@ -148,7 +154,7 @@ func addDefaultOrgRepositoryConditions(conditions *v1alpha1.RulesetConditions) *
conditions.RepositoryName = &v1alpha1.RepositoryNameCondition{
Include: []string{"~ALL"},
Exclude: []string{},
- Protected: github.Ptr(false),
+ Protected: new(false),
}
}
return conditions
diff --git a/internal/reconciler/orgrec/rec_rulesets_test.go b/internal/reconciler/orgrec/rec_rulesets_test.go
index 66802d9..c156dee 100644
--- a/internal/reconciler/orgrec/rec_rulesets_test.go
+++ b/internal/reconciler/orgrec/rec_rulesets_test.go
@@ -69,8 +69,8 @@ var _ = Describe("ReconcileRulesetPresets", func() {
Target: "branch",
Enforcement: "active",
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
- Deletion: github.Ptr(true),
+ Creation: new(true),
+ Deletion: new(true),
},
},
}
@@ -88,7 +88,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
Target: "branch",
Enforcement: "active",
Rules: v1alpha1.RulesetRules{
- Update: github.Ptr(true),
+ Update: new(true),
},
},
}
@@ -157,6 +157,26 @@ var _ = Describe("ReconcileRulesetPresets", func() {
err = rec.reconcileRulesetPresets(ctx)
})
+ Context("when plan is 'free'", func() {
+ BeforeEach(func() {
+ org.Spec.Plan = "free"
+ org.Spec.RulesetPresetList = []corev1.LocalObjectReference{
+ {Name: "ruleset-1"},
+ }
+ })
+
+ It("should skip reconciliation and return no error", func() {
+ Expect(err).NotTo(HaveOccurred())
+ })
+
+ It("should not create, update, or delete any rulesets", func() {
+ Expect(err).NotTo(HaveOccurred())
+ Expect(createdRulesets).To(BeEmpty())
+ Expect(updatedRulesets).To(BeEmpty())
+ Expect(deletedRulesetIDs).To(BeEmpty())
+ })
+ })
+
Context("when no rulesets are configured", func() {
It("should reconcile successfully with no changes", func() {
Expect(err).NotTo(HaveOccurred())
@@ -219,7 +239,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
// Existing ruleset with different configuration
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("evaluate"), // Different enforcement
Target: github.Ptr(github.RulesetTargetBranch),
@@ -261,7 +281,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
// Existing ruleset that matches desired state (including default ~ALL repository name condition)
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -273,7 +293,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
RepositoryName: &github.RepositoryRulesetRepositoryNamesConditionParameters{
Include: []string{"~ALL"},
Exclude: []string{},
- Protected: github.Ptr(false),
+ Protected: new(false),
},
},
Rules: &github.RepositoryRulesetRules{
@@ -301,7 +321,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
// Two existing rulesets, but only one is referenced
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -317,7 +337,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
},
},
{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
Name: "orphaned-ruleset",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -375,7 +395,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("evaluate"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -426,7 +446,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("evaluate"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -460,7 +480,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "orphaned-ruleset",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -542,7 +562,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "", // Empty name
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -584,7 +604,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
BeforeEach(func() {
rulesetPreset1.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorID: github.Ptr(int64(12345)),
+ ActorID: new(int64(12345)),
ActorType: "Team",
BypassMode: "always",
},
@@ -644,7 +664,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
RepositoryName: &v1alpha1.RepositoryNameCondition{
Include: []string{"backend-*", "frontend-*"},
Exclude: []string{"backend-legacy"},
- Protected: github.Ptr(true),
+ Protected: new(true),
},
}
@@ -660,7 +680,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
Expect(createdRulesets[0].Conditions.RepositoryName).NotTo(BeNil())
Expect(createdRulesets[0].Conditions.RepositoryName.Include).To(ConsistOf("backend-*", "frontend-*"))
Expect(createdRulesets[0].Conditions.RepositoryName.Exclude).To(ConsistOf("backend-legacy"))
- Expect(createdRulesets[0].Conditions.RepositoryName.Protected).To(Equal(github.Ptr(true)))
+ Expect(createdRulesets[0].Conditions.RepositoryName.Protected).To(Equal(new(true)))
})
It("should not override with default ~ALL repository name condition", func() {
@@ -772,7 +792,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -822,7 +842,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -888,7 +908,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(100)),
+ ID: new(int64(100)),
Name: "ruleset-1",
Enforcement: github.RulesetEnforcement("evaluate"),
Target: github.Ptr(github.RulesetTargetBranch),
@@ -931,7 +951,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
// Ruleset-2 already exists but needs update
existingRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(200)),
+ ID: new(int64(200)),
Name: "ruleset-2",
Enforcement: github.RulesetEnforcement("evaluate"), // Different
Target: github.Ptr(github.RulesetTargetBranch),
@@ -944,7 +964,7 @@ var _ = Describe("ReconcileRulesetPresets", func() {
Rules: &github.RepositoryRulesetRules{},
},
{
- ID: github.Ptr(int64(300)),
+ ID: new(int64(300)),
Name: "orphaned-ruleset", // Will be deleted
Enforcement: github.RulesetEnforcement("active"),
Target: github.Ptr(github.RulesetTargetBranch),
diff --git a/internal/reconciler/orgrec/reconciler_test.go b/internal/reconciler/orgrec/reconciler_test.go
index e910255..794c3dd 100644
--- a/internal/reconciler/orgrec/reconciler_test.go
+++ b/internal/reconciler/orgrec/reconciler_test.go
@@ -538,3 +538,39 @@ var _ = Describe("ReconcileDeletion", func() {
})
})
})
+
+var _ = Describe("RequiredReconciliations", func() {
+ var (
+ rec *GitHubOrgReconciler
+ org *v1alpha1.Organization
+ )
+
+ BeforeEach(func() {
+ org = &v1alpha1.Organization{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "test-org",
+ Namespace: "default",
+ },
+ Spec: v1alpha1.OrganizationSpec{
+ Name: "test-org",
+ Description: "Test Organization",
+ GitHubAppInstallationId: 12345,
+ },
+ }
+ })
+
+ JustBeforeEach(func() {
+ rec = &GitHubOrgReconciler{
+ Kubernetes: reconciler.Kubernetes[*v1alpha1.Organization]{
+ Resource: org,
+ },
+ }
+ })
+
+ It("should return all reconcilers in a single parallel group regardless of plan", func() {
+ groups := rec.RequiredReconciliations()
+ Expect(groups).To(HaveLen(1))
+ // All reconcilers run in parallel; plan-based checks are handled within each reconciler
+ Expect(groups[0]).To(HaveLen(5))
+ })
+})
diff --git a/internal/reconciler/reconcilerfactory/factory_test.go b/internal/reconciler/reconcilerfactory/factory_test.go
index 8560897..6f64e7c 100644
--- a/internal/reconciler/reconcilerfactory/factory_test.go
+++ b/internal/reconciler/reconcilerfactory/factory_test.go
@@ -435,7 +435,7 @@ var _ = Describe("Factory", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: stringPtr("test-team"),
+ Slug: new("test-team"),
},
}
@@ -1859,8 +1859,3 @@ func (m *mockGitHubClientManager) GetGitHubClientAndCheckRateLimit(_ context.Con
return m.client, nil
}
-
-// stringPtr returns a pointer to a string
-func stringPtr(s string) *string {
- return &s
-}
diff --git a/internal/reconciler/reporec/rec_actions_settings.go b/internal/reconciler/reporec/rec_actions_settings.go
index d9aa0d0..082027a 100644
--- a/internal/reconciler/reporec/rec_actions_settings.go
+++ b/internal/reconciler/reporec/rec_actions_settings.go
@@ -26,9 +26,13 @@ func (r *GitHubRepoReconciler) reconcileActionsSettings(ctx context.Context) err
return nil
}
- err := r.reconcileActionsAccessLevelForExternalWorkflows(ctx)
- if err != nil {
- return err
+ // Access Level is not supported for public and free repos
+ if org.HasEnterpriseFeatures() && r.Kubernetes.Resource.Spec.Visibility != githubv1alpha1.VisibilityPublic {
+ if err := r.reconcileActionsAccessLevelForExternalWorkflows(ctx); err != nil {
+ return err
+ }
+ } else {
+ log.V(1).Info("Skipping reconciliation of actions access policies on GitHub as repository is either public or belongs to an organization on the free plan")
}
log.V(1).Info("Successfully reconciled repository GitHub actions configurations on GitHub")
@@ -36,6 +40,9 @@ func (r *GitHubRepoReconciler) reconcileActionsSettings(ctx context.Context) err
}
func (r *GitHubRepoReconciler) reconcileActionsAccessLevelForExternalWorkflows(ctx context.Context) error {
+ log := logPkg.FromContext(ctx)
+ log.V(1).Info("Reconciling repository GitHub actions access policies on GitHub")
+
expectedActionsAccessLevel := utils.WithDefaultAsPtr(r.Kubernetes.Resource.Spec.AccessLevelForExternalWorkflows, "none")
currentAccessLevel, err := r.GitHub.Client.GetAccessLevelForExternalWorkflowsForRepo(ctx, r.GitHub.Resource.Owner, r.GitHub.Resource.Name)
if err != nil {
@@ -49,5 +56,7 @@ func (r *GitHubRepoReconciler) reconcileActionsAccessLevelForExternalWorkflows(c
return err
}
}
+
+ log.V(1).Info("Successfully reconciled GitHub actions access policies on GitHub")
return nil
}
diff --git a/internal/reconciler/reporec/rec_actions_settings_test.go b/internal/reconciler/reporec/rec_actions_settings_test.go
index 4ed5095..0dff5d8 100644
--- a/internal/reconciler/reporec/rec_actions_settings_test.go
+++ b/internal/reconciler/reporec/rec_actions_settings_test.go
@@ -44,10 +44,10 @@ var _ = Describe("ReconcileActionsSettings", func() {
Expect(schemeErr).NotTo(HaveOccurred())
// Default values
- accessLevelForExternalWorkflows = github.Ptr("none")
- orgActionsEnabled = github.Ptr("all")
+ accessLevelForExternalWorkflows = new("none")
+ orgActionsEnabled = new("all")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("none"),
+ AccessLevel: new("none"),
}
// Reset flags and errors
@@ -91,14 +91,14 @@ var _ = Describe("ReconcileActionsSettings", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
AccessLevelForExternalWorkflows: accessLevelForExternalWorkflows,
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123456)),
+ ID: new(int64(123456)),
},
}
@@ -114,7 +114,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(123456)),
+ ID: new(int64(123456)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
@@ -128,7 +128,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
Context("when actions are disabled for the organization", func() {
BeforeEach(func() {
- orgActionsEnabled = github.Ptr("none")
+ orgActionsEnabled = new("none")
})
It("should skip reconciliation and not call GitHub API", func() {
@@ -150,26 +150,26 @@ var _ = Describe("ReconcileActionsSettings", func() {
Context("when updating access level for external workflows", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("organization")
- orgActionsEnabled = github.Ptr("all")
+ accessLevelForExternalWorkflows = new("organization")
+ orgActionsEnabled = new("all")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("none"),
+ AccessLevel: new("none"),
}
})
It("should update the access level", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("organization")))
+ Expect(setAccessLevelWithValue).To(Equal(new("organization")))
})
})
Context("when access level is already at desired state", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("user")
- orgActionsEnabled = github.Ptr("all")
+ accessLevelForExternalWorkflows = new("user")
+ orgActionsEnabled = new("all")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("user"),
+ AccessLevel: new("user"),
}
})
@@ -182,82 +182,82 @@ var _ = Describe("ReconcileActionsSettings", func() {
Context("when access level is nil in spec", func() {
BeforeEach(func() {
accessLevelForExternalWorkflows = nil
- orgActionsEnabled = github.Ptr("all")
+ orgActionsEnabled = new("all")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("user"),
+ AccessLevel: new("user"),
}
})
It("should set access level to default 'none'", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("none")))
+ Expect(setAccessLevelWithValue).To(Equal(new("none")))
})
})
Context("access level value variations", func() {
BeforeEach(func() {
- orgActionsEnabled = github.Ptr("all")
+ orgActionsEnabled = new("all")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("none"),
+ AccessLevel: new("none"),
}
})
Context("setting access level to 'none'", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("none")
+ accessLevelForExternalWorkflows = new("none")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("organization"),
+ AccessLevel: new("organization"),
}
})
It("should set access level to none", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("none")))
+ Expect(setAccessLevelWithValue).To(Equal(new("none")))
})
})
Context("setting access level to 'organization'", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("organization")
+ accessLevelForExternalWorkflows = new("organization")
})
It("should set access level to organization", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("organization")))
+ Expect(setAccessLevelWithValue).To(Equal(new("organization")))
})
})
Context("setting access level to 'enterprise'", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("enterprise")
+ accessLevelForExternalWorkflows = new("enterprise")
})
It("should set access level to enterprise", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("enterprise")))
+ Expect(setAccessLevelWithValue).To(Equal(new("enterprise")))
})
})
Context("setting access level to 'user'", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("user")
+ accessLevelForExternalWorkflows = new("user")
})
It("should set access level to user", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("user")))
+ Expect(setAccessLevelWithValue).To(Equal(new("user")))
})
})
})
Context("error handling", func() {
BeforeEach(func() {
- orgActionsEnabled = github.Ptr("all")
+ orgActionsEnabled = new("all")
})
Context("when GetAccessLevelForExternalWorkflowsForRepo fails", func() {
@@ -273,9 +273,9 @@ var _ = Describe("ReconcileActionsSettings", func() {
Context("when SetAccessLevelForExternalWorkflowsForRepo fails", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("organization")
+ accessLevelForExternalWorkflows = new("organization")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
- AccessLevel: github.Ptr("none"),
+ AccessLevel: new("none"),
}
setAccessLevelError = errors.New("API error: failed to set access level")
})
@@ -299,14 +299,14 @@ var _ = Describe("ReconcileActionsSettings", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
- AccessLevelForExternalWorkflows: github.Ptr("none"),
+ Archived: new(false),
+ AccessLevelForExternalWorkflows: new("none"),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
},
Status: v1alpha1.RepositoryStatus{
- ID: github.Ptr(int64(123456)),
+ ID: new(int64(123456)),
},
}
@@ -323,7 +323,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(123456)),
+ ID: new(int64(123456)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
@@ -341,12 +341,12 @@ var _ = Describe("ReconcileActionsSettings", func() {
Context("edge cases", func() {
BeforeEach(func() {
- orgActionsEnabled = github.Ptr("all")
+ orgActionsEnabled = new("all")
})
Context("when current access level is nil", func() {
BeforeEach(func() {
- accessLevelForExternalWorkflows = github.Ptr("organization")
+ accessLevelForExternalWorkflows = new("organization")
currentAccessLevel = &github.RepositoryActionsAccessLevel{
AccessLevel: nil,
}
@@ -355,7 +355,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
It("should update access level", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("organization")))
+ Expect(setAccessLevelWithValue).To(Equal(new("organization")))
})
})
@@ -370,7 +370,7 @@ var _ = Describe("ReconcileActionsSettings", func() {
It("should set default access level 'none'", func() {
Expect(err).NotTo(HaveOccurred())
Expect(setAccessLevelCalled).To(BeTrue())
- Expect(setAccessLevelWithValue).To(Equal(github.Ptr("none")))
+ Expect(setAccessLevelWithValue).To(Equal(new("none")))
})
})
})
diff --git a/internal/reconciler/reporec/rec_autolinks_test.go b/internal/reconciler/reporec/rec_autolinks_test.go
index 3412114..d677b91 100644
--- a/internal/reconciler/reporec/rec_autolinks_test.go
+++ b/internal/reconciler/reporec/rec_autolinks_test.go
@@ -153,15 +153,15 @@ var _ = Describe("ReconcileAutolinks", func() {
}
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("foo"),
- URLTemplate: github.Ptr("https://example.com/foo"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(12345)),
+ KeyPrefix: new("foo"),
+ URLTemplate: new("https://example.com/foo"),
+ IsAlphanumeric: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- KeyPrefix: github.Ptr("bar"),
- URLTemplate: github.Ptr("https://example.com/bar"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(23456)),
+ KeyPrefix: new("bar"),
+ URLTemplate: new("https://example.com/bar"),
+ IsAlphanumeric: new(false),
},
}
})
@@ -228,15 +228,15 @@ var _ = Describe("ReconcileAutolinks", func() {
}
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("fooz"),
- URLTemplate: github.Ptr("https://example.com/fooz"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(12345)),
+ KeyPrefix: new("fooz"),
+ URLTemplate: new("https://example.com/fooz"),
+ IsAlphanumeric: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- KeyPrefix: github.Ptr("bar"),
- URLTemplate: github.Ptr("https://example.com/bar"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(23456)),
+ KeyPrefix: new("bar"),
+ URLTemplate: new("https://example.com/bar"),
+ IsAlphanumeric: new(false),
},
}
})
@@ -259,15 +259,15 @@ var _ = Describe("ReconcileAutolinks", func() {
BeforeEach(func() {
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("fooz"),
- URLTemplate: github.Ptr("https://example.com/fooz"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(12345)),
+ KeyPrefix: new("fooz"),
+ URLTemplate: new("https://example.com/fooz"),
+ IsAlphanumeric: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- KeyPrefix: github.Ptr("bar"),
- URLTemplate: github.Ptr("https://example.com/bar"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(23456)),
+ KeyPrefix: new("bar"),
+ URLTemplate: new("https://example.com/bar"),
+ IsAlphanumeric: new(false),
},
}
})
@@ -327,10 +327,10 @@ var _ = Describe("ReconcileAutolinks", func() {
}
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("fooz"),
- URLTemplate: github.Ptr("https://example.com/fooz"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(12345)),
+ KeyPrefix: new("fooz"),
+ URLTemplate: new("https://example.com/fooz"),
+ IsAlphanumeric: new(false),
},
}
})
@@ -768,16 +768,16 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() {
// JIRA- and GH- already exist in GitHub
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("JIRA-"),
- URLTemplate: github.Ptr("https://jira.example.com/browse/JIRA-"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(12345)),
+ KeyPrefix: new("JIRA-"),
+ URLTemplate: new("https://jira.example.com/browse/JIRA-"),
+ IsAlphanumeric: new(true),
},
{
- ID: github.Ptr(int64(23456)),
- KeyPrefix: github.Ptr("GH-"),
- URLTemplate: github.Ptr("https://github.com/org/repo/issues/"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(23456)),
+ KeyPrefix: new("GH-"),
+ URLTemplate: new("https://github.com/org/repo/issues/"),
+ IsAlphanumeric: new(true),
},
}
@@ -870,28 +870,28 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() {
// GitHub has extra autolinks (OLD- and LEGACY-) that are not in presets
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("JIRA-"),
- URLTemplate: github.Ptr("https://jira.example.com/browse/JIRA-"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(12345)),
+ KeyPrefix: new("JIRA-"),
+ URLTemplate: new("https://jira.example.com/browse/JIRA-"),
+ IsAlphanumeric: new(true),
},
{
- ID: github.Ptr(int64(23456)),
- KeyPrefix: github.Ptr("GH-"),
- URLTemplate: github.Ptr("https://github.com/org/repo/issues/"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(23456)),
+ KeyPrefix: new("GH-"),
+ URLTemplate: new("https://github.com/org/repo/issues/"),
+ IsAlphanumeric: new(true),
},
{
- ID: github.Ptr(int64(34567)),
- KeyPrefix: github.Ptr("OLD-"),
- URLTemplate: github.Ptr("https://old.example.com/"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(34567)),
+ KeyPrefix: new("OLD-"),
+ URLTemplate: new("https://old.example.com/"),
+ IsAlphanumeric: new(true),
},
{
- ID: github.Ptr(int64(45678)),
- KeyPrefix: github.Ptr("LEGACY-"),
- URLTemplate: github.Ptr("https://legacy.example.com/"),
- IsAlphanumeric: github.Ptr(false),
+ ID: new(int64(45678)),
+ KeyPrefix: new("LEGACY-"),
+ URLTemplate: new("https://legacy.example.com/"),
+ IsAlphanumeric: new(false),
},
}
@@ -988,16 +988,16 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() {
// GitHub has: JIRA- (keep), OLD- (remove), and missing: TICKET-, GH-, PR-
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("JIRA-"),
- URLTemplate: github.Ptr("https://jira.example.com/browse/JIRA-"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(12345)),
+ KeyPrefix: new("JIRA-"),
+ URLTemplate: new("https://jira.example.com/browse/JIRA-"),
+ IsAlphanumeric: new(true),
},
{
- ID: github.Ptr(int64(99999)),
- KeyPrefix: github.Ptr("OLD-"),
- URLTemplate: github.Ptr("https://old.example.com/"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(99999)),
+ KeyPrefix: new("OLD-"),
+ URLTemplate: new("https://old.example.com/"),
+ IsAlphanumeric: new(true),
},
}
@@ -1236,10 +1236,10 @@ var _ = Describe("ReconcileAutolinks with Multiple Presets", func() {
currentAutolinks = []*github.Autolink{
{
- ID: github.Ptr(int64(12345)),
- KeyPrefix: github.Ptr("OLD-"),
- URLTemplate: github.Ptr("https://old.example.com/"),
- IsAlphanumeric: github.Ptr(true),
+ ID: new(int64(12345)),
+ KeyPrefix: new("OLD-"),
+ URLTemplate: new("https://old.example.com/"),
+ IsAlphanumeric: new(true),
},
}
diff --git a/internal/reconciler/reporec/rec_custom_properties_test.go b/internal/reconciler/reporec/rec_custom_properties_test.go
index e9d5ef9..f79b295 100644
--- a/internal/reconciler/reporec/rec_custom_properties_test.go
+++ b/internal/reconciler/reporec/rec_custom_properties_test.go
@@ -63,29 +63,29 @@ var _ = Describe("ReconcileCustomProperties", func() {
// Default property definitions - these define what properties exist in the organization
propertyDefinitions = []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: "single_select",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "development",
- Description: github.Ptr("Environment type"),
+ Description: new("Environment type"),
AllowedValues: []string{"development", "staging", "production"},
},
{
- PropertyName: github.Ptr("team"),
+ PropertyName: new("team"),
ValueType: "string",
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "default-team",
},
{
- PropertyName: github.Ptr("languages"),
+ PropertyName: new("languages"),
ValueType: "multi_select",
- Required: github.Ptr(false),
+ Required: new(false),
AllowedValues: []string{"go", "typescript", "python", "java"},
},
{
- PropertyName: github.Ptr("archived"),
+ PropertyName: new("archived"),
ValueType: "true_false",
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "false",
},
}
@@ -124,7 +124,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
CustomProperties: customProperties,
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
@@ -175,8 +175,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when custom properties match current values", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
- {PropertyName: "team", Value: github.Ptr("platform")},
+ {PropertyName: "environment", Value: new("production")},
+ {PropertyName: "team", Value: new("platform")},
}
// GitHub doesn't return properties with nil values
currentPropertyValues = []*github.CustomPropertyValue{
@@ -194,8 +194,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when creating new custom property values", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("staging")},
- {PropertyName: "team", Value: github.Ptr("backend")},
+ {PropertyName: "environment", Value: new("staging")},
+ {PropertyName: "team", Value: new("backend")},
}
currentPropertyValues = []*github.CustomPropertyValue{}
})
@@ -221,12 +221,12 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when updating existing custom property values", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
- {PropertyName: "team", Value: github.Ptr("frontend")},
+ {PropertyName: "environment", Value: new("production")},
+ {PropertyName: "team", Value: new("frontend")},
}
currentPropertyValues = []*github.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("development")},
- {PropertyName: "team", Value: github.Ptr("backend")},
+ {PropertyName: "environment", Value: new("development")},
+ {PropertyName: "team", Value: new("backend")},
}
})
@@ -338,7 +338,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when some properties remain and some are removed", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
currentPropertyValues = []*github.CustomPropertyValue{
{PropertyName: "environment", Value: "development"},
@@ -368,7 +368,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when using true_false value type", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "archived", Value: github.Ptr("true")},
+ {PropertyName: "archived", Value: new("true")},
}
currentPropertyValues = []*github.CustomPropertyValue{}
})
@@ -396,8 +396,8 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
// Spec has properties in reverse order
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "team", Value: github.Ptr("backend")},
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "team", Value: new("backend")},
+ {PropertyName: "environment", Value: new("production")},
}
// Current has properties in different order (GitHub doesn't return properties with nil values)
currentPropertyValues = []*github.CustomPropertyValue{
@@ -416,7 +416,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
getCurrentValuesError = errors.New("failed to fetch custom property values")
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
})
@@ -431,7 +431,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
getDefinitionsError = errors.New("failed to fetch custom property definitions")
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
})
@@ -446,7 +446,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
// Set up a property that doesn't exist in definitions
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "nonexistent-property", Value: github.Ptr("value")},
+ {PropertyName: "nonexistent-property", Value: new("value")},
}
})
@@ -463,7 +463,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
updatePropertiesError = errors.New("failed to update custom properties")
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
currentPropertyValues = []*github.CustomPropertyValue{
{PropertyName: "environment", Value: "development"},
@@ -480,10 +480,10 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when updating with multiple property types", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
- {PropertyName: "team", Value: github.Ptr("platform")},
+ {PropertyName: "environment", Value: new("production")},
+ {PropertyName: "team", Value: new("platform")},
{PropertyName: "languages", Values: []string{"go", "typescript"}},
- {PropertyName: "archived", Value: github.Ptr("false")},
+ {PropertyName: "archived", Value: new("false")},
}
currentPropertyValues = []*github.CustomPropertyValue{}
})
@@ -510,14 +510,14 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
// Update some, keep some, remove some
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("staging")}, // updated
- {PropertyName: "team", Value: github.Ptr("backend")}, // kept same
+ {PropertyName: "environment", Value: new("staging")}, // updated
+ {PropertyName: "team", Value: new("backend")}, // kept same
// languages removed
- {PropertyName: "archived", Value: github.Ptr("true")}, // added
+ {PropertyName: "archived", Value: new("true")}, // added
}
currentPropertyValues = []*github.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("development")},
- {PropertyName: "team", Value: github.Ptr("backend")},
+ {PropertyName: "environment", Value: new("development")},
+ {PropertyName: "team", Value: new("backend")},
{PropertyName: "languages", Value: []string{"go"}},
}
})
@@ -543,7 +543,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
Context("when current values have extra properties not in spec", func() {
BeforeEach(func() {
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
currentPropertyValues = []*github.CustomPropertyValue{
{PropertyName: "environment", Value: "production"},
@@ -607,7 +607,7 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
propertyDefinitions = []*github.CustomProperty{}
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "environment", Value: github.Ptr("production")},
+ {PropertyName: "environment", Value: new("production")},
}
})
@@ -642,15 +642,15 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
propertyDefinitions = []*github.CustomProperty{
{
- PropertyName: github.Ptr("environment"),
+ PropertyName: new("environment"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "production",
},
{
- PropertyName: github.Ptr("team"),
+ PropertyName: new("team"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
},
}
customProperties = []v1alpha1.CustomPropertyValue{}
@@ -684,9 +684,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
propertyDefinitions = []*github.CustomProperty{
{
- PropertyName: github.Ptr("optional-prop"),
+ PropertyName: new("optional-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "default-value",
},
}
@@ -709,25 +709,25 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
propertyDefinitions = []*github.CustomProperty{
{
- PropertyName: github.Ptr("required-prop"),
+ PropertyName: new("required-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: "required-default",
},
{
- PropertyName: github.Ptr("optional-prop"),
+ PropertyName: new("optional-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
DefaultValue: "optional-default",
},
{
- PropertyName: github.Ptr("user-prop"),
+ PropertyName: new("user-prop"),
ValueType: github.PropertyValueTypeString,
- Required: github.Ptr(false),
+ Required: new(false),
},
}
customProperties = []v1alpha1.CustomPropertyValue{
- {PropertyName: "user-prop", Value: github.Ptr("user-value")},
+ {PropertyName: "user-prop", Value: new("user-value")},
}
currentPropertyValues = []*github.CustomPropertyValue{}
})
@@ -752,9 +752,9 @@ var _ = Describe("ReconcileCustomProperties", func() {
BeforeEach(func() {
propertyDefinitions = []*github.CustomProperty{
{
- PropertyName: github.Ptr("tags"),
+ PropertyName: new("tags"),
ValueType: github.PropertyValueTypeMultiSelect,
- Required: github.Ptr(true),
+ Required: new(true),
DefaultValue: []any{"default-tag1", "default-tag2"},
},
}
diff --git a/internal/reconciler/reporec/rec_deploykeys_test.go b/internal/reconciler/reporec/rec_deploykeys_test.go
index 22eb68e..ba35240 100644
--- a/internal/reconciler/reporec/rec_deploykeys_test.go
+++ b/internal/reconciler/reporec/rec_deploykeys_test.go
@@ -129,24 +129,24 @@ var _ = Describe("ReconcileDeployKeys", func() {
{
Title: "foo",
Key: "random-foo-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
}, {
Title: "bar",
Key: "random-bar-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
},
}
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("foo"),
- Key: github.Ptr("random-foo-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(12345)),
+ Title: new("foo"),
+ Key: new("random-foo-key"),
+ ReadOnly: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- Title: github.Ptr("bar"),
- Key: github.Ptr("random-bar-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(23456)),
+ Title: new("bar"),
+ Key: new("random-bar-key"),
+ ReadOnly: new(false),
},
}
})
@@ -164,11 +164,11 @@ var _ = Describe("ReconcileDeployKeys", func() {
{
Title: "foo",
Key: "random-foo-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
}, {
Title: "bar",
Key: "random-bar-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
},
}
currentDeployKeys = []*github.Key{}
@@ -181,14 +181,14 @@ var _ = Describe("ReconcileDeployKeys", func() {
Expect(appliedDeployKeys).To(HaveLen(2))
Expect(appliedDeployKeys).To(ConsistOf(
And(
- HaveField("Title", Equal(github.Ptr("foo"))),
- HaveField("Key", Equal(github.Ptr("random-foo-key"))),
- HaveField("ReadOnly", Equal(github.Ptr(false))),
+ HaveField("Title", Equal(new("foo"))),
+ HaveField("Key", Equal(new("random-foo-key"))),
+ HaveField("ReadOnly", Equal(new(false))),
),
And(
- HaveField("Title", Equal(github.Ptr("bar"))),
- HaveField("Key", Equal(github.Ptr("random-bar-key"))),
- HaveField("ReadOnly", Equal(github.Ptr(false))),
+ HaveField("Title", Equal(new("bar"))),
+ HaveField("Key", Equal(new("random-bar-key"))),
+ HaveField("ReadOnly", Equal(new(false))),
),
))
})
@@ -200,24 +200,24 @@ var _ = Describe("ReconcileDeployKeys", func() {
{
Title: "foo",
Key: "random-foo-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
}, {
Title: "bar",
Key: "random-bar-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
},
}
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("fooz"),
- Key: github.Ptr("random-fooz-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(12345)),
+ Title: new("fooz"),
+ Key: new("random-fooz-key"),
+ ReadOnly: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- Title: github.Ptr("bar"),
- Key: github.Ptr("random-bar-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(23456)),
+ Title: new("bar"),
+ Key: new("random-bar-key"),
+ ReadOnly: new(false),
},
}
})
@@ -240,15 +240,15 @@ var _ = Describe("ReconcileDeployKeys", func() {
BeforeEach(func() {
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("fooz"),
- Key: github.Ptr("random-fooz-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(12345)),
+ Title: new("fooz"),
+ Key: new("random-fooz-key"),
+ ReadOnly: new(false),
}, {
- ID: github.Ptr(int64(23456)),
- Title: github.Ptr("bar"),
- Key: github.Ptr("random-bar-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(23456)),
+ Title: new("bar"),
+ Key: new("random-bar-key"),
+ ReadOnly: new(false),
},
}
})
@@ -284,11 +284,11 @@ var _ = Describe("ReconcileDeployKeys", func() {
{
Title: "foo",
Key: "random-foo-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
}, {
Title: "bar",
Key: "random-bar-key",
- ReadOnly: github.Ptr(false),
+ ReadOnly: new(false),
},
}
currentDeployKeys = []*github.Key{}
@@ -308,10 +308,10 @@ var _ = Describe("ReconcileDeployKeys", func() {
}
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("fooz"),
- Key: github.Ptr("random-fooz-key"),
- ReadOnly: github.Ptr(false),
+ ID: new(int64(12345)),
+ Title: new("fooz"),
+ Key: new("random-fooz-key"),
+ ReadOnly: new(false),
},
}
})
@@ -357,10 +357,10 @@ var _ = Describe("ReconcileDeployKeys", func() {
}
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("readonly-key"),
- Key: github.Ptr("ssh-rsa AAAAB3Nza..."),
- ReadOnly: github.Ptr(true), // GitHub's default
+ ID: new(int64(12345)),
+ Title: new("readonly-key"),
+ Key: new("ssh-rsa AAAAB3Nza..."),
+ ReadOnly: new(true), // GitHub's default
},
}
})
@@ -383,10 +383,10 @@ var _ = Describe("ReconcileDeployKeys", func() {
}
currentDeployKeys = []*github.Key{
{
- ID: github.Ptr(int64(12345)),
- Title: github.Ptr("readonly-key"),
- Key: github.Ptr("ssh-rsa AAAAB3Nza..."),
- ReadOnly: github.Ptr(false), // differs from default
+ ID: new(int64(12345)),
+ Title: new("readonly-key"),
+ Key: new("ssh-rsa AAAAB3Nza..."),
+ ReadOnly: new(false), // differs from default
},
}
})
diff --git a/internal/reconciler/reporec/rec_repo.go b/internal/reconciler/reporec/rec_repo.go
index 3f3f2d2..d086fa6 100644
--- a/internal/reconciler/reporec/rec_repo.go
+++ b/internal/reconciler/reporec/rec_repo.go
@@ -64,7 +64,7 @@ func (r *GitHubRepoReconciler) getRepo(ctx context.Context) (*github.Repository,
if errors.As(err, &ghErr) && ghErr.Response.StatusCode == http.StatusNotFound {
log.V(1).Info("Repository does not exist, creating it")
newRepo := mapper.RepoToGithubRepo(r.Kubernetes.Resource)
- newRepo.AutoInit = github.Ptr(true)
+ newRepo.AutoInit = new(true)
ghRepo, err = r.GitHub.Client.CreateRepository(ctx, r.GitHub.Resource.Owner, newRepo)
if err != nil {
log.Error(err, "failed to create repository on GitHub")
diff --git a/internal/reconciler/reporec/rec_repo_test.go b/internal/reconciler/reporec/rec_repo_test.go
index fd24552..28f95f4 100644
--- a/internal/reconciler/reporec/rec_repo_test.go
+++ b/internal/reconciler/reporec/rec_repo_test.go
@@ -50,14 +50,14 @@ var _ = Describe("ReconcileRepository", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
Visibility: "internal",
- HasIssues: github.Ptr(true),
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(true),
+ HasIssues: new(true),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ DeleteBranchOnMerge: new(true),
MergeCommitMessage: "PR_TITLE",
MergeCommitTitle: "MERGE_MESSAGE",
OrganizationRef: v1alpha1.OrganizationRef{
@@ -73,25 +73,25 @@ var _ = Describe("ReconcileRepository", func() {
// Default: current GitHub repo matches desired state
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
HasIssues: repo.Spec.HasIssues,
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
- AllowRebaseMerge: github.Ptr(false),
- AllowMergeCommit: github.Ptr(false),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
+ AllowRebaseMerge: new(false),
+ AllowMergeCommit: new(false),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: github.Ptr(""),
- Description: github.Ptr(""),
- ID: github.Ptr(int64(12345)),
- DefaultBranch: github.Ptr(repo.Spec.DefaultBranch),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: new(""),
+ Description: new(""),
+ ID: new(int64(12345)),
+ DefaultBranch: new(repo.Spec.DefaultBranch),
}
// Set default mock functions (can be overridden in nested BeforeEach)
@@ -105,7 +105,7 @@ var _ = Describe("ReconcileRepository", func() {
// Return the edited repo with the same ID
result := *repository
if result.ID == nil {
- result.ID = github.Ptr(int64(12345))
+ result.ID = new(int64(12345))
}
return &result, nil
}
@@ -115,7 +115,7 @@ var _ = Describe("ReconcileRepository", func() {
createdRepo = repository
// Return the created repo with an ID
result := *repository
- result.ID = github.Ptr(int64(12345))
+ result.ID = new(int64(12345))
return &result, nil
}
})
@@ -163,10 +163,10 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository name differs", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("old-name"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("old-name"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
})
@@ -181,10 +181,10 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository archived status differs", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(true),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(true),
+ ID: new(int64(12345)),
}
})
@@ -199,10 +199,10 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository visibility differs", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("public"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("public"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
})
@@ -217,10 +217,10 @@ var _ = Describe("ReconcileRepository", func() {
Context("when multiple fields differ", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("old-name"),
- Visibility: github.Ptr("public"),
- Archived: github.Ptr(true),
- ID: github.Ptr(int64(12345)),
+ Name: new("old-name"),
+ Visibility: new("public"),
+ Archived: new(true),
+ ID: new(int64(12345)),
}
})
@@ -388,10 +388,10 @@ var _ = Describe("ReconcileRepository", func() {
Context("when EditRepository fails", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("old-name"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("old-name"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
mockClient.EditRepositoryFunc = func(ctx context.Context, owner, name string, repository *github.Repository) (*github.Repository, error) {
return nil, errors.New("failed to edit repository")
@@ -407,9 +407,9 @@ var _ = Describe("ReconcileRepository", func() {
Context("when GitHub returns repository with nil ID", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
ID: nil,
}
})
@@ -435,12 +435,12 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository spec has archived=true", func() {
BeforeEach(func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
})
@@ -468,27 +468,27 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository is already archived on GitHub", func() {
BeforeEach(func() {
- repo.Spec.Archived = github.Ptr(true)
+ repo.Spec.Archived = new(true)
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(true),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(true),
+ ID: new(int64(12345)),
HasIssues: repo.Spec.HasIssues,
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
- AllowRebaseMerge: github.Ptr(false),
- AllowMergeCommit: github.Ptr(false),
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
+ AllowRebaseMerge: new(false),
+ AllowMergeCommit: new(false),
DeleteBranchOnMerge: repo.Spec.DeleteBranchOnMerge,
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: github.Ptr(""),
- Description: github.Ptr(""),
- DefaultBranch: github.Ptr(repo.Spec.DefaultBranch),
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: new(""),
+ Description: new(""),
+ DefaultBranch: new(repo.Spec.DefaultBranch),
}
})
@@ -510,16 +510,16 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository tries to unarchive an archived repo", func() {
BeforeEach(func() {
// Spec wants to unarchive (archived=false), but repo IS archived on GitHub
- repo.Spec.Archived = github.Ptr(false)
+ repo.Spec.Archived = new(false)
repo.Spec.About = v1alpha1.About{
Description: "New description",
}
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(true),
- Description: github.Ptr("Old description"),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(true),
+ Description: new("Old description"),
+ ID: new(int64(12345)),
}
})
@@ -531,12 +531,12 @@ var _ = Describe("ReconcileRepository", func() {
Context("when repository is not archived", func() {
BeforeEach(func() {
- repo.Spec.Archived = github.Ptr(false)
+ repo.Spec.Archived = new(false)
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
})
@@ -560,25 +560,25 @@ var _ = Describe("ReconcileRepository", func() {
// GitHub repo matches the expected defaults
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false), // default
- HasIssues: github.Ptr(true), // default
- HasProjects: github.Ptr(false), // default
- HasWiki: github.Ptr(false), // default
- HasDownloads: github.Ptr(false), // default
- IsTemplate: github.Ptr(false), // default
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
- AllowRebaseMerge: github.Ptr(false),
- AllowMergeCommit: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(true), // default
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: github.Ptr(""),
- Description: github.Ptr(""),
- ID: github.Ptr(int64(12345)),
- DefaultBranch: github.Ptr(repo.Spec.DefaultBranch),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false), // default
+ HasIssues: new(true), // default
+ HasProjects: new(false), // default
+ HasWiki: new(false), // default
+ HasDownloads: new(false), // default
+ IsTemplate: new(false), // default
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
+ AllowRebaseMerge: new(false),
+ AllowMergeCommit: new(false),
+ DeleteBranchOnMerge: new(true), // default
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: new(""),
+ Description: new(""),
+ ID: new(int64(12345)),
+ DefaultBranch: new(repo.Spec.DefaultBranch),
}
})
@@ -603,25 +603,25 @@ var _ = Describe("ReconcileRepository", func() {
// GitHub repo has different values than defaults
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- HasIssues: github.Ptr(false), // differs from default (true)
- HasProjects: github.Ptr(false),
- HasWiki: github.Ptr(false),
- HasDownloads: github.Ptr(false),
- IsTemplate: github.Ptr(false),
- AutoInit: github.Ptr(true),
- AllowSquashMerge: github.Ptr(false),
- AllowRebaseMerge: github.Ptr(false),
- AllowMergeCommit: github.Ptr(false),
- DeleteBranchOnMerge: github.Ptr(false), // differs from default (true)
- MergeCommitTitle: github.Ptr("MERGE_MESSAGE"),
- MergeCommitMessage: github.Ptr("PR_TITLE"),
- Homepage: github.Ptr(""),
- Description: github.Ptr(""),
- ID: github.Ptr(int64(12345)),
- DefaultBranch: github.Ptr(repo.Spec.DefaultBranch),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ HasIssues: new(false), // differs from default (true)
+ HasProjects: new(false),
+ HasWiki: new(false),
+ HasDownloads: new(false),
+ IsTemplate: new(false),
+ AutoInit: new(true),
+ AllowSquashMerge: new(false),
+ AllowRebaseMerge: new(false),
+ AllowMergeCommit: new(false),
+ DeleteBranchOnMerge: new(false), // differs from default (true)
+ MergeCommitTitle: new("MERGE_MESSAGE"),
+ MergeCommitMessage: new("PR_TITLE"),
+ Homepage: new(""),
+ Description: new(""),
+ ID: new(int64(12345)),
+ DefaultBranch: new(repo.Spec.DefaultBranch),
}
})
@@ -699,7 +699,7 @@ var _ = Describe("getRepo", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -734,10 +734,10 @@ var _ = Describe("getRepo", func() {
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, name string) (*github.Repository, error) {
getRepoCalled = true
return &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}, nil
}
@@ -779,7 +779,7 @@ var _ = Describe("getRepo", func() {
Name: repository.Name,
Visibility: repository.Visibility,
Archived: repository.Archived,
- ID: github.Ptr(int64(67890)),
+ ID: new(int64(67890)),
}, nil
}
@@ -872,7 +872,7 @@ var _ = Describe("updateRepo", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -904,7 +904,7 @@ var _ = Describe("updateRepo", func() {
BeforeEach(func() {
mockClient.EditRepositoryFunc = func(ctx context.Context, owner, name string, repository *github.Repository) (*github.Repository, error) {
result := *repository
- result.ID = github.Ptr(int64(99999))
+ result.ID = new(int64(99999))
return &result, nil
}
@@ -964,7 +964,7 @@ var _ = Describe("updateID", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -995,8 +995,8 @@ var _ = Describe("updateID", func() {
Context("when updating with valid repository", func() {
BeforeEach(func() {
ghRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- ID: github.Ptr(int64(54321)),
+ Name: new("test-repo"),
+ ID: new(int64(54321)),
}
err = rec.updateID(ctx, ghRepo)
@@ -1037,7 +1037,7 @@ var _ = Describe("updateID", func() {
Context("when repository ID is nil", func() {
BeforeEach(func() {
ghRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
+ Name: new("test-repo"),
ID: nil,
}
diff --git a/internal/reconciler/reporec/rec_rulesets.go b/internal/reconciler/reporec/rec_rulesets.go
index 5bb42cb..2f5340f 100644
--- a/internal/reconciler/reporec/rec_rulesets.go
+++ b/internal/reconciler/reporec/rec_rulesets.go
@@ -16,6 +16,21 @@ func (r *GitHubRepoReconciler) reconcileRuleSets(ctx context.Context) error {
log := logPkg.FromContext(ctx)
log.V(1).Info("Reconciling repository rule sets on GitHub")
+ // Rulesets are not supported on non-public repositories in the free plan
+ var org githubv1alpha1.Organization
+ if err := r.Kubernetes.Client.Get(ctx, client.ObjectKey{
+ Name: r.Kubernetes.Resource.Spec.OrganizationRef.Name,
+ Namespace: r.Kubernetes.Resource.Namespace,
+ }, &org); err != nil {
+ log.Error(err, "unable to fetch Organization for Repository")
+ return err
+ }
+
+ if org.GetPlan() == githubv1alpha1.PlanFree && r.Kubernetes.Resource.Spec.Visibility != githubv1alpha1.VisibilityPublic {
+ log.V(1).Info("Skipping rulesets reconciliation for non-public repository on free plan")
+ return nil
+ }
+
existingRulesets, err := r.GitHub.Client.GetAllRepositoryRulesets(ctx, r.GitHub.Resource.Owner, r.GitHub.Resource.Name, false)
if err != nil {
log.Error(err, "failed to get existing repository rulesets")
diff --git a/internal/reconciler/reporec/rec_rulesets_test.go b/internal/reconciler/reporec/rec_rulesets_test.go
index c14a5aa..d5c23f3 100644
--- a/internal/reconciler/reporec/rec_rulesets_test.go
+++ b/internal/reconciler/reporec/rec_rulesets_test.go
@@ -85,7 +85,7 @@ var _ = Describe("ReconcileRuleSets", func() {
mockClient.CreateRepositoryRulesetFunc = func(_ context.Context, _, _ string, ruleset *github.RepositoryRuleset) (*github.RepositoryRuleset, error) {
createRulesetCalled = true
created := *ruleset
- created.ID = github.Ptr(int64(1000 + len(createdRulesets)))
+ created.ID = new(int64(1000 + len(createdRulesets)))
createdRulesets = append(createdRulesets, &created)
return &created, nil
}
@@ -93,7 +93,7 @@ var _ = Describe("ReconcileRuleSets", func() {
mockClient.UpdateRepositoryRulesetFunc = func(ctx context.Context, owner, repo string, rulesetID int64, ruleset *github.RepositoryRuleset) (*github.RepositoryRuleset, error) {
updateRulesetCalled = true
updated := *ruleset
- updated.ID = github.Ptr(rulesetID)
+ updated.ID = new(rulesetID)
updatedRulesets[rulesetID] = &updated
return &updated, nil
}
@@ -119,7 +119,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
RulesetPresetList: rulesetPresetRefs,
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
@@ -127,9 +127,21 @@ var _ = Describe("ReconcileRuleSets", func() {
},
}
+ // Create organization that the ruleset reconciliation will fetch
+ org := &v1alpha1.Organization{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "test-org",
+ Namespace: "default",
+ },
+ Spec: v1alpha1.OrganizationSpec{
+ Plan: v1alpha1.PlanEnterprise,
+ },
+ }
+
// Build k8s objects slice
- k8sObjects := make([]client.Object, 1, 1+len(rulesetPresets))
+ k8sObjects := make([]client.Object, 2, 2+len(rulesetPresets))
k8sObjects[0] = repo
+ k8sObjects[1] = org
for _, preset := range rulesetPresets {
k8sObjects = append(k8sObjects, preset)
}
@@ -183,7 +195,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -217,7 +229,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -235,7 +247,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -269,7 +281,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -278,7 +290,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// Existing ruleset matches - important: RefName patterns must match mapper output
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -319,8 +331,8 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
- RequiredSignatures: github.Ptr(true),
+ RequiredLinearHistory: new(true),
+ RequiredSignatures: new(true),
},
},
},
@@ -329,7 +341,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// Existing ruleset has different rules
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -372,7 +384,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -381,7 +393,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// Existing ruleset has different enforcement
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -421,7 +433,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -430,7 +442,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// Existing ruleset targets only main
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -461,7 +473,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// But rulesets exist on GitHub
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "old-ruleset",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -495,7 +507,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -503,7 +515,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "keep-this",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -517,13 +529,13 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
{
- ID: github.Ptr(int64(456)),
+ ID: new(int64(456)),
Name: "delete-this",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
},
{
- ID: github.Ptr(int64(789)),
+ ID: new(int64(789)),
Name: "delete-this-too",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -555,7 +567,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -573,7 +585,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -581,7 +593,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "existing-ruleset",
Enforcement: github.RulesetEnforcementActive, // Different enforcement
Target: github.Ptr(github.RulesetTargetBranch),
@@ -626,7 +638,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -688,7 +700,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -720,7 +732,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -728,7 +740,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
},
}
@@ -761,7 +773,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -795,7 +807,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -803,7 +815,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive, // Different
Target: github.Ptr(github.RulesetTargetBranch),
@@ -835,7 +847,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "old-ruleset",
Enforcement: github.RulesetEnforcementActive,
},
@@ -865,7 +877,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -902,11 +914,11 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "", // Empty name
},
{
- ID: github.Ptr(int64(456)),
+ ID: new(int64(456)),
Name: "valid-name",
},
}
@@ -938,24 +950,24 @@ var _ = Describe("ReconcileRuleSets", func() {
},
BypassActors: []v1alpha1.RulesetBypassActor{
{
- ActorID: github.Ptr(int64(12345)),
+ ActorID: new(int64(12345)),
ActorType: "Team",
BypassMode: "always",
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
- Update: github.Ptr(true),
- Deletion: github.Ptr(true),
- RequiredLinearHistory: github.Ptr(true),
- RequiredSignatures: github.Ptr(true),
- NonFastForward: github.Ptr(true),
+ Creation: new(true),
+ Update: new(true),
+ Deletion: new(true),
+ RequiredLinearHistory: new(true),
+ RequiredSignatures: new(true),
+ NonFastForward: new(true),
PullRequest: &v1alpha1.PullRequestRule{
- DismissStaleReviewsOnPush: github.Ptr(true),
- RequireCodeOwnerReviews: github.Ptr(true),
- RequireLastPushApproval: github.Ptr(true),
+ DismissStaleReviewsOnPush: new(true),
+ RequireCodeOwnerReviews: new(true),
+ RequireLastPushApproval: new(true),
RequiredApprovingReviewCount: 2,
- RequiredReviewThreadResolution: github.Ptr(true),
+ RequiredReviewThreadResolution: new(true),
},
},
},
@@ -989,13 +1001,13 @@ var _ = Describe("ReconcileRuleSets", func() {
},
BypassActors: []v1alpha1.RulesetBypassActor{
{
- ActorID: github.Ptr(int64(999)),
+ ActorID: new(int64(999)),
ActorType: "Team",
BypassMode: "always",
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -1003,7 +1015,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -1014,7 +1026,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
BypassActors: []*github.BypassActor{
{
- ActorID: github.Ptr(int64(888)),
+ ActorID: new(int64(888)),
ActorType: github.Ptr(github.BypassActorTypeTeam),
},
},
@@ -1052,12 +1064,12 @@ var _ = Describe("ReconcileRuleSets", func() {
CommitMessagePattern: &v1alpha1.PatternRule{
Pattern: "^[A-Z]+-[0-9]+:.*",
Operator: "starts_with",
- Negate: github.Ptr(false),
+ Negate: new(false),
},
BranchNamePattern: &v1alpha1.PatternRule{
Pattern: "^(feature|bugfix|hotfix)/",
Operator: "starts_with",
- Negate: github.Ptr(false),
+ Negate: new(false),
},
},
},
@@ -1091,7 +1103,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -1109,7 +1121,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Update: github.Ptr(true),
+ Update: new(true),
},
},
},
@@ -1140,8 +1152,8 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
- RequiredSignatures: github.Ptr(true), // Added
+ RequiredLinearHistory: new(true),
+ RequiredSignatures: new(true), // Added
},
},
},
@@ -1149,7 +1161,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "main-protection",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -1195,7 +1207,7 @@ var _ = Describe("ReconcileRuleSets", func() {
{Context: "ci/build"},
{Context: "ci/test"},
},
- StrictPolicy: github.Ptr(true),
+ StrictPolicy: new(true),
},
},
},
@@ -1229,8 +1241,8 @@ var _ = Describe("ReconcileRuleSets", func() {
},
Rules: v1alpha1.RulesetRules{
CopilotReview: &v1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
},
},
},
@@ -1269,8 +1281,8 @@ var _ = Describe("ReconcileRuleSets", func() {
},
Rules: v1alpha1.RulesetRules{
CopilotReview: &v1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(true),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(true),
},
},
},
@@ -1279,7 +1291,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "copilot-review-ruleset",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -1325,8 +1337,8 @@ var _ = Describe("ReconcileRuleSets", func() {
},
Rules: v1alpha1.RulesetRules{
CopilotReview: &v1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(true),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(true),
},
},
},
@@ -1335,7 +1347,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "copilot-review-ruleset",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -1384,7 +1396,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
Rules: v1alpha1.RulesetRules{
// No CopilotReview rule specified
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -1392,7 +1404,7 @@ var _ = Describe("ReconcileRuleSets", func() {
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Name: "copilot-review-ruleset",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTargetBranch),
@@ -1438,15 +1450,15 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
- RequiredSignatures: github.Ptr(true),
+ RequiredLinearHistory: new(true),
+ RequiredSignatures: new(true),
CopilotReview: &v1alpha1.CopilotCodeReviewRule{
- ReviewOnPush: github.Ptr(true),
- ReviewDraftPullRequests: github.Ptr(false),
+ ReviewOnPush: new(true),
+ ReviewDraftPullRequests: new(false),
},
PullRequest: &v1alpha1.PullRequestRule{
RequiredApprovingReviewCount: 2,
- RequireCodeOwnerReviews: github.Ptr(true),
+ RequireCodeOwnerReviews: new(true),
},
},
},
@@ -1489,7 +1501,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -1522,7 +1534,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -1541,7 +1553,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
},
@@ -1574,7 +1586,7 @@ var _ = Describe("ReconcileRuleSets", func() {
},
},
Rules: v1alpha1.RulesetRules{
- RequiredLinearHistory: github.Ptr(true),
+ RequiredLinearHistory: new(true),
},
},
},
@@ -1583,7 +1595,7 @@ var _ = Describe("ReconcileRuleSets", func() {
// An unrelated ruleset exists on GitHub that matches the skipped preset name
existingGHRulesets = []*github.RepositoryRuleset{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Name: "repo-target-ruleset",
Enforcement: github.RulesetEnforcementActive,
Target: github.Ptr(github.RulesetTarget("repository")),
diff --git a/internal/reconciler/reporec/rec_webhooks_test.go b/internal/reconciler/reporec/rec_webhooks_test.go
index 3180d91..30f2755 100644
--- a/internal/reconciler/reporec/rec_webhooks_test.go
+++ b/internal/reconciler/reporec/rec_webhooks_test.go
@@ -73,7 +73,7 @@ var _ = Describe("ReconcileWebhooks", func() {
mockClient.CreateHookFunc = func(ctx context.Context, owner, repo string, hook *github.Hook) (*github.Hook, error) {
createHookCalled = true
created := *hook
- created.ID = github.Ptr(int64(1000 + len(createdHooks)))
+ created.ID = new(int64(1000 + len(createdHooks)))
createdHooks = append(createdHooks, &created)
return &created, nil
}
@@ -109,7 +109,7 @@ var _ = Describe("ReconcileWebhooks", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
WebhookPresetList: webhookPresetRefs,
WebhookIgnorePresetsList: webhookIgnorePresetRefs,
OrganizationRef: v1alpha1.OrganizationRef{
@@ -181,13 +181,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -233,13 +233,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook1",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret1"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
{
@@ -250,13 +250,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://slack.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret2"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret2"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"pull_request", "issues"},
- SSLVerify: github.Ptr(false),
+ SSLVerify: new(false),
},
},
}
@@ -307,13 +307,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"pull_request", "push"}, // Sorted alphabetically to match hash
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
}
webhookPresets = []*v1alpha1.WebhookPreset{preset}
@@ -333,10 +333,10 @@ var _ = Describe("ReconcileWebhooks", func() {
// Existing webhook matches
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
@@ -378,13 +378,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("newsecret456"),
- Key: github.Ptr("newkey456"),
+ Name: new("newsecret456"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -397,7 +397,7 @@ var _ = Describe("ReconcileWebhooks", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -426,10 +426,10 @@ var _ = Describe("ReconcileWebhooks", func() {
// Existing webhook with same URL/content type/events but different secret
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push", "pull_request"},
},
@@ -456,10 +456,10 @@ var _ = Describe("ReconcileWebhooks", func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -521,13 +521,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -561,10 +561,10 @@ var _ = Describe("ReconcileWebhooks", func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -585,7 +585,7 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: nil, // Missing config
},
}
@@ -602,8 +602,8 @@ var _ = Describe("ReconcileWebhooks", func() {
{
ID: nil, // Missing ID
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -619,10 +619,10 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
URL: nil, // Missing URL
- ContentType: github.Ptr("application/json"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -638,9 +638,9 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
+ URL: new("https://example.com/webhook"),
ContentType: nil, // Missing ContentType
},
Events: []string{"push"},
@@ -664,13 +664,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/x-www-form-urlencoded",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -690,10 +690,10 @@ var _ = Describe("ReconcileWebhooks", func() {
// Existing webhook with different content type
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -722,13 +722,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request", "issues"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -748,10 +748,10 @@ var _ = Describe("ReconcileWebhooks", func() {
// Existing webhook with different events
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
},
@@ -780,9 +780,9 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -808,13 +808,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook1",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret1"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -851,13 +851,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook1",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret1"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -887,10 +887,10 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://foo.bar.random.info/webhook/fooz"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://foo.bar.random.info/webhook/fooz"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
@@ -903,7 +903,7 @@ var _ = Describe("ReconcileWebhooks", func() {
Namespace: "default",
},
Spec: v1alpha1.WebhookIgnorePresetSpec{
- IgnoreURLRegex: github.Ptr("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"),
+ IgnoreURLRegex: new("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"),
},
},
}
@@ -920,26 +920,26 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://foo.bar.random.info/webhook/fooz"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://foo.bar.random.info/webhook/fooz"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
{
- ID: github.Ptr(int64(234)),
+ ID: new(int64(234)),
Config: &github.HookConfig{
- URL: github.Ptr("https://bar.bar.random.info/webhook/fooz"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://bar.bar.random.info/webhook/fooz"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
{
- ID: github.Ptr(int64(345)),
+ ID: new(int64(345)),
Config: &github.HookConfig{
- URL: github.Ptr("https://foo.foo.random.info/webhook/random"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://foo.foo.random.info/webhook/random"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
@@ -952,7 +952,7 @@ var _ = Describe("ReconcileWebhooks", func() {
Namespace: "default",
},
Spec: v1alpha1.WebhookIgnorePresetSpec{
- IgnoreURLRegex: github.Ptr("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"),
+ IgnoreURLRegex: new("https:\\/\\/foo\\.bar\\.random\\.info\\/webhook\\/.*"),
},
},
{
@@ -961,7 +961,7 @@ var _ = Describe("ReconcileWebhooks", func() {
Namespace: "default",
},
Spec: v1alpha1.WebhookIgnorePresetSpec{
- IgnoreURLRegex: github.Ptr("https:\\/\\/bar\\.bar\\.random\\.info\\/webhook\\/.*"),
+ IgnoreURLRegex: new("https:\\/\\/bar\\.bar\\.random\\.info\\/webhook\\/.*"),
},
},
}
@@ -978,10 +978,10 @@ var _ = Describe("ReconcileWebhooks", func() {
BeforeEach(func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
Config: &github.HookConfig{
- URL: github.Ptr("https://foo.bar.random.info/webhook/fooz"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://foo.bar.random.info/webhook/fooz"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"},
},
@@ -994,7 +994,7 @@ var _ = Describe("ReconcileWebhooks", func() {
Namespace: "default",
},
Spec: v1alpha1.WebhookIgnorePresetSpec{
- IgnoreURLRegex: github.Ptr("("),
+ IgnoreURLRegex: new("("),
},
},
}
@@ -1018,13 +1018,13 @@ var _ = Describe("ReconcileWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/hooks/{{.SSHURL}}",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("webhook-secret"),
- Key: github.Ptr("token"),
+ Name: new("webhook-secret"),
+ Key: new("token"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1043,15 +1043,15 @@ var _ = Describe("ReconcileWebhooks", func() {
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repo string) (*github.Repository, error) {
return &github.Repository{
- ID: github.Ptr(int64(12345)),
- Name: github.Ptr(repo),
- FullName: github.Ptr(fmt.Sprintf("%s/%s", owner, repo)),
+ ID: new(int64(12345)),
+ Name: new(repo),
+ FullName: new(fmt.Sprintf("%s/%s", owner, repo)),
Owner: &github.User{
- Login: github.Ptr(owner),
+ Login: new(owner),
},
- SSHURL: github.Ptr("git@github.com:test-org/test-repo.git"),
- HTMLURL: github.Ptr("https://github.com/test-org/test-repo"),
- Archived: github.Ptr(false),
+ SSHURL: new("git@github.com:test-org/test-repo.git"),
+ HTMLURL: new("https://github.com/test-org/test-repo"),
+ Archived: new(false),
}, nil
}
})
@@ -1120,7 +1120,7 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
mockClient.CreateHookFunc = func(ctx context.Context, owner, repo string, hook *github.Hook) (*github.Hook, error) {
createHookCalled = true
created := *hook
- created.ID = github.Ptr(int64(2000 + len(createdHooks)))
+ created.ID = new(int64(2000 + len(createdHooks)))
createdHooks = append(createdHooks, &created)
return &created, nil
}
@@ -1195,13 +1195,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
{
@@ -1212,13 +1212,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/x-www-form-urlencoded",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1279,13 +1279,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
{
@@ -1296,13 +1296,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1355,13 +1355,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1384,13 +1384,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
// Existing webhook on GitHub with same hash (event order doesn't matter)
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"}, // Different order, same hash
- Active: github.Ptr(true),
+ Active: new(true),
},
}
})
@@ -1456,13 +1456,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/hooks/{{.SSHURL}}",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push", "pull_request"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1485,28 +1485,28 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
// Existing webhook on GitHub with templated URL resolved
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/hooks/git@github.com:test-org/test-repo.git"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/hooks/git@github.com:test-org/test-repo.git"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request", "push"}, // Different order, same hash
- Active: github.Ptr(true),
+ Active: new(true),
},
}
// Mock GetRepository to provide template data
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repo string) (*github.Repository, error) {
return &github.Repository{
- ID: github.Ptr(int64(12345)),
- Name: github.Ptr(repo),
- FullName: github.Ptr(fmt.Sprintf("%s/%s", owner, repo)),
+ ID: new(int64(12345)),
+ Name: new(repo),
+ FullName: new(fmt.Sprintf("%s/%s", owner, repo)),
Owner: &github.User{
- Login: github.Ptr(owner),
+ Login: new(owner),
},
- SSHURL: github.Ptr("git@github.com:test-org/test-repo.git"),
- HTMLURL: github.Ptr("https://github.com/test-org/test-repo"),
- Archived: github.Ptr(false),
+ SSHURL: new("git@github.com:test-org/test-repo.git"),
+ HTMLURL: new("https://github.com/test-org/test-repo"),
+ Archived: new(false),
}, nil
}
})
@@ -1570,13 +1570,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1595,13 +1595,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(999)),
+ ID: new(int64(999)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
- Active: github.Ptr(true),
+ Active: new(true),
},
}
})
@@ -1654,13 +1654,13 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("key1"),
+ Name: new("secret1"),
+ Key: new("key1"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -1680,22 +1680,22 @@ var _ = Describe("ReconcileWebhooks - Hash-based collision handling", func() {
// Both webhooks exist on GitHub
existingGHHooks = []*github.Hook{
{
- ID: github.Ptr(int64(1001)),
+ ID: new(int64(1001)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"push"},
- Active: github.Ptr(true),
+ Active: new(true),
},
{
- ID: github.Ptr(int64(1002)),
+ ID: new(int64(1002)),
Config: &github.HookConfig{
- URL: github.Ptr("https://example.com/webhook"),
- ContentType: github.Ptr("application/json"),
+ URL: new("https://example.com/webhook"),
+ ContentType: new("application/json"),
},
Events: []string{"pull_request"},
- Active: github.Ptr(true),
+ Active: new(true),
},
}
})
@@ -1829,7 +1829,7 @@ var _ = Describe("cleanupUnusedWebhooks", func() {
BeforeEach(func() {
hooksToRemove = map[string]*github.Hook{
"hash1": {
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
}
})
@@ -1844,10 +1844,10 @@ var _ = Describe("cleanupUnusedWebhooks", func() {
BeforeEach(func() {
hooksToRemove = map[string]*github.Hook{
"hash1": {
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
"hash2": {
- ID: github.Ptr(int64(456)),
+ ID: new(int64(456)),
},
}
})
@@ -1890,7 +1890,7 @@ var _ = Describe("cleanupUnusedWebhooks", func() {
BeforeEach(func() {
hooksToRemove = map[string]*github.Hook{
"hash1": {
- ID: github.Ptr(int64(123)),
+ ID: new(int64(123)),
},
}
deleteError = errors.New("delete failed")
@@ -1988,13 +1988,13 @@ var _ = Describe("createMissingWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -2017,13 +2017,13 @@ var _ = Describe("createMissingWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook1",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret1"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
"hash2": {
@@ -2033,13 +2033,13 @@ var _ = Describe("createMissingWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://slack.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret2"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret2"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(false),
+ Active: new(false),
Events: []string{"issues"},
- SSLVerify: github.Ptr(false),
+ SSLVerify: new(false),
},
},
}
@@ -2074,13 +2074,13 @@ var _ = Describe("createMissingWebhooks", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
},
}
@@ -2171,8 +2171,8 @@ var _ = Describe("updateWebhooksStatus", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret123"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret123"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
Events: []string{"push"},
@@ -2203,8 +2203,8 @@ var _ = Describe("updateWebhooksStatus", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook1",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret1"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret1"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
Events: []string{"push"},
@@ -2217,8 +2217,8 @@ var _ = Describe("updateWebhooksStatus", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://slack.com/webhook",
Secret: &v1alpha1.WebhookPresetSecretSpec{
- Name: github.Ptr("secret2"),
- Key: github.Ptr("newkey456"),
+ Name: new("secret2"),
+ Key: new("newkey456"),
},
ContentType: "application/json",
Events: []string{"issues"},
@@ -2303,22 +2303,22 @@ var _ = Describe("templatePayloadURL", func() {
Spec: v1alpha1.WebhookPresetSpec{
PayloadURL: "https://example.com/webhook",
ContentType: "application/json",
- Active: github.Ptr(true),
+ Active: new(true),
Events: []string{"push"},
- SSLVerify: github.Ptr(true),
+ SSLVerify: new(true),
},
}
mockRepo = &github.Repository{
- ID: github.Ptr(int64(12345)),
- Name: github.Ptr("test-repo"),
- FullName: github.Ptr("test-org/test-repo"),
+ ID: new(int64(12345)),
+ Name: new("test-repo"),
+ FullName: new("test-org/test-repo"),
Owner: &github.User{
- Login: github.Ptr("test-org"),
+ Login: new("test-org"),
},
- SSHURL: github.Ptr("git@github.com:test-org/test-repo.git"),
- HTMLURL: github.Ptr("https://github.com/test-org/test-repo"),
- Archived: github.Ptr(false),
+ SSHURL: new("git@github.com:test-org/test-repo.git"),
+ HTMLURL: new("https://github.com/test-org/test-repo"),
+ Archived: new(false),
}
mockClient.GetRepositoryFunc = func(ctx context.Context, owner, repo string) (*github.Repository, error) {
@@ -2498,7 +2498,7 @@ var _ = Describe("templatePayloadURL", func() {
Context("when URL contains special characters", func() {
BeforeEach(func() {
- mockRepo.Name = github.Ptr("test-repo-with-special")
+ mockRepo.Name = new("test-repo-with-special")
preset.Spec.PayloadURL = "https://example.com/{{.Name}}/webhook"
})
diff --git a/internal/reconciler/reporec/reconciler.go b/internal/reconciler/reporec/reconciler.go
index 530abc4..7693711 100644
--- a/internal/reconciler/reporec/reconciler.go
+++ b/internal/reconciler/reporec/reconciler.go
@@ -149,7 +149,7 @@ func (r *GitHubRepoReconciler) archiveRepository(ctx context.Context) error {
log.V(1).Info("Archiving repository")
_, err = r.GitHub.Client.EditRepository(ctx, r.GitHub.Resource.Owner, r.GitHub.Resource.Name, &github.Repository{
- Archived: github.Ptr(true),
+ Archived: new(true),
})
if err != nil {
log.Error(err, "failed to archive repository on GitHub")
diff --git a/internal/reconciler/reporec/reconciler_finalize_archive_test.go b/internal/reconciler/reporec/reconciler_finalize_archive_test.go
index 6117f62..ed5bd9c 100644
--- a/internal/reconciler/reporec/reconciler_finalize_archive_test.go
+++ b/internal/reconciler/reporec/reconciler_finalize_archive_test.go
@@ -48,7 +48,7 @@ var _ = Describe("ReconcileArchive", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -61,10 +61,10 @@ var _ = Describe("ReconcileArchive", func() {
// Default: repository is not archived
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
// Set default mock functions (can be overridden in nested BeforeEach)
@@ -96,7 +96,7 @@ var _ = Describe("ReconcileArchive", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
@@ -136,10 +136,10 @@ var _ = Describe("ReconcileArchive", func() {
Context("when repository is already archived", func() {
BeforeEach(func() {
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(true),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(true),
+ ID: new(int64(12345)),
}
})
@@ -248,10 +248,10 @@ var _ = Describe("ReconcileArchive", func() {
BeforeEach(func() {
// Edge case: Archived pointer exists but is nil (shouldn't happen, but let's be defensive)
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
Archived: nil, // nil pointer
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
}
})
diff --git a/internal/reconciler/reporec/reconciler_finalize_delete_test.go b/internal/reconciler/reporec/reconciler_finalize_delete_test.go
index 709855b..091ad3e 100644
--- a/internal/reconciler/reporec/reconciler_finalize_delete_test.go
+++ b/internal/reconciler/reporec/reconciler_finalize_delete_test.go
@@ -47,7 +47,7 @@ var _ = Describe("ReconcileDeletion", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -60,10 +60,10 @@ var _ = Describe("ReconcileDeletion", func() {
// Default: repository is not archived
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
// Set default mock functions (can be overridden in nested BeforeEach)
@@ -91,7 +91,7 @@ var _ = Describe("ReconcileDeletion", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
diff --git a/internal/reconciler/reporec/reconciler_finalize_ignore_test.go b/internal/reconciler/reporec/reconciler_finalize_ignore_test.go
index f8d24cc..b560aad 100644
--- a/internal/reconciler/reporec/reconciler_finalize_ignore_test.go
+++ b/internal/reconciler/reporec/reconciler_finalize_ignore_test.go
@@ -46,7 +46,7 @@ var _ = Describe("ReconcileIgnore", func() {
},
Spec: v1alpha1.RepositorySpec{
Name: "test-repo",
- Archived: github.Ptr(false),
+ Archived: new(false),
OrganizationRef: v1alpha1.OrganizationRef{
Name: "test-org",
},
@@ -59,10 +59,10 @@ var _ = Describe("ReconcileIgnore", func() {
// Default: repository is not archived
currentGHRepo = &github.Repository{
- Name: github.Ptr("test-repo"),
- Visibility: github.Ptr("internal"),
- Archived: github.Ptr(false),
- ID: github.Ptr(int64(12345)),
+ Name: new("test-repo"),
+ Visibility: new("internal"),
+ Archived: new(false),
+ ID: new(int64(12345)),
}
// Set default mock functions (can be overridden in nested BeforeEach)
@@ -98,7 +98,7 @@ var _ = Describe("ReconcileIgnore", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
@@ -152,7 +152,7 @@ var _ = Describe("ReconcileIgnore", func() {
Resource: GitHubRepoIdentifier{
Owner: "test-org",
Name: "test-repo",
- ID: github.Ptr(int64(12345)),
+ ID: new(int64(12345)),
},
},
Kubernetes: reconciler.Kubernetes[*v1alpha1.Repository]{
diff --git a/internal/reconciler/shared.go b/internal/reconciler/shared.go
index a9d1691..6c23bbb 100644
--- a/internal/reconciler/shared.go
+++ b/internal/reconciler/shared.go
@@ -7,7 +7,6 @@ import (
"github.com/Interhyp/git-hubby/api/v1alpha1"
"github.com/Interhyp/git-hubby/internal/ghclient"
"github.com/google/go-github/v86/github"
-
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v2 "k8s.io/client-go/applyconfigurations/meta/v1"
)
@@ -17,18 +16,18 @@ func IsActionsDisabledForOrgSpec(org *v1alpha1.Organization) bool {
*org.Spec.ActionsSettings.EnabledRepositories == "none"
}
-func ResolveNamesToIDsInRuleset(ctx context.Context, client ghclient.GitHubClient, orgName string, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
- installations, err := client.GetGitHubAppsInstallations(ctx, orgName) // fetch installations only once
+func ResolveNamesToIDsInRuleset(ctx context.Context, githubClient ghclient.GitHubClient, orgName string, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
+ installations, err := githubClient.GetGitHubAppsInstallations(ctx, orgName) // fetch installations only once
if err != nil {
return rs, err
}
- rs, err = resolveBypassActors(ctx, client, orgName, installations, rs)
+ rs, err = resolveBypassActors(ctx, githubClient, orgName, installations, rs)
if err != nil {
return rs, err
}
- rs, err = resolveWorkflowRepositoryNames(ctx, client, orgName, rs)
+ rs, err = resolveWorkflowRepositoryNames(ctx, githubClient, orgName, rs)
if err != nil {
return rs, err
}
@@ -39,13 +38,13 @@ func ResolveNamesToIDsInRuleset(ctx context.Context, client ghclient.GitHubClien
}
// resolveBypassActors resolves slugs/names in bypass actors to their numeric IDs.
-func resolveBypassActors(ctx context.Context, client ghclient.GitHubClient, orgName string, installations []*github.Installation, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
+func resolveBypassActors(ctx context.Context, githubClient ghclient.GitHubClient, orgName string, installations []*github.Installation, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
result := make([]v1alpha1.RulesetBypassActor, 0, len(rs.Spec.BypassActors))
for _, bypassActor := range rs.Spec.BypassActors {
actorType := github.BypassActorType(bypassActor.ActorType)
switch actorType {
case github.BypassActorTypeTeam:
- updatedActor, err := resolveBypassActor(&bypassActor, teamSlugResolver(ctx, client, orgName))
+ updatedActor, err := resolveBypassActor(&bypassActor, teamSlugResolver(ctx, githubClient, orgName))
if err != nil {
return rs, err
}
@@ -57,7 +56,7 @@ func resolveBypassActors(ctx context.Context, client ghclient.GitHubClient, orgN
}
bypassActor = *updatedActor
case github.BypassActorTypeRepositoryRole:
- updatedActor, err := resolveBypassActor(&bypassActor, repoRoleNameResolver(ctx, client, orgName))
+ updatedActor, err := resolveBypassActor(&bypassActor, repoRoleNameResolver(ctx, githubClient, orgName))
if err != nil {
return rs, err
}
@@ -76,7 +75,7 @@ func resolveBypassActors(ctx context.Context, client ghclient.GitHubClient, orgN
}
// resolveWorkflowRepositoryNames resolves RepositoryName to ResolvedRepositoryID for each workflow rule in the ruleset.
-func resolveWorkflowRepositoryNames(ctx context.Context, client ghclient.GitHubClient, orgName string, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
+func resolveWorkflowRepositoryNames(ctx context.Context, githubClient ghclient.GitHubClient, orgName string, rs v1alpha1.RulesetPreset) (v1alpha1.RulesetPreset, error) {
if rs.Spec.Rules.Workflows == nil {
return rs, nil
}
@@ -84,7 +83,7 @@ func resolveWorkflowRepositoryNames(ctx context.Context, client ghclient.GitHubC
if wf.ResolvedRepositoryID != nil {
continue
}
- repo, err := client.GetRepository(ctx, orgName, wf.RepositoryName)
+ repo, err := githubClient.GetRepository(ctx, orgName, wf.RepositoryName)
if err != nil {
return rs, fmt.Errorf("failed to resolve workflow repository %q to ID: %w", wf.RepositoryName, err)
}
@@ -149,18 +148,18 @@ func appSlugResolver(installations []*github.Installation, orgName string) slugR
}
}
-func teamSlugResolver(ctx context.Context, client ghclient.GitHubClient, orgName string) slugResolverFunc {
+func teamSlugResolver(ctx context.Context, githubClient ghclient.GitHubClient, orgName string) slugResolverFunc {
return func(slug string) (*int64, error) {
- team, err := client.GetTeamBySlug(ctx, orgName, slug)
+ team, err := githubClient.GetTeamBySlug(ctx, orgName, slug)
if err != nil {
return nil, err
}
return team.ID, nil
}
}
-func repoRoleNameResolver(ctx context.Context, client ghclient.GitHubClient, orgName string) slugResolverFunc {
+func repoRoleNameResolver(ctx context.Context, githubClient ghclient.GitHubClient, orgName string) slugResolverFunc {
return func(slug string) (*int64, error) {
- role, err := client.GetRoleByName(ctx, orgName, slug)
+ role, err := githubClient.GetRoleByName(ctx, orgName, slug)
if err != nil {
return nil, err
}
diff --git a/internal/reconciler/shared_test.go b/internal/reconciler/shared_test.go
index fdef75b..4edaf13 100644
--- a/internal/reconciler/shared_test.go
+++ b/internal/reconciler/shared_test.go
@@ -9,7 +9,6 @@ import (
"github.com/google/go-github/v86/github"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
- "k8s.io/utils/ptr"
)
var _ = Describe("ResolveNamesToIDsInRuleset", func() {
@@ -38,7 +37,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
},
Enforcement: "active",
Rules: v1alpha1.RulesetRules{
- Creation: github.Ptr(true),
+ Creation: new(true),
},
},
}
@@ -86,7 +85,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorID: ptr.To(int64(12345)),
+ ActorID: new(int64(12345)),
ActorType: "Team",
BypassMode: "always",
},
@@ -100,7 +99,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
It("should preserve the ActorID without resolution", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.BypassActors).To(HaveLen(1))
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(12345))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(12345))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("Team"))
})
@@ -114,7 +113,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("engineering-team"),
+ ActorSlug: new("engineering-team"),
ActorType: "Team",
BypassMode: "always",
},
@@ -128,9 +127,9 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(org).To(Equal(orgName))
Expect(slug).To(Equal("engineering-team"))
return &github.Team{
- ID: ptr.To(int64(98765)),
- Slug: ptr.To("engineering-team"),
- Name: ptr.To("Engineering Team"),
+ ID: new(int64(98765)),
+ Slug: new("engineering-team"),
+ Name: new("Engineering Team"),
}, nil
}
})
@@ -138,7 +137,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
It("should resolve the team slug to ActorID", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.BypassActors).To(HaveLen(1))
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(98765))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(98765))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("Team"))
})
@@ -155,7 +154,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("nonexistent-team"),
+ ActorSlug: new("nonexistent-team"),
ActorType: "Team",
BypassMode: "always",
},
@@ -180,7 +179,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("github-actions"),
+ ActorSlug: new("github-actions"),
ActorType: "Integration",
BypassMode: "pull_request",
},
@@ -189,14 +188,14 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(15368)),
- AppSlug: ptr.To("github-actions"),
+ ID: new(int64(1)),
+ AppID: new(int64(15368)),
+ AppSlug: new("github-actions"),
},
{
- ID: ptr.To(int64(2)),
- AppID: ptr.To(int64(99999)),
- AppSlug: ptr.To("other-app"),
+ ID: new(int64(2)),
+ AppID: new(int64(99999)),
+ AppSlug: new("other-app"),
},
}, nil
}
@@ -205,7 +204,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
It("should resolve the app slug to ActorID", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.BypassActors).To(HaveLen(1))
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(15368))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(15368))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("Integration"))
})
})
@@ -214,7 +213,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("nonexistent-app"),
+ ActorSlug: new("nonexistent-app"),
ActorType: "Integration",
BypassMode: "always",
},
@@ -223,9 +222,9 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(15368)),
- AppSlug: ptr.To("github-actions"),
+ ID: new(int64(1)),
+ AppID: new(int64(15368)),
+ AppSlug: new("github-actions"),
},
}, nil
}
@@ -242,7 +241,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("maintain"),
+ ActorSlug: new("maintain"),
ActorType: "RepositoryRole",
BypassMode: "always",
},
@@ -256,8 +255,8 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(org).To(Equal(orgName))
Expect(roleName).To(Equal("maintain"))
return &github.CustomOrgRole{
- ID: ptr.To(int64(54321)),
- Name: ptr.To("maintain"),
+ ID: new(int64(54321)),
+ Name: new("maintain"),
}, nil
}
})
@@ -265,7 +264,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
It("should resolve the role slug to ActorID", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.BypassActors).To(HaveLen(1))
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(54321))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(54321))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("RepositoryRole"))
})
@@ -282,7 +281,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("nonexistent-role"),
+ ActorSlug: new("nonexistent-role"),
ActorType: "RepositoryRole",
BypassMode: "always",
},
@@ -307,7 +306,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("some-slug"),
+ ActorSlug: new("some-slug"),
ActorType: "OrganizationAdmin",
BypassMode: "always",
},
@@ -356,7 +355,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
{
ActorType: "DeployKey",
BypassMode: "always",
- ActorID: github.Ptr(int64(12354)),
+ ActorID: new(int64(12354)),
},
}
@@ -400,7 +399,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
})
Context("when bypass actor is EnterpriseOwner with any ActorID", func() {
- actorID := github.Ptr(int64(84354))
+ actorID := new(int64(84354))
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
@@ -513,7 +512,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorID: ptr.To(int64(99999)), // API requires this to be null for DeployKey
+ ActorID: new(int64(99999)), // API requires this to be null for DeployKey
ActorType: "DeployKey",
BypassMode: "always",
},
@@ -537,7 +536,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("some-slug"), // API requires this to be null for DeployKey
+ ActorSlug: new("some-slug"), // API requires this to be null for DeployKey
ActorType: "DeployKey",
BypassMode: "always",
},
@@ -561,22 +560,22 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorID: ptr.To(int64(111)),
+ ActorID: new(int64(111)),
ActorType: "Team",
BypassMode: "always",
},
{
- ActorSlug: ptr.To("security-team"),
+ ActorSlug: new("security-team"),
ActorType: "Team",
BypassMode: "pull_request",
},
{
- ActorSlug: ptr.To("renovate"),
+ ActorSlug: new("renovate"),
ActorType: "Integration",
BypassMode: "always",
},
{
- ActorSlug: ptr.To("admin"),
+ ActorSlug: new("admin"),
ActorType: "RepositoryRole",
BypassMode: "always",
},
@@ -585,9 +584,9 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(10)),
- AppID: ptr.To(int64(29)),
- AppSlug: ptr.To("renovate"),
+ ID: new(int64(10)),
+ AppID: new(int64(29)),
+ AppSlug: new("renovate"),
},
}, nil
}
@@ -595,8 +594,8 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
if slug == "security-team" {
return &github.Team{
- ID: ptr.To(int64(222)),
- Slug: ptr.To("security-team"),
+ ID: new(int64(222)),
+ Slug: new("security-team"),
}, nil
}
return nil, errors.New("team not found")
@@ -605,8 +604,8 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetRoleByNameFunc = func(ctx context.Context, org string, roleName string) (*github.CustomOrgRole, error) {
if roleName == "admin" {
return &github.CustomOrgRole{
- ID: ptr.To(int64(333)),
- Name: ptr.To("admin"),
+ ID: new(int64(333)),
+ Name: new("admin"),
}, nil
}
return nil, errors.New("role not found")
@@ -618,19 +617,19 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(result.Spec.BypassActors).To(HaveLen(4))
// First actor - already has ID
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(111))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(111))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("Team"))
// Second actor - team slug resolved
- Expect(result.Spec.BypassActors[1].ActorID).To(Equal(ptr.To(int64(222))))
+ Expect(result.Spec.BypassActors[1].ActorID).To(Equal(new(int64(222))))
Expect(result.Spec.BypassActors[1].ActorType).To(Equal("Team"))
// Third actor - integration slug resolved
- Expect(result.Spec.BypassActors[2].ActorID).To(Equal(ptr.To(int64(29))))
+ Expect(result.Spec.BypassActors[2].ActorID).To(Equal(new(int64(29))))
Expect(result.Spec.BypassActors[2].ActorType).To(Equal("Integration"))
// Fourth actor - role slug resolved
- Expect(result.Spec.BypassActors[3].ActorID).To(Equal(ptr.To(int64(333))))
+ Expect(result.Spec.BypassActors[3].ActorID).To(Equal(new(int64(333))))
Expect(result.Spec.BypassActors[3].ActorType).To(Equal("RepositoryRole"))
})
@@ -646,7 +645,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("platform-team"),
+ ActorSlug: new("platform-team"),
ActorType: "Team",
BypassMode: "always",
},
@@ -659,7 +658,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BypassMode: "pull_request",
},
{
- ActorSlug: ptr.To("dependabot"),
+ ActorSlug: new("dependabot"),
ActorType: "Integration",
BypassMode: "always",
},
@@ -672,9 +671,9 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(29110)),
- AppSlug: ptr.To("dependabot"),
+ ID: new(int64(1)),
+ AppID: new(int64(29110)),
+ AppSlug: new("dependabot"),
},
}, nil
}
@@ -682,8 +681,8 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
if slug == "platform-team" {
return &github.Team{
- ID: ptr.To(int64(444)),
- Slug: ptr.To("platform-team"),
+ ID: new(int64(444)),
+ Slug: new("platform-team"),
}, nil
}
return nil, errors.New("team not found")
@@ -695,7 +694,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(result.Spec.BypassActors).To(HaveLen(5))
// First actor - team slug resolved
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(444))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(444))))
Expect(result.Spec.BypassActors[0].ActorType).To(Equal("Team"))
// Second actor - DeployKey with no ActorID/ActorSlug
@@ -711,7 +710,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(result.Spec.BypassActors[2].BypassMode).To(Equal("pull_request"))
// Fourth actor - integration slug resolved
- Expect(result.Spec.BypassActors[3].ActorID).To(Equal(ptr.To(int64(29110))))
+ Expect(result.Spec.BypassActors[3].ActorID).To(Equal(new(int64(29110))))
Expect(result.Spec.BypassActors[3].ActorType).To(Equal("Integration"))
// Fifth actor - EnterpriseOwner with no ActorID/ActorSlug
@@ -728,10 +727,10 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Checks: []v1alpha1.StatusCheck{
{
Context: "ci/build",
- IntegrationID: ptr.To(int64(77777)),
+ IntegrationID: new(int64(77777)),
},
},
- StrictPolicy: github.Ptr(true),
+ StrictPolicy: new(true),
}
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
@@ -743,7 +742,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.Rules.RequiredStatusChecks).NotTo(BeNil())
Expect(result.Spec.Rules.RequiredStatusChecks.Checks).To(HaveLen(1))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(ptr.To(int64(77777))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(new(int64(77777))))
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].Context).To(Equal("ci/build"))
})
})
@@ -754,23 +753,23 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Checks: []v1alpha1.StatusCheck{
{
Context: "ci/build",
- AppSlug: ptr.To("circleci"),
+ AppSlug: new("circleci"),
},
},
- StrictPolicy: github.Ptr(false),
+ StrictPolicy: new(false),
}
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(5)),
- AppID: ptr.To(int64(12345)),
- AppSlug: ptr.To("circleci"),
+ ID: new(int64(5)),
+ AppID: new(int64(12345)),
+ AppSlug: new("circleci"),
},
{
- ID: ptr.To(int64(6)),
- AppID: ptr.To(int64(67890)),
- AppSlug: ptr.To("jenkins"),
+ ID: new(int64(6)),
+ AppID: new(int64(67890)),
+ AppSlug: new("jenkins"),
},
}, nil
}
@@ -780,7 +779,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Expect(err).NotTo(HaveOccurred())
Expect(result.Spec.Rules.RequiredStatusChecks).NotTo(BeNil())
Expect(result.Spec.Rules.RequiredStatusChecks.Checks).To(HaveLen(1))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(ptr.To(int64(12345))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(new(int64(12345))))
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].Context).To(Equal("ci/build"))
})
})
@@ -791,7 +790,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Checks: []v1alpha1.StatusCheck{
{
Context: "ci/build",
- AppSlug: ptr.To("nonexistent-ci"),
+ AppSlug: new("nonexistent-ci"),
},
},
}
@@ -799,9 +798,9 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(100)),
- AppSlug: ptr.To("other-app"),
+ ID: new(int64(1)),
+ AppID: new(int64(100)),
+ AppSlug: new("other-app"),
},
}, nil
}
@@ -846,34 +845,34 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Checks: []v1alpha1.StatusCheck{
{
Context: "ci/build",
- IntegrationID: ptr.To(int64(999)),
+ IntegrationID: new(int64(999)),
},
{
Context: "ci/test",
- AppSlug: ptr.To("github-actions"),
+ AppSlug: new("github-actions"),
},
{
Context: "ci/lint",
},
{
Context: "ci/security",
- AppSlug: ptr.To("snyk"),
+ AppSlug: new("snyk"),
},
},
- StrictPolicy: github.Ptr(true),
+ StrictPolicy: new(true),
}
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(15368)),
- AppSlug: ptr.To("github-actions"),
+ ID: new(int64(1)),
+ AppID: new(int64(15368)),
+ AppSlug: new("github-actions"),
},
{
- ID: ptr.To(int64(2)),
- AppID: ptr.To(int64(24680)),
- AppSlug: ptr.To("snyk"),
+ ID: new(int64(2)),
+ AppID: new(int64(24680)),
+ AppSlug: new("snyk"),
},
}, nil
}
@@ -886,11 +885,11 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
// First check - already has IntegrationID
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].Context).To(Equal("ci/build"))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(ptr.To(int64(999))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(new(int64(999))))
// Second check - AppSlug resolved
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[1].Context).To(Equal("ci/test"))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[1].IntegrationID).To(Equal(ptr.To(int64(15368))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[1].IntegrationID).To(Equal(new(int64(15368))))
// Third check - no integration
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[2].Context).To(Equal("ci/lint"))
@@ -898,7 +897,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
// Fourth check - AppSlug resolved
Expect(result.Spec.Rules.RequiredStatusChecks.Checks[3].Context).To(Equal("ci/security"))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[3].IntegrationID).To(Equal(ptr.To(int64(24680))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[3].IntegrationID).To(Equal(new(int64(24680))))
})
})
@@ -906,7 +905,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
BeforeEach(func() {
rulesetInput.Spec.BypassActors = []v1alpha1.RulesetBypassActor{
{
- ActorSlug: ptr.To("dependabot"),
+ ActorSlug: new("dependabot"),
ActorType: "Integration",
BypassMode: "always",
},
@@ -915,7 +914,7 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
Checks: []v1alpha1.StatusCheck{
{
Context: "ci/build",
- AppSlug: ptr.To("github-actions"),
+ AppSlug: new("github-actions"),
},
},
}
@@ -923,14 +922,14 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
mockClient.GetGitHubAppsInstallationsFunc = func(ctx context.Context, org string) ([]*github.Installation, error) {
return []*github.Installation{
{
- ID: ptr.To(int64(1)),
- AppID: ptr.To(int64(29110)),
- AppSlug: ptr.To("dependabot"),
+ ID: new(int64(1)),
+ AppID: new(int64(29110)),
+ AppSlug: new("dependabot"),
},
{
- ID: ptr.To(int64(2)),
- AppID: ptr.To(int64(15368)),
- AppSlug: ptr.To("github-actions"),
+ ID: new(int64(2)),
+ AppID: new(int64(15368)),
+ AppSlug: new("github-actions"),
},
}, nil
}
@@ -941,12 +940,12 @@ var _ = Describe("ResolveNamesToIDsInRuleset", func() {
// Check bypass actor
Expect(result.Spec.BypassActors).To(HaveLen(1))
- Expect(result.Spec.BypassActors[0].ActorID).To(Equal(ptr.To(int64(29110))))
+ Expect(result.Spec.BypassActors[0].ActorID).To(Equal(new(int64(29110))))
// Check status check
Expect(result.Spec.Rules.RequiredStatusChecks).NotTo(BeNil())
Expect(result.Spec.Rules.RequiredStatusChecks.Checks).To(HaveLen(1))
- Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(ptr.To(int64(15368))))
+ Expect(result.Spec.Rules.RequiredStatusChecks.Checks[0].IntegrationID).To(Equal(new(int64(15368))))
})
It("should only fetch installations once", func() {
diff --git a/internal/reconciler/teamrec/multi_org_test.go b/internal/reconciler/teamrec/multi_org_test.go
index 027e1b2..624a1ca 100644
--- a/internal/reconciler/teamrec/multi_org_test.go
+++ b/internal/reconciler/teamrec/multi_org_test.go
@@ -59,7 +59,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
},
@@ -75,12 +75,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 already has the team
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -108,7 +108,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -174,7 +174,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
},
@@ -190,12 +190,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 already has the team
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -229,7 +229,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -293,7 +293,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
},
@@ -308,12 +308,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -333,7 +333,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -390,7 +390,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -411,7 +411,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -479,7 +479,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -505,7 +505,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -574,7 +574,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -595,7 +595,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -673,7 +673,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -730,7 +730,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -747,7 +747,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -811,7 +811,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -828,7 +828,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1006,7 +1006,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -1023,12 +1023,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 - team exists with old description, update succeeds
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Old description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Old description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -1046,12 +1046,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org2 - team exists with old description, update fails
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Old description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Old description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -1062,7 +1062,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1130,7 +1130,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -1158,7 +1158,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1232,7 +1232,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
PreviousOrganizationRefs: []v1alpha1.OrganizationRef{
{Name: "org1"},
{Name: "org2"},
@@ -1249,12 +1249,12 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 - already exists, no change needed
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -1280,7 +1280,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1357,7 +1357,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
},
}
@@ -1369,8 +1369,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -1380,8 +1380,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -1392,7 +1392,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1448,7 +1448,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
},
}
@@ -1461,8 +1461,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 deletion succeeds
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -1473,8 +1473,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org2 deletion fails
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -1485,7 +1485,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1544,7 +1544,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
},
}
@@ -1557,8 +1557,8 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
// org1 - team exists and should be deleted
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -1574,7 +1574,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -1631,7 +1631,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
},
},
Status: v1alpha1.TeamStatus{
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
},
}
@@ -1648,7 +1648,7 @@ var _ = Describe("Multi-Organization Team Scenarios", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/rec_idpgroup.go b/internal/reconciler/teamrec/rec_idpgroup.go
index 7b2e503..831845d 100644
--- a/internal/reconciler/teamrec/rec_idpgroup.go
+++ b/internal/reconciler/teamrec/rec_idpgroup.go
@@ -3,8 +3,10 @@ package teamrec
import (
"context"
+ githubv1alpha1 "github.com/Interhyp/git-hubby/api/v1alpha1"
"github.com/Interhyp/git-hubby/internal/reconciler"
"github.com/google/go-github/v86/github"
+ "sigs.k8s.io/controller-runtime/pkg/client"
logPkg "sigs.k8s.io/controller-runtime/pkg/log"
)
@@ -17,6 +19,20 @@ func (t *GitHubTeamReconciler) reconcileIDPGroup(ctx context.Context) error {
return nil // nothing to do
}
for _, githubOrg := range t.Team.Organizations.Current {
+ var org githubv1alpha1.Organization
+ if err := t.Kubernetes.Client.Get(ctx, client.ObjectKey{
+ Name: githubOrg.Resource,
+ Namespace: t.Kubernetes.Resource.Namespace,
+ }, &org); err != nil {
+ log.Error(err, "unable to fetch Organization for Team IDP group", "organization", githubOrg.Resource)
+ continue
+ }
+
+ if org.GetPlan() != githubv1alpha1.PlanEnterprise {
+ log.V(1).Info("Skipping IDP team group settings for organization because plan does not support it",
+ "organization", githubOrg.Resource, "plan", org.GetPlan())
+ continue
+ }
err := t.reconcileIDPGroupForOrg(ctx, githubOrg)
if err != nil {
return err
diff --git a/internal/reconciler/teamrec/rec_idpgroup_test.go b/internal/reconciler/teamrec/rec_idpgroup_test.go
index 1a5ec81..94f9013 100644
--- a/internal/reconciler/teamrec/rec_idpgroup_test.go
+++ b/internal/reconciler/teamrec/rec_idpgroup_test.go
@@ -53,9 +53,30 @@ var _ = Describe("ReconcileIDPGroup", func() {
},
}
+ // Create Organization objects that the IDP group reconciliation will fetch
+ org1 := &v1alpha1.Organization{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "org1",
+ Namespace: "default",
+ },
+ Spec: v1alpha1.OrganizationSpec{
+ Plan: v1alpha1.PlanEnterprise,
+ },
+ }
+
+ org2 := &v1alpha1.Organization{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "org2",
+ Namespace: "default",
+ },
+ Spec: v1alpha1.OrganizationSpec{
+ Plan: v1alpha1.PlanEnterprise,
+ },
+ }
+
k8sClient = fake.NewClientBuilder().
WithScheme(scheme).
- WithObjects(team).
+ WithObjects(team, org1, org2).
WithStatusSubresource(team).
Build()
})
@@ -68,7 +89,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -99,7 +120,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(12345)),
+ GroupID: new(int64(12345)),
GroupName: &groupName,
},
}, nil
@@ -108,7 +129,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -152,7 +173,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -199,7 +220,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -238,7 +259,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -276,7 +297,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -320,7 +341,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -351,7 +372,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(99999)),
+ GroupID: new(int64(99999)),
GroupName: &otherGroupName,
},
}, nil
@@ -367,7 +388,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -407,7 +428,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(12345)),
+ GroupID: new(int64(12345)),
GroupName: &groupName,
},
}, nil
@@ -426,7 +447,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -473,11 +494,11 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(99999)),
+ GroupID: new(int64(99999)),
GroupName: &otherGroupName,
},
{
- GroupID: github.Ptr(int64(12345)),
+ GroupID: new(int64(12345)),
GroupName: &groupName,
},
}, nil
@@ -493,7 +514,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -526,7 +547,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(99999)),
+ GroupID: new(int64(99999)),
GroupName: nil, // nil group name
},
}, nil
@@ -541,7 +562,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -574,7 +595,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{},
},
@@ -605,7 +626,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
mockClient1.GetExternalGroupsForTeamBySlugFunc = func(ctx context.Context, org string, slug string) ([]*github.ExternalGroup, error) {
return []*github.ExternalGroup{
{
- GroupID: github.Ptr(int64(12345)),
+ GroupID: new(int64(12345)),
GroupName: &groupName,
},
}, nil
@@ -624,7 +645,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -675,7 +696,7 @@ var _ = Describe("ReconcileIDPGroup", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/rec_members_test.go b/internal/reconciler/teamrec/rec_members_test.go
index c6cdb46..f681789 100644
--- a/internal/reconciler/teamrec/rec_members_test.go
+++ b/internal/reconciler/teamrec/rec_members_test.go
@@ -71,7 +71,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -104,15 +104,15 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -150,15 +150,15 @@ var _ = Describe("ReconcileTeamMembers", func() {
BeforeEach(func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -193,17 +193,17 @@ var _ = Describe("ReconcileTeamMembers", func() {
BeforeEach(func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
- {Login: github.Ptr("user3")},
- {Login: github.Ptr("user4")},
+ {Login: new("user1")},
+ {Login: new("user2")},
+ {Login: new("user3")},
+ {Login: new("user4")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -243,21 +243,21 @@ var _ = Describe("ReconcileTeamMembers", func() {
BeforeEach(func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
+ {Login: new("user1")},
}, nil
}
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -299,14 +299,14 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
// Only user1 exists in the org
return []*github.User{
- {Login: github.Ptr("user1")},
+ {Login: new("user1")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -350,7 +350,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -388,7 +388,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -421,7 +421,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
+ {Login: new("user1")},
}, nil
}
@@ -432,7 +432,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -461,8 +461,8 @@ var _ = Describe("ReconcileTeamMembers", func() {
BeforeEach(func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user3")},
+ {Login: new("user1")},
+ {Login: new("user3")},
}, nil
}
@@ -473,7 +473,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -508,15 +508,15 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1@example.com")},
- {Login: github.Ptr("user2@example.com")},
+ {Login: new("user1@example.com")},
+ {Login: new("user2@example.com")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -560,28 +560,28 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
+ {Login: new("user1")},
}, nil
}
mockClient1.ListMembersFunc = func(ctx context.Context, org string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
mockClient2.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -640,15 +640,15 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
- {Login: github.Ptr("user1")},
- {Login: github.Ptr("user2")},
+ {Login: new("user1")},
+ {Login: new("user2")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -686,14 +686,14 @@ var _ = Describe("ReconcileTeamMembers", func() {
mockClient1.GetAllTeamMembersFunc = func(ctx context.Context, org string, slug string) ([]*github.User, error) {
return []*github.User{
{Login: nil},
- {Login: github.Ptr("user1")},
+ {Login: new("user1")},
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -730,7 +730,7 @@ var _ = Describe("ReconcileTeamMembers", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/rec_refcleanup_test.go b/internal/reconciler/teamrec/rec_refcleanup_test.go
index aa0ce5a..7c1e39e 100644
--- a/internal/reconciler/teamrec/rec_refcleanup_test.go
+++ b/internal/reconciler/teamrec/rec_refcleanup_test.go
@@ -72,7 +72,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -150,7 +150,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -232,7 +232,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -320,7 +320,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -399,7 +399,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -463,7 +463,7 @@ var _ = Describe("ReconcileRemovedOrgRefs", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/rec_role_assignments_test.go b/internal/reconciler/teamrec/rec_role_assignments_test.go
index bddbaa1..d5670e3 100644
--- a/internal/reconciler/teamrec/rec_role_assignments_test.go
+++ b/internal/reconciler/teamrec/rec_role_assignments_test.go
@@ -63,9 +63,9 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
// GetAllOrgRoles returns available roles
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(1))},
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(2))},
- {Name: github.Ptr("custom_role"), ID: github.Ptr(int64(3))},
+ {Name: new("all_repo_read"), ID: new(int64(1))},
+ {Name: new("all_repo_write"), ID: new(int64(2))},
+ {Name: new("custom_role"), ID: new(int64(3))},
}, nil
}
@@ -77,7 +77,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -114,7 +114,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
BeforeEach(func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(2))},
+ {Name: new("all_repo_write"), ID: new(int64(2))},
}, nil
}
@@ -126,7 +126,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -170,10 +170,10 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(1))},
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(2))},
- {Name: github.Ptr("custom_role_1"), ID: github.Ptr(int64(3))},
- {Name: github.Ptr("custom_role_2"), ID: github.Ptr(int64(4))},
+ {Name: new("all_repo_read"), ID: new(int64(1))},
+ {Name: new("all_repo_write"), ID: new(int64(2))},
+ {Name: new("custom_role_1"), ID: new(int64(3))},
+ {Name: new("custom_role_2"), ID: new(int64(4))},
}, nil
}
@@ -186,7 +186,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -225,9 +225,9 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("custom_role_1"), ID: github.Ptr(int64(1))},
- {Name: github.Ptr("custom_role_2"), ID: github.Ptr(int64(2))},
- {Name: github.Ptr("custom_role_3"), ID: github.Ptr(int64(3))},
+ {Name: new("custom_role_1"), ID: new(int64(1))},
+ {Name: new("custom_role_2"), ID: new(int64(2))},
+ {Name: new("custom_role_3"), ID: new(int64(3))},
}, nil
}
@@ -245,7 +245,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -284,7 +284,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("custom_role_1"), ID: github.Ptr(int64(1))},
+ {Name: new("custom_role_1"), ID: new(int64(1))},
}, nil
}
@@ -296,7 +296,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -340,8 +340,8 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
// Setup for org1
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(1))},
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(2))},
+ {Name: new("all_repo_read"), ID: new(int64(1))},
+ {Name: new("all_repo_write"), ID: new(int64(2))},
}, nil
}
mockClient1.GetAllTeamsAssignedToOrgRoleFunc = func(ctx context.Context, org string, role string) ([]string, error) {
@@ -351,8 +351,8 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
// Setup for org2
mockClient2.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(10))},
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(20))},
+ {Name: new("all_repo_read"), ID: new(int64(10))},
+ {Name: new("all_repo_write"), ID: new(int64(20))},
}, nil
}
mockClient2.GetAllTeamsAssignedToOrgRoleFunc = func(ctx context.Context, org string, role string) ([]string, error) {
@@ -362,7 +362,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -420,7 +420,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -449,7 +449,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
BeforeEach(func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(1))},
+ {Name: new("all_repo_read"), ID: new(int64(1))},
}, nil
}
@@ -461,7 +461,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -492,7 +492,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(1))},
+ {Name: new("all_repo_write"), ID: new(int64(1))},
}, nil
}
@@ -508,7 +508,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -539,7 +539,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("custom_role"), ID: github.Ptr(int64(1))},
+ {Name: new("custom_role"), ID: new(int64(1))},
}, nil
}
@@ -556,7 +556,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -585,9 +585,9 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
BeforeEach(func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("all_repo_read"), ID: github.Ptr(int64(1))},
- {Name: nil, ID: github.Ptr(int64(2))}, // nil name should be skipped
- {Name: github.Ptr("all_repo_write"), ID: github.Ptr(int64(3))},
+ {Name: new("all_repo_read"), ID: new(int64(1))},
+ {Name: nil, ID: new(int64(2))}, // nil name should be skipped
+ {Name: new("all_repo_write"), ID: new(int64(3))},
nil, // nil role should be skipped
}, nil
}
@@ -600,7 +600,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -639,7 +639,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
mockClient1.GetAllOrgRolesFunc = func(ctx context.Context, org string) ([]*github.CustomOrgRole, error) {
return []*github.CustomOrgRole{
- {Name: github.Ptr("some_role"), ID: github.Ptr(int64(1))},
+ {Name: new("some_role"), ID: new(int64(1))},
}, nil
}
@@ -650,7 +650,7 @@ var _ = Describe("ReconcileTeamRoleAssignments", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/rec_team_test.go b/internal/reconciler/teamrec/rec_team_test.go
index fe51540..9f82704 100644
--- a/internal/reconciler/teamrec/rec_team_test.go
+++ b/internal/reconciler/teamrec/rec_team_test.go
@@ -85,7 +85,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -119,19 +119,19 @@ var _ = Describe("ReconcileTeam", func() {
// Team has a custom description "Test team description", so that's what should be used
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -164,12 +164,12 @@ var _ = Describe("ReconcileTeam", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Old description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Old description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -187,7 +187,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -221,12 +221,12 @@ var _ = Describe("ReconcileTeam", func() {
expectedDescription := "⚠️ To join the team, create a pull request here: https://github.com/org1/github-configuration-deployment/blob/main/teams/test-team.yaml"
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
Description: &expectedDescription,
- Privacy: github.Ptr("secret"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Privacy: new("secret"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -244,7 +244,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -277,12 +277,12 @@ var _ = Describe("ReconcileTeam", func() {
expectedDescription := "⚠️ To join the team, create a pull request here: https://github.com/org1/github-configuration-deployment/blob/main/teams/test-team.yaml"
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
Description: &expectedDescription,
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("push"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Privacy: new("closed"),
+ Permission: new("push"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
mockClient1.EditTeamBySlugFunc = func(ctx context.Context, org string, slug string, newTeam *github.NewTeam) (*github.Team, error) {
@@ -299,7 +299,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -332,12 +332,12 @@ var _ = Describe("ReconcileTeam", func() {
expectedDescription := "⚠️ To join the team, create a pull request here: https://github.com/org1/github-configuration-deployment/blob/main/teams/test-team.yaml"
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
Description: &expectedDescription,
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_enabled"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_enabled"),
}, nil
}
@@ -355,7 +355,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -392,7 +392,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -435,7 +435,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -464,12 +464,12 @@ var _ = Describe("ReconcileTeam", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Old description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Old description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -480,7 +480,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -515,23 +515,23 @@ var _ = Describe("ReconcileTeam", func() {
// Team has custom description "Test team description", so that's what should be used
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Old description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Old description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -549,7 +549,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -596,19 +596,19 @@ var _ = Describe("ReconcileTeam", func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -641,19 +641,19 @@ var _ = Describe("ReconcileTeam", func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr(""),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new(""),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -685,7 +685,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{},
},
@@ -709,8 +709,8 @@ var _ = Describe("ReconcileTeam", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
// All other fields are nil
}, nil
}
@@ -729,7 +729,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -767,12 +767,12 @@ var _ = Describe("ReconcileTeam", func() {
// Team has custom description "Test team description"
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
- Description: github.Ptr("Test team description"),
- Privacy: github.Ptr("closed"),
- Permission: github.Ptr("pull"),
- NotificationSetting: github.Ptr("notifications_disabled"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
+ Description: new("Test team description"),
+ Privacy: new("closed"),
+ Permission: new("pull"),
+ NotificationSetting: new("notifications_disabled"),
}, nil
}
@@ -783,7 +783,7 @@ var _ = Describe("ReconcileTeam", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
diff --git a/internal/reconciler/teamrec/reconciler_test.go b/internal/reconciler/teamrec/reconciler_test.go
index 59bcd1a..1b99219 100644
--- a/internal/reconciler/teamrec/reconciler_test.go
+++ b/internal/reconciler/teamrec/reconciler_test.go
@@ -68,8 +68,8 @@ var _ = Describe("ReconcileDeletion", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -80,7 +80,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -116,8 +116,8 @@ var _ = Describe("ReconcileDeletion", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -127,8 +127,8 @@ var _ = Describe("ReconcileDeletion", func() {
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -139,7 +139,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -193,7 +193,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -229,7 +229,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -265,7 +265,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -297,8 +297,8 @@ var _ = Describe("ReconcileDeletion", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -309,7 +309,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -341,8 +341,8 @@ var _ = Describe("ReconcileDeletion", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -352,8 +352,8 @@ var _ = Describe("ReconcileDeletion", func() {
mockClient2.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr("test-team"),
+ Name: new("test-team"),
+ Slug: new("test-team"),
}, nil
}
@@ -364,7 +364,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -404,8 +404,8 @@ var _ = Describe("ReconcileDeletion", func() {
BeforeEach(func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
return &github.Team{
- Name: github.Ptr("Test Team"),
- Slug: github.Ptr("test-team"),
+ Name: new("Test Team"),
+ Slug: new("test-team"),
}, nil
}
@@ -417,7 +417,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "Test Team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -451,8 +451,8 @@ var _ = Describe("ReconcileDeletion", func() {
mockClient1.GetTeamBySlugFunc = func(ctx context.Context, org string, slug string) (*github.Team, error) {
Expect(slug).To(Equal(""))
return &github.Team{
- Name: github.Ptr("test-team"),
- Slug: github.Ptr(""),
+ Name: new("test-team"),
+ Slug: new(""),
}, nil
}
@@ -463,7 +463,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr(""),
+ Slug: new(""),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{
{
@@ -497,7 +497,7 @@ var _ = Describe("ReconcileDeletion", func() {
rec = &GitHubTeamReconciler{
Team: reconciler.GitHubTeamIdentifier{
Name: "test-team",
- Slug: github.Ptr("test-team"),
+ Slug: new("test-team"),
Organizations: reconciler.ReferencedOrganizations{
Current: []reconciler.GitHub[string]{},
},
@@ -514,3 +514,43 @@ var _ = Describe("ReconcileDeletion", func() {
})
})
})
+
+var _ = Describe("RequiredReconciliations", func() {
+ var (
+ rec *GitHubTeamReconciler
+ team *v1alpha1.Team
+ scheme *runtime.Scheme
+ )
+
+ BeforeEach(func() {
+ scheme = runtime.NewScheme()
+ Expect(v1alpha1.AddToScheme(scheme)).To(Succeed())
+
+ team = &v1alpha1.Team{
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "test-team",
+ Namespace: "default",
+ },
+ Spec: v1alpha1.TeamSpec{
+ Name: "test-team",
+ Members: []string{"user1"},
+ OrganizationRefs: []v1alpha1.OrganizationRef{
+ {Name: "my-org"},
+ },
+ },
+ }
+ })
+
+ It("should always return a static list with all reconcilers including IDP group", func() {
+ rec = &GitHubTeamReconciler{
+ Kubernetes: reconciler.Kubernetes[*v1alpha1.Team]{
+ Client: fake.NewClientBuilder().WithScheme(scheme).WithObjects(team).Build(),
+ Resource: team,
+ },
+ }
+ groups := rec.RequiredReconciliations()
+ Expect(groups).To(HaveLen(2))
+ // Second group should have 4 reconcilers (IDP plan check is inside reconcileIDPGroup)
+ Expect(groups[1]).To(HaveLen(4))
+ })
+})
diff --git a/internal/webhook/v1alpha1/organization_webhook.go b/internal/webhook/v1alpha1/organization_webhook.go
index c62831e..5dc12d4 100644
--- a/internal/webhook/v1alpha1/organization_webhook.go
+++ b/internal/webhook/v1alpha1/organization_webhook.go
@@ -81,6 +81,8 @@ func validateOrganization(organization *githubv1alpha1.Organization) error {
customPropertiesField := field.NewPath("spec").Child("customProperties")
allErrs = validateCustomProperties(organization.Spec.CustomProperties, customPropertiesField)
+ allErrs = append(allErrs, validatePlanFeatureCombinations(organization)...)
+
if len(allErrs) == 0 {
return nil
}
@@ -89,6 +91,34 @@ func validateOrganization(organization *githubv1alpha1.Organization) error {
organization.Name, allErrs)
}
+func validatePlanFeatureCombinations(organization *githubv1alpha1.Organization) field.ErrorList {
+ plan := organization.Spec.Plan
+ if plan == "" || plan == githubv1alpha1.PlanEnterprise {
+ return nil
+ }
+
+ var errs field.ErrorList
+ specPath := field.NewPath("spec")
+
+ // Rulesets are available on 'team' and 'enterprise' plans
+ if plan != githubv1alpha1.PlanTeam && len(organization.Spec.RulesetPresetList) > 0 {
+ errs = append(errs, field.Forbidden(
+ specPath.Child("rulesetPresets"),
+ fmt.Sprintf("organization rulesets require the 'enterprise' or 'team' plan, but plan is '%s'", plan),
+ ))
+ }
+
+ // Code security configurations are only available on the 'enterprise' plan
+ if len(organization.Spec.CodeSecurityConfigurations) > 0 {
+ errs = append(errs, field.Forbidden(
+ specPath.Child("codeSecurityConfigurations"),
+ fmt.Sprintf("code security configurations require the 'enterprise' plan, but plan is '%s'", plan),
+ ))
+ }
+
+ return errs
+}
+
func validateCustomProperties(customProperties []githubv1alpha1.OrgCustomProperty, customPropertiesField *field.Path) field.ErrorList {
errs := make([]*field.Error, 0, 1)
seen := make(map[string]any)
diff --git a/internal/webhook/v1alpha1/organization_webhook_test.go b/internal/webhook/v1alpha1/organization_webhook_test.go
index 4678665..923de4d 100644
--- a/internal/webhook/v1alpha1/organization_webhook_test.go
+++ b/internal/webhook/v1alpha1/organization_webhook_test.go
@@ -18,8 +18,9 @@ package v1alpha1
import (
"context"
+ stderrors "errors"
- "github.com/google/go-github/v86/github"
+ v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -88,7 +89,7 @@ var _ = Describe("Organization Webhook", func() {
Context("Custom Properties Validation", func() {
It("Should allow valid string type custom property", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("test-value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("test-value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
PropertyName: "test-prop",
@@ -105,7 +106,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should allow valid single_select custom property", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -143,7 +144,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should allow valid true_false custom property", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("true")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("true")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -161,7 +162,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject single_select without allowed_values", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -201,7 +202,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject string type with allowed_values", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("test-value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("test-value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -238,7 +239,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject non-required property with default_value", func() {
required := false
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("should-not-be-here")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("should-not-be-here")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -257,7 +258,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject duplicate property names", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("test-value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("test-value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -282,7 +283,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject invalid true_false default value", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("invalid-bool")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("invalid-bool")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -301,7 +302,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject single_select with invalid default value", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("invalid-option")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("invalid-option")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
PropertyName: "test-select",
@@ -340,7 +341,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject multi_select with single value instead of array", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -380,7 +381,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject empty allowed_values for single_select", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -414,7 +415,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should validate property name pattern with special characters", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("value")}
// Valid property names with special characters
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
@@ -451,7 +452,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should handle multiple validation errors at once", func() {
required := true
- invalidDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("invalid")}
+ invalidDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("invalid")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -485,7 +486,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify field paths in error messages for invalid bool", func() {
required := true
- invalidBool := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("not-a-bool")}
+ invalidBool := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("not-a-bool")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -507,7 +508,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify field paths for duplicate property names", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -535,7 +536,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify field paths for missing allowed_values", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("option1")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("option1")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -556,7 +557,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify field paths for invalid allowed_values usage", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -578,7 +579,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify error message for single_select with invalid default", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("invalid-option")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("invalid-option")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -644,7 +645,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should allow description field in custom properties", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("value")}
description := "A test property"
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
@@ -664,9 +665,9 @@ var _ = Describe("Organization Webhook", func() {
It("Should validate all value types in one organization", func() {
required := true
- stringDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("string-value")}
- boolDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("true")}
- singleSelectDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("opt1")}
+ stringDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("string-value")}
+ boolDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("true")}
+ singleSelectDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("opt1")}
multiSelectDefault := githubv1alpha1.OrgCustomPropertyDefaultValue{Values: []string{"opt1", "opt2"}}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
@@ -705,7 +706,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should allow 'false' as valid true_false default value", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("false")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("false")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -723,7 +724,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should reject true_false with case-incorrect values", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("True")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("True")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -764,7 +765,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify field paths for non-required with default", func() {
required := false
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("should-not-be-here")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("should-not-be-here")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -804,7 +805,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should verify error message contains property name context", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("invalid-bool")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("invalid-bool")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -841,7 +842,7 @@ var _ = Describe("Organization Webhook", func() {
It("Should validate updated custom properties", func() {
required := true
- defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: github.Ptr("updated-value")}
+ defaultValue := githubv1alpha1.OrgCustomPropertyDefaultValue{Value: new("updated-value")}
obj.Spec.CustomProperties = []githubv1alpha1.OrgCustomProperty{
{
@@ -873,4 +874,100 @@ var _ = Describe("Organization Webhook", func() {
Expect(warnings).To(BeEmpty())
})
})
+
+ Context("When validating plan/feature combinations", func() {
+ It("Should allow rulesetPresets on enterprise plan", func() {
+ obj.Spec.Plan = "enterprise"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ warnings, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(warnings).To(BeEmpty())
+ })
+
+ It("Should allow rulesetPresets when plan is empty (defaults to enterprise)", func() {
+ obj.Spec.Plan = ""
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ warnings, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(warnings).To(BeEmpty())
+ })
+
+ It("Should allow rulesetPresets on team plan", func() {
+ obj.Spec.Plan = "team"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ warnings, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(warnings).To(BeEmpty())
+ })
+
+ It("Should reject rulesetPresets on free plan", func() {
+ obj.Spec.Plan = "free"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ _, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).To(HaveOccurred())
+ var statusErr *errors.StatusError
+ Expect(stderrors.As(err, &statusErr)).To(BeTrue())
+ Expect(statusErr.Error()).To(ContainSubstring("rulesetPresets"))
+ })
+
+ It("Should reject codeSecurityConfigurations on team plan", func() {
+ obj.Spec.Plan = "team"
+ obj.Spec.CodeSecurityConfigurations = []githubv1alpha1.AttachableCodeSecurityConfigurationRef{
+ {Name: "my-config"},
+ }
+ _, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).To(HaveOccurred())
+ var statusErr *errors.StatusError
+ Expect(stderrors.As(err, &statusErr)).To(BeTrue())
+ Expect(statusErr.Error()).To(ContainSubstring("codeSecurityConfigurations"))
+ Expect(statusErr.Error()).To(ContainSubstring("enterprise"))
+ })
+
+ It("Should reject both rulesetPresets and codeSecurityConfigurations on free plan", func() {
+ obj.Spec.Plan = "free"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ obj.Spec.CodeSecurityConfigurations = []githubv1alpha1.AttachableCodeSecurityConfigurationRef{
+ {Name: "my-config"},
+ }
+ _, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).To(HaveOccurred())
+ var statusErr *errors.StatusError
+ Expect(stderrors.As(err, &statusErr)).To(BeTrue())
+ Expect(statusErr.Error()).To(ContainSubstring("rulesetPresets"))
+ Expect(statusErr.Error()).To(ContainSubstring("codeSecurityConfigurations"))
+ })
+
+ It("Should allow empty enterprise-only fields on team plan", func() {
+ obj.Spec.Plan = "team"
+ obj.Spec.RulesetPresetList = nil
+ obj.Spec.CodeSecurityConfigurations = nil
+ warnings, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(warnings).To(BeEmpty())
+ })
+
+ It("Should allow rulesetPresets but reject codeSecurityConfigurations on team plan", func() {
+ obj.Spec.Plan = "team"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ obj.Spec.CodeSecurityConfigurations = []githubv1alpha1.AttachableCodeSecurityConfigurationRef{
+ {Name: "my-config"},
+ }
+ _, err := validator.ValidateCreate(ctx, obj)
+ Expect(err).To(HaveOccurred())
+ var statusErr *errors.StatusError
+ Expect(stderrors.As(err, &statusErr)).To(BeTrue())
+ Expect(statusErr.Error()).NotTo(ContainSubstring("rulesetPresets"))
+ Expect(statusErr.Error()).To(ContainSubstring("codeSecurityConfigurations"))
+ })
+
+ It("Should validate plan/feature combinations on update", func() {
+ obj.Spec.Plan = "free"
+ obj.Spec.RulesetPresetList = []v1.LocalObjectReference{{Name: "my-ruleset"}}
+ _, err := validator.ValidateUpdate(ctx, oldObj, obj)
+ Expect(err).To(HaveOccurred())
+ var statusErr *errors.StatusError
+ Expect(stderrors.As(err, &statusErr)).To(BeTrue())
+ Expect(statusErr.Error()).To(ContainSubstring("rulesetPresets"))
+ })
+ })
})
diff --git a/internal/webhook/v1alpha1/repository_webhook_test.go b/internal/webhook/v1alpha1/repository_webhook_test.go
index 653eb42..b8af738 100644
--- a/internal/webhook/v1alpha1/repository_webhook_test.go
+++ b/internal/webhook/v1alpha1/repository_webhook_test.go
@@ -234,7 +234,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should allow valid string custom property", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "string-prop", Value: gogithub.Ptr("test-string-value")},
+ {PropertyName: "string-prop", Value: new("test-string-value")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
@@ -244,7 +244,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should allow valid single_select custom property", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "select-prop", Value: gogithub.Ptr("option2")},
+ {PropertyName: "select-prop", Value: new("option2")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
Expect(err).NotTo(HaveOccurred())
@@ -262,7 +262,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should allow valid true_false custom property", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "bool-prop", Value: gogithub.Ptr("true")},
+ {PropertyName: "bool-prop", Value: new("true")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
Expect(err).NotTo(HaveOccurred())
@@ -271,7 +271,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should reject invalid true_false value", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "bool-prop", Value: gogithub.Ptr("invalid-bool")},
+ {PropertyName: "bool-prop", Value: new("invalid-bool")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
Expect(err).To(HaveOccurred())
@@ -281,7 +281,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should reject invalid single_select value", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "select-prop", Value: gogithub.Ptr("invalid-option")},
+ {PropertyName: "select-prop", Value: new("invalid-option")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
Expect(err).To(HaveOccurred())
@@ -312,7 +312,7 @@ var _ = Describe("Repository Webhook", func() {
It("Should allow properties not defined in organization (they are ignored)", func() {
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "undefined-prop", Value: gogithub.Ptr("some-value")},
+ {PropertyName: "undefined-prop", Value: new("some-value")},
}
warnings, err := validator.ValidateCreate(ctx, obj)
Expect(err).NotTo(HaveOccurred())
@@ -357,7 +357,7 @@ var _ = Describe("Repository Webhook", func() {
}
obj.Spec.CustomProperties = []githubv1alpha1.CustomPropertyValue{
- {PropertyName: "updated-prop", Value: gogithub.Ptr("updated-value")},
+ {PropertyName: "updated-prop", Value: new("updated-value")},
}
warnings, err := validator.ValidateUpdate(ctx, oldObj, obj)
Expect(err).NotTo(HaveOccurred())
diff --git a/mise.toml b/mise.toml
index d5b02fd..3dd827f 100644
--- a/mise.toml
+++ b/mise.toml
@@ -3,4 +3,4 @@ go = "1.26.3"
kubebuilder = "4.14.0"
[settings]
-idiomatic_version_file_enable_tools = ["node"] # use .node-version
\ No newline at end of file
+idiomatic_version_file_enable_tools = ["node"] # use .node-version
diff --git a/test/mock/ghclientmock/mock_actions.go b/test/mock/ghclientmock/mock_actions.go
index 08dfed1..2ea75cd 100644
--- a/test/mock/ghclientmock/mock_actions.go
+++ b/test/mock/ghclientmock/mock_actions.go
@@ -176,7 +176,7 @@ func (m *MockGitHubClientWrapper) CreateRunnerGroupForOrg(ctx context.Context, o
}
return &github.RunnerGroup{
- ID: github.Ptr(int64(1)),
+ ID: new(int64(1)),
Name: createRequest.Name,
}, nil
}
@@ -189,7 +189,7 @@ func (m *MockGitHubClientWrapper) UpdateRunnerGroupForOrg(ctx context.Context, o
}
return &github.RunnerGroup{
- ID: github.Ptr(groupID),
+ ID: new(groupID),
Name: updateRequest.Name,
Visibility: updateRequest.Visibility,
RestrictedToWorkflows: updateRequest.RestrictedToWorkflows,
diff --git a/test/mock/ghclientmock/mock_code_security.go b/test/mock/ghclientmock/mock_code_security.go
index 8ede278..06a19c1 100644
--- a/test/mock/ghclientmock/mock_code_security.go
+++ b/test/mock/ghclientmock/mock_code_security.go
@@ -40,7 +40,7 @@ func (m *MockGitHubClientWrapper) CreateCodeSecurityConfigurationForOrg(ctx cont
}
// Default implementation
- config.ID = github.Ptr(int64(1))
+ config.ID = new(int64(1))
return &config, nil
}
diff --git a/test/mock/ghclientmock/mock_helpers.go b/test/mock/ghclientmock/mock_helpers.go
index 72b47e5..67883ee 100644
--- a/test/mock/ghclientmock/mock_helpers.go
+++ b/test/mock/ghclientmock/mock_helpers.go
@@ -45,11 +45,11 @@ func (m *MockGitHubClientWrapper) SetRepositoryArchived(owner, repo string, arch
m.GetRepositoryFunc = func(ctx context.Context, repoOwner, repoName string) (*github.Repository, error) {
if repoOwner == owner && repoName == repo {
return &github.Repository{
- ID: github.Ptr(int64(12345)),
- Name: github.Ptr(repo),
- FullName: github.Ptr(fmt.Sprintf("%s/%s", owner, repo)),
- Owner: &github.User{Login: github.Ptr(owner)},
- Archived: github.Ptr(archived),
+ ID: new(int64(12345)),
+ Name: new(repo),
+ FullName: new(fmt.Sprintf("%s/%s", owner, repo)),
+ Owner: &github.User{Login: new(owner)},
+ Archived: new(archived),
}, nil
}
return m.GetRepository(ctx, repoOwner, repoName)
diff --git a/test/mock/ghclientmock/mock_organization.go b/test/mock/ghclientmock/mock_organization.go
index 4f4b498..7b8e781 100644
--- a/test/mock/ghclientmock/mock_organization.go
+++ b/test/mock/ghclientmock/mock_organization.go
@@ -18,8 +18,8 @@ func (m *MockGitHubClientWrapper) GetOrganization(ctx context.Context, org strin
// Default implementation
return &github.Organization{
- Login: github.Ptr(org),
- Name: github.Ptr(org),
+ Login: new(org),
+ Name: new(org),
}, nil
}
diff --git a/test/mock/ghclientmock/mock_repository.go b/test/mock/ghclientmock/mock_repository.go
index 34e6d4e..d2c9f57 100644
--- a/test/mock/ghclientmock/mock_repository.go
+++ b/test/mock/ghclientmock/mock_repository.go
@@ -18,13 +18,13 @@ func (m *MockGitHubClientWrapper) GetRepository(ctx context.Context, owner, repo
// Default implementation
return &github.Repository{
- ID: github.Ptr(int64(12345)),
- Name: github.Ptr(repo),
- FullName: github.Ptr(fmt.Sprintf("%s/%s", owner, repo)),
+ ID: new(int64(12345)),
+ Name: new(repo),
+ FullName: new(fmt.Sprintf("%s/%s", owner, repo)),
Owner: &github.User{
- Login: github.Ptr(owner),
+ Login: new(owner),
},
- Archived: github.Ptr(false),
+ Archived: new(false),
}, nil
}
@@ -37,11 +37,11 @@ func (m *MockGitHubClientWrapper) CreateRepository(ctx context.Context, org stri
// Default implementation - return the created repository
createdRepo := *repo
- createdRepo.ID = github.Ptr(int64(12345))
- createdRepo.FullName = github.Ptr(fmt.Sprintf("%s/%s", org, repo.GetName()))
- createdRepo.Owner = &github.User{Login: github.Ptr(org)}
+ createdRepo.ID = new(int64(12345))
+ createdRepo.FullName = new(fmt.Sprintf("%s/%s", org, repo.GetName()))
+ createdRepo.Owner = &github.User{Login: new(org)}
if createdRepo.Archived == nil {
- createdRepo.Archived = github.Ptr(false)
+ createdRepo.Archived = new(false)
}
return &createdRepo, nil
@@ -56,11 +56,11 @@ func (m *MockGitHubClientWrapper) EditRepository(ctx context.Context, owner, rep
// Default implementation - return the updated repository
updatedRepo := *repository
- updatedRepo.FullName = github.Ptr(fmt.Sprintf("%s/%s", owner, repo))
- updatedRepo.Owner = &github.User{Login: github.Ptr(owner)}
+ updatedRepo.FullName = new(fmt.Sprintf("%s/%s", owner, repo))
+ updatedRepo.Owner = &github.User{Login: new(owner)}
// Ensure ID is set if not already present
if updatedRepo.ID == nil {
- updatedRepo.ID = github.Ptr(int64(12345))
+ updatedRepo.ID = new(int64(12345))
}
return &updatedRepo, nil
diff --git a/test/mock/ghclientmock/mock_ruleset.go b/test/mock/ghclientmock/mock_ruleset.go
index ec3dd48..9dbd779 100644
--- a/test/mock/ghclientmock/mock_ruleset.go
+++ b/test/mock/ghclientmock/mock_ruleset.go
@@ -17,7 +17,7 @@ func (m *MockGitHubClientWrapper) GetRepositoryRuleset(ctx context.Context, owne
// Default implementation - return a ruleset with the given ID
return &github.RepositoryRuleset{
- ID: github.Ptr(rulesetID),
+ ID: new(rulesetID),
Name: "test-ruleset",
}, nil
}
@@ -42,7 +42,7 @@ func (m *MockGitHubClientWrapper) CreateRepositoryRuleset(ctx context.Context, o
// Default implementation - return the created ruleset with an ID
createdRuleset := *ruleset
- createdRuleset.ID = github.Ptr(int64(456))
+ createdRuleset.ID = new(int64(456))
return &createdRuleset, nil
}
@@ -56,7 +56,7 @@ func (m *MockGitHubClientWrapper) UpdateRepositoryRuleset(ctx context.Context, o
// Default implementation - return the updated ruleset
updatedRuleset := *ruleset
- updatedRuleset.ID = github.Ptr(rulesetID)
+ updatedRuleset.ID = new(rulesetID)
return &updatedRuleset, nil
}
@@ -83,7 +83,7 @@ func (m *MockGitHubClientWrapper) GetOrganizationRuleset(ctx context.Context, or
// Default implementation - return a ruleset with the given ID
return &github.RepositoryRuleset{
- ID: github.Ptr(rulesetID),
+ ID: new(rulesetID),
Name: "org-test-ruleset",
}, nil
}
@@ -108,7 +108,7 @@ func (m *MockGitHubClientWrapper) CreateOrganizationRuleset(ctx context.Context,
// Default implementation - return the created ruleset with an ID
createdRuleset := *ruleset
- createdRuleset.ID = github.Ptr(int64(789))
+ createdRuleset.ID = new(int64(789))
return &createdRuleset, nil
}
@@ -122,7 +122,7 @@ func (m *MockGitHubClientWrapper) UpdateOrganizationRuleset(ctx context.Context,
// Default implementation - return the updated ruleset
updatedRuleset := *ruleset
- updatedRuleset.ID = github.Ptr(rulesetID)
+ updatedRuleset.ID = new(rulesetID)
return &updatedRuleset, nil
}
diff --git a/test/mock/ghclientmock/mock_webhook.go b/test/mock/ghclientmock/mock_webhook.go
index 84392b1..8ad21ce 100644
--- a/test/mock/ghclientmock/mock_webhook.go
+++ b/test/mock/ghclientmock/mock_webhook.go
@@ -28,7 +28,7 @@ func (m *MockGitHubClientWrapper) CreateHook(ctx context.Context, owner, repo st
// Default implementation - return the created hook with an ID
createdHook := *hook
- createdHook.ID = github.Ptr(int64(123))
+ createdHook.ID = new(int64(123))
return &createdHook, nil
}