Skip to content

Commit

Permalink
changed references of OIDCLabelKey
Browse files Browse the repository at this point in the history
  • Loading branch information
yijie-04 committed Jan 26, 2024
1 parent 5244f19 commit 2c94ec7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
12 changes: 10 additions & 2 deletions pkg/auth/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"knative.dev/pkg/kmeta"
pkgreconciler "knative.dev/pkg/reconciler"

"knative.dev/eventing/pkg/apis/sources"
"knative.dev/eventing/pkg/auth"

Check failure on line 29 in pkg/auth/serviceaccount.go

View workflow job for this annotation

GitHub Actions / analyze / Go vulnerability Detection

could not import knative.dev/eventing/pkg/auth (import cycle: [knative.dev/eventing/pkg/auth])

"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
Expand All @@ -39,6 +39,14 @@ import (
"knative.dev/pkg/ptr"
)

const (
//OIDCLabelKey is used to filter out all the informers that related to OIDC work
OIDCLabelKey = "oidc"

// OIDCTokenRoleLabelSelector is the label selector for the OIDC token creator role and rolebinding informers
OIDCLabelSelector = OIDCLabelKey
)

// GetOIDCServiceAccountNameForResource returns the service account name to use
// for OIDC authentication for the given resource.
func GetOIDCServiceAccountNameForResource(gvk schema.GroupVersionKind, objectMeta metav1.ObjectMeta) string {
Expand Down Expand Up @@ -69,7 +77,7 @@ func GetOIDCServiceAccountForResource(gvk schema.GroupVersionKind, objectMeta me
"description": fmt.Sprintf("Service Account for OIDC Authentication for %s %q", gvk.GroupKind().Kind, objectMeta.Name),
},
Labels: map[string]string{
sources.OIDCLabelKey: "enabled",
auth.OIDCLabelKey: "enabled",
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/serviceaccount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
duckv1 "knative.dev/pkg/apis/duck/v1"
kubeclient "knative.dev/pkg/client/injection/kube/client/fake"

"knative.dev/eventing/pkg/apis/sources"
"knative.dev/eventing/pkg/auth"

"github.com/google/go-cmp/cmp"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestGetOIDCServiceAccountForResource(t *testing.T) {
"description": "Service Account for OIDC Authentication for Broker \"my-broker\"",
},
Labels: map[string]string{
sources.OIDCLabelKey: "enabled",
auth.OIDCLabelKey: "enabled",
},
},
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/reconciler/apiserversource/apiserversource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"fmt"
"testing"

"knative.dev/eventing/pkg/apis/sources"

"knative.dev/pkg/kmeta"

rbacv1 "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -1425,7 +1423,7 @@ func makeOIDCRole() *rbacv1.Role {
"description": fmt.Sprintf("Role for OIDC Authentication for ApiServerSource %q", sourceName),
},
Labels: map[string]string{
sources.OIDCLabelKey: "",
auth.OIDCLabelKey: "",
},
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(src),
Expand Down Expand Up @@ -1455,7 +1453,7 @@ func makeOIDCRoleBinding() *rbacv1.RoleBinding {
"description": fmt.Sprintf("Role Binding for OIDC Authentication for ApiServerSource %q", sourceName),
},
Labels: map[string]string{
sources.OIDCLabelKey: "",
auth.OIDCLabelKey: "",
},
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(src),
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/apiserversource/resources/oidc_rolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package resources
import (
"fmt"

"knative.dev/eventing/pkg/apis/sources"
"knative.dev/eventing/pkg/auth"

Check failure on line 22 in pkg/reconciler/apiserversource/resources/oidc_rolebinding.go

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

could not import knative.dev/eventing/pkg/auth (-: import cycle not allowed: import stack: [knative.dev/eventing/cmd/apiserver_receive_adapter knative.dev/eventing/pkg/adapter/apiserver knative.dev/eventing/pkg/adapter/apiserver/events knative.dev/eventing/pkg/adapter/v2 knative.dev/eventing/pkg/auth knative.dev/eventing/pkg/auth]) (typecheck)

"knative.dev/pkg/kmeta"

Expand Down Expand Up @@ -54,7 +54,7 @@ func MakeOIDCRole(source *v1.ApiServerSource) (*rbacv1.Role, error) {
"description": fmt.Sprintf("Role for OIDC Authentication for ApiServerSource %q", source.GetName()),
},
Labels: map[string]string{
sources.OIDCLabelKey: "",
auth.OIDCLabelKey: "",
},
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(source),
Expand Down Expand Up @@ -92,7 +92,7 @@ func MakeOIDCRoleBinding(source *v1.ApiServerSource) (*rbacv1.RoleBinding, error
"description": fmt.Sprintf("Role Binding for OIDC Authentication for ApiServerSource %q", source.GetName()),
},
Labels: map[string]string{
sources.OIDCLabelKey: "",
auth.OIDCLabelKey: "",
},
OwnerReferences: []metav1.OwnerReference{
*kmeta.NewControllerRef(source),
Expand Down

0 comments on commit 2c94ec7

Please sign in to comment.