diff --git a/kube/arguments.go b/kube/arguments.go index 275de94..1857b46 100644 --- a/kube/arguments.go +++ b/kube/arguments.go @@ -201,6 +201,8 @@ func (c *Completer) argumentsCompleter(namespace string, args []string) []prompt return prompt.FilterContains(getServiceSuggestions(c.client, namespace), third, true) case "job", "jobs": return prompt.FilterContains(getJobSuggestions(c.client, namespace), third, true) + case "statefulsets": + return prompt.FilterContains(getStatefulsetsSuggestions(c.client, namespace), third, true) } } case "describe": @@ -254,6 +256,8 @@ func (c *Completer) argumentsCompleter(namespace string, args []string) []prompt return prompt.FilterContains(getServiceSuggestions(c.client, namespace), third, true) case "job", "jobs": return prompt.FilterContains(getJobSuggestions(c.client, namespace), third, true) + case "statefulsets": + return prompt.FilterContains(getStatefulsetsSuggestions(c.client, namespace), third, true) } } case "create": @@ -320,6 +324,8 @@ func (c *Completer) argumentsCompleter(namespace string, args []string) []prompt return prompt.FilterContains(getServiceSuggestions(c.client, namespace), third, true) case "job", "jobs": return prompt.FilterContains(getJobSuggestions(c.client, namespace), third, true) + case "statefulsets": + return prompt.FilterContains(getStatefulsetsSuggestions(c.client, namespace), third, true) } } case "edit": @@ -372,6 +378,8 @@ func (c *Completer) argumentsCompleter(namespace string, args []string) []prompt return prompt.FilterContains(getServiceSuggestions(c.client, namespace), third, true) case "job", "jobs": return prompt.FilterContains(getJobSuggestions(c.client, namespace), third, true) + case "statefulsets": + return prompt.FilterContains(getStatefulsetsSuggestions(c.client, namespace), third, true) } } diff --git a/kube/resource.go b/kube/resource.go index 8578fca..3aa743d 100644 --- a/kube/resource.go +++ b/kube/resource.go @@ -194,6 +194,17 @@ func getPodSuggestions(client *kubernetes.Clientset, namespace string) []prompt. return s } +func getStatefulsetsSuggestions(client *kubernetes.Clientset, namespace string) []prompt.Suggest { + l, _ := client.AppsV1().StatefulSets(namespace).List(metav1.ListOptions{}) + s := make([]prompt.Suggest, len(l.Items)) + for i := range l.Items { + s[i] = prompt.Suggest{ + Text: l.Items[i].Name, + } + } + return s +} + func getPod(namespace, podName string) (corev1.Pod, bool) { x, ok := podList.Load(namespace) if !ok {