2022-06-09 20:45:21 +00:00
|
|
|
// Copyright 2021-2022 the Pinniped contributors. All Rights Reserved.
|
2021-02-19 18:21:10 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package groupsuffix
|
|
|
|
|
|
|
|
import (
|
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
|
|
|
|
|
|
|
identityv1alpha1 "go.pinniped.dev/generated/latest/apis/concierge/identity/v1alpha1"
|
|
|
|
loginv1alpha1 "go.pinniped.dev/generated/latest/apis/concierge/login/v1alpha1"
|
2022-06-09 20:45:21 +00:00
|
|
|
oauthv1alpha1 "go.pinniped.dev/generated/latest/apis/supervisor/virtual/oauth/v1alpha1"
|
2021-02-19 18:21:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type GroupData schema.GroupVersion
|
|
|
|
|
|
|
|
func (d GroupData) APIServiceName() string {
|
|
|
|
return d.Version + "." + d.Group
|
|
|
|
}
|
|
|
|
|
|
|
|
func ConciergeAggregatedGroups(apiGroupSuffix string) (login, identity GroupData) {
|
|
|
|
loginConciergeAPIGroup, ok1 := Replace(loginv1alpha1.GroupName, apiGroupSuffix)
|
|
|
|
identityConciergeAPIGroup, ok2 := Replace(identityv1alpha1.GroupName, apiGroupSuffix)
|
|
|
|
|
|
|
|
if valid := ok1 && ok2; !valid {
|
|
|
|
panic("static group input is invalid")
|
|
|
|
}
|
|
|
|
|
|
|
|
return GroupData{
|
|
|
|
Group: loginConciergeAPIGroup,
|
|
|
|
Version: loginv1alpha1.SchemeGroupVersion.Version,
|
|
|
|
}, GroupData{
|
|
|
|
Group: identityConciergeAPIGroup,
|
|
|
|
Version: identityv1alpha1.SchemeGroupVersion.Version,
|
|
|
|
}
|
|
|
|
}
|
2022-06-09 20:45:21 +00:00
|
|
|
|
|
|
|
func SupervisorAggregatedGroups(apiGroupSuffix string) (oauth GroupData) {
|
|
|
|
oauthVirtualSupervisorAPIGroup, ok1 := Replace(oauthv1alpha1.GroupName, apiGroupSuffix)
|
|
|
|
|
|
|
|
if !ok1 {
|
|
|
|
panic("static group input is invalid")
|
|
|
|
}
|
|
|
|
|
|
|
|
return GroupData{
|
|
|
|
Group: oauthVirtualSupervisorAPIGroup,
|
|
|
|
Version: oauthv1alpha1.SchemeGroupVersion.Version,
|
|
|
|
}
|
|
|
|
}
|