Provide additional shortnames for resources (#10030)

This change expands on existing shortnames while adding others for various policy resources. This improves the user experience when issuing commands via kubectl.

Fixes #9322

Signed-off-by: Paul Balogh <javaducky@gmail.com>
This commit is contained in:
Paul Balogh 2023-01-17 09:27:39 -06:00 committed by GitHub
parent 439a130cd4
commit cf712d7b45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 27 deletions

View File

@ -15,7 +15,7 @@ spec:
kind: AuthorizationPolicy
plural: authorizationpolicies
singular: authorizationpolicy
shortNames: []
shortNames: [authzpolicy]
versions:
- name: v1alpha1
served: true

View File

@ -15,7 +15,7 @@ spec:
kind: MeshTLSAuthentication
plural: meshtlsauthentications
singular: meshtlsauthentication
shortNames: []
shortNames: [meshtlsauthn]
versions:
- name: v1alpha1
served: true

View File

@ -15,7 +15,7 @@ spec:
kind: NetworkAuthentication
plural: networkauthentications
singular: networkauthentication
shortNames: []
shortNames: [netauthn, networkauthn]
versions:
- name: v1alpha1
served: true

View File

@ -15,7 +15,7 @@ spec:
kind: ServerAuthorization
plural: serverauthorizations
singular: serverauthorization
shortNames: [saz]
shortNames: [saz, serverauthz, srvauthz]
versions:
- name: v1alpha1
served: true

View File

@ -15,7 +15,7 @@ spec:
kind: AuthorizationPolicy
plural: authorizationpolicies
singular: authorizationpolicy
shortNames: []
shortNames: [authzpolicy]
versions:
- name: v1alpha1
served: true
@ -1649,7 +1649,7 @@ spec:
kind: MeshTLSAuthentication
plural: meshtlsauthentications
singular: meshtlsauthentication
shortNames: []
shortNames: [meshtlsauthn]
versions:
- name: v1alpha1
served: true
@ -1735,7 +1735,7 @@ spec:
kind: NetworkAuthentication
plural: networkauthentications
singular: networkauthentication
shortNames: []
shortNames: [netauthn, networkauthn]
versions:
- name: v1alpha1
served: true
@ -1788,7 +1788,7 @@ spec:
kind: ServerAuthorization
plural: serverauthorizations
singular: serverauthorization
shortNames: [saz]
shortNames: [saz, serverauthz, srvauthz]
versions:
- name: v1alpha1
served: true

View File

@ -17,7 +17,7 @@ spec:
kind: AuthorizationPolicy
plural: authorizationpolicies
singular: authorizationpolicy
shortNames: []
shortNames: [authzpolicy]
versions:
- name: v1alpha1
served: true
@ -1655,7 +1655,7 @@ spec:
kind: MeshTLSAuthentication
plural: meshtlsauthentications
singular: meshtlsauthentication
shortNames: []
shortNames: [meshtlsauthn]
versions:
- name: v1alpha1
served: true
@ -1743,7 +1743,7 @@ spec:
kind: NetworkAuthentication
plural: networkauthentications
singular: networkauthentication
shortNames: []
shortNames: [netauthn, networkauthn]
versions:
- name: v1alpha1
served: true
@ -1798,7 +1798,7 @@ spec:
kind: ServerAuthorization
plural: serverauthorizations
singular: serverauthorization
shortNames: [saz]
shortNames: [saz, serverauthz, srvauthz]
versions:
- name: v1alpha1
served: true

View File

@ -17,7 +17,7 @@ spec:
kind: AuthorizationPolicy
plural: authorizationpolicies
singular: authorizationpolicy
shortNames: []
shortNames: [authzpolicy]
versions:
- name: v1alpha1
served: true
@ -1655,7 +1655,7 @@ spec:
kind: MeshTLSAuthentication
plural: meshtlsauthentications
singular: meshtlsauthentication
shortNames: []
shortNames: [meshtlsauthn]
versions:
- name: v1alpha1
served: true
@ -1743,7 +1743,7 @@ spec:
kind: NetworkAuthentication
plural: networkauthentications
singular: networkauthentication
shortNames: []
shortNames: [netauthn, networkauthn]
versions:
- name: v1alpha1
served: true
@ -1798,7 +1798,7 @@ spec:
kind: ServerAuthorization
plural: serverauthorizations
singular: serverauthorization
shortNames: [saz]
shortNames: [saz, serverauthz, srvauthz]
versions:
- name: v1alpha1
served: true

View File

@ -20,8 +20,10 @@ const (
Endpoints = "endpoints"
EndpointSlices = "endpointslices"
Job = "job"
MeshTLSAuthentication = "meshtlsauthentication"
MutatingWebhookConfig = "mutatingwebhookconfig"
Namespace = "namespace"
NetworkAuthentication = "networkauthentication"
Pod = "pod"
ReplicationController = "replicationcontroller"
ReplicaSet = "replicaset"
@ -117,16 +119,21 @@ var resourceNames = []resourceName{
{"ds", "daemonset", "daemonsets"},
{"deploy", "deployment", "deployments"},
{"job", "job", "jobs"},
{"meshtlsauthn", "meshtlsauthentication", "meshtlsauthentications"},
{"ns", "namespace", "namespaces"},
{"netauthn", "networkauthentication", "networkauthentications"},
{"networkauthn", "networkauthentication", "networkauthentications"},
{"po", "pod", "pods"},
{"rc", "replicationcontroller", "replicationcontrollers"},
{"rs", "replicaset", "replicasets"},
{"svc", "service", "services"},
{"sp", "serviceprofile", "serviceprofiles"},
{"saz", "serverauthorization", "serverauthorizations"},
{"serverauthz", "serverauthorization", "serverauthorizations"},
{"srvauthz", "serverauthorization", "serverauthorizations"},
{"srv", "server", "servers"},
{"ap", "authorizationpolicy", "authorizationpolicies"},
{"route", "httproute", "httproutes"},
{"authzpolicy", "authorizationpolicy", "authorizationpolicies"},
{"sts", "statefulset", "statefulsets"},
{"ln", "link", "links"},
{"all", "all", "all"},
@ -206,6 +213,7 @@ func ShortNameFromCanonicalResourceName(canonicalName string) string {
// KindToL5DLabel converts a Kubernetes `kind` to a Linkerd label.
// For example:
//
// `pod` -> `pod`
// `job` -> `k8s_job`
func KindToL5DLabel(k8sKind string) string {

View File

@ -36,6 +36,12 @@ func TestCanonicalResourceNameFromFriendlyName(t *testing.T) {
"authorities": Authority,
"cj": CronJob,
"cronjob": CronJob,
"serverauthz": ServerAuthorization,
"srvauthz": ServerAuthorization,
"authzpolicy": AuthorizationPolicy,
"meshtlsauthn": MeshTLSAuthentication,
"networkauthn": NetworkAuthentication,
"netauthn": NetworkAuthentication,
}
for input, expectedName := range expectations {