-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make scheme conditional on provided feature gates
- Loading branch information
Showing
7 changed files
with
99 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package scheme | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
clientgoscheme "k8s.io/client-go/kubernetes/scheme" | ||
knativev1alpha1 "knative.dev/networking/pkg/apis/networking/v1alpha1" | ||
gatewayv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2" | ||
gatewayv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" | ||
|
||
"github.com/kong/kubernetes-ingress-controller/v2/internal/manager/featuregates" | ||
konghqcomv1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1" | ||
konghqcomv1alpha1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1alpha1" | ||
configurationv1beta1 "github.com/kong/kubernetes-ingress-controller/v2/pkg/apis/configuration/v1beta1" | ||
) | ||
|
||
// Get returns the scheme for the manager, enabling all the default schemes and | ||
// those that were enabled via the feature flags. | ||
func Get(fg map[string]bool) (*runtime.Scheme, error) { | ||
scheme := runtime.NewScheme() | ||
|
||
if err := clientgoscheme.AddToScheme(scheme); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := konghqcomv1.AddToScheme(scheme); err != nil { | ||
return nil, err | ||
} | ||
if err := konghqcomv1alpha1.AddToScheme(scheme); err != nil { | ||
return nil, err | ||
} | ||
if err := configurationv1beta1.AddToScheme(scheme); err != nil { | ||
return nil, err | ||
} | ||
|
||
if v, ok := fg[featuregates.KnativeFeature]; ok && v { | ||
if err := knativev1alpha1.AddToScheme(scheme); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
if v, ok := fg[featuregates.GatewayAlphaFeature]; ok && v { | ||
if err := gatewayv1alpha2.Install(scheme); err != nil { | ||
return nil, err | ||
} | ||
} | ||
if v, ok := fg[featuregates.GatewayFeature]; ok && v { | ||
if err := gatewayv1beta1.Install(scheme); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
return scheme, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters