repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
remind101/empire
db.go
first
func first(db *gorm.DB, scope scope, v interface{}) error { return scope.scope(db).First(v).Error }
go
func first(db *gorm.DB, scope scope, v interface{}) error { return scope.scope(db).First(v).Error }
[ "func", "first", "(", "db", "*", "gorm", ".", "DB", ",", "scope", "scope", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "scope", ".", "scope", "(", "db", ")", ".", "First", "(", "v", ")", ".", "Error", "\n", "}" ]
// first is a small helper that finds the first record matching a scope, and // returns the error.
[ "first", "is", "a", "small", "helper", "that", "finds", "the", "first", "record", "matching", "a", "scope", "and", "returns", "the", "error", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L251-L253
train
remind101/empire
db.go
find
func find(db *gorm.DB, scope scope, v interface{}) error { return scope.scope(db).Find(v).Error }
go
func find(db *gorm.DB, scope scope, v interface{}) error { return scope.scope(db).Find(v).Error }
[ "func", "find", "(", "db", "*", "gorm", ".", "DB", ",", "scope", "scope", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "scope", ".", "scope", "(", "db", ")", ".", "Find", "(", "v", ")", ".", "Error", "\n", "}" ]
// find is a small helper that finds records matching the scope, and returns the // error.
[ "find", "is", "a", "small", "helper", "that", "finds", "records", "matching", "the", "scope", "and", "returns", "the", "error", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L257-L259
train
remind101/empire
pkg/dockerutil/dockerutil.go
FakePull
func FakePull(img image.Image, w io.Writer) error { messages := []jsonmessage.JSONMessage{ {Status: fmt.Sprintf("Pulling repository %s", img.Repository)}, {Status: fmt.Sprintf("Pulling image (%s) from %s", img.Tag, img.Repository), Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: fmt.Sprintf("Pulling image (%s) from %s, endpoint: https://registry-1.docker.io/v1/", img.Tag, img.Repository), Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: "Pulling dependent layers", Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: "Download complete", Progress: &jsonmessage.JSONProgress{}, ID: "a1dd7097a8e8"}, {Status: fmt.Sprintf("Status: Image is up to date for %s", img)}, } enc := json.NewEncoder(w) for _, m := range messages { if err := enc.Encode(&m); err != nil { return err } } return nil }
go
func FakePull(img image.Image, w io.Writer) error { messages := []jsonmessage.JSONMessage{ {Status: fmt.Sprintf("Pulling repository %s", img.Repository)}, {Status: fmt.Sprintf("Pulling image (%s) from %s", img.Tag, img.Repository), Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: fmt.Sprintf("Pulling image (%s) from %s, endpoint: https://registry-1.docker.io/v1/", img.Tag, img.Repository), Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: "Pulling dependent layers", Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"}, {Status: "Download complete", Progress: &jsonmessage.JSONProgress{}, ID: "a1dd7097a8e8"}, {Status: fmt.Sprintf("Status: Image is up to date for %s", img)}, } enc := json.NewEncoder(w) for _, m := range messages { if err := enc.Encode(&m); err != nil { return err } } return nil }
[ "func", "FakePull", "(", "img", "image", ".", "Image", ",", "w", "io", ".", "Writer", ")", "error", "{", "messages", ":=", "[", "]", "jsonmessage", ".", "JSONMessage", "{", "{", "Status", ":", "fmt", ".", "Sprintf", "(", "\"Pulling repository %s\"", ",",...
// FakePull writes a jsonmessage stream to w that looks like a Docker pull.
[ "FakePull", "writes", "a", "jsonmessage", "stream", "to", "w", "that", "looks", "like", "a", "Docker", "pull", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/dockerutil.go#L16-L35
train
remind101/empire
pkg/dockerutil/dockerutil.go
PullImageOptions
func PullImageOptions(img image.Image) (docker.PullImageOptions, error) { var options docker.PullImageOptions // From the Docker API docs: // // Tag or digest. If empty when pulling an image, this // causes all tags for the given image to be pulled. // // So, we prefer the digest if it's provided. tag := img.Digest if tag == "" { tag = img.Tag } // If there's no tag or digest, error out. Providing an empty // tag to DockerPull will pull all images, which we don't want. if tag == "" { return options, fmt.Errorf("no tag or digest provided") } options.Tag = tag options.Repository = img.Repository // Only required for Docker Engine 1.9 or 1.10 w/ Remote API < 1.21 // and Docker Engine < 1.9 // This parameter was removed in Docker Engine 1.11 // // See https://goo.gl/9y9Bpx options.Registry = img.Registry return options, nil }
go
func PullImageOptions(img image.Image) (docker.PullImageOptions, error) { var options docker.PullImageOptions // From the Docker API docs: // // Tag or digest. If empty when pulling an image, this // causes all tags for the given image to be pulled. // // So, we prefer the digest if it's provided. tag := img.Digest if tag == "" { tag = img.Tag } // If there's no tag or digest, error out. Providing an empty // tag to DockerPull will pull all images, which we don't want. if tag == "" { return options, fmt.Errorf("no tag or digest provided") } options.Tag = tag options.Repository = img.Repository // Only required for Docker Engine 1.9 or 1.10 w/ Remote API < 1.21 // and Docker Engine < 1.9 // This parameter was removed in Docker Engine 1.11 // // See https://goo.gl/9y9Bpx options.Registry = img.Registry return options, nil }
[ "func", "PullImageOptions", "(", "img", "image", ".", "Image", ")", "(", "docker", ".", "PullImageOptions", ",", "error", ")", "{", "var", "options", "docker", ".", "PullImageOptions", "\n", "tag", ":=", "img", ".", "Digest", "\n", "if", "tag", "==", "\"...
// PullImageOptions generates an appropriate docker.PullImageOptions to pull the // target image based on the idiosyncrasies of docker.
[ "PullImageOptions", "generates", "an", "appropriate", "docker", ".", "PullImageOptions", "to", "pull", "the", "target", "image", "based", "on", "the", "idiosyncrasies", "of", "docker", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/dockerutil.go#L39-L70
train
remind101/empire
pkg/dockerutil/dockerutil.go
DecodeJSONMessageStream
func DecodeJSONMessageStream(w io.Writer) *DecodedJSONMessageWriter { outFd, _ := term.GetFdInfo(w) return &DecodedJSONMessageWriter{ w: w, fd: outFd, } }
go
func DecodeJSONMessageStream(w io.Writer) *DecodedJSONMessageWriter { outFd, _ := term.GetFdInfo(w) return &DecodedJSONMessageWriter{ w: w, fd: outFd, } }
[ "func", "DecodeJSONMessageStream", "(", "w", "io", ".", "Writer", ")", "*", "DecodedJSONMessageWriter", "{", "outFd", ",", "_", ":=", "term", ".", "GetFdInfo", "(", "w", ")", "\n", "return", "&", "DecodedJSONMessageWriter", "{", "w", ":", "w", ",", "fd", ...
// DecodeJSONMessageStream wraps an io.Writer to decode a jsonmessage stream into // plain text. Bytes written to w represent the decoded plain text stream.
[ "DecodeJSONMessageStream", "wraps", "an", "io", ".", "Writer", "to", "decode", "a", "jsonmessage", "stream", "into", "plain", "text", ".", "Bytes", "written", "to", "w", "represent", "the", "decoded", "plain", "text", "stream", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/dockerutil.go#L74-L80
train
remind101/empire
pkg/dockerutil/dockerutil.go
Write
func (w *DecodedJSONMessageWriter) Write(b []byte) (int, error) { err := jsonmessage.DisplayJSONMessagesStream(bytes.NewReader(b), w.w, w.fd, false, nil) if err != nil { if err, ok := err.(*jsonmessage.JSONError); ok { w.err = err return len(b), nil } } return len(b), err }
go
func (w *DecodedJSONMessageWriter) Write(b []byte) (int, error) { err := jsonmessage.DisplayJSONMessagesStream(bytes.NewReader(b), w.w, w.fd, false, nil) if err != nil { if err, ok := err.(*jsonmessage.JSONError); ok { w.err = err return len(b), nil } } return len(b), err }
[ "func", "(", "w", "*", "DecodedJSONMessageWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "err", ":=", "jsonmessage", ".", "DisplayJSONMessagesStream", "(", "bytes", ".", "NewReader", "(", "b", ")", ",", "w",...
// Write decodes the jsonmessage stream in the bytes, and writes the decoded // plain text to the underlying io.Writer.
[ "Write", "decodes", "the", "jsonmessage", "stream", "in", "the", "bytes", "and", "writes", "the", "decoded", "plain", "text", "to", "the", "underlying", "io", ".", "Writer", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/dockerutil.go#L95-L104
train
remind101/empire
pkg/heroku/organization.go
OrganizationList
func (c *Client) OrganizationList(lr *ListRange) ([]Organization, error) { req, err := c.NewRequest("GET", "/organizations", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var organizationsRes []Organization return organizationsRes, c.DoReq(req, &organizationsRes) }
go
func (c *Client) OrganizationList(lr *ListRange) ([]Organization, error) { req, err := c.NewRequest("GET", "/organizations", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var organizationsRes []Organization return organizationsRes, c.DoReq(req, &organizationsRes) }
[ "func", "(", "c", "*", "Client", ")", "OrganizationList", "(", "lr", "*", "ListRange", ")", "(", "[", "]", "Organization", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/organizations\"", ",", "nil", ...
// List organizations in which you are a member. // // lr is an optional ListRange that sets the Range options for the paginated // list of results.
[ "List", "organizations", "in", "which", "you", "are", "a", "member", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "of", "results", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization.go#L30-L42
train
remind101/empire
pkg/heroku/organization.go
OrganizationUpdate
func (c *Client) OrganizationUpdate(organizationIdentity string, options *OrganizationUpdateOpts) (*Organization, error) { var organizationRes Organization return &organizationRes, c.Patch(&organizationRes, "/organizations/"+organizationIdentity, options) }
go
func (c *Client) OrganizationUpdate(organizationIdentity string, options *OrganizationUpdateOpts) (*Organization, error) { var organizationRes Organization return &organizationRes, c.Patch(&organizationRes, "/organizations/"+organizationIdentity, options) }
[ "func", "(", "c", "*", "Client", ")", "OrganizationUpdate", "(", "organizationIdentity", "string", ",", "options", "*", "OrganizationUpdateOpts", ")", "(", "*", "Organization", ",", "error", ")", "{", "var", "organizationRes", "Organization", "\n", "return", "&"...
// Set or Unset the organization as your default organization. // // organizationIdentity is the unique identifier of the Organization. options is // the struct of optional parameters for this action.
[ "Set", "or", "Unset", "the", "organization", "as", "your", "default", "organization", ".", "organizationIdentity", "is", "the", "unique", "identifier", "of", "the", "Organization", ".", "options", "is", "the", "struct", "of", "optional", "parameters", "for", "th...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization.go#L48-L51
train
remind101/empire
pkg/heroku/account.go
AccountUpdate
func (c *Client) AccountUpdate(password string, options *AccountUpdateOpts) (*Account, error) { params := struct { Password string `json:"password"` AllowTracking *bool `json:"allow_tracking,omitempty"` Beta *bool `json:"beta,omitempty"` Name *string `json:"name,omitempty"` }{ Password: password, } if options != nil { params.AllowTracking = options.AllowTracking params.Beta = options.Beta params.Name = options.Name } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
go
func (c *Client) AccountUpdate(password string, options *AccountUpdateOpts) (*Account, error) { params := struct { Password string `json:"password"` AllowTracking *bool `json:"allow_tracking,omitempty"` Beta *bool `json:"beta,omitempty"` Name *string `json:"name,omitempty"` }{ Password: password, } if options != nil { params.AllowTracking = options.AllowTracking params.Beta = options.Beta params.Name = options.Name } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
[ "func", "(", "c", "*", "Client", ")", "AccountUpdate", "(", "password", "string", ",", "options", "*", "AccountUpdateOpts", ")", "(", "*", "Account", ",", "error", ")", "{", "params", ":=", "struct", "{", "Password", "string", "`json:\"password\"`", "\n", ...
// Update account. // // password is the current password on the account. options is the struct of // optional parameters for this action.
[ "Update", "account", ".", "password", "is", "the", "current", "password", "on", "the", "account", ".", "options", "is", "the", "struct", "of", "optional", "parameters", "for", "this", "action", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/account.go#L51-L67
train
remind101/empire
pkg/heroku/account.go
AccountChangeEmail
func (c *Client) AccountChangeEmail(password string, email string) (*Account, error) { params := struct { Password string `json:"password"` Email string `json:"email"` }{ Password: password, Email: email, } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
go
func (c *Client) AccountChangeEmail(password string, email string) (*Account, error) { params := struct { Password string `json:"password"` Email string `json:"email"` }{ Password: password, Email: email, } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
[ "func", "(", "c", "*", "Client", ")", "AccountChangeEmail", "(", "password", "string", ",", "email", "string", ")", "(", "*", "Account", ",", "error", ")", "{", "params", ":=", "struct", "{", "Password", "string", "`json:\"password\"`", "\n", "Email", "str...
// Change Email for account. // // password is the current password on the account. email is the unique email // address of account.
[ "Change", "Email", "for", "account", ".", "password", "is", "the", "current", "password", "on", "the", "account", ".", "email", "is", "the", "unique", "email", "address", "of", "account", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/account.go#L83-L93
train
remind101/empire
pkg/heroku/account.go
AccountChangePassword
func (c *Client) AccountChangePassword(newPassword string, password string) (*Account, error) { params := struct { NewPassword string `json:"new_password"` Password string `json:"password"` }{ NewPassword: newPassword, Password: password, } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
go
func (c *Client) AccountChangePassword(newPassword string, password string) (*Account, error) { params := struct { NewPassword string `json:"new_password"` Password string `json:"password"` }{ NewPassword: newPassword, Password: password, } var accountRes Account return &accountRes, c.Patch(&accountRes, "/account", params) }
[ "func", "(", "c", "*", "Client", ")", "AccountChangePassword", "(", "newPassword", "string", ",", "password", "string", ")", "(", "*", "Account", ",", "error", ")", "{", "params", ":=", "struct", "{", "NewPassword", "string", "`json:\"new_password\"`", "\n", ...
// Change Password for account. // // newPassword is the the new password for the account when changing the // password. password is the current password on the account.
[ "Change", "Password", "for", "account", ".", "newPassword", "is", "the", "the", "new", "password", "for", "the", "account", "when", "changing", "the", "password", ".", "password", "is", "the", "current", "password", "on", "the", "account", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/account.go#L99-L109
train
remind101/empire
cmd/empire/context.go
newContext
func newContext(c *cli.Context) (ctx *Context, err error) { ctx = &Context{ Context: c, netCtx: context.Background(), } ctx.reporter, err = newReporter(ctx) if err != nil { return } ctx.logger, err = newLogger(ctx) if err != nil { return } ctx.stats, err = newStats(ctx) if err != nil { return } ctx.netCtx = ctx.embed(ctx.netCtx) return }
go
func newContext(c *cli.Context) (ctx *Context, err error) { ctx = &Context{ Context: c, netCtx: context.Background(), } ctx.reporter, err = newReporter(ctx) if err != nil { return } ctx.logger, err = newLogger(ctx) if err != nil { return } ctx.stats, err = newStats(ctx) if err != nil { return } ctx.netCtx = ctx.embed(ctx.netCtx) return }
[ "func", "newContext", "(", "c", "*", "cli", ".", "Context", ")", "(", "ctx", "*", "Context", ",", "err", "error", ")", "{", "ctx", "=", "&", "Context", "{", "Context", ":", "c", ",", "netCtx", ":", "context", ".", "Background", "(", ")", ",", "}"...
// newContext builds a new base Context object.
[ "newContext", "builds", "a", "new", "base", "Context", "object", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/cmd/empire/context.go#L43-L67
train
remind101/empire
cmd/empire/context.go
ClientConfig
func (c *Context) ClientConfig(serviceName string, cfgs ...*aws.Config) client.Config { if c.awsConfigProvider == nil { c.awsConfigProvider = newConfigProvider(c) } return c.awsConfigProvider.ClientConfig(serviceName, cfgs...) }
go
func (c *Context) ClientConfig(serviceName string, cfgs ...*aws.Config) client.Config { if c.awsConfigProvider == nil { c.awsConfigProvider = newConfigProvider(c) } return c.awsConfigProvider.ClientConfig(serviceName, cfgs...) }
[ "func", "(", "c", "*", "Context", ")", "ClientConfig", "(", "serviceName", "string", ",", "cfgs", "...", "*", "aws", ".", "Config", ")", "client", ".", "Config", "{", "if", "c", ".", "awsConfigProvider", "==", "nil", "{", "c", ".", "awsConfigProvider", ...
// ClientConfig implements the client.ConfigProvider interface. This will return // a mostly standard client.Config, but also includes middleware that will // generate metrics for retried requests, and enables debug mode if // `FlagAWSDebug` is set.
[ "ClientConfig", "implements", "the", "client", ".", "ConfigProvider", "interface", ".", "This", "will", "return", "a", "mostly", "standard", "client", ".", "Config", "but", "also", "includes", "middleware", "that", "will", "generate", "metrics", "for", "retried", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/cmd/empire/context.go#L99-L105
train
remind101/empire
pkg/heroku/formation.go
FormationInfo
func (c *Client) FormationInfo(appIdentity string, formationIdentity string) (*Formation, error) { var formation Formation return &formation, c.Get(&formation, "/apps/"+appIdentity+"/formation/"+formationIdentity) }
go
func (c *Client) FormationInfo(appIdentity string, formationIdentity string) (*Formation, error) { var formation Formation return &formation, c.Get(&formation, "/apps/"+appIdentity+"/formation/"+formationIdentity) }
[ "func", "(", "c", "*", "Client", ")", "FormationInfo", "(", "appIdentity", "string", ",", "formationIdentity", "string", ")", "(", "*", "Formation", ",", "error", ")", "{", "var", "formation", "Formation", "\n", "return", "&", "formation", ",", "c", ".", ...
// Info for a process type // // appIdentity is the unique identifier of the Formation's App. // formationIdentity is the unique identifier of the Formation.
[ "Info", "for", "a", "process", "type", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", "s", "App", ".", "formationIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/formation.go#L42-L45
train
remind101/empire
pkg/heroku/formation.go
FormationList
func (c *Client) FormationList(appIdentity string, lr *ListRange) ([]Formation, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/formation", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var formationsRes []Formation return formationsRes, c.DoReq(req, &formationsRes) }
go
func (c *Client) FormationList(appIdentity string, lr *ListRange) ([]Formation, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/formation", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var formationsRes []Formation return formationsRes, c.DoReq(req, &formationsRes) }
[ "func", "(", "c", "*", "Client", ")", "FormationList", "(", "appIdentity", "string", ",", "lr", "*", "ListRange", ")", "(", "[", "]", "Formation", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/apps/...
// List process type formation // // appIdentity is the unique identifier of the Formation's App. lr is an // optional ListRange that sets the Range options for the paginated list of // results.
[ "List", "process", "type", "formation", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", "s", "App", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "o...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/formation.go#L52-L64
train
remind101/empire
pkg/heroku/formation.go
FormationBatchUpdate
func (c *Client) FormationBatchUpdate(appIdentity string, updates []FormationBatchUpdateOpts, message string) ([]Formation, error) { params := struct { Updates []FormationBatchUpdateOpts `json:"updates"` }{ Updates: updates, } rh := RequestHeaders{CommitMessage: message} var formationsRes []Formation return formationsRes, c.PatchWithHeaders(&formationsRes, "/apps/"+appIdentity+"/formation", params, rh.Headers()) }
go
func (c *Client) FormationBatchUpdate(appIdentity string, updates []FormationBatchUpdateOpts, message string) ([]Formation, error) { params := struct { Updates []FormationBatchUpdateOpts `json:"updates"` }{ Updates: updates, } rh := RequestHeaders{CommitMessage: message} var formationsRes []Formation return formationsRes, c.PatchWithHeaders(&formationsRes, "/apps/"+appIdentity+"/formation", params, rh.Headers()) }
[ "func", "(", "c", "*", "Client", ")", "FormationBatchUpdate", "(", "appIdentity", "string", ",", "updates", "[", "]", "FormationBatchUpdateOpts", ",", "message", "string", ")", "(", "[", "]", "Formation", ",", "error", ")", "{", "params", ":=", "struct", "...
// Batch update process types // // appIdentity is the unique identifier of the Formation's App. updates is the // Array with formation updates. Each element must have "process", the id or // name of the process type to be updated, and can optionally update its // "quantity" or "size".
[ "Batch", "update", "process", "types", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", "s", "App", ".", "updates", "is", "the", "Array", "with", "formation", "updates", ".", "Each", "element", "must", "have", "process", "the", "...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/formation.go#L72-L81
train
remind101/empire
pkg/heroku/formation.go
FormationUpdate
func (c *Client) FormationUpdate(appIdentity string, formationIdentity string, options *FormationUpdateOpts) (*Formation, error) { var formationRes Formation return &formationRes, c.Patch(&formationRes, "/apps/"+appIdentity+"/formation/"+formationIdentity, options) }
go
func (c *Client) FormationUpdate(appIdentity string, formationIdentity string, options *FormationUpdateOpts) (*Formation, error) { var formationRes Formation return &formationRes, c.Patch(&formationRes, "/apps/"+appIdentity+"/formation/"+formationIdentity, options) }
[ "func", "(", "c", "*", "Client", ")", "FormationUpdate", "(", "appIdentity", "string", ",", "formationIdentity", "string", ",", "options", "*", "FormationUpdateOpts", ")", "(", "*", "Formation", ",", "error", ")", "{", "var", "formationRes", "Formation", "\n",...
// Update process type // // appIdentity is the unique identifier of the Formation's App. // formationIdentity is the unique identifier of the Formation. options is the // struct of optional parameters for this action.
[ "Update", "process", "type", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", "s", "App", ".", "formationIdentity", "is", "the", "unique", "identifier", "of", "the", "Formation", ".", "options", "is", "the", "struct", "of", "option...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/formation.go#L99-L102
train
remind101/empire
server/github/deployer.go
NotifyTugboat
func NotifyTugboat(d Deployer, url string) *TugboatDeployer { c := tugboat.NewClient(nil) c.URL = url return &TugboatDeployer{ deployer: d, client: c, } }
go
func NotifyTugboat(d Deployer, url string) *TugboatDeployer { c := tugboat.NewClient(nil) c.URL = url return &TugboatDeployer{ deployer: d, client: c, } }
[ "func", "NotifyTugboat", "(", "d", "Deployer", ",", "url", "string", ")", "*", "TugboatDeployer", "{", "c", ":=", "tugboat", ".", "NewClient", "(", "nil", ")", "\n", "c", ".", "URL", "=", "url", "\n", "return", "&", "TugboatDeployer", "{", "deployer", ...
// NotifyTugboat wraps a Deployer to sent deployment logs and status updates to // a Tugboat instance.
[ "NotifyTugboat", "wraps", "a", "Deployer", "to", "sent", "deployment", "logs", "and", "status", "updates", "to", "a", "Tugboat", "instance", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/github/deployer.go#L88-L95
train
remind101/empire
server/github/deployer.go
DeployAsync
func DeployAsync(d Deployer) Deployer { return DeployerFunc(func(ctx context.Context, event events.Deployment, w io.Writer) error { go d.Deploy(ctx, event, w) return nil }) }
go
func DeployAsync(d Deployer) Deployer { return DeployerFunc(func(ctx context.Context, event events.Deployment, w io.Writer) error { go d.Deploy(ctx, event, w) return nil }) }
[ "func", "DeployAsync", "(", "d", "Deployer", ")", "Deployer", "{", "return", "DeployerFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "event", "events", ".", "Deployment", ",", "w", "io", ".", "Writer", ")", "error", "{", "go", "d", "."...
// DeployAsync wraps a Deployer to perform the Deploy within a goroutine.
[ "DeployAsync", "wraps", "a", "Deployer", "to", "perform", "the", "Deploy", "within", "a", "goroutine", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/github/deployer.go#L128-L133
train
remind101/empire
pkg/heroku/addon.go
AddonCreate
func (c *Client) AddonCreate(appIdentity string, plan string, options *AddonCreateOpts) (*Addon, error) { params := struct { Plan string `json:"plan"` Config *map[string]string `json:"config,omitempty"` }{ Plan: plan, } if options != nil { params.Config = options.Config } var addonRes Addon return &addonRes, c.Post(&addonRes, "/apps/"+appIdentity+"/addons", params) }
go
func (c *Client) AddonCreate(appIdentity string, plan string, options *AddonCreateOpts) (*Addon, error) { params := struct { Plan string `json:"plan"` Config *map[string]string `json:"config,omitempty"` }{ Plan: plan, } if options != nil { params.Config = options.Config } var addonRes Addon return &addonRes, c.Post(&addonRes, "/apps/"+appIdentity+"/addons", params) }
[ "func", "(", "c", "*", "Client", ")", "AddonCreate", "(", "appIdentity", "string", ",", "plan", "string", ",", "options", "*", "AddonCreateOpts", ")", "(", "*", "Addon", ",", "error", ")", "{", "params", ":=", "struct", "{", "Plan", "string", "`json:\"pl...
// Create a new add-on. // // appIdentity is the unique identifier of the Addon's App. plan is the unique // identifier of this plan or unique name of this plan. options is the struct of // optional parameters for this action.
[ "Create", "a", "new", "add", "-", "on", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "s", "App", ".", "plan", "is", "the", "unique", "identifier", "of", "this", "plan", "or", "unique", "name", "of", "this", "plan", "."...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon.go#L43-L55
train
remind101/empire
pkg/heroku/addon.go
AddonDelete
func (c *Client) AddonDelete(appIdentity string, addonIdentity string) error { return c.Delete("/apps/" + appIdentity + "/addons/" + addonIdentity) }
go
func (c *Client) AddonDelete(appIdentity string, addonIdentity string) error { return c.Delete("/apps/" + appIdentity + "/addons/" + addonIdentity) }
[ "func", "(", "c", "*", "Client", ")", "AddonDelete", "(", "appIdentity", "string", ",", "addonIdentity", "string", ")", "error", "{", "return", "c", ".", "Delete", "(", "\"/apps/\"", "+", "appIdentity", "+", "\"/addons/\"", "+", "addonIdentity", ")", "\n", ...
// Delete an existing add-on. // // appIdentity is the unique identifier of the Addon's App. addonIdentity is the // unique identifier of the Addon.
[ "Delete", "an", "existing", "add", "-", "on", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "s", "App", ".", "addonIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon.go#L67-L69
train
remind101/empire
pkg/heroku/addon.go
AddonInfo
func (c *Client) AddonInfo(appIdentity string, addonIdentity string) (*Addon, error) { var addon Addon return &addon, c.Get(&addon, "/apps/"+appIdentity+"/addons/"+addonIdentity) }
go
func (c *Client) AddonInfo(appIdentity string, addonIdentity string) (*Addon, error) { var addon Addon return &addon, c.Get(&addon, "/apps/"+appIdentity+"/addons/"+addonIdentity) }
[ "func", "(", "c", "*", "Client", ")", "AddonInfo", "(", "appIdentity", "string", ",", "addonIdentity", "string", ")", "(", "*", "Addon", ",", "error", ")", "{", "var", "addon", "Addon", "\n", "return", "&", "addon", ",", "c", ".", "Get", "(", "&", ...
// Info for an existing add-on. // // appIdentity is the unique identifier of the Addon's App. addonIdentity is the // unique identifier of the Addon.
[ "Info", "for", "an", "existing", "add", "-", "on", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "s", "App", ".", "addonIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon.go#L75-L78
train
remind101/empire
pkg/heroku/addon.go
AddonList
func (c *Client) AddonList(appIdentity string, lr *ListRange) ([]Addon, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/addons", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var addonsRes []Addon return addonsRes, c.DoReq(req, &addonsRes) }
go
func (c *Client) AddonList(appIdentity string, lr *ListRange) ([]Addon, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/addons", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var addonsRes []Addon return addonsRes, c.DoReq(req, &addonsRes) }
[ "func", "(", "c", "*", "Client", ")", "AddonList", "(", "appIdentity", "string", ",", "lr", "*", "ListRange", ")", "(", "[", "]", "Addon", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/apps/\"", "...
// List existing add-ons. // // appIdentity is the unique identifier of the Addon's App. lr is an optional // ListRange that sets the Range options for the paginated list of results.
[ "List", "existing", "add", "-", "ons", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Addon", "s", "App", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon.go#L84-L96
train
remind101/empire
pkg/heroku/addon.go
AddonUpdate
func (c *Client) AddonUpdate(appIdentity string, addonIdentity string, plan string) (*Addon, error) { params := struct { Plan string `json:"plan"` }{ Plan: plan, } var addonRes Addon return &addonRes, c.Patch(&addonRes, "/apps/"+appIdentity+"/addons/"+addonIdentity, params) }
go
func (c *Client) AddonUpdate(appIdentity string, addonIdentity string, plan string) (*Addon, error) { params := struct { Plan string `json:"plan"` }{ Plan: plan, } var addonRes Addon return &addonRes, c.Patch(&addonRes, "/apps/"+appIdentity+"/addons/"+addonIdentity, params) }
[ "func", "(", "c", "*", "Client", ")", "AddonUpdate", "(", "appIdentity", "string", ",", "addonIdentity", "string", ",", "plan", "string", ")", "(", "*", "Addon", ",", "error", ")", "{", "params", ":=", "struct", "{", "Plan", "string", "`json:\"plan\"`", ...
// Change add-on plan. Some add-ons may not support changing plans. In that // case, an error will be returned. // // appIdentity is the unique identifier of the Addon's App. addonIdentity is the // unique identifier of the Addon. plan is the unique identifier of this plan or // unique name of this plan.
[ "Change", "add", "-", "on", "plan", ".", "Some", "add", "-", "ons", "may", "not", "support", "changing", "plans", ".", "In", "that", "case", "an", "error", "will", "be", "returned", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon.go#L104-L112
train
remind101/empire
pkg/heroku/stack.go
StackInfo
func (c *Client) StackInfo(stackIdentity string) (*Stack, error) { var stack Stack return &stack, c.Get(&stack, "/stacks/"+stackIdentity) }
go
func (c *Client) StackInfo(stackIdentity string) (*Stack, error) { var stack Stack return &stack, c.Get(&stack, "/stacks/"+stackIdentity) }
[ "func", "(", "c", "*", "Client", ")", "StackInfo", "(", "stackIdentity", "string", ")", "(", "*", "Stack", ",", "error", ")", "{", "var", "stack", "Stack", "\n", "return", "&", "stack", ",", "c", ".", "Get", "(", "&", "stack", ",", "\"/stacks/\"", ...
// Stack info. // // stackIdentity is the unique identifier of the Stack.
[ "Stack", "info", ".", "stackIdentity", "is", "the", "unique", "identifier", "of", "the", "Stack", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/stack.go#L33-L36
train
remind101/empire
pkg/heroku/stack.go
StackList
func (c *Client) StackList(lr *ListRange) ([]Stack, error) { req, err := c.NewRequest("GET", "/stacks", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var stacksRes []Stack return stacksRes, c.DoReq(req, &stacksRes) }
go
func (c *Client) StackList(lr *ListRange) ([]Stack, error) { req, err := c.NewRequest("GET", "/stacks", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var stacksRes []Stack return stacksRes, c.DoReq(req, &stacksRes) }
[ "func", "(", "c", "*", "Client", ")", "StackList", "(", "lr", "*", "ListRange", ")", "(", "[", "]", "Stack", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/stacks\"", ",", "nil", ",", "nil", ")",...
// List available stacks. // // lr is an optional ListRange that sets the Range options for the paginated // list of results.
[ "List", "available", "stacks", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "of", "results", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/stack.go#L42-L54
train
remind101/empire
slugs.go
ParsedProcfile
func (s *Slug) ParsedProcfile() (procfile.Procfile, error) { return procfile.ParseProcfile(s.Procfile) }
go
func (s *Slug) ParsedProcfile() (procfile.Procfile, error) { return procfile.ParseProcfile(s.Procfile) }
[ "func", "(", "s", "*", "Slug", ")", "ParsedProcfile", "(", ")", "(", "procfile", ".", "Procfile", ",", "error", ")", "{", "return", "procfile", ".", "ParseProcfile", "(", "s", ".", "Procfile", ")", "\n", "}" ]
// ParsedProcfile returns the parsed Procfile.
[ "ParsedProcfile", "returns", "the", "parsed", "Procfile", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/slugs.go#L25-L27
train
remind101/empire
slugs.go
Formation
func (s *Slug) Formation() (Formation, error) { p, err := s.ParsedProcfile() if err != nil { return nil, err } return formationFromProcfile(p) }
go
func (s *Slug) Formation() (Formation, error) { p, err := s.ParsedProcfile() if err != nil { return nil, err } return formationFromProcfile(p) }
[ "func", "(", "s", "*", "Slug", ")", "Formation", "(", ")", "(", "Formation", ",", "error", ")", "{", "p", ",", "err", ":=", "s", ".", "ParsedProcfile", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n",...
// Formation returns a new Formation built from the extracted Procfile.
[ "Formation", "returns", "a", "new", "Formation", "built", "from", "the", "extracted", "Procfile", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/slugs.go#L30-L37
train
remind101/empire
slugs.go
Create
func (s *slugsService) Create(ctx context.Context, db *gorm.DB, img image.Image, w *DeploymentStream) (*Slug, error) { return slugsCreateByImage(ctx, db, s.ImageRegistry, img, w) }
go
func (s *slugsService) Create(ctx context.Context, db *gorm.DB, img image.Image, w *DeploymentStream) (*Slug, error) { return slugsCreateByImage(ctx, db, s.ImageRegistry, img, w) }
[ "func", "(", "s", "*", "slugsService", ")", "Create", "(", "ctx", "context", ".", "Context", ",", "db", "*", "gorm", ".", "DB", ",", "img", "image", ".", "Image", ",", "w", "*", "DeploymentStream", ")", "(", "*", "Slug", ",", "error", ")", "{", "...
// SlugsCreateByImage creates a Slug for the given image.
[ "SlugsCreateByImage", "creates", "a", "Slug", "for", "the", "given", "image", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/slugs.go#L45-L47
train
remind101/empire
slugs.go
slugsCreate
func slugsCreate(db *gorm.DB, slug *Slug) (*Slug, error) { return slug, db.Create(slug).Error }
go
func slugsCreate(db *gorm.DB, slug *Slug) (*Slug, error) { return slug, db.Create(slug).Error }
[ "func", "slugsCreate", "(", "db", "*", "gorm", ".", "DB", ",", "slug", "*", "Slug", ")", "(", "*", "Slug", ",", "error", ")", "{", "return", "slug", ",", "db", ".", "Create", "(", "slug", ")", ".", "Error", "\n", "}" ]
// slugsCreate inserts a Slug into the database.
[ "slugsCreate", "inserts", "a", "Slug", "into", "the", "database", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/slugs.go#L50-L52
train
remind101/empire
slugs.go
slugsCreateByImage
func slugsCreateByImage(ctx context.Context, db *gorm.DB, r ImageRegistry, img image.Image, w *DeploymentStream) (*Slug, error) { var ( slug Slug err error ) slug.Image, err = r.Resolve(ctx, img, w.Stream) if err != nil { return nil, fmt.Errorf("resolving %s: %v", img, err) } slug.Procfile, err = r.ExtractProcfile(ctx, slug.Image, w.Stream) if err != nil { return nil, fmt.Errorf("extracting Procfile from %s: %v", slug.Image, err) } return slugsCreate(db, &slug) }
go
func slugsCreateByImage(ctx context.Context, db *gorm.DB, r ImageRegistry, img image.Image, w *DeploymentStream) (*Slug, error) { var ( slug Slug err error ) slug.Image, err = r.Resolve(ctx, img, w.Stream) if err != nil { return nil, fmt.Errorf("resolving %s: %v", img, err) } slug.Procfile, err = r.ExtractProcfile(ctx, slug.Image, w.Stream) if err != nil { return nil, fmt.Errorf("extracting Procfile from %s: %v", slug.Image, err) } return slugsCreate(db, &slug) }
[ "func", "slugsCreateByImage", "(", "ctx", "context", ".", "Context", ",", "db", "*", "gorm", ".", "DB", ",", "r", "ImageRegistry", ",", "img", "image", ".", "Image", ",", "w", "*", "DeploymentStream", ")", "(", "*", "Slug", ",", "error", ")", "{", "v...
// SlugsCreateByImage first attempts to find a matching slug for the image. If // it's not found, it will fallback to extracting the process types using the // provided extractor, then create a slug.
[ "SlugsCreateByImage", "first", "attempts", "to", "find", "a", "matching", "slug", "for", "the", "image", ".", "If", "it", "s", "not", "found", "it", "will", "fallback", "to", "extracting", "the", "process", "types", "using", "the", "provided", "extractor", "...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/slugs.go#L57-L74
train
remind101/empire
server/cloudformation/ports.go
Get
func (a *dbPortAllocator) Get() (int64, error) { sql := `UPDATE ports SET taken = true WHERE port = (SELECT port FROM ports WHERE taken IS NULL ORDER BY port ASC LIMIT 1) RETURNING port` var port int64 err := a.db.QueryRow(sql).Scan(&port) return port, err }
go
func (a *dbPortAllocator) Get() (int64, error) { sql := `UPDATE ports SET taken = true WHERE port = (SELECT port FROM ports WHERE taken IS NULL ORDER BY port ASC LIMIT 1) RETURNING port` var port int64 err := a.db.QueryRow(sql).Scan(&port) return port, err }
[ "func", "(", "a", "*", "dbPortAllocator", ")", "Get", "(", ")", "(", "int64", ",", "error", ")", "{", "sql", ":=", "`UPDATE ports SET taken = true WHERE port = (SELECT port FROM ports WHERE taken IS NULL ORDER BY port ASC LIMIT 1) RETURNING port`", "\n", "var", "port", "int...
// Get finds an existing allocated port from the `ports` table. If one is not // allocated for the process, it allocates one and returns it.
[ "Get", "finds", "an", "existing", "allocated", "port", "from", "the", "ports", "table", ".", "If", "one", "is", "not", "allocated", "for", "the", "process", "it", "allocates", "one", "and", "returns", "it", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/ports.go#L63-L68
train
remind101/empire
server/cloudformation/ports.go
Put
func (a *dbPortAllocator) Put(port int64) error { sql := `UPDATE ports SET taken = NULL WHERE port = $1` _, err := a.db.Exec(sql, port) return err }
go
func (a *dbPortAllocator) Put(port int64) error { sql := `UPDATE ports SET taken = NULL WHERE port = $1` _, err := a.db.Exec(sql, port) return err }
[ "func", "(", "a", "*", "dbPortAllocator", ")", "Put", "(", "port", "int64", ")", "error", "{", "sql", ":=", "`UPDATE ports SET taken = NULL WHERE port = $1`", "\n", "_", ",", "err", ":=", "a", ".", "db", ".", "Exec", "(", "sql", ",", "port", ")", "\n", ...
// Put releases any allocated port for the process, returning it back to the // pool.
[ "Put", "releases", "any", "allocated", "port", "for", "the", "process", "returning", "it", "back", "to", "the", "pool", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/ports.go#L72-L76
train
remind101/empire
server/cloudformation/ecs.go
newECSClient
func newECSClient(config client.ConfigProvider) *ecs.ECS { return ecs.New(config, &aws.Config{ Retryer: newRetryer(), }) }
go
func newECSClient(config client.ConfigProvider) *ecs.ECS { return ecs.New(config, &aws.Config{ Retryer: newRetryer(), }) }
[ "func", "newECSClient", "(", "config", "client", ".", "ConfigProvider", ")", "*", "ecs", ".", "ECS", "{", "return", "ecs", ".", "New", "(", "config", ",", "&", "aws", ".", "Config", "{", "Retryer", ":", "newRetryer", "(", ")", ",", "}", ")", "\n", ...
// newECSClient returns a new ecs.ECS instance, that has more relaxed retry // timeouts.
[ "newECSClient", "returns", "a", "new", "ecs", ".", "ECS", "instance", "that", "has", "more", "relaxed", "retry", "timeouts", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/ecs.go#L33-L37
train
remind101/empire
server/heroku/heroku.go
New
func New(e *empire.Empire) *Server { r := &Server{ Empire: e, mux: mux.NewRouter(), } // Apps r.handle("GET", "/apps", r.GetApps) // hk apps r.handle("GET", "/apps/{app}", r.GetAppInfo) // hk info r.handle("DELETE", "/apps/{app}", r.DeleteApp) // hk destroy r.handle("PATCH", "/apps/{app}", r.PatchApp) // hk destroy r.handle("POST", "/apps/{app}/deploys", r.DeployApp) // Deploy an image to an app r.handle("POST", "/apps", r.PostApps) // hk create r.handle("POST", "/organizations/apps", r.PostApps) // hk create // Domains r.handle("GET", "/apps/{app}/domains", r.GetDomains) // hk domains r.handle("POST", "/apps/{app}/domains", r.PostDomains) // hk domain-add r.handle("DELETE", "/apps/{app}/domains/{hostname}", r.DeleteDomain) // hk domain-remove // Deploys r.handle("POST", "/deploys", r.PostDeploys) // Deploy an app // Releases r.handle("GET", "/apps/{app}/releases", r.GetReleases) // hk releases r.handle("GET", "/apps/{app}/releases/{version}", r.GetRelease) // hk release-info r.handle("POST", "/apps/{app}/releases", r.PostReleases) // hk rollback // Configs r.handle("GET", "/apps/{app}/config-vars", r.GetConfigs) // hk env, hk get r.handle("GET", "/apps/{app}/config-vars/{version}", r.GetConfigsByRelease) // hk env v1, hk get v1 r.handle("PATCH", "/apps/{app}/config-vars", r.PatchConfigs) // hk set, hk unset // Processes r.handle("GET", "/apps/{app}/dynos", r.GetProcesses) // hk dynos r.handle("POST", "/apps/{app}/dynos", r.PostProcess) // hk run r.handle("DELETE", "/apps/{app}/dynos", r.DeleteProcesses) // hk restart r.handle("DELETE", "/apps/{app}/dynos/{ptype}.{pid}", r.DeleteProcesses) // hk restart web.1 r.handle("DELETE", "/apps/{app}/dynos/{pid}", r.DeleteProcesses) // hk restart web // Formations r.handle("GET", "/apps/{app}/formation", r.GetFormation) // hk scale -l r.handle("PATCH", "/apps/{app}/formation", r.PatchFormation) // hk scale // OAuth r.handle("POST", "/oauth/authorizations", r.PostAuthorizations). // Authentication for this endpoint is handled directly in the // handler. AuthWith(auth.StrategyUsernamePassword) // Certs r.handle("POST", "/apps/{app}/certs", r.PostCerts) // SSL sslRemoved := errHandler(ErrSSLRemoved) r.handle("GET", "/apps/{app}/ssl-endpoints", sslRemoved) // hk ssl r.handle("POST", "/apps/{app}/ssl-endpoints", sslRemoved) // hk ssl-cert-add r.handle("PATCH", "/apps/{app}/ssl-endpoints/{cert}", sslRemoved) // hk ssl-cert-add, hk ssl-cert-rollback r.handle("DELETE", "/apps/{app}/ssl-endpoints/{cert}", sslRemoved) // hk ssl-destroy // Logs r.handle("POST", "/apps/{app}/log-sessions", r.PostLogs) // hk log return r }
go
func New(e *empire.Empire) *Server { r := &Server{ Empire: e, mux: mux.NewRouter(), } // Apps r.handle("GET", "/apps", r.GetApps) // hk apps r.handle("GET", "/apps/{app}", r.GetAppInfo) // hk info r.handle("DELETE", "/apps/{app}", r.DeleteApp) // hk destroy r.handle("PATCH", "/apps/{app}", r.PatchApp) // hk destroy r.handle("POST", "/apps/{app}/deploys", r.DeployApp) // Deploy an image to an app r.handle("POST", "/apps", r.PostApps) // hk create r.handle("POST", "/organizations/apps", r.PostApps) // hk create // Domains r.handle("GET", "/apps/{app}/domains", r.GetDomains) // hk domains r.handle("POST", "/apps/{app}/domains", r.PostDomains) // hk domain-add r.handle("DELETE", "/apps/{app}/domains/{hostname}", r.DeleteDomain) // hk domain-remove // Deploys r.handle("POST", "/deploys", r.PostDeploys) // Deploy an app // Releases r.handle("GET", "/apps/{app}/releases", r.GetReleases) // hk releases r.handle("GET", "/apps/{app}/releases/{version}", r.GetRelease) // hk release-info r.handle("POST", "/apps/{app}/releases", r.PostReleases) // hk rollback // Configs r.handle("GET", "/apps/{app}/config-vars", r.GetConfigs) // hk env, hk get r.handle("GET", "/apps/{app}/config-vars/{version}", r.GetConfigsByRelease) // hk env v1, hk get v1 r.handle("PATCH", "/apps/{app}/config-vars", r.PatchConfigs) // hk set, hk unset // Processes r.handle("GET", "/apps/{app}/dynos", r.GetProcesses) // hk dynos r.handle("POST", "/apps/{app}/dynos", r.PostProcess) // hk run r.handle("DELETE", "/apps/{app}/dynos", r.DeleteProcesses) // hk restart r.handle("DELETE", "/apps/{app}/dynos/{ptype}.{pid}", r.DeleteProcesses) // hk restart web.1 r.handle("DELETE", "/apps/{app}/dynos/{pid}", r.DeleteProcesses) // hk restart web // Formations r.handle("GET", "/apps/{app}/formation", r.GetFormation) // hk scale -l r.handle("PATCH", "/apps/{app}/formation", r.PatchFormation) // hk scale // OAuth r.handle("POST", "/oauth/authorizations", r.PostAuthorizations). // Authentication for this endpoint is handled directly in the // handler. AuthWith(auth.StrategyUsernamePassword) // Certs r.handle("POST", "/apps/{app}/certs", r.PostCerts) // SSL sslRemoved := errHandler(ErrSSLRemoved) r.handle("GET", "/apps/{app}/ssl-endpoints", sslRemoved) // hk ssl r.handle("POST", "/apps/{app}/ssl-endpoints", sslRemoved) // hk ssl-cert-add r.handle("PATCH", "/apps/{app}/ssl-endpoints/{cert}", sslRemoved) // hk ssl-cert-add, hk ssl-cert-rollback r.handle("DELETE", "/apps/{app}/ssl-endpoints/{cert}", sslRemoved) // hk ssl-destroy // Logs r.handle("POST", "/apps/{app}/log-sessions", r.PostLogs) // hk log return r }
[ "func", "New", "(", "e", "*", "empire", ".", "Empire", ")", "*", "Server", "{", "r", ":=", "&", "Server", "{", "Empire", ":", "e", ",", "mux", ":", "mux", ".", "NewRouter", "(", ")", ",", "}", "\n", "r", ".", "handle", "(", "\"GET\"", ",", "\...
// New returns a new Server instance to serve the Heroku compatible API.
[ "New", "returns", "a", "new", "Server", "instance", "to", "serve", "the", "Heroku", "compatible", "API", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L52-L116
train
remind101/empire
server/heroku/heroku.go
AuthWith
func (r *route) AuthWith(strategies ...string) *route { r.authStrategies = strategies return r }
go
func (r *route) AuthWith(strategies ...string) *route { r.authStrategies = strategies return r }
[ "func", "(", "r", "*", "route", ")", "AuthWith", "(", "strategies", "...", "string", ")", "*", "route", "{", "r", ".", "authStrategies", "=", "strategies", "\n", "return", "r", "\n", "}" ]
// AuthWith sets the explicit strategies used to authenticate this route.
[ "AuthWith", "sets", "the", "explicit", "strategies", "used", "to", "authenticate", "this", "route", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L136-L139
train
remind101/empire
server/heroku/heroku.go
handle
func (s *Server) handle(method, path string, h handlerFunc, authStrategy ...string) *route { r := s.route(h) s.mux.Handle(path, r).Methods(method) return r }
go
func (s *Server) handle(method, path string, h handlerFunc, authStrategy ...string) *route { r := s.route(h) s.mux.Handle(path, r).Methods(method) return r }
[ "func", "(", "s", "*", "Server", ")", "handle", "(", "method", ",", "path", "string", ",", "h", "handlerFunc", ",", "authStrategy", "...", "string", ")", "*", "route", "{", "r", ":=", "s", ".", "route", "(", "h", ")", "\n", "s", ".", "mux", ".", ...
// handle adds a new handler to the router, which also increments a counter.
[ "handle", "adds", "a", "new", "handler", "to", "the", "router", "which", "also", "increments", "a", "counter", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L167-L171
train
remind101/empire
server/heroku/heroku.go
route
func (s *Server) route(h handlerFunc) *route { name := handlerName(h) return &route{Name: name, handler: h, s: s} }
go
func (s *Server) route(h handlerFunc) *route { name := handlerName(h) return &route{Name: name, handler: h, s: s} }
[ "func", "(", "s", "*", "Server", ")", "route", "(", "h", "handlerFunc", ")", "*", "route", "{", "name", ":=", "handlerName", "(", "h", ")", "\n", "return", "&", "route", "{", "Name", ":", "name", ",", "handler", ":", "h", ",", "s", ":", "s", "}...
// route creates a new route object for the given handler.
[ "route", "creates", "a", "new", "route", "object", "for", "the", "given", "handler", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L174-L177
train
remind101/empire
server/heroku/heroku.go
Encode
func Encode(w http.ResponseWriter, v interface{}) error { if v == nil { // Empty JSON body "{}" v = map[string]interface{}{} } return json.NewEncoder(w).Encode(v) }
go
func Encode(w http.ResponseWriter, v interface{}) error { if v == nil { // Empty JSON body "{}" v = map[string]interface{}{} } return json.NewEncoder(w).Encode(v) }
[ "func", "Encode", "(", "w", "http", ".", "ResponseWriter", ",", "v", "interface", "{", "}", ")", "error", "{", "if", "v", "==", "nil", "{", "v", "=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "}", "\n", "return", "json", ...
// Encode json encodes v into w.
[ "Encode", "json", "encodes", "v", "into", "w", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L180-L187
train
remind101/empire
server/heroku/heroku.go
DecodeRequest
func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error { if err := json.NewDecoder(r.Body).Decode(v); err != nil { if err == io.EOF && ignoreEOF { return nil } return fmt.Errorf("error decoding request body: %v", err) } return nil }
go
func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error { if err := json.NewDecoder(r.Body).Decode(v); err != nil { if err == io.EOF && ignoreEOF { return nil } return fmt.Errorf("error decoding request body: %v", err) } return nil }
[ "func", "DecodeRequest", "(", "r", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ",", "ignoreEOF", "bool", ")", "error", "{", "if", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body", ")", ".", "Decode", "(", "v", ")", ...
// DecodeRequest json decodes the request body into v, optionally ignoring EOF // errors to handle cases where the request body might be empty.
[ "DecodeRequest", "json", "decodes", "the", "request", "body", "into", "v", "optionally", "ignoring", "EOF", "errors", "to", "handle", "cases", "where", "the", "request", "body", "might", "be", "empty", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L191-L199
train
remind101/empire
server/heroku/heroku.go
Decode
func Decode(r *http.Request, v interface{}) error { return DecodeRequest(r, v, false) }
go
func Decode(r *http.Request, v interface{}) error { return DecodeRequest(r, v, false) }
[ "func", "Decode", "(", "r", "*", "http", ".", "Request", ",", "v", "interface", "{", "}", ")", "error", "{", "return", "DecodeRequest", "(", "r", ",", "v", ",", "false", ")", "\n", "}" ]
// Decode json decodes the request body into v.
[ "Decode", "json", "decodes", "the", "request", "body", "into", "v", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L202-L204
train
remind101/empire
server/heroku/heroku.go
Stream
func Stream(w http.ResponseWriter, v interface{}) error { if err := Encode(w, v); err != nil { return err } if f, ok := w.(http.Flusher); ok { f.Flush() } return nil }
go
func Stream(w http.ResponseWriter, v interface{}) error { if err := Encode(w, v); err != nil { return err } if f, ok := w.(http.Flusher); ok { f.Flush() } return nil }
[ "func", "Stream", "(", "w", "http", ".", "ResponseWriter", ",", "v", "interface", "{", "}", ")", "error", "{", "if", "err", ":=", "Encode", "(", "w", ",", "v", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "f", ",",...
// Stream encodes and flushes data to the client.
[ "Stream", "encodes", "and", "flushes", "data", "to", "the", "client", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L207-L217
train
remind101/empire
server/heroku/heroku.go
NoContent
func NoContent(w http.ResponseWriter) error { w.WriteHeader(http.StatusNoContent) return nil }
go
func NoContent(w http.ResponseWriter) error { w.WriteHeader(http.StatusNoContent) return nil }
[ "func", "NoContent", "(", "w", "http", ".", "ResponseWriter", ")", "error", "{", "w", ".", "WriteHeader", "(", "http", ".", "StatusNoContent", ")", "\n", "return", "nil", "\n", "}" ]
// NoContent responds with a 404 and an empty body.
[ "NoContent", "responds", "with", "a", "404", "and", "an", "empty", "body", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L239-L242
train
remind101/empire
server/heroku/heroku.go
RangeHeader
func RangeHeader(r *http.Request) (headerutil.Range, error) { header := r.Header.Get("Range") if header == "" { return headerutil.Range{}, nil } rangeHeader, err := headerutil.ParseRange(header) if err != nil { return headerutil.Range{}, err } return *rangeHeader, nil }
go
func RangeHeader(r *http.Request) (headerutil.Range, error) { header := r.Header.Get("Range") if header == "" { return headerutil.Range{}, nil } rangeHeader, err := headerutil.ParseRange(header) if err != nil { return headerutil.Range{}, err } return *rangeHeader, nil }
[ "func", "RangeHeader", "(", "r", "*", "http", ".", "Request", ")", "(", "headerutil", ".", "Range", ",", "error", ")", "{", "header", ":=", "r", ".", "Header", ".", "Get", "(", "\"Range\"", ")", "\n", "if", "header", "==", "\"\"", "{", "return", "h...
// RangeHeader parses the Range header and returns an headerutil.Range.
[ "RangeHeader", "parses", "the", "Range", "header", "and", "returns", "an", "headerutil", ".", "Range", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L245-L256
train
remind101/empire
server/heroku/heroku.go
handlerName
func handlerName(h handlerFunc) string { name := runtime.FuncForPC(reflect.ValueOf(h).Pointer()).Name() parts := nameRegexp.FindStringSubmatch(name) if len(parts) != 2 { return "" } return parts[1] }
go
func handlerName(h handlerFunc) string { name := runtime.FuncForPC(reflect.ValueOf(h).Pointer()).Name() parts := nameRegexp.FindStringSubmatch(name) if len(parts) != 2 { return "" } return parts[1] }
[ "func", "handlerName", "(", "h", "handlerFunc", ")", "string", "{", "name", ":=", "runtime", ".", "FuncForPC", "(", "reflect", ".", "ValueOf", "(", "h", ")", ".", "Pointer", "(", ")", ")", ".", "Name", "(", ")", "\n", "parts", ":=", "nameRegexp", "."...
// handlerName returns the name of the handler, which can be used as a metrics // postfix.
[ "handlerName", "returns", "the", "name", "of", "the", "handler", "which", "can", "be", "used", "as", "a", "metrics", "postfix", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/heroku.go#L267-L274
train
remind101/empire
server/saml.go
SAMLLogin
func (s *Server) SAMLLogin(w http.ResponseWriter, r *http.Request) { if s.ServiceProvider == nil { http.NotFound(w, r) return } // TODO(ejholmes): Handle error _ = s.ServiceProvider.InitiateLogin(w) }
go
func (s *Server) SAMLLogin(w http.ResponseWriter, r *http.Request) { if s.ServiceProvider == nil { http.NotFound(w, r) return } // TODO(ejholmes): Handle error _ = s.ServiceProvider.InitiateLogin(w) }
[ "func", "(", "s", "*", "Server", ")", "SAMLLogin", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "s", ".", "ServiceProvider", "==", "nil", "{", "http", ".", "NotFound", "(", "w", ",", "r", ")", "\...
// SAMLLogin starts a Service Provider initiated login. It generates an // AuthnRequest, signs the generated id and stores it in a cookie, then starts // the login with the IdP.
[ "SAMLLogin", "starts", "a", "Service", "Provider", "initiated", "login", ".", "It", "generates", "an", "AuthnRequest", "signs", "the", "generated", "id", "and", "stores", "it", "in", "a", "cookie", "then", "starts", "the", "login", "with", "the", "IdP", "." ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/saml.go#L19-L27
train
remind101/empire
server/saml.go
SAMLACS
func (s *Server) SAMLACS(w http.ResponseWriter, r *http.Request) { if s.ServiceProvider == nil { http.NotFound(w, r) return } assertion, err := s.ServiceProvider.Parse(w, r) if err != nil { if err, ok := err.(*saml.InvalidResponseError); ok { reporter.Report(r.Context(), err.PrivateErr) } http.Error(w, err.Error(), 403) return } session := samlauth.SessionFromAssertion(assertion) // Create an Access Token for the API. at, err := s.Heroku.AccessTokensCreate(&heroku.AccessToken{ ExpiresAt: session.ExpiresAt, User: session.User, }) if err != nil { http.Error(w, err.Error(), 403) return } switch r.Header.Get("Accept") { case "text/plain": w.Header().Set("Content-Type", "text/plain") io.WriteString(w, at.Token) default: w.Header().Set("Content-Type", "text/html") instructionsTemplate.Execute(w, &instructionsData{ URL: s.URL, User: session.User, Token: at, }) } }
go
func (s *Server) SAMLACS(w http.ResponseWriter, r *http.Request) { if s.ServiceProvider == nil { http.NotFound(w, r) return } assertion, err := s.ServiceProvider.Parse(w, r) if err != nil { if err, ok := err.(*saml.InvalidResponseError); ok { reporter.Report(r.Context(), err.PrivateErr) } http.Error(w, err.Error(), 403) return } session := samlauth.SessionFromAssertion(assertion) // Create an Access Token for the API. at, err := s.Heroku.AccessTokensCreate(&heroku.AccessToken{ ExpiresAt: session.ExpiresAt, User: session.User, }) if err != nil { http.Error(w, err.Error(), 403) return } switch r.Header.Get("Accept") { case "text/plain": w.Header().Set("Content-Type", "text/plain") io.WriteString(w, at.Token) default: w.Header().Set("Content-Type", "text/html") instructionsTemplate.Execute(w, &instructionsData{ URL: s.URL, User: session.User, Token: at, }) } }
[ "func", "(", "s", "*", "Server", ")", "SAMLACS", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "s", ".", "ServiceProvider", "==", "nil", "{", "http", ".", "NotFound", "(", "w", ",", "r", ")", "\n"...
// SAMLACS handles the SAML Response call. It will validate the SAML Response // and assertions, generate an API token, then present the token to the user.
[ "SAMLACS", "handles", "the", "SAML", "Response", "call", ".", "It", "will", "validate", "the", "SAML", "Response", "and", "assertions", "generate", "an", "API", "token", "then", "present", "the", "token", "to", "the", "user", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/saml.go#L31-L70
train
remind101/empire
pkg/heroku/ssl_endpoint.go
SSLEndpointDelete
func (c *Client) SSLEndpointDelete(appIdentity string, sslEndpointIdentity string) error { return c.Delete("/apps/" + appIdentity + "/ssl-endpoints/" + sslEndpointIdentity) }
go
func (c *Client) SSLEndpointDelete(appIdentity string, sslEndpointIdentity string) error { return c.Delete("/apps/" + appIdentity + "/ssl-endpoints/" + sslEndpointIdentity) }
[ "func", "(", "c", "*", "Client", ")", "SSLEndpointDelete", "(", "appIdentity", "string", ",", "sslEndpointIdentity", "string", ")", "error", "{", "return", "c", ".", "Delete", "(", "\"/apps/\"", "+", "appIdentity", "+", "\"/ssl-endpoints/\"", "+", "sslEndpointId...
// Delete existing SSL endpoint. // // appIdentity is the unique identifier of the SSLEndpoint's App. // sslEndpointIdentity is the unique identifier of the SSLEndpoint.
[ "Delete", "existing", "SSL", "endpoint", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "s", "App", ".", "sslEndpointIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/ssl_endpoint.go#L66-L68
train
remind101/empire
pkg/heroku/ssl_endpoint.go
SSLEndpointInfo
func (c *Client) SSLEndpointInfo(appIdentity string, sslEndpointIdentity string) (*SSLEndpoint, error) { var sslEndpoint SSLEndpoint return &sslEndpoint, c.Get(&sslEndpoint, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity) }
go
func (c *Client) SSLEndpointInfo(appIdentity string, sslEndpointIdentity string) (*SSLEndpoint, error) { var sslEndpoint SSLEndpoint return &sslEndpoint, c.Get(&sslEndpoint, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity) }
[ "func", "(", "c", "*", "Client", ")", "SSLEndpointInfo", "(", "appIdentity", "string", ",", "sslEndpointIdentity", "string", ")", "(", "*", "SSLEndpoint", ",", "error", ")", "{", "var", "sslEndpoint", "SSLEndpoint", "\n", "return", "&", "sslEndpoint", ",", "...
// Info for existing SSL endpoint. // // appIdentity is the unique identifier of the SSLEndpoint's App. // sslEndpointIdentity is the unique identifier of the SSLEndpoint.
[ "Info", "for", "existing", "SSL", "endpoint", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "s", "App", ".", "sslEndpointIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/ssl_endpoint.go#L74-L77
train
remind101/empire
pkg/heroku/ssl_endpoint.go
SSLEndpointList
func (c *Client) SSLEndpointList(appIdentity string, lr *ListRange) ([]SSLEndpoint, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/ssl-endpoints", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var sslEndpointsRes []SSLEndpoint return sslEndpointsRes, c.DoReq(req, &sslEndpointsRes) }
go
func (c *Client) SSLEndpointList(appIdentity string, lr *ListRange) ([]SSLEndpoint, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/ssl-endpoints", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var sslEndpointsRes []SSLEndpoint return sslEndpointsRes, c.DoReq(req, &sslEndpointsRes) }
[ "func", "(", "c", "*", "Client", ")", "SSLEndpointList", "(", "appIdentity", "string", ",", "lr", "*", "ListRange", ")", "(", "[", "]", "SSLEndpoint", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/a...
// List existing SSL endpoints. // // appIdentity is the unique identifier of the SSLEndpoint's App. lr is an // optional ListRange that sets the Range options for the paginated list of // results.
[ "List", "existing", "SSL", "endpoints", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "s", "App", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "li...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/ssl_endpoint.go#L84-L96
train
remind101/empire
pkg/heroku/ssl_endpoint.go
SSLEndpointUpdate
func (c *Client) SSLEndpointUpdate(appIdentity string, sslEndpointIdentity string, options *SSLEndpointUpdateOpts) (*SSLEndpoint, error) { var sslEndpointRes SSLEndpoint return &sslEndpointRes, c.Patch(&sslEndpointRes, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity, options) }
go
func (c *Client) SSLEndpointUpdate(appIdentity string, sslEndpointIdentity string, options *SSLEndpointUpdateOpts) (*SSLEndpoint, error) { var sslEndpointRes SSLEndpoint return &sslEndpointRes, c.Patch(&sslEndpointRes, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity, options) }
[ "func", "(", "c", "*", "Client", ")", "SSLEndpointUpdate", "(", "appIdentity", "string", ",", "sslEndpointIdentity", "string", ",", "options", "*", "SSLEndpointUpdateOpts", ")", "(", "*", "SSLEndpoint", ",", "error", ")", "{", "var", "sslEndpointRes", "SSLEndpoi...
// Update an existing SSL endpoint. // // appIdentity is the unique identifier of the SSLEndpoint's App. // sslEndpointIdentity is the unique identifier of the SSLEndpoint. options is // the struct of optional parameters for this action.
[ "Update", "an", "existing", "SSL", "endpoint", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", "s", "App", ".", "sslEndpointIdentity", "is", "the", "unique", "identifier", "of", "the", "SSLEndpoint", ".", "options", "is", "...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/ssl_endpoint.go#L103-L106
train
remind101/empire
server/heroku/formations.go
GetFormation
func (h *Server) GetFormation(w http.ResponseWriter, r *http.Request) error { ctx := r.Context() app, err := h.findApp(r) if err != nil { return err } formation, err := h.ListScale(ctx, app) if err != nil { return err } var resp []*Formation for name, proc := range formation { resp = append(resp, &Formation{ Type: name, Quantity: proc.Quantity, Size: proc.Constraints().String(), }) } w.WriteHeader(200) return Encode(w, resp) }
go
func (h *Server) GetFormation(w http.ResponseWriter, r *http.Request) error { ctx := r.Context() app, err := h.findApp(r) if err != nil { return err } formation, err := h.ListScale(ctx, app) if err != nil { return err } var resp []*Formation for name, proc := range formation { resp = append(resp, &Formation{ Type: name, Quantity: proc.Quantity, Size: proc.Constraints().String(), }) } w.WriteHeader(200) return Encode(w, resp) }
[ "func", "(", "h", "*", "Server", ")", "GetFormation", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n", "app", ",", "err", ":=", "h", ".", "findApp...
// ServeHTTPContext handles the http response
[ "ServeHTTPContext", "handles", "the", "http", "response" ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/formations.go#L73-L97
train
remind101/empire
pkg/headerutil/headerutil.go
WithDefaults
func (r *Range) WithDefaults(d Range) Range { if r == nil { return d } // Make a copy. c := *r if c.Max == nil { c.Max = d.Max } if c.Sort == nil { c.Sort = d.Sort } if c.Order == nil { c.Order = d.Order } return c }
go
func (r *Range) WithDefaults(d Range) Range { if r == nil { return d } // Make a copy. c := *r if c.Max == nil { c.Max = d.Max } if c.Sort == nil { c.Sort = d.Sort } if c.Order == nil { c.Order = d.Order } return c }
[ "func", "(", "r", "*", "Range", ")", "WithDefaults", "(", "d", "Range", ")", "Range", "{", "if", "r", "==", "nil", "{", "return", "d", "\n", "}", "\n", "c", ":=", "*", "r", "\n", "if", "c", ".", "Max", "==", "nil", "{", "c", ".", "Max", "="...
// WithDefaults returns a new Range instance with the defaults taken from d.
[ "WithDefaults", "returns", "a", "new", "Range", "instance", "with", "the", "defaults", "taken", "from", "d", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/headerutil/headerutil.go#L51-L72
train
remind101/empire
pkg/heroku/plan.go
PlanInfo
func (c *Client) PlanInfo(addonServiceIdentity string, planIdentity string) (*Plan, error) { var plan Plan return &plan, c.Get(&plan, "/addon-services/"+addonServiceIdentity+"/plans/"+planIdentity) }
go
func (c *Client) PlanInfo(addonServiceIdentity string, planIdentity string) (*Plan, error) { var plan Plan return &plan, c.Get(&plan, "/addon-services/"+addonServiceIdentity+"/plans/"+planIdentity) }
[ "func", "(", "c", "*", "Client", ")", "PlanInfo", "(", "addonServiceIdentity", "string", ",", "planIdentity", "string", ")", "(", "*", "Plan", ",", "error", ")", "{", "var", "plan", "Plan", "\n", "return", "&", "plan", ",", "c", ".", "Get", "(", "&",...
// Info for existing plan. // // addonServiceIdentity is the unique identifier of the Plan's AddonService. // planIdentity is the unique identifier of the Plan.
[ "Info", "for", "existing", "plan", ".", "addonServiceIdentity", "is", "the", "unique", "identifier", "of", "the", "Plan", "s", "AddonService", ".", "planIdentity", "is", "the", "unique", "identifier", "of", "the", "Plan", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/plan.go#L46-L49
train
remind101/empire
pkg/heroku/plan.go
PlanList
func (c *Client) PlanList(addonServiceIdentity string, lr *ListRange) ([]Plan, error) { req, err := c.NewRequest("GET", "/addon-services/"+addonServiceIdentity+"/plans", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var plansRes []Plan return plansRes, c.DoReq(req, &plansRes) }
go
func (c *Client) PlanList(addonServiceIdentity string, lr *ListRange) ([]Plan, error) { req, err := c.NewRequest("GET", "/addon-services/"+addonServiceIdentity+"/plans", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var plansRes []Plan return plansRes, c.DoReq(req, &plansRes) }
[ "func", "(", "c", "*", "Client", ")", "PlanList", "(", "addonServiceIdentity", "string", ",", "lr", "*", "ListRange", ")", "(", "[", "]", "Plan", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/addon-...
// List existing plans. // // addonServiceIdentity is the unique identifier of the Plan's AddonService. lr // is an optional ListRange that sets the Range options for the paginated list // of results.
[ "List", "existing", "plans", ".", "addonServiceIdentity", "is", "the", "unique", "identifier", "of", "the", "Plan", "s", "AddonService", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/plan.go#L56-L68
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
Hash
func (r *Request) Hash() string { h := fnv.New64() h.Write([]byte(fmt.Sprintf("%s.%s", r.StackId, r.RequestId))) return base62.Encode(h.Sum64()) }
go
func (r *Request) Hash() string { h := fnv.New64() h.Write([]byte(fmt.Sprintf("%s.%s", r.StackId, r.RequestId))) return base62.Encode(h.Sum64()) }
[ "func", "(", "r", "*", "Request", ")", "Hash", "(", ")", "string", "{", "h", ":=", "fnv", ".", "New64", "(", ")", "\n", "h", ".", "Write", "(", "[", "]", "byte", "(", "fmt", ".", "Sprintf", "(", "\"%s.%s\"", ",", "r", ".", "StackId", ",", "r"...
// Hash returns a compact unique identifier for the request.
[ "Hash", "returns", "a", "compact", "unique", "identifier", "for", "the", "request", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L103-L107
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
NewResponseFromRequest
func NewResponseFromRequest(req Request) Response { return Response{ StackId: req.StackId, RequestId: req.RequestId, LogicalResourceId: req.LogicalResourceId, } }
go
func NewResponseFromRequest(req Request) Response { return Response{ StackId: req.StackId, RequestId: req.RequestId, LogicalResourceId: req.LogicalResourceId, } }
[ "func", "NewResponseFromRequest", "(", "req", "Request", ")", "Response", "{", "return", "Response", "{", "StackId", ":", "req", ".", "StackId", ",", "RequestId", ":", "req", ".", "RequestId", ",", "LogicalResourceId", ":", "req", ".", "LogicalResourceId", ","...
// NewResponseFromRequest initializes a new Response from a Request, filling in // the required verbatim fields.
[ "NewResponseFromRequest", "initializes", "a", "new", "Response", "from", "a", "Request", "filling", "in", "the", "required", "verbatim", "fields", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L152-L158
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
SendResponse
func SendResponse(req Request, response Response) error { return SendResponseWithClient(http.DefaultClient, req, response) }
go
func SendResponse(req Request, response Response) error { return SendResponseWithClient(http.DefaultClient, req, response) }
[ "func", "SendResponse", "(", "req", "Request", ",", "response", "Response", ")", "error", "{", "return", "SendResponseWithClient", "(", "http", ".", "DefaultClient", ",", "req", ",", "response", ")", "\n", "}" ]
// SendResponse sends the response the Response to the requests response url
[ "SendResponse", "sends", "the", "response", "the", "Response", "to", "the", "requests", "response", "url" ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L161-L163
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
SendResponseWithClient
func SendResponseWithClient(client interface { Do(*http.Request) (*http.Response, error) }, req Request, response Response) error { c := ResponseClient{client} return c.SendResponse(req, response) }
go
func SendResponseWithClient(client interface { Do(*http.Request) (*http.Response, error) }, req Request, response Response) error { c := ResponseClient{client} return c.SendResponse(req, response) }
[ "func", "SendResponseWithClient", "(", "client", "interface", "{", "Do", "(", "*", "http", ".", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "\n", "}", ",", "req", "Request", ",", "response", "Response", ")", "error", "{", "c",...
// SendResponseWithClient uploads the response to the requests signed // ResponseURL.
[ "SendResponseWithClient", "uploads", "the", "response", "to", "the", "requests", "signed", "ResponseURL", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L167-L172
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
SendResponse
func (c *ResponseClient) SendResponse(req Request, response Response) error { raw, err := json.Marshal(response) if err != nil { return err } r, err := http.NewRequest("PUT", req.ResponseURL, bytes.NewReader(raw)) if err != nil { return err } resp, err := c.client.Do(r) if err != nil { return err } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) if code := resp.StatusCode; code/100 != 2 { return fmt.Errorf("unexpected response from pre-signed url: %v: %v", code, string(body)) } return nil }
go
func (c *ResponseClient) SendResponse(req Request, response Response) error { raw, err := json.Marshal(response) if err != nil { return err } r, err := http.NewRequest("PUT", req.ResponseURL, bytes.NewReader(raw)) if err != nil { return err } resp, err := c.client.Do(r) if err != nil { return err } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) if code := resp.StatusCode; code/100 != 2 { return fmt.Errorf("unexpected response from pre-signed url: %v: %v", code, string(body)) } return nil }
[ "func", "(", "c", "*", "ResponseClient", ")", "SendResponse", "(", "req", "Request", ",", "response", "Response", ")", "error", "{", "raw", ",", "err", ":=", "json", ".", "Marshal", "(", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// SendResponse sends the response to the request's ResponseURL.
[ "SendResponse", "sends", "the", "response", "to", "the", "request", "s", "ResponseURL", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L182-L205
train
remind101/empire
pkg/cloudformation/customresources/customresources.go
WithTimeout
func WithTimeout(p Provisioner, timeout time.Duration, grace time.Duration) Provisioner { return &timeoutProvisioner{ Provisioner: p, timeout: timeout, grace: grace, } }
go
func WithTimeout(p Provisioner, timeout time.Duration, grace time.Duration) Provisioner { return &timeoutProvisioner{ Provisioner: p, timeout: timeout, grace: grace, } }
[ "func", "WithTimeout", "(", "p", "Provisioner", ",", "timeout", "time", ".", "Duration", ",", "grace", "time", ".", "Duration", ")", "Provisioner", "{", "return", "&", "timeoutProvisioner", "{", "Provisioner", ":", "p", ",", "timeout", ":", "timeout", ",", ...
// WithTimeout wraps a Provisioner with a context.WithTimeout.
[ "WithTimeout", "wraps", "a", "Provisioner", "with", "a", "context", ".", "WithTimeout", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/customresources.go#L208-L214
train
remind101/empire
pkg/cloudformation/customresources/types.go
Eq
func (i *IntValue) Eq(other *IntValue) bool { if i == nil { return other == nil } if other == nil { return i == nil } return *i == *other }
go
func (i *IntValue) Eq(other *IntValue) bool { if i == nil { return other == nil } if other == nil { return i == nil } return *i == *other }
[ "func", "(", "i", "*", "IntValue", ")", "Eq", "(", "other", "*", "IntValue", ")", "bool", "{", "if", "i", "==", "nil", "{", "return", "other", "==", "nil", "\n", "}", "\n", "if", "other", "==", "nil", "{", "return", "i", "==", "nil", "\n", "}",...
// Eq returns true of other is the same _value_ as i.
[ "Eq", "returns", "true", "of", "other", "is", "the", "same", "_value_", "as", "i", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/cloudformation/customresources/types.go#L20-L30
train
remind101/empire
stats/runtime.go
SampleEvery
func SampleEvery(stats Stats, t time.Duration) { c := time.Tick(t) for _ = range c { r := newRuntimeSample() r.drain(stats) } }
go
func SampleEvery(stats Stats, t time.Duration) { c := time.Tick(t) for _ = range c { r := newRuntimeSample() r.drain(stats) } }
[ "func", "SampleEvery", "(", "stats", "Stats", ",", "t", "time", ".", "Duration", ")", "{", "c", ":=", "time", ".", "Tick", "(", "t", ")", "\n", "for", "_", "=", "range", "c", "{", "r", ":=", "newRuntimeSample", "(", ")", "\n", "r", ".", "drain", ...
// SampleEvery enters a loop, sampling at the specified interval
[ "SampleEvery", "enters", "a", "loop", "sampling", "at", "the", "specified", "interval" ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/runtime.go#L14-L20
train
remind101/empire
stats/runtime.go
newRuntimeSample
func newRuntimeSample() *runtimeSample { r := &runtimeSample{MemStats: &runtime.MemStats{}} runtime.ReadMemStats(r.MemStats) r.NumGoroutine = runtime.NumGoroutine() return r }
go
func newRuntimeSample() *runtimeSample { r := &runtimeSample{MemStats: &runtime.MemStats{}} runtime.ReadMemStats(r.MemStats) r.NumGoroutine = runtime.NumGoroutine() return r }
[ "func", "newRuntimeSample", "(", ")", "*", "runtimeSample", "{", "r", ":=", "&", "runtimeSample", "{", "MemStats", ":", "&", "runtime", ".", "MemStats", "{", "}", "}", "\n", "runtime", ".", "ReadMemStats", "(", "r", ".", "MemStats", ")", "\n", "r", "."...
// newRuntimeSample samples the current runtime and returns a RuntimeSample.
[ "newRuntimeSample", "samples", "the", "current", "runtime", "and", "returns", "a", "RuntimeSample", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/runtime.go#L29-L34
train
remind101/empire
stats/runtime.go
drain
func (r *runtimeSample) drain(stats Stats) { stats.Gauge("runtime.NumGoroutine", float32(r.NumGoroutine), 1.0, nil) stats.Gauge("runtime.MemStats.Alloc", float32(r.MemStats.Alloc), 1.0, nil) stats.Gauge("runtime.MemStats.Frees", float32(r.MemStats.Frees), 1.0, nil) stats.Gauge("runtime.MemStats.HeapAlloc", float32(r.MemStats.HeapAlloc), 1.0, nil) stats.Gauge("runtime.MemStats.HeapIdle", float32(r.MemStats.HeapIdle), 1.0, nil) stats.Gauge("runtime.MemStats.HeapObjects", float32(r.MemStats.HeapObjects), 1.0, nil) stats.Gauge("runtime.MemStats.HeapReleased", float32(r.MemStats.HeapReleased), 1.0, nil) stats.Gauge("runtime.MemStats.HeapSys", float32(r.MemStats.HeapSys), 1.0, nil) stats.Gauge("runtime.MemStats.LastGC", float32(r.MemStats.LastGC), 1.0, nil) stats.Gauge("runtime.MemStats.Lookups", float32(r.MemStats.Lookups), 1.0, nil) stats.Gauge("runtime.MemStats.Mallocs", float32(r.MemStats.Mallocs), 1.0, nil) stats.Gauge("runtime.MemStats.MCacheInuse", float32(r.MemStats.MCacheInuse), 1.0, nil) stats.Gauge("runtime.MemStats.MCacheSys", float32(r.MemStats.MCacheSys), 1.0, nil) stats.Gauge("runtime.MemStats.MSpanInuse", float32(r.MemStats.MSpanInuse), 1.0, nil) stats.Gauge("runtime.MemStats.MSpanSys", float32(r.MemStats.MSpanSys), 1.0, nil) stats.Gauge("runtime.MemStats.NextGC", float32(r.MemStats.NextGC), 1.0, nil) stats.Gauge("runtime.MemStats.NumGC", float32(r.MemStats.NumGC), 1.0, nil) stats.Gauge("runtime.MemStats.StackInuse", float32(r.MemStats.StackInuse), 1.0, nil) }
go
func (r *runtimeSample) drain(stats Stats) { stats.Gauge("runtime.NumGoroutine", float32(r.NumGoroutine), 1.0, nil) stats.Gauge("runtime.MemStats.Alloc", float32(r.MemStats.Alloc), 1.0, nil) stats.Gauge("runtime.MemStats.Frees", float32(r.MemStats.Frees), 1.0, nil) stats.Gauge("runtime.MemStats.HeapAlloc", float32(r.MemStats.HeapAlloc), 1.0, nil) stats.Gauge("runtime.MemStats.HeapIdle", float32(r.MemStats.HeapIdle), 1.0, nil) stats.Gauge("runtime.MemStats.HeapObjects", float32(r.MemStats.HeapObjects), 1.0, nil) stats.Gauge("runtime.MemStats.HeapReleased", float32(r.MemStats.HeapReleased), 1.0, nil) stats.Gauge("runtime.MemStats.HeapSys", float32(r.MemStats.HeapSys), 1.0, nil) stats.Gauge("runtime.MemStats.LastGC", float32(r.MemStats.LastGC), 1.0, nil) stats.Gauge("runtime.MemStats.Lookups", float32(r.MemStats.Lookups), 1.0, nil) stats.Gauge("runtime.MemStats.Mallocs", float32(r.MemStats.Mallocs), 1.0, nil) stats.Gauge("runtime.MemStats.MCacheInuse", float32(r.MemStats.MCacheInuse), 1.0, nil) stats.Gauge("runtime.MemStats.MCacheSys", float32(r.MemStats.MCacheSys), 1.0, nil) stats.Gauge("runtime.MemStats.MSpanInuse", float32(r.MemStats.MSpanInuse), 1.0, nil) stats.Gauge("runtime.MemStats.MSpanSys", float32(r.MemStats.MSpanSys), 1.0, nil) stats.Gauge("runtime.MemStats.NextGC", float32(r.MemStats.NextGC), 1.0, nil) stats.Gauge("runtime.MemStats.NumGC", float32(r.MemStats.NumGC), 1.0, nil) stats.Gauge("runtime.MemStats.StackInuse", float32(r.MemStats.StackInuse), 1.0, nil) }
[ "func", "(", "r", "*", "runtimeSample", ")", "drain", "(", "stats", "Stats", ")", "{", "stats", ".", "Gauge", "(", "\"runtime.NumGoroutine\"", ",", "float32", "(", "r", ".", "NumGoroutine", ")", ",", "1.0", ",", "nil", ")", "\n", "stats", ".", "Gauge",...
// drain drains all of the metrics.
[ "drain", "drains", "all", "of", "the", "metrics", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/runtime.go#L37-L56
train
remind101/empire
pkg/heroku/app_transfer.go
AppTransferCreate
func (c *Client) AppTransferCreate(app string, recipient string) (*AppTransfer, error) { params := struct { App string `json:"app"` Recipient string `json:"recipient"` }{ App: app, Recipient: recipient, } var appTransferRes AppTransfer return &appTransferRes, c.Post(&appTransferRes, "/account/app-transfers", params) }
go
func (c *Client) AppTransferCreate(app string, recipient string) (*AppTransfer, error) { params := struct { App string `json:"app"` Recipient string `json:"recipient"` }{ App: app, Recipient: recipient, } var appTransferRes AppTransfer return &appTransferRes, c.Post(&appTransferRes, "/account/app-transfers", params) }
[ "func", "(", "c", "*", "Client", ")", "AppTransferCreate", "(", "app", "string", ",", "recipient", "string", ")", "(", "*", "AppTransfer", ",", "error", ")", "{", "params", ":=", "struct", "{", "App", "string", "`json:\"app\"`", "\n", "Recipient", "string"...
// Create a new app transfer. // // app is the unique identifier of app or unique name of app. recipient is the // unique email address of account or unique identifier of an account.
[ "Create", "a", "new", "app", "transfer", ".", "app", "is", "the", "unique", "identifier", "of", "app", "or", "unique", "name", "of", "app", ".", "recipient", "is", "the", "unique", "email", "address", "of", "account", "or", "unique", "identifier", "of", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_transfer.go#L49-L59
train
remind101/empire
pkg/heroku/app_transfer.go
AppTransferInfo
func (c *Client) AppTransferInfo(appTransferIdentity string) (*AppTransfer, error) { var appTransfer AppTransfer return &appTransfer, c.Get(&appTransfer, "/account/app-transfers/"+appTransferIdentity) }
go
func (c *Client) AppTransferInfo(appTransferIdentity string) (*AppTransfer, error) { var appTransfer AppTransfer return &appTransfer, c.Get(&appTransfer, "/account/app-transfers/"+appTransferIdentity) }
[ "func", "(", "c", "*", "Client", ")", "AppTransferInfo", "(", "appTransferIdentity", "string", ")", "(", "*", "AppTransfer", ",", "error", ")", "{", "var", "appTransfer", "AppTransfer", "\n", "return", "&", "appTransfer", ",", "c", ".", "Get", "(", "&", ...
// Info for existing app transfer. // // appTransferIdentity is the unique identifier of the AppTransfer.
[ "Info", "for", "existing", "app", "transfer", ".", "appTransferIdentity", "is", "the", "unique", "identifier", "of", "the", "AppTransfer", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_transfer.go#L71-L74
train
remind101/empire
pkg/heroku/app_transfer.go
AppTransferList
func (c *Client) AppTransferList(lr *ListRange) ([]AppTransfer, error) { req, err := c.NewRequest("GET", "/account/app-transfers", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var appTransfersRes []AppTransfer return appTransfersRes, c.DoReq(req, &appTransfersRes) }
go
func (c *Client) AppTransferList(lr *ListRange) ([]AppTransfer, error) { req, err := c.NewRequest("GET", "/account/app-transfers", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var appTransfersRes []AppTransfer return appTransfersRes, c.DoReq(req, &appTransfersRes) }
[ "func", "(", "c", "*", "Client", ")", "AppTransferList", "(", "lr", "*", "ListRange", ")", "(", "[", "]", "AppTransfer", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/account/app-transfers\"", ",", "n...
// List existing apps transfers. // // lr is an optional ListRange that sets the Range options for the paginated // list of results.
[ "List", "existing", "apps", "transfers", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "of", "results", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_transfer.go#L80-L92
train
remind101/empire
pkg/heroku/app_transfer.go
AppTransferUpdate
func (c *Client) AppTransferUpdate(appTransferIdentity string, state string) (*AppTransfer, error) { params := struct { State string `json:"state"` }{ State: state, } var appTransferRes AppTransfer return &appTransferRes, c.Patch(&appTransferRes, "/account/app-transfers/"+appTransferIdentity, params) }
go
func (c *Client) AppTransferUpdate(appTransferIdentity string, state string) (*AppTransfer, error) { params := struct { State string `json:"state"` }{ State: state, } var appTransferRes AppTransfer return &appTransferRes, c.Patch(&appTransferRes, "/account/app-transfers/"+appTransferIdentity, params) }
[ "func", "(", "c", "*", "Client", ")", "AppTransferUpdate", "(", "appTransferIdentity", "string", ",", "state", "string", ")", "(", "*", "AppTransfer", ",", "error", ")", "{", "params", ":=", "struct", "{", "State", "string", "`json:\"state\"`", "\n", "}", ...
// Update an existing app transfer. // // appTransferIdentity is the unique identifier of the AppTransfer. state is the // the current state of an app transfer.
[ "Update", "an", "existing", "app", "transfer", ".", "appTransferIdentity", "is", "the", "unique", "identifier", "of", "the", "AppTransfer", ".", "state", "is", "the", "the", "current", "state", "of", "an", "app", "transfer", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_transfer.go#L98-L106
train
remind101/empire
registry/registry.go
DockerDaemon
func DockerDaemon(c *dockerutil.Client) *DockerDaemonRegistry { e := multiExtractor( newFileExtractor(c), newCMDExtractor(c), ) return &DockerDaemonRegistry{ docker: c, extractor: e, } }
go
func DockerDaemon(c *dockerutil.Client) *DockerDaemonRegistry { e := multiExtractor( newFileExtractor(c), newCMDExtractor(c), ) return &DockerDaemonRegistry{ docker: c, extractor: e, } }
[ "func", "DockerDaemon", "(", "c", "*", "dockerutil", ".", "Client", ")", "*", "DockerDaemonRegistry", "{", "e", ":=", "multiExtractor", "(", "newFileExtractor", "(", "c", ")", ",", "newCMDExtractor", "(", "c", ")", ",", ")", "\n", "return", "&", "DockerDae...
// DockerDaemon returns an empire.ImageRegistry that uses a local Docker Daemon // to extract procfiles and resolve images.
[ "DockerDaemon", "returns", "an", "empire", ".", "ImageRegistry", "that", "uses", "a", "local", "Docker", "Daemon", "to", "extract", "procfiles", "and", "resolve", "images", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L66-L75
train
remind101/empire
registry/registry.go
multiExtractor
func multiExtractor(extractors ...empire.ProcfileExtractor) empire.ProcfileExtractor { return empire.ProcfileExtractorFunc(func(ctx context.Context, image image.Image, w *jsonmessage.Stream) ([]byte, error) { for _, extractor := range extractors { p, err := extractor.ExtractProcfile(ctx, image, w) // Yay! if err == nil { return p, nil } // Try the next one if _, ok := err.(*empire.ProcfileError); ok { continue } // Bubble up the error return p, err } return nil, &empire.ProcfileError{ Err: errors.New("no suitable Procfile extractor found"), } }) }
go
func multiExtractor(extractors ...empire.ProcfileExtractor) empire.ProcfileExtractor { return empire.ProcfileExtractorFunc(func(ctx context.Context, image image.Image, w *jsonmessage.Stream) ([]byte, error) { for _, extractor := range extractors { p, err := extractor.ExtractProcfile(ctx, image, w) // Yay! if err == nil { return p, nil } // Try the next one if _, ok := err.(*empire.ProcfileError); ok { continue } // Bubble up the error return p, err } return nil, &empire.ProcfileError{ Err: errors.New("no suitable Procfile extractor found"), } }) }
[ "func", "multiExtractor", "(", "extractors", "...", "empire", ".", "ProcfileExtractor", ")", "empire", ".", "ProcfileExtractor", "{", "return", "empire", ".", "ProcfileExtractorFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "image", "image", "."...
// multiExtractor is an Extractor implementation that tries multiple Extractors // in succession until one succeeds.
[ "multiExtractor", "is", "an", "Extractor", "implementation", "that", "tries", "multiple", "Extractors", "in", "succession", "until", "one", "succeeds", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L166-L189
train
remind101/empire
registry/registry.go
ExtractProcfile
func (e *fileExtractor) ExtractProcfile(ctx context.Context, img image.Image, w *jsonmessage.Stream) ([]byte, error) { c, err := e.createContainer(ctx, img) if err != nil { return nil, err } defer e.removeContainer(ctx, c.ID) pfile, err := e.procfile(ctx, c.ID) if err != nil { return nil, err } b, err := e.copyFile(ctx, c.ID, pfile) if err != nil { return nil, &empire.ProcfileError{Err: err} } w.Encode(jsonmessage.JSONMessage{ Status: fmt.Sprintf("Status: Extracted Procfile from %q", pfile), }) return b, nil }
go
func (e *fileExtractor) ExtractProcfile(ctx context.Context, img image.Image, w *jsonmessage.Stream) ([]byte, error) { c, err := e.createContainer(ctx, img) if err != nil { return nil, err } defer e.removeContainer(ctx, c.ID) pfile, err := e.procfile(ctx, c.ID) if err != nil { return nil, err } b, err := e.copyFile(ctx, c.ID, pfile) if err != nil { return nil, &empire.ProcfileError{Err: err} } w.Encode(jsonmessage.JSONMessage{ Status: fmt.Sprintf("Status: Extracted Procfile from %q", pfile), }) return b, nil }
[ "func", "(", "e", "*", "fileExtractor", ")", "ExtractProcfile", "(", "ctx", "context", ".", "Context", ",", "img", "image", ".", "Image", ",", "w", "*", "jsonmessage", ".", "Stream", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "c", ",", "er...
// Extract implements Extractor Extract.
[ "Extract", "implements", "Extractor", "Extract", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L203-L226
train
remind101/empire
registry/registry.go
procfile
func (e *fileExtractor) procfile(ctx context.Context, id string) (string, error) { p := "" c, err := e.client.InspectContainer(id) if err != nil { return "", err } if c.Config != nil { p = c.Config.WorkingDir } return path.Join(p, empire.Procfile), nil }
go
func (e *fileExtractor) procfile(ctx context.Context, id string) (string, error) { p := "" c, err := e.client.InspectContainer(id) if err != nil { return "", err } if c.Config != nil { p = c.Config.WorkingDir } return path.Join(p, empire.Procfile), nil }
[ "func", "(", "e", "*", "fileExtractor", ")", "procfile", "(", "ctx", "context", ".", "Context", ",", "id", "string", ")", "(", "string", ",", "error", ")", "{", "p", ":=", "\"\"", "\n", "c", ",", "err", ":=", "e", ".", "client", ".", "InspectContai...
// procfile returns the path to the Procfile. If the container has a WORKDIR // set, then this will return a path to the Procfile within that directory.
[ "procfile", "returns", "the", "path", "to", "the", "Procfile", ".", "If", "the", "container", "has", "a", "WORKDIR", "set", "then", "this", "will", "return", "a", "path", "to", "the", "Procfile", "within", "that", "directory", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L230-L243
train
remind101/empire
registry/registry.go
createContainer
func (e *fileExtractor) createContainer(ctx context.Context, img image.Image) (*docker.Container, error) { return e.client.CreateContainer(ctx, docker.CreateContainerOptions{ Config: &docker.Config{ Image: img.String(), }, }) }
go
func (e *fileExtractor) createContainer(ctx context.Context, img image.Image) (*docker.Container, error) { return e.client.CreateContainer(ctx, docker.CreateContainerOptions{ Config: &docker.Config{ Image: img.String(), }, }) }
[ "func", "(", "e", "*", "fileExtractor", ")", "createContainer", "(", "ctx", "context", ".", "Context", ",", "img", "image", ".", "Image", ")", "(", "*", "docker", ".", "Container", ",", "error", ")", "{", "return", "e", ".", "client", ".", "CreateConta...
// createContainer creates a new docker container for the given docker image.
[ "createContainer", "creates", "a", "new", "docker", "container", "for", "the", "given", "docker", "image", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L246-L252
train
remind101/empire
registry/registry.go
removeContainer
func (e *fileExtractor) removeContainer(ctx context.Context, containerID string) error { return e.client.RemoveContainer(ctx, docker.RemoveContainerOptions{ ID: containerID, }) }
go
func (e *fileExtractor) removeContainer(ctx context.Context, containerID string) error { return e.client.RemoveContainer(ctx, docker.RemoveContainerOptions{ ID: containerID, }) }
[ "func", "(", "e", "*", "fileExtractor", ")", "removeContainer", "(", "ctx", "context", ".", "Context", ",", "containerID", "string", ")", "error", "{", "return", "e", ".", "client", ".", "RemoveContainer", "(", "ctx", ",", "docker", ".", "RemoveContainerOpti...
// removeContainer removes a container by its ID.
[ "removeContainer", "removes", "a", "container", "by", "its", "ID", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L255-L259
train
remind101/empire
registry/registry.go
copyFile
func (e *fileExtractor) copyFile(ctx context.Context, containerID, path string) ([]byte, error) { var buf bytes.Buffer if err := e.client.CopyFromContainer(ctx, docker.CopyFromContainerOptions{ Container: containerID, Resource: path, OutputStream: &buf, }); err != nil { return nil, err } // Open the tar archive for reading. r := bytes.NewReader(buf.Bytes()) return firstFile(tar.NewReader(r)) }
go
func (e *fileExtractor) copyFile(ctx context.Context, containerID, path string) ([]byte, error) { var buf bytes.Buffer if err := e.client.CopyFromContainer(ctx, docker.CopyFromContainerOptions{ Container: containerID, Resource: path, OutputStream: &buf, }); err != nil { return nil, err } // Open the tar archive for reading. r := bytes.NewReader(buf.Bytes()) return firstFile(tar.NewReader(r)) }
[ "func", "(", "e", "*", "fileExtractor", ")", "copyFile", "(", "ctx", "context", ".", "Context", ",", "containerID", ",", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "if", "err", ...
// copyFile copies a file from a container.
[ "copyFile", "copies", "a", "file", "from", "a", "container", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L262-L276
train
remind101/empire
registry/registry.go
firstFile
func firstFile(tr *tar.Reader) ([]byte, error) { if _, err := tr.Next(); err != nil { return nil, err } var buf bytes.Buffer if _, err := io.Copy(&buf, tr); err != nil { return nil, err } return buf.Bytes(), nil }
go
func firstFile(tr *tar.Reader) ([]byte, error) { if _, err := tr.Next(); err != nil { return nil, err } var buf bytes.Buffer if _, err := io.Copy(&buf, tr); err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "firstFile", "(", "tr", "*", "tar", ".", "Reader", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "_", ",", "err", ":=", "tr", ".", "Next", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "...
// firstFile extracts the first file from a tar archive.
[ "firstFile", "extracts", "the", "first", "file", "from", "a", "tar", "archive", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/registry/registry.go#L279-L290
train
remind101/empire
pkg/heroku/release.go
ReleaseInfo
func (c *Client) ReleaseInfo(appIdentity string, releaseIdentity string) (*Release, error) { var release Release return &release, c.Get(&release, "/apps/"+appIdentity+"/releases/"+releaseIdentity) }
go
func (c *Client) ReleaseInfo(appIdentity string, releaseIdentity string) (*Release, error) { var release Release return &release, c.Get(&release, "/apps/"+appIdentity+"/releases/"+releaseIdentity) }
[ "func", "(", "c", "*", "Client", ")", "ReleaseInfo", "(", "appIdentity", "string", ",", "releaseIdentity", "string", ")", "(", "*", "Release", ",", "error", ")", "{", "var", "release", "Release", "\n", "return", "&", "release", ",", "c", ".", "Get", "(...
// Info for existing release. // // appIdentity is the unique identifier of the Release's App. releaseIdentity is // the unique identifier of the Release.
[ "Info", "for", "existing", "release", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Release", "s", "App", ".", "releaseIdentity", "is", "the", "unique", "identifier", "of", "the", "Release", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/release.go#L45-L48
train
remind101/empire
pkg/heroku/release.go
ReleaseList
func (c *Client) ReleaseList(appIdentity string, lr *ListRange) ([]Release, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/releases", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var releasesRes []Release return releasesRes, c.DoReq(req, &releasesRes) }
go
func (c *Client) ReleaseList(appIdentity string, lr *ListRange) ([]Release, error) { req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/releases", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var releasesRes []Release return releasesRes, c.DoReq(req, &releasesRes) }
[ "func", "(", "c", "*", "Client", ")", "ReleaseList", "(", "appIdentity", "string", ",", "lr", "*", "ListRange", ")", "(", "[", "]", "Release", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/apps/\"",...
// List existing releases. // // appIdentity is the unique identifier of the Release's App. lr is an optional // ListRange that sets the Range options for the paginated list of results.
[ "List", "existing", "releases", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Release", "s", "App", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "of", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/release.go#L54-L66
train
remind101/empire
pkg/heroku/release.go
ReleaseCreate
func (c *Client) ReleaseCreate(appIdentity string, slug string, options *ReleaseCreateOpts) (*Release, error) { params := struct { Slug string `json:"slug"` Description *string `json:"description,omitempty"` }{ Slug: slug, } if options != nil { params.Description = options.Description } var releaseRes Release return &releaseRes, c.Post(&releaseRes, "/apps/"+appIdentity+"/releases", params) }
go
func (c *Client) ReleaseCreate(appIdentity string, slug string, options *ReleaseCreateOpts) (*Release, error) { params := struct { Slug string `json:"slug"` Description *string `json:"description,omitempty"` }{ Slug: slug, } if options != nil { params.Description = options.Description } var releaseRes Release return &releaseRes, c.Post(&releaseRes, "/apps/"+appIdentity+"/releases", params) }
[ "func", "(", "c", "*", "Client", ")", "ReleaseCreate", "(", "appIdentity", "string", ",", "slug", "string", ",", "options", "*", "ReleaseCreateOpts", ")", "(", "*", "Release", ",", "error", ")", "{", "params", ":=", "struct", "{", "Slug", "string", "`jso...
// Create new release. The API cannot be used to create releases on Bamboo apps. // // appIdentity is the unique identifier of the Release's App. slug is the unique // identifier of slug. options is the struct of optional parameters for this // action.
[ "Create", "new", "release", ".", "The", "API", "cannot", "be", "used", "to", "create", "releases", "on", "Bamboo", "apps", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Release", "s", "App", ".", "slug", "is", "the", "unique", "i...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/release.go#L73-L85
train
remind101/empire
pkg/heroku/release.go
ReleaseRollback
func (c *Client) ReleaseRollback(appIdentity, release, message string) (*Release, error) { params := struct { Release string `json:"release"` }{ Release: release, } rh := RequestHeaders{CommitMessage: message} var releaseRes Release return &releaseRes, c.PostWithHeaders(&releaseRes, "/apps/"+appIdentity+"/releases", params, rh.Headers()) }
go
func (c *Client) ReleaseRollback(appIdentity, release, message string) (*Release, error) { params := struct { Release string `json:"release"` }{ Release: release, } rh := RequestHeaders{CommitMessage: message} var releaseRes Release return &releaseRes, c.PostWithHeaders(&releaseRes, "/apps/"+appIdentity+"/releases", params, rh.Headers()) }
[ "func", "(", "c", "*", "Client", ")", "ReleaseRollback", "(", "appIdentity", ",", "release", ",", "message", "string", ")", "(", "*", "Release", ",", "error", ")", "{", "params", ":=", "struct", "{", "Release", "string", "`json:\"release\"`", "\n", "}", ...
// Rollback to an existing release. // // appIdentity is the unique identifier of the Release's App. release is the // unique identifier of release.
[ "Rollback", "to", "an", "existing", "release", ".", "appIdentity", "is", "the", "unique", "identifier", "of", "the", "Release", "s", "App", ".", "release", "is", "the", "unique", "identifier", "of", "release", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/release.go#L97-L106
train
remind101/empire
pkg/jsonmessage/jsonmessage.go
NewStream
func NewStream(w io.Writer) *Stream { return &Stream{ Writer: w, enc: json.NewEncoder(w), } }
go
func NewStream(w io.Writer) *Stream { return &Stream{ Writer: w, enc: json.NewEncoder(w), } }
[ "func", "NewStream", "(", "w", "io", ".", "Writer", ")", "*", "Stream", "{", "return", "&", "Stream", "{", "Writer", ":", "w", ",", "enc", ":", "json", ".", "NewEncoder", "(", "w", ")", ",", "}", "\n", "}" ]
// NewStream returns a new Stream backed by w.
[ "NewStream", "returns", "a", "new", "Stream", "backed", "by", "w", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/jsonmessage/jsonmessage.go#L18-L23
train
remind101/empire
pkg/jsonmessage/jsonmessage.go
Encode
func (w *Stream) Encode(m JSONMessage) error { return w.enc.Encode(m) }
go
func (w *Stream) Encode(m JSONMessage) error { return w.enc.Encode(m) }
[ "func", "(", "w", "*", "Stream", ")", "Encode", "(", "m", "JSONMessage", ")", "error", "{", "return", "w", ".", "enc", ".", "Encode", "(", "m", ")", "\n", "}" ]
// Encode encodes m into the stream and implements the jsonmessage.Writer // interface.
[ "Encode", "encodes", "m", "into", "the", "stream", "and", "implements", "the", "jsonmessage", ".", "Writer", "interface", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/jsonmessage/jsonmessage.go#L27-L29
train
remind101/empire
server/heroku/errors.go
Unauthorized
func Unauthorized(reason error) *ErrorResource { if reason == nil { return ErrUnauthorized } return &ErrorResource{ Status: http.StatusUnauthorized, ID: "unauthorized", Message: reason.Error(), } }
go
func Unauthorized(reason error) *ErrorResource { if reason == nil { return ErrUnauthorized } return &ErrorResource{ Status: http.StatusUnauthorized, ID: "unauthorized", Message: reason.Error(), } }
[ "func", "Unauthorized", "(", "reason", "error", ")", "*", "ErrorResource", "{", "if", "reason", "==", "nil", "{", "return", "ErrUnauthorized", "\n", "}", "\n", "return", "&", "ErrorResource", "{", "Status", ":", "http", ".", "StatusUnauthorized", ",", "ID", ...
// Returns an appropriate ErrorResource when a request is unauthorized.
[ "Returns", "an", "appropriate", "ErrorResource", "when", "a", "request", "is", "unauthorized", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/errors.go#L95-L105
train
remind101/empire
server/heroku/errors.go
SAMLUnauthorized
func SAMLUnauthorized(loginURL string) func(error) *ErrorResource { return func(reason error) *ErrorResource { if reason == nil { reason = errors.New("Request not authenticated, API token is missing, invalid or expired") } return &ErrorResource{ Status: http.StatusUnauthorized, ID: "saml_unauthorized", Message: fmt.Sprintf("%s. Login at %s", reason, loginURL), } } }
go
func SAMLUnauthorized(loginURL string) func(error) *ErrorResource { return func(reason error) *ErrorResource { if reason == nil { reason = errors.New("Request not authenticated, API token is missing, invalid or expired") } return &ErrorResource{ Status: http.StatusUnauthorized, ID: "saml_unauthorized", Message: fmt.Sprintf("%s. Login at %s", reason, loginURL), } } }
[ "func", "SAMLUnauthorized", "(", "loginURL", "string", ")", "func", "(", "error", ")", "*", "ErrorResource", "{", "return", "func", "(", "reason", "error", ")", "*", "ErrorResource", "{", "if", "reason", "==", "nil", "{", "reason", "=", "errors", ".", "N...
// SAMLUnauthorized can be used in place of Unauthorized to return a link to // login via SAML.
[ "SAMLUnauthorized", "can", "be", "used", "in", "place", "of", "Unauthorized", "to", "return", "a", "link", "to", "login", "via", "SAML", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/errors.go#L109-L121
train
remind101/empire
server/heroku/errors.go
errHandler
func errHandler(err error) handlerFunc { return func(w http.ResponseWriter, r *http.Request) error { return err } }
go
func errHandler(err error) handlerFunc { return func(w http.ResponseWriter, r *http.Request) error { return err } }
[ "func", "errHandler", "(", "err", "error", ")", "handlerFunc", "{", "return", "func", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "error", "{", "return", "err", "\n", "}", "\n", "}" ]
// errHandler returns a handler that responds with the given error.
[ "errHandler", "returns", "a", "handler", "that", "responds", "with", "the", "given", "error", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/heroku/errors.go#L124-L128
train
remind101/empire
pkg/heroku/key.go
KeyCreate
func (c *Client) KeyCreate(publicKey string) (*Key, error) { params := struct { PublicKey string `json:"public_key"` }{ PublicKey: publicKey, } var keyRes Key return &keyRes, c.Post(&keyRes, "/account/keys", params) }
go
func (c *Client) KeyCreate(publicKey string) (*Key, error) { params := struct { PublicKey string `json:"public_key"` }{ PublicKey: publicKey, } var keyRes Key return &keyRes, c.Post(&keyRes, "/account/keys", params) }
[ "func", "(", "c", "*", "Client", ")", "KeyCreate", "(", "publicKey", "string", ")", "(", "*", "Key", ",", "error", ")", "{", "params", ":=", "struct", "{", "PublicKey", "string", "`json:\"public_key\"`", "\n", "}", "{", "PublicKey", ":", "publicKey", ","...
// Create a new key. // // publicKey is the full public_key as uploaded.
[ "Create", "a", "new", "key", ".", "publicKey", "is", "the", "full", "public_key", "as", "uploaded", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/key.go#L39-L47
train
remind101/empire
pkg/heroku/key.go
KeyInfo
func (c *Client) KeyInfo(keyIdentity string) (*Key, error) { var key Key return &key, c.Get(&key, "/account/keys/"+keyIdentity) }
go
func (c *Client) KeyInfo(keyIdentity string) (*Key, error) { var key Key return &key, c.Get(&key, "/account/keys/"+keyIdentity) }
[ "func", "(", "c", "*", "Client", ")", "KeyInfo", "(", "keyIdentity", "string", ")", "(", "*", "Key", ",", "error", ")", "{", "var", "key", "Key", "\n", "return", "&", "key", ",", "c", ".", "Get", "(", "&", "key", ",", "\"/account/keys/\"", "+", "...
// Info for existing key. // // keyIdentity is the unique identifier of the Key.
[ "Info", "for", "existing", "key", ".", "keyIdentity", "is", "the", "unique", "identifier", "of", "the", "Key", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/key.go#L59-L62
train
remind101/empire
pkg/heroku/key.go
KeyList
func (c *Client) KeyList(lr *ListRange) ([]Key, error) { req, err := c.NewRequest("GET", "/account/keys", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var keysRes []Key return keysRes, c.DoReq(req, &keysRes) }
go
func (c *Client) KeyList(lr *ListRange) ([]Key, error) { req, err := c.NewRequest("GET", "/account/keys", nil, nil) if err != nil { return nil, err } if lr != nil { lr.SetHeader(req) } var keysRes []Key return keysRes, c.DoReq(req, &keysRes) }
[ "func", "(", "c", "*", "Client", ")", "KeyList", "(", "lr", "*", "ListRange", ")", "(", "[", "]", "Key", ",", "error", ")", "{", "req", ",", "err", ":=", "c", ".", "NewRequest", "(", "\"GET\"", ",", "\"/account/keys\"", ",", "nil", ",", "nil", ")...
// List existing keys. // // lr is an optional ListRange that sets the Range options for the paginated // list of results.
[ "List", "existing", "keys", ".", "lr", "is", "an", "optional", "ListRange", "that", "sets", "the", "Range", "options", "for", "the", "paginated", "list", "of", "results", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/key.go#L68-L80
train
remind101/empire
server/auth/auth.go
PrependAuthenticator
func (a *Auth) PrependAuthenticator(name string, authenticator Authenticator) *Auth { c := a.copy() strategy := &Strategy{ Name: name, Authenticator: authenticator, } c.Strategies = append([]*Strategy{strategy}, c.Strategies...) return c }
go
func (a *Auth) PrependAuthenticator(name string, authenticator Authenticator) *Auth { c := a.copy() strategy := &Strategy{ Name: name, Authenticator: authenticator, } c.Strategies = append([]*Strategy{strategy}, c.Strategies...) return c }
[ "func", "(", "a", "*", "Auth", ")", "PrependAuthenticator", "(", "name", "string", ",", "authenticator", "Authenticator", ")", "*", "Auth", "{", "c", ":=", "a", ".", "copy", "(", ")", "\n", "strategy", ":=", "&", "Strategy", "{", "Name", ":", "name", ...
// AddAuthenticator returns a shallow copy of the Auth object with the given // authentication method added.
[ "AddAuthenticator", "returns", "a", "shallow", "copy", "of", "the", "Auth", "object", "with", "the", "given", "authentication", "method", "added", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L106-L114
train
remind101/empire
server/auth/auth.go
Authenticate
func (a *Auth) Authenticate(ctx context.Context, username, password, otp string, strategies ...string) (context.Context, error) { // Default to using all strategies to authenticate. authenticator := a.Strategies.AuthenticatorFor(strategies...) return a.authenticate(ctx, authenticator, username, password, otp) }
go
func (a *Auth) Authenticate(ctx context.Context, username, password, otp string, strategies ...string) (context.Context, error) { // Default to using all strategies to authenticate. authenticator := a.Strategies.AuthenticatorFor(strategies...) return a.authenticate(ctx, authenticator, username, password, otp) }
[ "func", "(", "a", "*", "Auth", ")", "Authenticate", "(", "ctx", "context", ".", "Context", ",", "username", ",", "password", ",", "otp", "string", ",", "strategies", "...", "string", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "authent...
// Authenticate authenticates the request using the named strategy, and returns // a new context.Context with the user embedded. The user can be retrieved with // UserFromContext.
[ "Authenticate", "authenticates", "the", "request", "using", "the", "named", "strategy", "and", "returns", "a", "new", "context", ".", "Context", "with", "the", "user", "embedded", ".", "The", "user", "can", "be", "retrieved", "with", "UserFromContext", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L119-L123
train
remind101/empire
server/auth/auth.go
Authenticate
func (fn AuthenticatorFunc) Authenticate(username, password, otp string) (*Session, error) { return fn(username, password, otp) }
go
func (fn AuthenticatorFunc) Authenticate(username, password, otp string) (*Session, error) { return fn(username, password, otp) }
[ "func", "(", "fn", "AuthenticatorFunc", ")", "Authenticate", "(", "username", ",", "password", ",", "otp", "string", ")", "(", "*", "Session", ",", "error", ")", "{", "return", "fn", "(", "username", ",", "password", ",", "otp", ")", "\n", "}" ]
// Authenticate calls the AuthenticatorFunc.
[ "Authenticate", "calls", "the", "AuthenticatorFunc", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L168-L170
train
remind101/empire
server/auth/auth.go
StaticAuthenticator
func StaticAuthenticator(username, password, otp string, user *empire.User) Authenticator { return AuthenticatorFunc(func(givenUsername, givenPassword, givenOtp string) (*Session, error) { if givenUsername != username { return nil, ErrForbidden } if givenPassword != password { return nil, ErrForbidden } if givenOtp != otp { return nil, ErrTwoFactor } return NewSession(user), nil }) }
go
func StaticAuthenticator(username, password, otp string, user *empire.User) Authenticator { return AuthenticatorFunc(func(givenUsername, givenPassword, givenOtp string) (*Session, error) { if givenUsername != username { return nil, ErrForbidden } if givenPassword != password { return nil, ErrForbidden } if givenOtp != otp { return nil, ErrTwoFactor } return NewSession(user), nil }) }
[ "func", "StaticAuthenticator", "(", "username", ",", "password", ",", "otp", "string", ",", "user", "*", "empire", ".", "User", ")", "Authenticator", "{", "return", "AuthenticatorFunc", "(", "func", "(", "givenUsername", ",", "givenPassword", ",", "givenOtp", ...
// StaticAuthenticator returns an Authenticator that returns the provided user // when the given credentials are provided.
[ "StaticAuthenticator", "returns", "an", "Authenticator", "that", "returns", "the", "provided", "user", "when", "the", "given", "credentials", "are", "provided", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L187-L203
train
remind101/empire
server/auth/auth.go
Anyone
func Anyone(user *empire.User) Authenticator { return AuthenticatorFunc(func(username, password, otp string) (*Session, error) { return NewSession(user), nil }) }
go
func Anyone(user *empire.User) Authenticator { return AuthenticatorFunc(func(username, password, otp string) (*Session, error) { return NewSession(user), nil }) }
[ "func", "Anyone", "(", "user", "*", "empire", ".", "User", ")", "Authenticator", "{", "return", "AuthenticatorFunc", "(", "func", "(", "username", ",", "password", ",", "otp", "string", ")", "(", "*", "Session", ",", "error", ")", "{", "return", "NewSess...
// Anyone returns an Authenticator that let's anyone in and sets them as the // given user.
[ "Anyone", "returns", "an", "Authenticator", "that", "let", "s", "anyone", "in", "and", "sets", "them", "as", "the", "given", "user", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L207-L211
train
remind101/empire
server/auth/auth.go
WithMaxSessionDuration
func WithMaxSessionDuration(auth Authenticator, exp func() time.Time) Authenticator { return AuthenticatorFunc(func(username, password, otp string) (*Session, error) { session, err := auth.Authenticate(username, password, otp) if err != nil { return session, err } t := exp() if exp := session.ExpiresAt; exp != nil { if exp.Before(t) { // Re-setting ExpiresAt to t would increase the // expiration of this session, instead we want // to keep it in tact. return session, err } } session.ExpiresAt = &t return session, err }) }
go
func WithMaxSessionDuration(auth Authenticator, exp func() time.Time) Authenticator { return AuthenticatorFunc(func(username, password, otp string) (*Session, error) { session, err := auth.Authenticate(username, password, otp) if err != nil { return session, err } t := exp() if exp := session.ExpiresAt; exp != nil { if exp.Before(t) { // Re-setting ExpiresAt to t would increase the // expiration of this session, instead we want // to keep it in tact. return session, err } } session.ExpiresAt = &t return session, err }) }
[ "func", "WithMaxSessionDuration", "(", "auth", "Authenticator", ",", "exp", "func", "(", ")", "time", ".", "Time", ")", "Authenticator", "{", "return", "AuthenticatorFunc", "(", "func", "(", "username", ",", "password", ",", "otp", "string", ")", "(", "*", ...
// WithMaxSessionDuration wraps an Authenticator to ensure that sessions always // have a maximum lifetime. If the Session already has an expiration that will // expire before d, the existing expiration is left in tact.
[ "WithMaxSessionDuration", "wraps", "an", "Authenticator", "to", "ensure", "that", "sessions", "always", "have", "a", "maximum", "lifetime", ".", "If", "the", "Session", "already", "has", "an", "expiration", "that", "will", "expire", "before", "d", "the", "existi...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L245-L264
train
remind101/empire
server/auth/auth.go
WithSession
func WithSession(ctx context.Context, session *Session) context.Context { return context.WithValue(ctx, sessionKey, session) }
go
func WithSession(ctx context.Context, session *Session) context.Context { return context.WithValue(ctx, sessionKey, session) }
[ "func", "WithSession", "(", "ctx", "context", ".", "Context", ",", "session", "*", "Session", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "sessionKey", ",", "session", ")", "\n", "}" ]
// WithSession embeds the authentication Session in the context.Context.
[ "WithSession", "embeds", "the", "authentication", "Session", "in", "the", "context", ".", "Context", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L274-L276
train
remind101/empire
server/auth/auth.go
UserFromContext
func UserFromContext(ctx context.Context) *empire.User { session := SessionFromContext(ctx) return session.User }
go
func UserFromContext(ctx context.Context) *empire.User { session := SessionFromContext(ctx) return session.User }
[ "func", "UserFromContext", "(", "ctx", "context", ".", "Context", ")", "*", "empire", ".", "User", "{", "session", ":=", "SessionFromContext", "(", "ctx", ")", "\n", "return", "session", ".", "User", "\n", "}" ]
// UserFromContext returns a user from a context.Context if one is present.
[ "UserFromContext", "returns", "a", "user", "from", "a", "context", ".", "Context", "if", "one", "is", "present", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L279-L282
train
remind101/empire
server/auth/auth.go
SessionFromContext
func SessionFromContext(ctx context.Context) *Session { session, ok := ctx.Value(sessionKey).(*Session) if !ok { panic("expected user to be authenticated") } return session }
go
func SessionFromContext(ctx context.Context) *Session { session, ok := ctx.Value(sessionKey).(*Session) if !ok { panic("expected user to be authenticated") } return session }
[ "func", "SessionFromContext", "(", "ctx", "context", ".", "Context", ")", "*", "Session", "{", "session", ",", "ok", ":=", "ctx", ".", "Value", "(", "sessionKey", ")", ".", "(", "*", "Session", ")", "\n", "if", "!", "ok", "{", "panic", "(", "\"expect...
// SessionFromContext returns the embedded Session in the context.Context.
[ "SessionFromContext", "returns", "the", "embedded", "Session", "in", "the", "context", ".", "Context", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/auth.go#L285-L291
train
remind101/empire
server/github/builder.go
ImageFromTemplate
func ImageFromTemplate(t *template.Template) ImageBuilder { return ImageBuilderFunc(func(ctx context.Context, _ io.Writer, event events.Deployment) (image.Image, error) { buf := new(bytes.Buffer) if err := t.Execute(buf, event); err != nil { return image.Image{}, err } return image.Decode(buf.String()) }) }
go
func ImageFromTemplate(t *template.Template) ImageBuilder { return ImageBuilderFunc(func(ctx context.Context, _ io.Writer, event events.Deployment) (image.Image, error) { buf := new(bytes.Buffer) if err := t.Execute(buf, event); err != nil { return image.Image{}, err } return image.Decode(buf.String()) }) }
[ "func", "ImageFromTemplate", "(", "t", "*", "template", ".", "Template", ")", "ImageBuilder", "{", "return", "ImageBuilderFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "_", "io", ".", "Writer", ",", "event", "events", ".", "Deployment", "...
// ImageFromTemplate returns an ImageBuilder that will execute a template to // determine what docker image should be deployed. Note that this doesn't not // actually perform any "build".
[ "ImageFromTemplate", "returns", "an", "ImageBuilder", "that", "will", "execute", "a", "template", "to", "determine", "what", "docker", "image", "should", "be", "deployed", ".", "Note", "that", "this", "doesn", "t", "not", "actually", "perform", "any", "build", ...
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/github/builder.go#L31-L40
train
remind101/empire
internal/migrate/migrate.go
newPostgresLocker
func newPostgresLocker(db *sql.DB) sync.Locker { key := crc32.ChecksumIEEE([]byte("migrations")) return &postgresLocker{ key: key, db: db, } }
go
func newPostgresLocker(db *sql.DB) sync.Locker { key := crc32.ChecksumIEEE([]byte("migrations")) return &postgresLocker{ key: key, db: db, } }
[ "func", "newPostgresLocker", "(", "db", "*", "sql", ".", "DB", ")", "sync", ".", "Locker", "{", "key", ":=", "crc32", ".", "ChecksumIEEE", "(", "[", "]", "byte", "(", "\"migrations\"", ")", ")", "\n", "return", "&", "postgresLocker", "{", "key", ":", ...
// NewPostgresLocker returns a new sync.Locker that obtains locks with // pg_advisory_lock.
[ "NewPostgresLocker", "returns", "a", "new", "sync", ".", "Locker", "that", "obtains", "locks", "with", "pg_advisory_lock", "." ]
3daba389f6b07b5d219246bfc7d901fcec664161
https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/migrate/migrate.go#L95-L101
train