generated from cybozu-go/neco-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Daichi Sakaue <[email protected]>
- Loading branch information
Showing
10 changed files
with
96 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func completeNamespaces(cmd *cobra.Command, args []string, toComplete string) (ret []string, directive cobra.ShellCompDirective) { | ||
ret = make([]string, 0) | ||
directive = cobra.ShellCompDirectiveNoFileComp | ||
|
||
clientset, _, err := createK8sClients() | ||
if err != nil { | ||
ret = append(ret, "error1") | ||
return | ||
} | ||
|
||
nss, err := clientset.CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{}) | ||
if err != nil { | ||
ret = append(ret, "error2") | ||
return | ||
} | ||
|
||
for _, ns := range nss.Items { | ||
ret = append(ret, ns.Name) | ||
} | ||
return | ||
} | ||
|
||
func completePods(cmd *cobra.Command, args []string, toComplete string) (ret []string, directive cobra.ShellCompDirective) { | ||
ret = make([]string, 0) | ||
directive = cobra.ShellCompDirectiveNoFileComp | ||
|
||
clientset, _, err := createK8sClients() | ||
if err != nil { | ||
return | ||
} | ||
|
||
pods, err := listRelevantPods(context.Background(), clientset, rootOptions.namespace) | ||
if err != nil { | ||
return | ||
} | ||
|
||
for _, p := range pods { | ||
ret = append(ret, p.Name) | ||
} | ||
return | ||
} |
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,8 @@ | ||
#!/bin/bash | ||
|
||
if ! grep boarded /root/.bashrc > /dev/null 2>&1; then | ||
echo '. /usr/share/bash-completion/bash_completion' >> /root/.bashrc | ||
echo 'export PATH=${PATH}:/tmp' >> /root/.bashrc | ||
echo '. <(npv completion bash)' >> /root/.bashrc | ||
echo '# boarded' >> /root/.bashrc | ||
fi |
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