This file is indexed.

/usr/share/gocode/src/github.com/influxdb/enterprise-client/v1/registration.go is in golang-github-influxdb-enterprise-client-dev 0.0~git20151113.0.25665cb-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package client

import (
	"errors"
	"net/url"
)

// Registration is used to collect data needed by
// Enterprise to properly start the registration
// Process.
type Registration struct {
	ClusterID string
	Product   string // influxdb, chronograf, telegraf, kapicator
	// OPTIONAL: Enterprise will redirect the customer back to the
	// RedirectURL if it is specified.
	RedirectURL string
}

// IsValid returns an error if the Registration is not valid.
// This is necessary since there is no server-side validation
// of this data.
func (r Registration) IsValid() error {
	if r.ClusterID == "" || r.Product == "" {
		return errors.New("You must supply both a ClusterID and a Product!")
	}
	return nil
}

// RegistrationURL returns a URL based on the Registration
// data provided. The app can then use this URL to direct
// customers over to the Enterprise application to complete
// their registration.
func (c *Client) RegistrationURL(r Registration) (string, error) {
	err := r.IsValid()
	if err != nil {
		return "", err
	}

	u, _ := url.Parse(c.URL)
	u.Path = "/start"

	q := u.Query()
	q.Set("cluster_id", r.ClusterID)
	q.Set("product", r.Product)
	if r.RedirectURL != "" {
		q.Set("redirect_url", r.RedirectURL)
	}
	u.RawQuery = q.Encode()

	return u.String(), nil
}