Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit a4ca74b

Browse files
committed
Revise flag names.
1 parent 3667bcd commit a4ca74b

File tree

7 files changed

+37
-30
lines changed

7 files changed

+37
-30
lines changed

cmds/check.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ func newCheckCmd() *cobra.Command {
1313
Short: "Validate kloader configuration",
1414
Run: func(cmd *cobra.Command, args []string) {
1515
if configMap != "" {
16-
mounter := controller.NewConfigMapMounter(getRestConfig(), configMap, mountDir, bashFile)
16+
mounter := controller.NewConfigMapMounter(getRestConfig(), configMap, mountDir, bashFile, resyncPeriod)
1717
obj, err := mounter.KubeClient.CoreV1().ConfigMaps(mounter.Source.Namespace).
1818
Get(mounter.Source.Name, metav1.GetOptions{})
1919
if err != nil {
2020
log.Fatalln("Failed to get ConfigMap, Cause", err)
2121
}
2222
mounter.Mount(obj)
2323
} else if secret != "" {
24-
mounter := controller.NewSecretMounter(getRestConfig(), secret, mountDir, bashFile)
24+
mounter := controller.NewSecretMounter(getRestConfig(), secret, mountDir, bashFile, resyncPeriod)
2525
obj, err := mounter.KubeClient.CoreV1().Secrets(mounter.Source.Namespace).
2626
Get(mounter.Source.Name, metav1.GetOptions{})
2727
if err != nil {

cmds/run.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ func newRunCmd() *cobra.Command {
1515
Short: "Run and hold kloader",
1616
Run: func(cmd *cobra.Command, args []string) {
1717
if configMap != "" {
18-
mounter := controller.NewConfigMapMounter(getRestConfig(), configMap, mountDir, bashFile)
18+
mounter := controller.NewConfigMapMounter(getRestConfig(), configMap, mountDir, bashFile, resyncPeriod)
1919
mounter.Run()
2020
} else if secret != "" {
21-
mounter := controller.NewSecretMounter(getRestConfig(), secret, mountDir, bashFile)
21+
mounter := controller.NewSecretMounter(getRestConfig(), secret, mountDir, bashFile, resyncPeriod)
2222
mounter.Run()
2323
}
2424
hold.Hold()
@@ -41,7 +41,7 @@ func getRestConfig() *rest.Config {
4141
log.Fatalln("MountDir is required, but not provided")
4242
}
4343

44-
config, err := clientcmd.BuildConfigFromFlags(kubeMaster, kubeConfig)
44+
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
4545
if err != nil {
4646
log.Fatalln("Failed to create KubeConfig")
4747
}

cmds/util.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package cmds
22

33
import (
4+
"time"
5+
46
"github.com/spf13/cobra"
57
)
68

79
var (
8-
configMap, secret, mountDir, bashFile, kubeMaster, kubeConfig string
10+
configMap, secret, mountDir, bashFile string
11+
masterURL, kubeconfigPath string
12+
resyncPeriod time.Duration = 5 * time.Minute
913
)
1014

1115
func addFlags(cmd *cobra.Command) {
12-
cmd.PersistentFlags().StringVarP(&configMap, "config-map", "c", "", "Configmap name that needs to be mount")
13-
cmd.PersistentFlags().StringVarP(&secret, "secret", "s", "", "Secret name that needs to be mount")
14-
cmd.PersistentFlags().StringVarP(&mountDir, "mount-location", "m", "", "Volume location where the file will be mounted")
15-
cmd.PersistentFlags().StringVarP(&bashFile, "boot-cmd", "b", "", "Bash script that will be run on every change of the file")
16-
cmd.PersistentFlags().StringVar(&kubeMaster, "k8s-master", "", "The address of the Kubernetes API server (overrides any value in kubeconfig)")
17-
cmd.PersistentFlags().StringVar(&kubeConfig, "k8s-config", "", "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
16+
cmd.Flags().StringVarP(&configMap, "configmap", "c", "", "Configmap name that needs to be mount")
17+
cmd.Flags().StringVarP(&secret, "secret", "s", "", "Secret name that needs to be mount")
18+
cmd.Flags().StringVarP(&mountDir, "mount-location", "m", "", "Volume location where the file will be mounted")
19+
cmd.Flags().StringVarP(&bashFile, "boot-cmd", "b", "", "Bash script that will be run on every change of the file")
20+
cmd.Flags().StringVar(&masterURL, "master", masterURL, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
21+
cmd.Flags().StringVar(&kubeconfigPath, "kubeconfig", kubeconfigPath, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
22+
cmd.Flags().DurationVar(&resyncPeriod, "resync-period", resyncPeriod, "If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out.")
1823
}

controller/mount_configmap.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type configMapMounter struct {
3434
informer cache.SharedIndexInformer
3535
}
3636

37-
func NewConfigMapMounter(kubeConfig *rest.Config, configMap, mountDir, cmd string) *configMapMounter {
37+
func NewConfigMapMounter(kubeConfig *rest.Config, configMap, mountDir, cmd string, resyncPeriod time.Duration) *configMapMounter {
3838
configMapParts := strings.SplitN(strings.TrimSpace(configMap), ".", 2)
3939
source := &apiv1.ObjectReference{
4040
Name: configMapParts[0],
@@ -62,7 +62,7 @@ func NewConfigMapMounter(kubeConfig *rest.Config, configMap, mountDir, cmd strin
6262
},
6363
},
6464
&apiv1.ConfigMap{},
65-
time.Minute*5,
65+
resyncPeriod,
6666
cache.Indexers{},
6767
)
6868

controller/mount_secret.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type secretMounter struct {
3232
informer cache.SharedIndexInformer
3333
}
3434

35-
func NewSecretMounter(kubeConfig *rest.Config, secret, mountDir, cmd string) *secretMounter {
35+
func NewSecretMounter(kubeConfig *rest.Config, secret, mountDir, cmd string, resyncPeriod time.Duration) *secretMounter {
3636
secretParts := strings.SplitN(strings.TrimSpace(secret), ".", 2)
3737
source := &apiv1.ObjectReference{
3838
Name: secretParts[0],
@@ -60,7 +60,7 @@ func NewSecretMounter(kubeConfig *rest.Config, secret, mountDir, cmd string) *se
6060
},
6161
},
6262
&apiv1.Secret{},
63-
time.Minute*5,
63+
resyncPeriod,
6464
cache.Indexers{},
6565
)
6666

docs/reference/kloader_check.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ kloader check [flags]
1414
### Options
1515

1616
```
17-
-b, --boot-cmd string Bash script that will be run on every change of the file
18-
-c, --config-map string Configmap name that needs to be mount
19-
-h, --help help for check
20-
--k8s-config string Path to kubeconfig file with authorization information (the master location is set by the master flag).
21-
--k8s-master string The address of the Kubernetes API server (overrides any value in kubeconfig)
22-
-m, --mount-location string Volume location where the file will be mounted
23-
-s, --secret string Secret name that needs to be mount
17+
-b, --boot-cmd string Bash script that will be run on every change of the file
18+
-c, --configmap string Configmap name that needs to be mount
19+
-h, --help help for check
20+
--kubeconfig string Path to kubeconfig file with authorization information (the master location is set by the master flag).
21+
--master string The address of the Kubernetes API server (overrides any value in kubeconfig)
22+
-m, --mount-location string Volume location where the file will be mounted
23+
--resync-period duration If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out. (default 5m0s)
24+
-s, --secret string Secret name that needs to be mount
2425
```
2526

2627
### Options inherited from parent commands

docs/reference/kloader_run.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ kloader run [flags]
1414
### Options
1515

1616
```
17-
-b, --boot-cmd string Bash script that will be run on every change of the file
18-
-c, --config-map string Configmap name that needs to be mount
19-
-h, --help help for run
20-
--k8s-config string Path to kubeconfig file with authorization information (the master location is set by the master flag).
21-
--k8s-master string The address of the Kubernetes API server (overrides any value in kubeconfig)
22-
-m, --mount-location string Volume location where the file will be mounted
23-
-s, --secret string Secret name that needs to be mount
17+
-b, --boot-cmd string Bash script that will be run on every change of the file
18+
-c, --configmap string Configmap name that needs to be mount
19+
-h, --help help for run
20+
--kubeconfig string Path to kubeconfig file with authorization information (the master location is set by the master flag).
21+
--master string The address of the Kubernetes API server (overrides any value in kubeconfig)
22+
-m, --mount-location string Volume location where the file will be mounted
23+
--resync-period duration If non-zero, will re-list this often. Otherwise, re-list will be delayed aslong as possible (until the upstream source closes the watch or times out. (default 5m0s)
24+
-s, --secret string Secret name that needs to be mount
2425
```
2526

2627
### Options inherited from parent commands

0 commit comments

Comments
 (0)