github.com/landoop/schema-registry@v0.0.0-20190327143759-50a5701c1891/README.md (about) 1 Schema Registry CLI and client 2 ============================================== 3 4 This repository contains a Command Line Interface (CLI) and a Go client for the REST API of Confluent's Kafka Schema Registry. 5 6 [](https://travis-ci.org/Landoop/schema-registry) 7 [](https://godoc.org/github.com/Landoop/schema-registry) 8 [](https://slackpass.io/landoop-community) 9 10 CLI 11 --- 12 13 To install the CLI, assuming a properly setup Go installation, do: 14 15 `go get -u github.com/landoop/schema-registry/schema-registry-cli` 16 17 After that, the CLI is found in `$GOPATH/bin/schema-registry-cli`. Running `schema-registry-cli` without arguments gives: 18 19 ``` 20 A command line interface for the Confluent schema registry 21 22 Usage: 23 schema-registry-cli [command] 24 25 Available Commands: 26 add registers the schema provided through stdin 27 compatible tests compatibility between a schema from stdin and a given subject 28 exists checks if the schema provided through stdin exists for the subject 29 get retrieves a schema specified by id or subject 30 get-config retrieves global or suject specific configuration 31 subjects lists all registered subjects 32 versions lists all available versions 33 34 Flags: 35 -h, --help help for schema-registry-cli 36 -n, --no-color dont color output 37 -e, --url string schema registry url, overrides SCHEMA_REGISTRY_URL (default "http://localhost:8081") 38 -v, --verbose be verbose 39 40 Use "schema-registry-cli [command] --help" for more information about a command. 41 ``` 42 43 The schema registry url can be configured through the `SCHEMA_REGISTRY_URL` environment variable, and overridden through `--url`. When none is provided, `http://localhost:8081` is used as default. 44 45 Client 46 ------ 47 48 The client package provides a client to deal with the registry from code. It is used by the CLI internally. Usage looks like: 49 50 ```go 51 import "github.com/landoop/schema-registry" 52 53 client, _ := schemaregistry.NewClient(schemaregistry.DefaultUrl) 54 client.Subjects() 55 ``` 56 57 Or, to use with a Schema Registry endpoint listening on HTTPS: 58 59 ```go 60 import ( 61 "crypto/tls" 62 "crypto/x509" 63 "io/ioutil" 64 65 "github.com/landoop/schema-registry" 66 ) 67 68 // Create a TLS config to use to connect to Schema Registry. This config will permit TLS connections to an endpoint 69 // whose TLS cert is signed by the given caFile. 70 caCert, err := ioutil.ReadFile("/path/to/ca/file") 71 if err != nil { 72 panic(err) 73 } 74 75 caCertPool := x509.NewCertPool() 76 caCertPool.AppendCertsFromPEM(caCert) 77 78 tlsConfig := &tls.Config{ 79 RootCAs: caCertPool, 80 InsecureSkipVerify: true, 81 } 82 83 httpsClientTransport := &http.Transport{ 84 TLSClientConfig: tlsConfig, 85 } 86 87 httpsClient := &http.Client{ 88 Transport: httpsClientTransport, 89 } 90 91 // Create the Schema Registry client 92 client, _ := schemaregistry.NewClient(baseurl, UsingClient(httpsClient)) 93 client.Subjects() 94 ``` 95 96 The documentation of the package can be found here: [](https://godoc.org/github.com/Landoop/schema-registry)