Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Commit

Permalink
Adding support for communicating with Aurora using TLS.
Browse files Browse the repository at this point in the history
  • Loading branch information
ridv committed Apr 26, 2018
1 parent 72692b5 commit f4d8653
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ required = ["git.apache.org/thrift.git/lib/go/thrift"]

[[constraint]]
name = "github.com/paypal/gorealis"
revision = "94e7c878b4e54385b6fbbb7b0c1ce5a82865af2b"
branch = "develop"

[[constraint]]
name = "github.com/spf13/cobra"
Expand Down
20 changes: 17 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ var username, password, zkAddr, schedAddr string
var env, role, name string
var client realis.Realis
var monitor *realis.Monitor
var insecureSkipVerify bool
var caCertsPath string
var clientKey, clientCert string

func init() {
rootCmd.PersistentFlags().StringVarP(&zkAddr, "zookeeper", "z", "", "Zookeeper node(s) where Aurora stores information.")
rootCmd.PersistentFlags().StringVarP(&username, "username", "u", "", "Username to use for API authentication")
rootCmd.PersistentFlags().StringVarP(&password, "password", "p", "", "Password to use for API authentication")
rootCmd.PersistentFlags().StringVarP(&schedAddr, "scheduler_addr", "s", "", "Aurora Scheduler's address.")
rootCmd.PersistentFlags().StringVarP(&clientKey, "clientKey", "k", "", "Client key to use to connect to Aurora.")
rootCmd.PersistentFlags().StringVarP(&clientCert, "clientCert", "c", "", "Client certificate to use to connect to Aurora.")
rootCmd.PersistentFlags().StringVarP(&caCertsPath, "caCertsPath", "a", "", "CA certificates path to use.")
}

func Execute() {
Expand All @@ -50,18 +56,26 @@ func connect(cmd *cobra.Command, args []string) {
Jitter: 0.1,
})}


// Prefer zookeeper if both ways of connecting are provided
if zkAddr != "" {
realisOptions = append(realisOptions, realis.ZKUrl(zkAddr))

// Configure Zookeeper to connect
zkOptions := []realis.ZKOpt{ realis.ZKEndpoints(zkAddr), realis.ZKPath("/aurora/scheduler")}

if clientKey != "" || clientCert != "" || caCertsPath != "" {
zkOptions = append(zkOptions, realis.ZKAuroraPortOverride(8081), realis.ZKAuroraSchemeOverride("https"))

realisOptions = append(realisOptions, realis.Certspath(caCertsPath), realis.ClientCerts(clientKey, clientCert))
}

realisOptions = append(realisOptions, realis.ZookeeperOptions(zkOptions...))
} else if schedAddr != "" {
realisOptions = append(realisOptions, realis.SchedulerUrl(schedAddr))
} else {
fmt.Println("Zookeeper address or Scheduler URL must be provided.")
os.Exit(1)
}


// Connect to Aurora Scheduler and create a client object
client, err = realis.NewRealisClient(realisOptions...)

Expand Down

0 comments on commit f4d8653

Please sign in to comment.