Skip to content

Commit d75e059

Browse files
committed
autogen indexers
1 parent faea603 commit d75e059

15 files changed

+853
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const BackupCompliancePolicyByGroupIndex = "backupcompliancepolicy.groupRef"
25+
26+
type BackupCompliancePolicyByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewBackupCompliancePolicyByGroupIndexer(logger *zap.Logger) *BackupCompliancePolicyByGroupIndexer {
31+
return &BackupCompliancePolicyByGroupIndexer{logger: logger.Named(BackupCompliancePolicyByGroupIndex).Sugar()}
32+
}
33+
func (*BackupCompliancePolicyByGroupIndexer) Object() client.Object {
34+
return &v1.BackupCompliancePolicy{}
35+
}
36+
func (*BackupCompliancePolicyByGroupIndexer) Name() string {
37+
return BackupCompliancePolicyByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *BackupCompliancePolicyByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.BackupCompliancePolicy)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.BackupCompliancePolicy but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const BackupScheduleByGroupIndex = "backupschedule.groupRef"
25+
26+
type BackupScheduleByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewBackupScheduleByGroupIndexer(logger *zap.Logger) *BackupScheduleByGroupIndexer {
31+
return &BackupScheduleByGroupIndexer{logger: logger.Named(BackupScheduleByGroupIndex).Sugar()}
32+
}
33+
func (*BackupScheduleByGroupIndexer) Object() client.Object {
34+
return &v1.BackupSchedule{}
35+
}
36+
func (*BackupScheduleByGroupIndexer) Name() string {
37+
return BackupScheduleByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *BackupScheduleByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.BackupSchedule)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.BackupSchedule but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const ClusterByGroupIndex = "cluster.groupRef"
25+
26+
type ClusterByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewClusterByGroupIndexer(logger *zap.Logger) *ClusterByGroupIndexer {
31+
return &ClusterByGroupIndexer{logger: logger.Named(ClusterByGroupIndex).Sugar()}
32+
}
33+
func (*ClusterByGroupIndexer) Object() client.Object {
34+
return &v1.Cluster{}
35+
}
36+
func (*ClusterByGroupIndexer) Name() string {
37+
return ClusterByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *ClusterByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.Cluster)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.Cluster but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const CustomRoleByGroupIndex = "customrole.groupRef"
25+
26+
type CustomRoleByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewCustomRoleByGroupIndexer(logger *zap.Logger) *CustomRoleByGroupIndexer {
31+
return &CustomRoleByGroupIndexer{logger: logger.Named(CustomRoleByGroupIndex).Sugar()}
32+
}
33+
func (*CustomRoleByGroupIndexer) Object() client.Object {
34+
return &v1.CustomRole{}
35+
}
36+
func (*CustomRoleByGroupIndexer) Name() string {
37+
return CustomRoleByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *CustomRoleByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.CustomRole)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.CustomRole but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const DatabaseUserByGroupIndex = "databaseuser.groupRef"
25+
26+
type DatabaseUserByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewDatabaseUserByGroupIndexer(logger *zap.Logger) *DatabaseUserByGroupIndexer {
31+
return &DatabaseUserByGroupIndexer{logger: logger.Named(DatabaseUserByGroupIndex).Sugar()}
32+
}
33+
func (*DatabaseUserByGroupIndexer) Object() client.Object {
34+
return &v1.DatabaseUser{}
35+
}
36+
func (*DatabaseUserByGroupIndexer) Name() string {
37+
return DatabaseUserByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *DatabaseUserByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.DatabaseUser)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.DatabaseUser but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const DataFederationByGroupIndex = "datafederation.groupRef"
25+
26+
type DataFederationByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewDataFederationByGroupIndexer(logger *zap.Logger) *DataFederationByGroupIndexer {
31+
return &DataFederationByGroupIndexer{logger: logger.Named(DataFederationByGroupIndex).Sugar()}
32+
}
33+
func (*DataFederationByGroupIndexer) Object() client.Object {
34+
return &v1.DataFederation{}
35+
}
36+
func (*DataFederationByGroupIndexer) Name() string {
37+
return DataFederationByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *DataFederationByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.DataFederation)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.DataFederation but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package indexer
16+
17+
import (
18+
v1 "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/nextapi/generated/v1"
19+
zap "go.uber.org/zap"
20+
client "sigs.k8s.io/controller-runtime/pkg/client"
21+
)
22+
23+
// nolint:dupl
24+
const FlexClusterByGroupIndex = "flexcluster.groupRef"
25+
26+
type FlexClusterByGroupIndexer struct {
27+
logger *zap.SugaredLogger
28+
}
29+
30+
func NewFlexClusterByGroupIndexer(logger *zap.Logger) *FlexClusterByGroupIndexer {
31+
return &FlexClusterByGroupIndexer{logger: logger.Named(FlexClusterByGroupIndex).Sugar()}
32+
}
33+
func (*FlexClusterByGroupIndexer) Object() client.Object {
34+
return &v1.FlexCluster{}
35+
}
36+
func (*FlexClusterByGroupIndexer) Name() string {
37+
return FlexClusterByGroupIndex
38+
}
39+
40+
// Keys extracts the index key(s) from the given object
41+
func (i *FlexClusterByGroupIndexer) Keys(object client.Object) []string {
42+
resource, ok := object.(*v1.FlexCluster)
43+
if !ok {
44+
i.logger.Errorf("expected *v1.FlexCluster but got %T", object)
45+
return nil
46+
}
47+
var keys []string
48+
if resource.Spec.V20250312.GroupRef != nil && resource.Spec.V20250312.GroupRef.Name != "" {
49+
keys = append(keys, resource.Namespace+"/"+resource.Spec.V20250312.GroupRef.Name)
50+
}
51+
return keys
52+
}

0 commit comments

Comments
 (0)