Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a global var for pki dir #102

Merged
merged 1 commit into from
Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions auth/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
package auth

import "strings"
import (
"path/filepath"
"strings"

"k8s.io/client-go/util/homedir"
)

var DefaultPKIDir = filepath.Join(homedir.HomeDir(), ".guard")

type orgs []string

Expand All @@ -17,5 +24,9 @@ func (o orgs) Has(name string) bool {
}

func (o orgs) String() string {
return strings.Join(o, "/")
names := make([]string, len(o))
for i, org := range o {
names[i] = strings.Title(org)
}
return strings.Join(names, "/")
}
9 changes: 4 additions & 5 deletions commands/initca.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ import (

"github.com/appscode/go/log"
"github.com/appscode/go/term"
"github.com/appscode/guard/auth"
"github.com/appscode/kutil/tools/certstore"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"k8s.io/client-go/util/homedir"
)

var (
rootDir = filepath.Join(homedir.HomeDir(), ".guard")
)

func NewCmdInitCA() *cobra.Command {
var (
rootDir = auth.DefaultPKIDir
)
cmd := &cobra.Command{
Use: "ca",
Short: "Init CA",
Expand Down
5 changes: 4 additions & 1 deletion commands/initclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import (
)

func NewCmdInitClient() *cobra.Command {
var org string
var (
rootDir = auth.DefaultPKIDir
org string
)
cmd := &cobra.Command{
Use: "client",
Short: "Generate client certificate pair",
Expand Down
10 changes: 7 additions & 3 deletions commands/initserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ import (

"github.com/appscode/go/log"
"github.com/appscode/go/term"
"github.com/appscode/guard/auth"
"github.com/appscode/kutil/tools/certstore"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"k8s.io/client-go/util/cert"
)

func NewCmdInitServer() *cobra.Command {
sans := cert.AltNames{
IPs: []net.IP{net.ParseIP("127.0.0.1")},
}
var (
rootDir = auth.DefaultPKIDir
sans = cert.AltNames{
IPs: []net.IP{net.ParseIP("127.0.0.1")},
}
)
cmd := &cobra.Command{
Use: "server",
Short: "Generate server certificate pair",
Expand Down
6 changes: 5 additions & 1 deletion commands/webhok_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import (
)

func NewCmdGetWebhookConfig() *cobra.Command {
var org, addr string
var (
rootDir = auth.DefaultPKIDir
org string
addr string
)
cmd := &cobra.Command{
Use: "webhook-config",
Short: "Prints authentication token webhook config file",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/guard_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Get PKI

* [guard](/docs/reference/guard.md) - Guard by AppsCode - Kubernetes Authentication WebHook Server
* [guard get installer](/docs/reference/guard_get_installer.md) - Prints Kubernetes objects for deploying guard server
* [guard get token](/docs/reference/guard_get_token.md) - Get tokens for Github/Gitlab/Google
* [guard get token](/docs/reference/guard_get_token.md) - Get tokens for Appscode/Azure/Github/Gitlab/Google/Ldap
* [guard get webhook-config](/docs/reference/guard_get_webhook-config.md) - Prints authentication token webhook config file

6 changes: 3 additions & 3 deletions docs/reference/guard_get_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ section_menu_id: reference
---
## guard get token

Get tokens for Github/Gitlab/Google
Get tokens for Appscode/Azure/Github/Gitlab/Google/Ldap

### Synopsis

Get tokens for Github/Gitlab/Google
Get tokens for Appscode/Azure/Github/Gitlab/Google/Ldap

```
guard get token [flags]
Expand All @@ -32,7 +32,7 @@ guard get token [flags]
--ldap.realm string Realm, set the realm to empty string to use the default realm from config
--ldap.spn string Service principal name
--ldap.username string Username
-o, --organization string Name of Organization (Github/Gitlab/Google).
-o, --organization string Name of Organization (Appscode/Azure/Github/Gitlab/Google/Ldap).
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/guard_get_webhook-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ guard get webhook-config [flags]
```
--addr string Address (host:port) of guard server. (default "10.96.10.96:443")
-h, --help help for webhook-config
-o, --organization string Name of Organization (Github/Gitlab/Google).
-o, --organization string Name of Organization (Appscode/Azure/Github/Gitlab/Google/Ldap).
--pki-dir string Path to directory where pki files are stored. (default "$HOME/.guard")
```

Expand Down
2 changes: 1 addition & 1 deletion docs/reference/guard_init_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ guard init client [flags]

```
-h, --help help for client
-o, --organization string Name of Organization (Github/Gitlab/Google).
-o, --organization string Name of Organization (Appscode/Azure/Github/Gitlab/Google/Ldap).
--pki-dir string Path to directory where pki files are stored. (default "$HOME/.guard")
```

Expand Down
2 changes: 2 additions & 0 deletions installer/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package installer

import (
"github.com/appscode/guard/auth"
"github.com/appscode/guard/auth/providers/azure"
"github.com/appscode/guard/auth/providers/google"
"github.com/appscode/guard/auth/providers/ldap"
Expand All @@ -25,6 +26,7 @@ type Options struct {

func New() Options {
return Options{
pkiDir: auth.DefaultPKIDir,
namespace: metav1.NamespaceSystem,
addr: "10.96.10.96:443",
privateRegistry: "appscode",
Expand Down