Show DefaultStrategy as a new printer column for CredentialIssuer

This commit is contained in:
Ryan Richard 2021-09-21 12:01:30 -07:00
parent 1b2a116518
commit fca183b203
12 changed files with 27 additions and 2 deletions

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -22,6 +22,9 @@ spec:
- jsonPath: .spec.impersonationProxy.mode - jsonPath: .spec.impersonationProxy.mode
name: ProxyMode name: ProxyMode
type: string type: string
- jsonPath: .status.strategies[?(@.status == "Success")].type
name: DefaultStrategy
type: string
- jsonPath: .metadata.creationTimestamp - jsonPath: .metadata.creationTimestamp
name: Age name: Age
type: date type: date

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -22,6 +22,9 @@ spec:
- jsonPath: .spec.impersonationProxy.mode - jsonPath: .spec.impersonationProxy.mode
name: ProxyMode name: ProxyMode
type: string type: string
- jsonPath: .status.strategies[?(@.status == "Success")].type
name: DefaultStrategy
type: string
- jsonPath: .metadata.creationTimestamp - jsonPath: .metadata.creationTimestamp
name: Age name: Age
type: date type: date

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -22,6 +22,9 @@ spec:
- jsonPath: .spec.impersonationProxy.mode - jsonPath: .spec.impersonationProxy.mode
name: ProxyMode name: ProxyMode
type: string type: string
- jsonPath: .status.strategies[?(@.status == "Success")].type
name: DefaultStrategy
type: string
- jsonPath: .metadata.creationTimestamp - jsonPath: .metadata.creationTimestamp
name: Age name: Age
type: date type: date

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -22,6 +22,9 @@ spec:
- jsonPath: .spec.impersonationProxy.mode - jsonPath: .spec.impersonationProxy.mode
name: ProxyMode name: ProxyMode
type: string type: string
- jsonPath: .status.strategies[?(@.status == "Success")].type
name: DefaultStrategy
type: string
- jsonPath: .metadata.creationTimestamp - jsonPath: .metadata.creationTimestamp
name: Age name: Age
type: date type: date

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -22,6 +22,9 @@ spec:
- jsonPath: .spec.impersonationProxy.mode - jsonPath: .spec.impersonationProxy.mode
name: ProxyMode name: ProxyMode
type: string type: string
- jsonPath: .status.strategies[?(@.status == "Success")].type
name: DefaultStrategy
type: string
- jsonPath: .metadata.creationTimestamp - jsonPath: .metadata.creationTimestamp
name: Age name: Age
type: date type: date

View File

@ -216,6 +216,7 @@ type ImpersonationProxyInfo struct {
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:resource:categories=pinniped,scope=Cluster // +kubebuilder:resource:categories=pinniped,scope=Cluster
// +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode` // +kubebuilder:printcolumn:name="ProxyMode",type=string,JSONPath=`.spec.impersonationProxy.mode`
// +kubebuilder:printcolumn:name="DefaultStrategy",type=string,JSONPath=`.status.strategies[?(@.status == "Success")].type`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
// +kubebuilder:subresource:status // +kubebuilder:subresource:status
type CredentialIssuer struct { type CredentialIssuer struct {

View File

@ -430,10 +430,14 @@ func TestCRDAdditionalPrinterColumns_Parallel(t *testing.T) {
addSuffix("credentialissuers.config.concierge"): { addSuffix("credentialissuers.config.concierge"): {
"v1alpha1": []apiextensionsv1.CustomResourceColumnDefinition{ "v1alpha1": []apiextensionsv1.CustomResourceColumnDefinition{
{Name: "ProxyMode", Type: "string", JSONPath: ".spec.impersonationProxy.mode"}, {Name: "ProxyMode", Type: "string", JSONPath: ".spec.impersonationProxy.mode"},
// CredentialIssuers status is a list of strategies, each with its own status. Unfortunately, // CredentialIssuer status is a list of strategies, each with its own status. Unfortunately,
// AdditionalPrinterColumns cannot show multiple results, e.g. a list of strategy types where // AdditionalPrinterColumns cannot show multiple results, e.g. a list of strategy types where
// the status is equal to Successful. See https://github.com/kubernetes/kubernetes/issues/67268. // the status is equal to Successful. See https://github.com/kubernetes/kubernetes/issues/67268.
// So we don't show any status as a AdditionalPrinterColumn at the moment. // Although this selector can evaluate to multiple results, the kubectl implementation of JSONPath
// will always only show the first result. Thus, this column will show the first successful strategy
// type, which is the same thing that `pinniped get kubeconfig` looks for, so the value of this
// column represents the current default strategy that will be used by `pinniped get kubeconfig`.
{Name: "DefaultStrategy", Type: "string", JSONPath: `.status.strategies[?(@.status == "Success")].type`},
{Name: "Age", Type: "date", JSONPath: ".metadata.creationTimestamp"}, {Name: "Age", Type: "date", JSONPath: ".metadata.creationTimestamp"},
}, },
}, },