Skip to content

Commit

Permalink
implemented disambiguator in api names
Browse files Browse the repository at this point in the history
  • Loading branch information
asafalgawi committed Apr 2, 2024
1 parent 45e4552 commit ad54677
Show file tree
Hide file tree
Showing 65 changed files with 333 additions and 142 deletions.
9 changes: 9 additions & 0 deletions apis/config/groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package config

import (
"fmt"

"github.com/open-policy-agent/gatekeeper/v3/apis/disambiguator"
)

var ConfigGroupName = fmt.Sprintf("config.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)
3 changes: 2 additions & 1 deletion apis/config/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ limitations under the License.
package v1alpha1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/config"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "config.gatekeeper.sh", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: config.ConfigGroupName, Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
19 changes: 19 additions & 0 deletions apis/disambiguator/disambiguator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package disambiguator

import (
"fmt"
"os"
)

const GatekeeprApiSuffix = "gatekeeper.sh"

Check warning on line 8 in apis/disambiguator/disambiguator.go

View workflow job for this annotation

GitHub Actions / Lint

var-naming: const GatekeeprApiSuffix should be GatekeeprAPISuffix (revive)

var Disambiguator string = readDisambiguatorFromEnvVars()

Check warning on line 10 in apis/disambiguator/disambiguator.go

View workflow job for this annotation

GitHub Actions / Lint

var-declaration: should omit type string from declaration of var Disambiguator; it will be inferred from the right-hand side (revive)

func readDisambiguatorFromEnvVars() string {
value, exists := os.LookupEnv("GATEKEEPER_API_NAME_DISAMBIGUATOR")
if exists {
return fmt.Sprintf("%s-", value)
}

return ""
}
9 changes: 9 additions & 0 deletions apis/expansion/groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package expansion

import (
"fmt"

"github.com/open-policy-agent/gatekeeper/v3/apis/disambiguator"
)

var ExpansionGroupName = fmt.Sprintf("expansion.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)
3 changes: 2 additions & 1 deletion apis/expansion/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ limitations under the License.
package v1beta1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/expansion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "expansion.gatekeeper.sh", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: expansion.ExpansionGroupName, Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
9 changes: 9 additions & 0 deletions apis/mutations/group.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package mutations

import (
"fmt"

"github.com/open-policy-agent/gatekeeper/v3/apis/disambiguator"
)

var MutationGroupName string = fmt.Sprintf("mutations.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)

Check warning on line 9 in apis/mutations/group.go

View workflow job for this annotation

GitHub Actions / Lint

var-declaration: should omit type string from declaration of var MutationGroupName; it will be inferred from the right-hand side (revive)
3 changes: 2 additions & 1 deletion apis/mutations/v1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ limitations under the License.
package v1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/mutations"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "mutations.gatekeeper.sh", Version: "v1"}
GroupVersion = schema.GroupVersion{Group: mutations.MutationGroupName, Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
3 changes: 2 additions & 1 deletion apis/mutations/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ limitations under the License.
package v1alpha1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/mutations"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "mutations.gatekeeper.sh", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: mutations.MutationGroupName, Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
3 changes: 2 additions & 1 deletion apis/mutations/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ limitations under the License.
package v1beta1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/mutations"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "mutations.gatekeeper.sh", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: mutations.MutationGroupName, Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
10 changes: 10 additions & 0 deletions apis/status/groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package status

import (
"fmt"

"github.com/open-policy-agent/gatekeeper/v3/apis/disambiguator"
)

var StatusGroupName string = fmt.Sprintf("status.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)
var ConstraintsGroupName = fmt.Sprintf("constraints.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)
5 changes: 3 additions & 2 deletions apis/status/v1beta1/constraintpodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1
import (
"strings"

"github.com/open-policy-agent/gatekeeper/v3/apis/status"
"github.com/open-policy-agent/gatekeeper/v3/pkg/operations"
"github.com/open-policy-agent/gatekeeper/v3/pkg/util"
corev1 "k8s.io/api/core/v1"
Expand All @@ -28,8 +29,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// ConstraintsGroup is the API Group for Gatekeeper Constraints.
const ConstraintsGroup = "constraints.gatekeeper.sh"
// ConstraintsGroupName is the API Group for Gatekeeper Constraints.
var ConstraintsGroupName = status.ConstraintsGroupName

// ConstraintPodStatusStatus defines the observed state of ConstraintPodStatus.
type ConstraintPodStatusStatus struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/status/v1beta1/constraintpodstatus_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestNewConstraintStatusForPod(t *testing.T) {
)

cstr := &unstructured.Unstructured{}
cstr.SetGroupVersionKind(schema.GroupVersionKind{Group: v1beta1.ConstraintsGroup, Version: "v1beta1", Kind: cstrKind})
cstr.SetGroupVersionKind(schema.GroupVersionKind{Group: v1beta1.ConstraintsGroupName, Version: "v1beta1", Kind: cstrKind})
cstr.SetName(cstrName)

wantStatus := &v1beta1.ConstraintPodStatus{}
Expand Down
3 changes: 2 additions & 1 deletion apis/status/v1beta1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ limitations under the License.
package v1beta1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/status"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "status.gatekeeper.sh", Version: "v1beta1"}
GroupVersion = schema.GroupVersion{Group: status.StatusGroupName, Version: "v1beta1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
3 changes: 2 additions & 1 deletion apis/status/v1beta1/mutatorpodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1
import (
"strings"

"github.com/open-policy-agent/gatekeeper/v3/apis/mutations"
mtypes "github.com/open-policy-agent/gatekeeper/v3/pkg/mutation/types"
"github.com/open-policy-agent/gatekeeper/v3/pkg/operations"
"github.com/open-policy-agent/gatekeeper/v3/pkg/util"
Expand All @@ -29,7 +30,7 @@ import (
)

// MutationsGroup is the API Group for Gatekeeper Mutators.
const MutationsGroup = "mutations.gatekeeper.sh"
var MutationsGroup = mutations.MutationGroupName

// MutatorPodStatusStatus defines the observed state of MutatorPodStatus.
type MutatorPodStatusStatus struct {
Expand Down
9 changes: 9 additions & 0 deletions apis/syncset/groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package syncset

import (
"fmt"

"github.com/open-policy-agent/gatekeeper/v3/apis/disambiguator"
)

var SyncSetGroupNama = fmt.Sprintf("syncset.%s%s", disambiguator.Disambiguator, disambiguator.GatekeeprApiSuffix)
3 changes: 2 additions & 1 deletion apis/syncset/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
package v1alpha1

import (
"github.com/open-policy-agent/gatekeeper/v3/apis/syncset"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "syncset.gatekeeper.sh", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: syncset.SyncSetGroupNama, Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
4 changes: 2 additions & 2 deletions charts/gatekeeper/crds/assign-customresourcedefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: assign.mutations.gatekeeper.sh
name: assign.mutations.asafalg-gatekeeper.sh
spec:
group: mutations.gatekeeper.sh
group: mutations.asafalg-gatekeeper.sh
names:
kind: Assign
listKind: AssignList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: assignimage.mutations.gatekeeper.sh
name: assignimage.mutations.asafalg-gatekeeper.sh
spec:
group: mutations.gatekeeper.sh
group: mutations.asafalg-gatekeeper.sh
names:
kind: AssignImage
listKind: AssignImageList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: assignmetadata.mutations.gatekeeper.sh
name: assignmetadata.mutations.asafalg-gatekeeper.sh
spec:
group: mutations.gatekeeper.sh
group: mutations.asafalg-gatekeeper.sh
names:
kind: AssignMetadata
listKind: AssignMetadataList
Expand Down
4 changes: 2 additions & 2 deletions charts/gatekeeper/crds/config-customresourcedefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: configs.config.gatekeeper.sh
name: configs.config.asafalg-gatekeeper.sh
spec:
group: config.gatekeeper.sh
group: config.asafalg-gatekeeper.sh
names:
kind: Config
listKind: ConfigList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: constraintpodstatuses.status.gatekeeper.sh
name: constraintpodstatuses.status.asafalg-gatekeeper.sh
spec:
group: status.gatekeeper.sh
group: status.asafalg-gatekeeper.sh
names:
kind: ConstraintPodStatus
listKind: ConstraintPodStatusList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: constrainttemplates.templates.gatekeeper.sh
name: constrainttemplates.templates.asafalg-gatekeeper.sh
spec:
group: templates.gatekeeper.sh
group: templates.asafalg-gatekeeper.sh
names:
kind: ConstraintTemplate
listKind: ConstraintTemplateList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: constrainttemplatepodstatuses.status.gatekeeper.sh
name: constrainttemplatepodstatuses.status.asafalg-gatekeeper.sh
spec:
group: status.gatekeeper.sh
group: status.asafalg-gatekeeper.sh
names:
kind: ConstraintTemplatePodStatus
listKind: ConstraintTemplatePodStatusList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: expansiontemplate.expansion.gatekeeper.sh
name: expansiontemplate.expansion.asafalg-gatekeeper.sh
spec:
group: expansion.gatekeeper.sh
group: expansion.asafalg-gatekeeper.sh
names:
kind: ExpansionTemplate
listKind: ExpansionTemplateList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: expansiontemplatepodstatuses.status.gatekeeper.sh
name: expansiontemplatepodstatuses.status.asafalg-gatekeeper.sh
spec:
group: status.gatekeeper.sh
group: status.asafalg-gatekeeper.sh
names:
kind: ExpansionTemplatePodStatus
listKind: ExpansionTemplatePodStatusList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: modifyset.mutations.gatekeeper.sh
name: modifyset.mutations.asafalg-gatekeeper.sh
spec:
group: mutations.gatekeeper.sh
group: mutations.asafalg-gatekeeper.sh
names:
kind: ModifySet
listKind: ModifySetList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: mutatorpodstatuses.status.gatekeeper.sh
name: mutatorpodstatuses.status.asafalg-gatekeeper.sh
spec:
group: status.gatekeeper.sh
group: status.asafalg-gatekeeper.sh
names:
kind: MutatorPodStatus
listKind: MutatorPodStatusList
Expand Down
4 changes: 2 additions & 2 deletions charts/gatekeeper/crds/provider-customresourcedefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: providers.externaldata.gatekeeper.sh
name: providers.externaldata.asafalg-gatekeeper.sh
spec:
group: externaldata.gatekeeper.sh
group: externaldata.asafalg-gatekeeper.sh
names:
kind: Provider
listKind: ProviderList
Expand Down
4 changes: 2 additions & 2 deletions charts/gatekeeper/crds/syncset-customresourcedefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
controller-gen.kubebuilder.io/version: v0.10.0
labels:
gatekeeper.sh/system: "yes"
name: syncsets.syncset.gatekeeper.sh
name: syncsets.syncset.asafalg-gatekeeper.sh
spec:
group: syncset.gatekeeper.sh
group: syncset.asafalg-gatekeeper.sh
names:
kind: SyncSet
listKind: SyncSetList
Expand Down
2 changes: 2 additions & 0 deletions charts/gatekeeper/templates/gatekeeper-audit-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ spec:
value: manager
- name: OTEL_RESOURCE_ATTRIBUTES
value: k8s.pod.name=$(POD_NAME),k8s.namespace.name=$(NAMESPACE),k8s.container.name=$(CONTAINER_NAME)
- name: GATEKEEPER_API_NAME_DISAMBIGUATOR
value: asafalg
imagePullPolicy: '{{ .Values.image.pullPolicy }}'
livenessProbe:
httpGet:
Expand Down
Loading

0 comments on commit ad54677

Please sign in to comment.