repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
remind101/empire | releases.go | Release | func (s *releasesService) Release(ctx context.Context, release *Release, ss twelvefactor.StatusStream) error {
a, err := newSchedulerApp(release)
if err != nil {
return err
}
return s.Scheduler.Submit(ctx, a, ss)
} | go | func (s *releasesService) Release(ctx context.Context, release *Release, ss twelvefactor.StatusStream) error {
a, err := newSchedulerApp(release)
if err != nil {
return err
}
return s.Scheduler.Submit(ctx, a, ss)
} | [
"func",
"(",
"s",
"*",
"releasesService",
")",
"Release",
"(",
"ctx",
"context",
".",
"Context",
",",
"release",
"*",
"Release",
",",
"ss",
"twelvefactor",
".",
"StatusStream",
")",
"error",
"{",
"a",
",",
"err",
":=",
"newSchedulerApp",
"(",
"release",
... | // Release submits a release to the scheduler. | [
"Release",
"submits",
"a",
"release",
"to",
"the",
"scheduler",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L163-L169 | train |
remind101/empire | releases.go | Restart | func (s *releasesService) Restart(ctx context.Context, db *gorm.DB, app *App) error {
return s.Scheduler.Restart(ctx, app.ID, nil)
} | go | func (s *releasesService) Restart(ctx context.Context, db *gorm.DB, app *App) error {
return s.Scheduler.Restart(ctx, app.ID, nil)
} | [
"func",
"(",
"s",
"*",
"releasesService",
")",
"Restart",
"(",
"ctx",
"context",
".",
"Context",
",",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"error",
"{",
"return",
"s",
".",
"Scheduler",
".",
"Restart",
"(",
"ctx",
",",
"app",
... | // Restart will find the last release for an app and submit it to the scheduler
// to restart the app. | [
"Restart",
"will",
"find",
"the",
"last",
"release",
"for",
"an",
"app",
"and",
"submit",
"it",
"to",
"the",
"scheduler",
"to",
"restart",
"the",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L190-L192 | train |
remind101/empire | releases.go | releasesFind | func releasesFind(db *gorm.DB, scope scope) (*Release, error) {
var release Release
scope = composedScope{releasesPreload, scope}
if err := first(db, scope, &release); err != nil {
return &release, err
}
return &release, nil
} | go | func releasesFind(db *gorm.DB, scope scope) (*Release, error) {
var release Release
scope = composedScope{releasesPreload, scope}
if err := first(db, scope, &release); err != nil {
return &release, err
}
return &release, nil
} | [
"func",
"releasesFind",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"var",
"release",
"Release",
"\n\n",
"scope",
"=",
"composedScope",
"{",
"releasesPreload",
",",
"scope",
"}",
"\n",
"if... | // releasesFind returns the first matching release. | [
"releasesFind",
"returns",
"the",
"first",
"matching",
"release",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L198-L207 | train |
remind101/empire | releases.go | releases | func releases(db *gorm.DB, scope scope) ([]*Release, error) {
var releases []*Release
scope = composedScope{releasesPreload, scope}
return releases, find(db, scope, &releases)
} | go | func releases(db *gorm.DB, scope scope) ([]*Release, error) {
var releases []*Release
scope = composedScope{releasesPreload, scope}
return releases, find(db, scope, &releases)
} | [
"func",
"releases",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"[",
"]",
"*",
"Release",
",",
"error",
")",
"{",
"var",
"releases",
"[",
"]",
"*",
"Release",
"\n",
"scope",
"=",
"composedScope",
"{",
"releasesPreload",
",",
... | // releases returns all releases matching the scope. | [
"releases",
"returns",
"all",
"releases",
"matching",
"the",
"scope",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L210-L214 | train |
remind101/empire | releases.go | currentFormation | func currentFormation(db *gorm.DB, app *App) (Formation, error) {
// Get the current release
current, err := releasesFind(db, ReleasesQuery{App: app})
if err != nil {
return nil, err
}
f := current.Formation
return f, nil
} | go | func currentFormation(db *gorm.DB, app *App) (Formation, error) {
// Get the current release
current, err := releasesFind(db, ReleasesQuery{App: app})
if err != nil {
return nil, err
}
f := current.Formation
return f, nil
} | [
"func",
"currentFormation",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"(",
"Formation",
",",
"error",
")",
"{",
"// Get the current release",
"current",
",",
"err",
":=",
"releasesFind",
"(",
"db",
",",
"ReleasesQuery",
"{",
"App",
... | // currentFormations gets the current formations for an app | [
"currentFormations",
"gets",
"the",
"current",
"formations",
"for",
"an",
"app"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L243-L251 | train |
remind101/empire | releases.go | releasesLastVersion | func releasesLastVersion(db *gorm.DB, appID string) (int, error) {
var version int
rows, err := db.Raw(`select version from releases where app_id = ? order by version desc`, appID).Rows()
if err != nil {
return version, err
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&version)
return version, ... | go | func releasesLastVersion(db *gorm.DB, appID string) (int, error) {
var version int
rows, err := db.Raw(`select version from releases where app_id = ? order by version desc`, appID).Rows()
if err != nil {
return version, err
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&version)
return version, ... | [
"func",
"releasesLastVersion",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"appID",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"var",
"version",
"int",
"\n\n",
"rows",
",",
"err",
":=",
"db",
".",
"Raw",
"(",
"`select version from releases where app_id... | // ReleasesLastVersion returns the last ReleaseVersion for the given App. | [
"ReleasesLastVersion",
"returns",
"the",
"last",
"ReleaseVersion",
"for",
"the",
"given",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L254-L269 | train |
remind101/empire | releases.go | releasesCreate | func releasesCreate(db *gorm.DB, release *Release) (*Release, error) {
// Get the last release version for this app.
v, err := releasesLastVersion(db, release.App.ID)
if err != nil {
return release, err
}
// Increment the release version.
release.Version = v + 1
if err := db.Create(release).Error; err != nil... | go | func releasesCreate(db *gorm.DB, release *Release) (*Release, error) {
// Get the last release version for this app.
v, err := releasesLastVersion(db, release.App.ID)
if err != nil {
return release, err
}
// Increment the release version.
release.Version = v + 1
if err := db.Create(release).Error; err != nil... | [
"func",
"releasesCreate",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"release",
"*",
"Release",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"// Get the last release version for this app.",
"v",
",",
"err",
":=",
"releasesLastVersion",
"(",
"db",
",",
"rel... | // releasesCreate creates a new Release and inserts it into the database. | [
"releasesCreate",
"creates",
"a",
"new",
"Release",
"and",
"inserts",
"it",
"into",
"the",
"database",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L272-L287 | train |
remind101/empire | releases.go | standardWebExposure | func standardWebExposure(app *App) *twelvefactor.Exposure {
ports := []twelvefactor.Port{
{
Container: 8080,
Host: 80,
Protocol: &twelvefactor.HTTP{},
},
}
// If a certificate is attached to the "web" process, add an SSL port.
if cert, ok := app.Certs[webProcessType]; ok {
ports = append(ports... | go | func standardWebExposure(app *App) *twelvefactor.Exposure {
ports := []twelvefactor.Port{
{
Container: 8080,
Host: 80,
Protocol: &twelvefactor.HTTP{},
},
}
// If a certificate is attached to the "web" process, add an SSL port.
if cert, ok := app.Certs[webProcessType]; ok {
ports = append(ports... | [
"func",
"standardWebExposure",
"(",
"app",
"*",
"App",
")",
"*",
"twelvefactor",
".",
"Exposure",
"{",
"ports",
":=",
"[",
"]",
"twelvefactor",
".",
"Port",
"{",
"{",
"Container",
":",
"8080",
",",
"Host",
":",
"80",
",",
"Protocol",
":",
"&",
"twelvef... | // standardWebExposure generates a scheduler.Exposure for a web process in the
// standard Procfile format. | [
"standardWebExposure",
"generates",
"a",
"scheduler",
".",
"Exposure",
"for",
"a",
"web",
"process",
"in",
"the",
"standard",
"Procfile",
"format",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/releases.go#L398-L422 | train |
remind101/empire | internal/saml/identity_provider.go | ServeHTTP | func (idp *IdentityProvider) ServeHTTP(w http.ResponseWriter, r *http.Request) {
metadataURL, err := url.Parse(idp.MetadataURL)
if err != nil {
panic(err)
}
ssoURL, err := url.Parse(idp.SSOURL)
if err != nil {
panic(err)
}
switch r.URL.Path {
case metadataURL.Path:
idp.ServeMetadata(w, r)
case ssoURL.Pa... | go | func (idp *IdentityProvider) ServeHTTP(w http.ResponseWriter, r *http.Request) {
metadataURL, err := url.Parse(idp.MetadataURL)
if err != nil {
panic(err)
}
ssoURL, err := url.Parse(idp.SSOURL)
if err != nil {
panic(err)
}
switch r.URL.Path {
case metadataURL.Path:
idp.ServeMetadata(w, r)
case ssoURL.Pa... | [
"func",
"(",
"idp",
"*",
"IdentityProvider",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"metadataURL",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"idp",
".",
"MetadataURL",
")",
"\n",
... | // ServeHTTP implements the http.Handler interface to serve the IDP metadata and
// SSO. | [
"ServeHTTP",
"implements",
"the",
"http",
".",
"Handler",
"interface",
"to",
"serve",
"the",
"IDP",
"metadata",
"and",
"SSO",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/saml/identity_provider.go#L131-L149 | train |
remind101/empire | internal/saml/identity_provider.go | ServeMetadata | func (idp *IdentityProvider) ServeMetadata(w http.ResponseWriter, r *http.Request) {
buf, _ := xml.MarshalIndent(idp.Metadata(), "", " ")
w.Header().Set("Content-Type", "application/samlmetadata+xml")
w.Write(buf)
} | go | func (idp *IdentityProvider) ServeMetadata(w http.ResponseWriter, r *http.Request) {
buf, _ := xml.MarshalIndent(idp.Metadata(), "", " ")
w.Header().Set("Content-Type", "application/samlmetadata+xml")
w.Write(buf)
} | [
"func",
"(",
"idp",
"*",
"IdentityProvider",
")",
"ServeMetadata",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"buf",
",",
"_",
":=",
"xml",
".",
"MarshalIndent",
"(",
"idp",
".",
"Metadata",
"(",
")",
",... | // ServeMetadata is an http.HandlerFunc that serves the IDP metadata | [
"ServeMetadata",
"is",
"an",
"http",
".",
"HandlerFunc",
"that",
"serves",
"the",
"IDP",
"metadata"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/saml/identity_provider.go#L152-L156 | train |
remind101/empire | internal/saml/identity_provider.go | ServeSSO | func (idp *IdentityProvider) ServeSSO(w http.ResponseWriter, r *http.Request) {
req, err := NewIdpAuthnRequest(idp, r)
if err != nil {
log.Printf("failed to parse request: %s", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
if err := req.Validate(); err != nil {
... | go | func (idp *IdentityProvider) ServeSSO(w http.ResponseWriter, r *http.Request) {
req, err := NewIdpAuthnRequest(idp, r)
if err != nil {
log.Printf("failed to parse request: %s", err)
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
if err := req.Validate(); err != nil {
... | [
"func",
"(",
"idp",
"*",
"IdentityProvider",
")",
"ServeSSO",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"req",
",",
"err",
":=",
"NewIdpAuthnRequest",
"(",
"idp",
",",
"r",
")",
"\n",
"if",
"err",
"!=",... | // ServeSSO handles SAML auth requests.
//
// When it gets a request for a user that does not have a valid session,
// then it prompts the user via XXX.
//
// If the session already exists, then it produces a SAML assertion and
// returns an HTTP response according to the specified binding. The
// only supported bindin... | [
"ServeSSO",
"handles",
"SAML",
"auth",
"requests",
".",
"When",
"it",
"gets",
"a",
"request",
"for",
"a",
"user",
"that",
"does",
"not",
"have",
"a",
"valid",
"session",
"then",
"it",
"prompts",
"the",
"user",
"via",
"XXX",
".",
"If",
"the",
"session",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/saml/identity_provider.go#L175-L208 | train |
remind101/empire | internal/saml/identity_provider.go | NewIdpAuthnRequest | func NewIdpAuthnRequest(idp *IdentityProvider, r *http.Request) (*IdpAuthnRequest, error) {
req := &IdpAuthnRequest{
IDP: idp,
HTTPRequest: r,
}
switch r.Method {
case "GET":
compressedRequest, err := base64.StdEncoding.DecodeString(r.URL.Query().Get("SAMLRequest"))
if err != nil {
return nil, f... | go | func NewIdpAuthnRequest(idp *IdentityProvider, r *http.Request) (*IdpAuthnRequest, error) {
req := &IdpAuthnRequest{
IDP: idp,
HTTPRequest: r,
}
switch r.Method {
case "GET":
compressedRequest, err := base64.StdEncoding.DecodeString(r.URL.Query().Get("SAMLRequest"))
if err != nil {
return nil, f... | [
"func",
"NewIdpAuthnRequest",
"(",
"idp",
"*",
"IdentityProvider",
",",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"*",
"IdpAuthnRequest",
",",
"error",
")",
"{",
"req",
":=",
"&",
"IdpAuthnRequest",
"{",
"IDP",
":",
"idp",
",",
"HTTPRequest",
":",
"r",... | // NewIdpAuthnRequest returns a new IdpAuthnRequest for the given HTTP request to the authorization
// service. | [
"NewIdpAuthnRequest",
"returns",
"a",
"new",
"IdpAuthnRequest",
"for",
"the",
"given",
"HTTP",
"request",
"to",
"the",
"authorization",
"service",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/saml/identity_provider.go#L266-L297 | train |
remind101/empire | internal/saml/identity_provider.go | MarshalAssertion | func (req *IdpAuthnRequest) MarshalAssertion() error {
buf, err := xml.Marshal(req.Assertion)
if err != nil {
return err
}
buf, err = xmlsec.Sign([]byte(req.IDP.Key),
buf, xmlsec.SignatureOptions{})
if err != nil {
return err
}
buf, err = xmlsec.Encrypt(getSPEncryptionCert(req.ServiceProviderMetadata),
... | go | func (req *IdpAuthnRequest) MarshalAssertion() error {
buf, err := xml.Marshal(req.Assertion)
if err != nil {
return err
}
buf, err = xmlsec.Sign([]byte(req.IDP.Key),
buf, xmlsec.SignatureOptions{})
if err != nil {
return err
}
buf, err = xmlsec.Encrypt(getSPEncryptionCert(req.ServiceProviderMetadata),
... | [
"func",
"(",
"req",
"*",
"IdpAuthnRequest",
")",
"MarshalAssertion",
"(",
")",
"error",
"{",
"buf",
",",
"err",
":=",
"xml",
".",
"Marshal",
"(",
"req",
".",
"Assertion",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
... | // MarshalAssertion sets `AssertionBuffer` to a signed, encrypted
// version of `Assertion`. | [
"MarshalAssertion",
"sets",
"AssertionBuffer",
"to",
"a",
"signed",
"encrypted",
"version",
"of",
"Assertion",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/saml/identity_provider.go#L480-L500 | train |
remind101/empire | pkg/troposphere/functions.go | Ref | func Ref(ref interface{}) interface{} {
switch v := ref.(type) {
case NamedResource:
ref = v.Name
}
return map[string]interface{}{"Ref": ref}
} | go | func Ref(ref interface{}) interface{} {
switch v := ref.(type) {
case NamedResource:
ref = v.Name
}
return map[string]interface{}{"Ref": ref}
} | [
"func",
"Ref",
"(",
"ref",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"switch",
"v",
":=",
"ref",
".",
"(",
"type",
")",
"{",
"case",
"NamedResource",
":",
"ref",
"=",
"v",
".",
"Name",
"\n",
"}",
"\n",
"return",
"map",
"[",
"string"... | // Ref provides a helper for the Ref function. | [
"Ref",
"provides",
"a",
"helper",
"for",
"the",
"Ref",
"function",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/troposphere/functions.go#L4-L10 | train |
remind101/empire | pkg/troposphere/functions.go | GetAtt | func GetAtt(ref, attr interface{}) interface{} {
switch v := ref.(type) {
case NamedResource:
ref = v.Name
}
return map[string][]interface{}{"Fn::GetAtt": []interface{}{ref, attr}}
} | go | func GetAtt(ref, attr interface{}) interface{} {
switch v := ref.(type) {
case NamedResource:
ref = v.Name
}
return map[string][]interface{}{"Fn::GetAtt": []interface{}{ref, attr}}
} | [
"func",
"GetAtt",
"(",
"ref",
",",
"attr",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"switch",
"v",
":=",
"ref",
".",
"(",
"type",
")",
"{",
"case",
"NamedResource",
":",
"ref",
"=",
"v",
".",
"Name",
"\n",
"}",
"\n",
"return",
"map... | // GetAtt provides a helper for the GetAtt function. | [
"GetAtt",
"provides",
"a",
"helper",
"for",
"the",
"GetAtt",
"function",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/troposphere/functions.go#L13-L19 | train |
remind101/empire | pkg/heroku/log_drain.go | LogDrainCreate | func (c *Client) LogDrainCreate(appIdentity string, url string) (*LogDrain, error) {
params := struct {
URL string `json:"url"`
}{
URL: url,
}
var logDrainRes LogDrain
return &logDrainRes, c.Post(&logDrainRes, "/apps/"+appIdentity+"/log-drains", params)
} | go | func (c *Client) LogDrainCreate(appIdentity string, url string) (*LogDrain, error) {
params := struct {
URL string `json:"url"`
}{
URL: url,
}
var logDrainRes LogDrain
return &logDrainRes, c.Post(&logDrainRes, "/apps/"+appIdentity+"/log-drains", params)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LogDrainCreate",
"(",
"appIdentity",
"string",
",",
"url",
"string",
")",
"(",
"*",
"LogDrain",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"URL",
"string",
"`json:\"url\"`",
"\n",
"}",
"{",
"URL",
":",... | // Create a new log drain.
//
// appIdentity is the unique identifier of the LogDrain's App. url is the url
// associated with the log drain. | [
"Create",
"a",
"new",
"log",
"drain",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogDrain",
"s",
"App",
".",
"url",
"is",
"the",
"url",
"associated",
"with",
"the",
"log",
"drain",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/log_drain.go#L42-L50 | train |
remind101/empire | pkg/heroku/log_drain.go | LogDrainDelete | func (c *Client) LogDrainDelete(appIdentity string, logDrainIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/log-drains/" + logDrainIdentity)
} | go | func (c *Client) LogDrainDelete(appIdentity string, logDrainIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/log-drains/" + logDrainIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LogDrainDelete",
"(",
"appIdentity",
"string",
",",
"logDrainIdentity",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Delete",
"(",
"\"",
"\"",
"+",
"appIdentity",
"+",
"\"",
"\"",
"+",
"logDrainIdentity",
")",
... | // Delete an existing log drain. Log drains added by add-ons can only be removed
// by removing the add-on.
//
// appIdentity is the unique identifier of the LogDrain's App. logDrainIdentity
// is the unique identifier of the LogDrain. | [
"Delete",
"an",
"existing",
"log",
"drain",
".",
"Log",
"drains",
"added",
"by",
"add",
"-",
"ons",
"can",
"only",
"be",
"removed",
"by",
"removing",
"the",
"add",
"-",
"on",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogDrain... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/log_drain.go#L57-L59 | train |
remind101/empire | pkg/heroku/log_drain.go | LogDrainInfo | func (c *Client) LogDrainInfo(appIdentity string, logDrainIdentity string) (*LogDrain, error) {
var logDrain LogDrain
return &logDrain, c.Get(&logDrain, "/apps/"+appIdentity+"/log-drains/"+logDrainIdentity)
} | go | func (c *Client) LogDrainInfo(appIdentity string, logDrainIdentity string) (*LogDrain, error) {
var logDrain LogDrain
return &logDrain, c.Get(&logDrain, "/apps/"+appIdentity+"/log-drains/"+logDrainIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LogDrainInfo",
"(",
"appIdentity",
"string",
",",
"logDrainIdentity",
"string",
")",
"(",
"*",
"LogDrain",
",",
"error",
")",
"{",
"var",
"logDrain",
"LogDrain",
"\n",
"return",
"&",
"logDrain",
",",
"c",
".",
"Get"... | // Info for existing log drain.
//
// appIdentity is the unique identifier of the LogDrain's App. logDrainIdentity
// is the unique identifier of the LogDrain. | [
"Info",
"for",
"existing",
"log",
"drain",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogDrain",
"s",
"App",
".",
"logDrainIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogDrain",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/log_drain.go#L65-L68 | train |
remind101/empire | pkg/heroku/log_drain.go | LogDrainList | func (c *Client) LogDrainList(appIdentity string, lr *ListRange) ([]LogDrain, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/log-drains", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var logDrainsRes []LogDrain
return logDrainsRes, c.DoReq(req, &logDrainsR... | go | func (c *Client) LogDrainList(appIdentity string, lr *ListRange) ([]LogDrain, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/log-drains", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var logDrainsRes []LogDrain
return logDrainsRes, c.DoReq(req, &logDrainsR... | [
"func",
"(",
"c",
"*",
"Client",
")",
"LogDrainList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"LogDrain",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
... | // List existing log drains.
//
// appIdentity is the unique identifier of the LogDrain's App. lr is an optional
// ListRange that sets the Range options for the paginated list of results. | [
"List",
"existing",
"log",
"drains",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogDrain",
"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/log_drain.go#L74-L86 | train |
remind101/empire | pkg/heroku/region.go | RegionInfo | func (c *Client) RegionInfo(regionIdentity string) (*Region, error) {
var region Region
return ®ion, c.Get(®ion, "/regions/"+regionIdentity)
} | go | func (c *Client) RegionInfo(regionIdentity string) (*Region, error) {
var region Region
return ®ion, c.Get(®ion, "/regions/"+regionIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RegionInfo",
"(",
"regionIdentity",
"string",
")",
"(",
"*",
"Region",
",",
"error",
")",
"{",
"var",
"region",
"Region",
"\n",
"return",
"&",
"region",
",",
"c",
".",
"Get",
"(",
"&",
"region",
",",
"\"",
"\"... | // Info for existing region.
//
// regionIdentity is the unique identifier of the Region. | [
"Info",
"for",
"existing",
"region",
".",
"regionIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Region",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/region.go#L32-L35 | train |
remind101/empire | pkg/heroku/region.go | RegionList | func (c *Client) RegionList(lr *ListRange) ([]Region, error) {
req, err := c.NewRequest("GET", "/regions", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var regionsRes []Region
return regionsRes, c.DoReq(req, ®ionsRes)
} | go | func (c *Client) RegionList(lr *ListRange) ([]Region, error) {
req, err := c.NewRequest("GET", "/regions", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var regionsRes []Region
return regionsRes, c.DoReq(req, ®ionsRes)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RegionList",
"(",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"Region",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"nil",
... | // List existing regions.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results. | [
"List",
"existing",
"regions",
".",
"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/region.go#L41-L53 | train |
remind101/empire | server/auth/cache.go | CacheAuthorization | func CacheAuthorization(a Authorizer, expiration time.Duration) Authorizer {
cache := cache.New(expiration, 30*time.Second)
return &cachedAuthorizer{
Authorizer: a,
cache: cache,
}
} | go | func CacheAuthorization(a Authorizer, expiration time.Duration) Authorizer {
cache := cache.New(expiration, 30*time.Second)
return &cachedAuthorizer{
Authorizer: a,
cache: cache,
}
} | [
"func",
"CacheAuthorization",
"(",
"a",
"Authorizer",
",",
"expiration",
"time",
".",
"Duration",
")",
"Authorizer",
"{",
"cache",
":=",
"cache",
".",
"New",
"(",
"expiration",
",",
"30",
"*",
"time",
".",
"Second",
")",
"\n\n",
"return",
"&",
"cachedAutho... | // CacheAuthorization wraps an Authorizer in an in memory cache that expires
// after the given expiration. Only positive authorizations will be cached. | [
"CacheAuthorization",
"wraps",
"an",
"Authorizer",
"in",
"an",
"in",
"memory",
"cache",
"that",
"expires",
"after",
"the",
"given",
"expiration",
".",
"Only",
"positive",
"authorizations",
"will",
"be",
"cached",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/auth/cache.go#L12-L19 | train |
remind101/empire | pkg/heroku/dyno.go | DynoRestart | func (c *Client) DynoRestart(appIdentity, dynoIdentity, message string) error {
rh := RequestHeaders{CommitMessage: message}
return c.DeleteWithHeaders("/apps/"+appIdentity+"/dynos/"+dynoIdentity, rh.Headers())
} | go | func (c *Client) DynoRestart(appIdentity, dynoIdentity, message string) error {
rh := RequestHeaders{CommitMessage: message}
return c.DeleteWithHeaders("/apps/"+appIdentity+"/dynos/"+dynoIdentity, rh.Headers())
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DynoRestart",
"(",
"appIdentity",
",",
"dynoIdentity",
",",
"message",
"string",
")",
"error",
"{",
"rh",
":=",
"RequestHeaders",
"{",
"CommitMessage",
":",
"message",
"}",
"\n",
"return",
"c",
".",
"DeleteWithHeaders",... | // Restart dyno.
//
// appIdentity is the unique identifier of the Dyno's App. dynoIdentity is the
// unique identifier of the Dyno. | [
"Restart",
"dyno",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"s",
"App",
".",
"dynoIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/dyno.go#L96-L99 | train |
remind101/empire | pkg/heroku/dyno.go | DynoRestartAll | func (c *Client) DynoRestartAll(appIdentity, message string) error {
rh := RequestHeaders{CommitMessage: message}
return c.DeleteWithHeaders("/apps/"+appIdentity+"/dynos", rh.Headers())
} | go | func (c *Client) DynoRestartAll(appIdentity, message string) error {
rh := RequestHeaders{CommitMessage: message}
return c.DeleteWithHeaders("/apps/"+appIdentity+"/dynos", rh.Headers())
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DynoRestartAll",
"(",
"appIdentity",
",",
"message",
"string",
")",
"error",
"{",
"rh",
":=",
"RequestHeaders",
"{",
"CommitMessage",
":",
"message",
"}",
"\n",
"return",
"c",
".",
"DeleteWithHeaders",
"(",
"\"",
"\""... | // Restart all dynos
//
// appIdentity is the unique identifier of the Dyno's App. | [
"Restart",
"all",
"dynos",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"s",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/dyno.go#L104-L107 | train |
remind101/empire | pkg/heroku/dyno.go | DynoInfo | func (c *Client) DynoInfo(appIdentity string, dynoIdentity string) (*Dyno, error) {
var dyno Dyno
return &dyno, c.Get(&dyno, "/apps/"+appIdentity+"/dynos/"+dynoIdentity)
} | go | func (c *Client) DynoInfo(appIdentity string, dynoIdentity string) (*Dyno, error) {
var dyno Dyno
return &dyno, c.Get(&dyno, "/apps/"+appIdentity+"/dynos/"+dynoIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DynoInfo",
"(",
"appIdentity",
"string",
",",
"dynoIdentity",
"string",
")",
"(",
"*",
"Dyno",
",",
"error",
")",
"{",
"var",
"dyno",
"Dyno",
"\n",
"return",
"&",
"dyno",
",",
"c",
".",
"Get",
"(",
"&",
"dyno"... | // Info for existing dyno.
//
// appIdentity is the unique identifier of the Dyno's App. dynoIdentity is the
// unique identifier of the Dyno. | [
"Info",
"for",
"existing",
"dyno",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"s",
"App",
".",
"dynoIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/dyno.go#L113-L116 | train |
remind101/empire | pkg/heroku/dyno.go | DynoList | func (c *Client) DynoList(appIdentity string, lr *ListRange) ([]Dyno, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/dynos", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var dynosRes []Dyno
return dynosRes, c.DoReq(req, &dynosRes)
} | go | func (c *Client) DynoList(appIdentity string, lr *ListRange) ([]Dyno, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/dynos", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var dynosRes []Dyno
return dynosRes, c.DoReq(req, &dynosRes)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DynoList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"Dyno",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
... | // List existing dynos.
//
// appIdentity is the unique identifier of the Dyno's App. lr is an optional
// ListRange that sets the Range options for the paginated list of results. | [
"List",
"existing",
"dynos",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Dyno",
"s",
"App",
".",
"lr",
"is",
"an",
"optional",
"ListRange",
"that",
"sets",
"the",
"Range",
"options",
"for",
"the",
"paginated",
"list",
"of",
"resu... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/dyno.go#L122-L134 | train |
remind101/empire | apps.go | IsValid | func (a *App) IsValid() error {
if !NamePattern.Match([]byte(a.Name)) {
return ErrInvalidName
}
return nil
} | go | func (a *App) IsValid() error {
if !NamePattern.Match([]byte(a.Name)) {
return ErrInvalidName
}
return nil
} | [
"func",
"(",
"a",
"*",
"App",
")",
"IsValid",
"(",
")",
"error",
"{",
"if",
"!",
"NamePattern",
".",
"Match",
"(",
"[",
"]",
"byte",
"(",
"a",
".",
"Name",
")",
")",
"{",
"return",
"ErrInvalidName",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] | // IsValid returns an error if the app isn't valid. | [
"IsValid",
"returns",
"an",
"error",
"if",
"the",
"app",
"isn",
"t",
"valid",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L97-L103 | train |
remind101/empire | apps.go | Destroy | func (s *appsService) Destroy(ctx context.Context, db *gorm.DB, app *App) error {
if err := appsDestroy(db, app); err != nil {
return err
}
return s.Scheduler.Remove(ctx, app.ID)
} | go | func (s *appsService) Destroy(ctx context.Context, db *gorm.DB, app *App) error {
if err := appsDestroy(db, app); err != nil {
return err
}
return s.Scheduler.Remove(ctx, app.ID)
} | [
"func",
"(",
"s",
"*",
"appsService",
")",
"Destroy",
"(",
"ctx",
"context",
".",
"Context",
",",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"error",
"{",
"if",
"err",
":=",
"appsDestroy",
"(",
"db",
",",
"app",
")",
";",
"err",
... | // Destroy destroys removes an app from the scheduler, then destroys it here. | [
"Destroy",
"destroys",
"removes",
"an",
"app",
"from",
"the",
"scheduler",
"then",
"destroys",
"it",
"here",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L153-L159 | train |
remind101/empire | apps.go | appsEnsureRepo | func appsEnsureRepo(db *gorm.DB, app *App, repo string) error {
if app.Repo != nil {
return nil
}
app.Repo = &repo
return appsUpdate(db, app)
} | go | func appsEnsureRepo(db *gorm.DB, app *App, repo string) error {
if app.Repo != nil {
return nil
}
app.Repo = &repo
return appsUpdate(db, app)
} | [
"func",
"appsEnsureRepo",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
",",
"repo",
"string",
")",
"error",
"{",
"if",
"app",
".",
"Repo",
"!=",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"app",
".",
"Repo",
"=",
"&",
"repo",
... | // appsEnsureRepo will set the repo if it's not set. | [
"appsEnsureRepo",
"will",
"set",
"the",
"repo",
"if",
"it",
"s",
"not",
"set",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L219-L227 | train |
remind101/empire | apps.go | appsFindOrCreateByRepo | func appsFindOrCreateByRepo(db *gorm.DB, repo string) (*App, error) {
n := appNameFromRepo(repo)
a, err := appsFind(db, AppsQuery{Name: &n})
if err != nil && err != gorm.RecordNotFound {
return a, err
}
// If the app wasn't found, create a new app.
if err != gorm.RecordNotFound {
return a, appsEnsureRepo(db,... | go | func appsFindOrCreateByRepo(db *gorm.DB, repo string) (*App, error) {
n := appNameFromRepo(repo)
a, err := appsFind(db, AppsQuery{Name: &n})
if err != nil && err != gorm.RecordNotFound {
return a, err
}
// If the app wasn't found, create a new app.
if err != gorm.RecordNotFound {
return a, appsEnsureRepo(db,... | [
"func",
"appsFindOrCreateByRepo",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"repo",
"string",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"n",
":=",
"appNameFromRepo",
"(",
"repo",
")",
"\n",
"a",
",",
"err",
":=",
"appsFind",
"(",
"db",
",",
"Apps... | // appsFindOrCreateByRepo first attempts to find an app by repo, falling back to
// creating a new app. | [
"appsFindOrCreateByRepo",
"first",
"attempts",
"to",
"find",
"an",
"app",
"by",
"repo",
"falling",
"back",
"to",
"creating",
"a",
"new",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L231-L249 | train |
remind101/empire | apps.go | appsFind | func appsFind(db *gorm.DB, scope scope) (*App, error) {
var app App
return &app, first(db, scope, &app)
} | go | func appsFind(db *gorm.DB, scope scope) (*App, error) {
var app App
return &app, first(db, scope, &app)
} | [
"func",
"appsFind",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"var",
"app",
"App",
"\n",
"return",
"&",
"app",
",",
"first",
"(",
"db",
",",
"scope",
",",
"&",
"app",
")",
"\n",
"}... | // appsFind finds a single app given the scope. | [
"appsFind",
"finds",
"a",
"single",
"app",
"given",
"the",
"scope",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L252-L255 | train |
remind101/empire | apps.go | apps | func apps(db *gorm.DB, scope scope) ([]*App, error) {
var apps []*App
// Default to ordering by name.
scope = composedScope{order("name"), scope}
return apps, find(db, scope, &apps)
} | go | func apps(db *gorm.DB, scope scope) ([]*App, error) {
var apps []*App
// Default to ordering by name.
scope = composedScope{order("name"), scope}
return apps, find(db, scope, &apps)
} | [
"func",
"apps",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"[",
"]",
"*",
"App",
",",
"error",
")",
"{",
"var",
"apps",
"[",
"]",
"*",
"App",
"\n",
"// Default to ordering by name.",
"scope",
"=",
"composedScope",
"{",
"order... | // apps finds all apps matching the scope. | [
"apps",
"finds",
"all",
"apps",
"matching",
"the",
"scope",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L258-L263 | train |
remind101/empire | apps.go | appsCreate | func appsCreate(db *gorm.DB, app *App) (*App, error) {
return app, db.Create(app).Error
} | go | func appsCreate(db *gorm.DB, app *App) (*App, error) {
return app, db.Create(app).Error
} | [
"func",
"appsCreate",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"return",
"app",
",",
"db",
".",
"Create",
"(",
"app",
")",
".",
"Error",
"\n",
"}"
] | // appsCreate inserts the app into the database. | [
"appsCreate",
"inserts",
"the",
"app",
"into",
"the",
"database",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L266-L268 | train |
remind101/empire | apps.go | appsUpdate | func appsUpdate(db *gorm.DB, app *App) error {
return db.Save(app).Error
} | go | func appsUpdate(db *gorm.DB, app *App) error {
return db.Save(app).Error
} | [
"func",
"appsUpdate",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"error",
"{",
"return",
"db",
".",
"Save",
"(",
"app",
")",
".",
"Error",
"\n",
"}"
] | // appsUpdate updates an app. | [
"appsUpdate",
"updates",
"an",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L271-L273 | train |
remind101/empire | apps.go | appsDestroy | func appsDestroy(db *gorm.DB, app *App) error {
now := timex.Now()
app.DeletedAt = &now
return appsUpdate(db, app)
} | go | func appsDestroy(db *gorm.DB, app *App) error {
now := timex.Now()
app.DeletedAt = &now
return appsUpdate(db, app)
} | [
"func",
"appsDestroy",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"error",
"{",
"now",
":=",
"timex",
".",
"Now",
"(",
")",
"\n",
"app",
".",
"DeletedAt",
"=",
"&",
"now",
"\n",
"return",
"appsUpdate",
"(",
"db",
",",
"app",
... | // appsDestroy destroys an app. | [
"appsDestroy",
"destroys",
"an",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/apps.go#L276-L280 | train |
remind101/empire | pkg/httpmock/httpmock.go | NewServeReplay | func NewServeReplay(t *testing.T) *ServeReplay {
return &ServeReplay{
t: t,
Handlers: make([]http.Handler, 0),
NoneLeftFunc: defaultNoneLeftFunc,
}
} | go | func NewServeReplay(t *testing.T) *ServeReplay {
return &ServeReplay{
t: t,
Handlers: make([]http.Handler, 0),
NoneLeftFunc: defaultNoneLeftFunc,
}
} | [
"func",
"NewServeReplay",
"(",
"t",
"*",
"testing",
".",
"T",
")",
"*",
"ServeReplay",
"{",
"return",
"&",
"ServeReplay",
"{",
"t",
":",
"t",
",",
"Handlers",
":",
"make",
"(",
"[",
"]",
"http",
".",
"Handler",
",",
"0",
")",
",",
"NoneLeftFunc",
"... | // NewServeReplay returns a new ServeReplay. | [
"NewServeReplay",
"returns",
"a",
"new",
"ServeReplay",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/httpmock/httpmock.go#L26-L32 | train |
remind101/empire | pkg/httpmock/httpmock.go | Add | func (h *ServeReplay) Add(handler http.Handler) *ServeReplay {
h.Handlers = append(h.Handlers, handler)
return h
} | go | func (h *ServeReplay) Add(handler http.Handler) *ServeReplay {
h.Handlers = append(h.Handlers, handler)
return h
} | [
"func",
"(",
"h",
"*",
"ServeReplay",
")",
"Add",
"(",
"handler",
"http",
".",
"Handler",
")",
"*",
"ServeReplay",
"{",
"h",
".",
"Handlers",
"=",
"append",
"(",
"h",
".",
"Handlers",
",",
"handler",
")",
"\n",
"return",
"h",
"\n",
"}"
] | // Add appends a handler to ServReplay's handler list.
// It returns itself to allow chaining. | [
"Add",
"appends",
"a",
"handler",
"to",
"ServReplay",
"s",
"handler",
"list",
".",
"It",
"returns",
"itself",
"to",
"allow",
"chaining",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/httpmock/httpmock.go#L36-L39 | train |
remind101/empire | pkg/httpmock/httpmock.go | ServeHTTP | func (h *ServeReplay) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.i >= len(h.Handlers) {
h.NoneLeftFunc(h.t, r)
} else {
h.Handlers[h.i].ServeHTTP(w, r)
h.i++
}
} | go | func (h *ServeReplay) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.i >= len(h.Handlers) {
h.NoneLeftFunc(h.t, r)
} else {
h.Handlers[h.i].ServeHTTP(w, r)
h.i++
}
} | [
"func",
"(",
"h",
"*",
"ServeReplay",
")",
"ServeHTTP",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"h",
".",
"i",
">=",
"len",
"(",
"h",
".",
"Handlers",
")",
"{",
"h",
".",
"NoneLeftFunc",
"("... | // ServeHTTP dispatches the request to the next handler in the list. | [
"ServeHTTP",
"dispatches",
"the",
"request",
"to",
"the",
"next",
"handler",
"in",
"the",
"list",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/httpmock/httpmock.go#L42-L49 | train |
remind101/empire | pkg/heroku/organization_app_collaborator.go | OrganizationAppCollaboratorDelete | func (c *Client) OrganizationAppCollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/organizations/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
} | go | func (c *Client) OrganizationAppCollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/organizations/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationAppCollaboratorDelete",
"(",
"appIdentity",
"string",
",",
"collaboratorIdentity",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Delete",
"(",
"\"",
"\"",
"+",
"appIdentity",
"+",
"\"",
"\"",
"+",
"colla... | // Delete an existing collaborator from an organization app.
//
// appIdentity is the unique identifier of the OrganizationAppCollaborator's
// App. collaboratorIdentity is the unique identifier of the
// OrganizationAppCollaborator's Collaborator. | [
"Delete",
"an",
"existing",
"collaborator",
"from",
"an",
"organization",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationAppCollaborator",
"s",
"App",
".",
"collaboratorIdentity",
"is",
"the",
"unique",
"identifier",
"of",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_app_collaborator.go#L67-L69 | train |
remind101/empire | pkg/heroku/organization_app_collaborator.go | OrganizationAppCollaboratorInfo | func (c *Client) OrganizationAppCollaboratorInfo(appIdentity string, collaboratorIdentity string) (*OrganizationAppCollaborator, error) {
var organizationAppCollaborator OrganizationAppCollaborator
return &organizationAppCollaborator, c.Get(&organizationAppCollaborator, "/organizations/apps/"+appIdentity+"/collaborat... | go | func (c *Client) OrganizationAppCollaboratorInfo(appIdentity string, collaboratorIdentity string) (*OrganizationAppCollaborator, error) {
var organizationAppCollaborator OrganizationAppCollaborator
return &organizationAppCollaborator, c.Get(&organizationAppCollaborator, "/organizations/apps/"+appIdentity+"/collaborat... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationAppCollaboratorInfo",
"(",
"appIdentity",
"string",
",",
"collaboratorIdentity",
"string",
")",
"(",
"*",
"OrganizationAppCollaborator",
",",
"error",
")",
"{",
"var",
"organizationAppCollaborator",
"OrganizationAppColl... | // Info for a collaborator on an organization app.
//
// appIdentity is the unique identifier of the OrganizationAppCollaborator's
// App. collaboratorIdentity is the unique identifier of the
// OrganizationAppCollaborator's Collaborator. | [
"Info",
"for",
"a",
"collaborator",
"on",
"an",
"organization",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationAppCollaborator",
"s",
"App",
".",
"collaboratorIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_app_collaborator.go#L76-L79 | train |
remind101/empire | pkg/heroku/organization_app_collaborator.go | OrganizationAppCollaboratorList | func (c *Client) OrganizationAppCollaboratorList(appIdentity string, lr *ListRange) ([]OrganizationAppCollaborator, error) {
req, err := c.NewRequest("GET", "/organizations/apps/"+appIdentity+"/collaborators", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationApp... | go | func (c *Client) OrganizationAppCollaboratorList(appIdentity string, lr *ListRange) ([]OrganizationAppCollaborator, error) {
req, err := c.NewRequest("GET", "/organizations/apps/"+appIdentity+"/collaborators", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationApp... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationAppCollaboratorList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"OrganizationAppCollaborator",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
... | // List collaborators on an organization app.
//
// appIdentity is the unique identifier of the OrganizationAppCollaborator's
// App. lr is an optional ListRange that sets the Range options for the
// paginated list of results. | [
"List",
"collaborators",
"on",
"an",
"organization",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationAppCollaborator",
"s",
"App",
".",
"lr",
"is",
"an",
"optional",
"ListRange",
"that",
"sets",
"the",
"Range",
"options"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_app_collaborator.go#L86-L98 | train |
remind101/empire | twelvefactor/twelvefactor.go | Transform | func Transform(s Scheduler, fn func(*Manifest) *Manifest) Scheduler {
return &transformer{s, fn}
} | go | func Transform(s Scheduler, fn func(*Manifest) *Manifest) Scheduler {
return &transformer{s, fn}
} | [
"func",
"Transform",
"(",
"s",
"Scheduler",
",",
"fn",
"func",
"(",
"*",
"Manifest",
")",
"*",
"Manifest",
")",
"Scheduler",
"{",
"return",
"&",
"transformer",
"{",
"s",
",",
"fn",
"}",
"\n",
"}"
] | // Trasnform wraps a Scheduler to perform transformations on the Manifest. This
// can be used to, for example, add defaults placement constraints before
// providing it to the backend scheduler. | [
"Trasnform",
"wraps",
"a",
"Scheduler",
"to",
"perform",
"transformations",
"on",
"the",
"Manifest",
".",
"This",
"can",
"be",
"used",
"to",
"for",
"example",
"add",
"defaults",
"placement",
"constraints",
"before",
"providing",
"it",
"to",
"the",
"backend",
"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/twelvefactor/twelvefactor.go#L194-L196 | train |
remind101/empire | twelvefactor/twelvefactor.go | Env | func Env(app *Manifest, process *Process) map[string]string {
return merge(app.Env, process.Env)
} | go | func Env(app *Manifest, process *Process) map[string]string {
return merge(app.Env, process.Env)
} | [
"func",
"Env",
"(",
"app",
"*",
"Manifest",
",",
"process",
"*",
"Process",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"return",
"merge",
"(",
"app",
".",
"Env",
",",
"process",
".",
"Env",
")",
"\n",
"}"
] | // Env merges the App environment with any environment variables provided
// in the process. | [
"Env",
"merges",
"the",
"App",
"environment",
"with",
"any",
"environment",
"variables",
"provided",
"in",
"the",
"process",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/twelvefactor/twelvefactor.go#L218-L220 | train |
remind101/empire | twelvefactor/twelvefactor.go | Labels | func Labels(app *Manifest, process *Process) map[string]string {
return merge(app.Labels, process.Labels)
} | go | func Labels(app *Manifest, process *Process) map[string]string {
return merge(app.Labels, process.Labels)
} | [
"func",
"Labels",
"(",
"app",
"*",
"Manifest",
",",
"process",
"*",
"Process",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"return",
"merge",
"(",
"app",
".",
"Labels",
",",
"process",
".",
"Labels",
")",
"\n",
"}"
] | // Labels merges the App labels with any labels provided in the process. | [
"Labels",
"merges",
"the",
"App",
"labels",
"with",
"any",
"labels",
"provided",
"in",
"the",
"process",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/twelvefactor/twelvefactor.go#L223-L225 | train |
remind101/empire | twelvefactor/twelvefactor.go | merge | func merge(envs ...map[string]string) map[string]string {
merged := make(map[string]string)
for _, env := range envs {
for k, v := range env {
merged[k] = v
}
}
return merged
} | go | func merge(envs ...map[string]string) map[string]string {
merged := make(map[string]string)
for _, env := range envs {
for k, v := range env {
merged[k] = v
}
}
return merged
} | [
"func",
"merge",
"(",
"envs",
"...",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"merged",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"for",
"_",
",",
"env",
":=",
"range",
"envs",
"... | // merges the maps together, favoring keys from the right to the left. | [
"merges",
"the",
"maps",
"together",
"favoring",
"keys",
"from",
"the",
"right",
"to",
"the",
"left",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/twelvefactor/twelvefactor.go#L228-L236 | train |
remind101/empire | cmd/emp/main.go | matchesCommand | func matchesCommand(cmd *Command, want string) bool {
if cmd.Alias != "" && cmd.Alias == want {
return true
}
return cmd.Name() == want
} | go | func matchesCommand(cmd *Command, want string) bool {
if cmd.Alias != "" && cmd.Alias == want {
return true
}
return cmd.Name() == want
} | [
"func",
"matchesCommand",
"(",
"cmd",
"*",
"Command",
",",
"want",
"string",
")",
"bool",
"{",
"if",
"cmd",
".",
"Alias",
"!=",
"\"",
"\"",
"&&",
"cmd",
".",
"Alias",
"==",
"want",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"return",
"cmd",
".",
"Na... | // matchesCommand checks if the Command matches the command that we want to run. | [
"matchesCommand",
"checks",
"if",
"the",
"Command",
"matches",
"the",
"command",
"that",
"we",
"want",
"to",
"run",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/cmd/emp/main.go#L294-L300 | train |
remind101/empire | internal/uuid/time.go | UnixTime | func (t Time) UnixTime() (sec, nsec int64) {
sec = int64(t - g1582ns100)
nsec = (sec % 10000000) * 100
sec /= 10000000
return sec, nsec
} | go | func (t Time) UnixTime() (sec, nsec int64) {
sec = int64(t - g1582ns100)
nsec = (sec % 10000000) * 100
sec /= 10000000
return sec, nsec
} | [
"func",
"(",
"t",
"Time",
")",
"UnixTime",
"(",
")",
"(",
"sec",
",",
"nsec",
"int64",
")",
"{",
"sec",
"=",
"int64",
"(",
"t",
"-",
"g1582ns100",
")",
"\n",
"nsec",
"=",
"(",
"sec",
"%",
"10000000",
")",
"*",
"100",
"\n",
"sec",
"/=",
"1000000... | // UnixTime converts t the number of seconds and nanoseconds using the Unix
// epoch of 1 Jan 1970. | [
"UnixTime",
"converts",
"t",
"the",
"number",
"of",
"seconds",
"and",
"nanoseconds",
"using",
"the",
"Unix",
"epoch",
"of",
"1",
"Jan",
"1970",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/uuid/time.go#L35-L40 | train |
remind101/empire | internal/uuid/time.go | Time | func (uuid UUID) Time() (Time, bool) {
if len(uuid) != 16 {
return 0, false
}
time := int64(binary.BigEndian.Uint32(uuid[0:4]))
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
return Time(time), true
} | go | func (uuid UUID) Time() (Time, bool) {
if len(uuid) != 16 {
return 0, false
}
time := int64(binary.BigEndian.Uint32(uuid[0:4]))
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
return Time(time), true
} | [
"func",
"(",
"uuid",
"UUID",
")",
"Time",
"(",
")",
"(",
"Time",
",",
"bool",
")",
"{",
"if",
"len",
"(",
"uuid",
")",
"!=",
"16",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"time",
":=",
"int64",
"(",
"binary",
".",
"BigEndian",
".",
... | // Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
// uuid. It returns false if uuid is not valid. The time is only well defined
// for version 1 and 2 UUIDs. | [
"Time",
"returns",
"the",
"time",
"in",
"100s",
"of",
"nanoseconds",
"since",
"15",
"Oct",
"1582",
"encoded",
"in",
"uuid",
".",
"It",
"returns",
"false",
"if",
"uuid",
"is",
"not",
"valid",
".",
"The",
"time",
"is",
"only",
"well",
"defined",
"for",
"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/uuid/time.go#L114-L122 | train |
remind101/empire | internal/uuid/time.go | ClockSequence | func (uuid UUID) ClockSequence() (int, bool) {
if len(uuid) != 16 {
return 0, false
}
return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true
} | go | func (uuid UUID) ClockSequence() (int, bool) {
if len(uuid) != 16 {
return 0, false
}
return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true
} | [
"func",
"(",
"uuid",
"UUID",
")",
"ClockSequence",
"(",
")",
"(",
"int",
",",
"bool",
")",
"{",
"if",
"len",
"(",
"uuid",
")",
"!=",
"16",
"{",
"return",
"0",
",",
"false",
"\n",
"}",
"\n",
"return",
"int",
"(",
"binary",
".",
"BigEndian",
".",
... | // ClockSequence returns the clock sequence encoded in uuid. It returns false
// if uuid is not valid. The clock sequence is only well defined for version 1
// and 2 UUIDs. | [
"ClockSequence",
"returns",
"the",
"clock",
"sequence",
"encoded",
"in",
"uuid",
".",
"It",
"returns",
"false",
"if",
"uuid",
"is",
"not",
"valid",
".",
"The",
"clock",
"sequence",
"is",
"only",
"well",
"defined",
"for",
"version",
"1",
"and",
"2",
"UUIDs"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/internal/uuid/time.go#L127-L132 | train |
remind101/empire | configs.go | newConfig | func newConfig(old *Config, vars Vars) *Config {
v := mergeVars(old.Vars, vars)
return &Config{
AppID: old.AppID,
Vars: v,
}
} | go | func newConfig(old *Config, vars Vars) *Config {
v := mergeVars(old.Vars, vars)
return &Config{
AppID: old.AppID,
Vars: v,
}
} | [
"func",
"newConfig",
"(",
"old",
"*",
"Config",
",",
"vars",
"Vars",
")",
"*",
"Config",
"{",
"v",
":=",
"mergeVars",
"(",
"old",
".",
"Vars",
",",
"vars",
")",
"\n\n",
"return",
"&",
"Config",
"{",
"AppID",
":",
"old",
".",
"AppID",
",",
"Vars",
... | // newConfig initializes a new config based on the old config, with the new
// variables provided. | [
"newConfig",
"initializes",
"a",
"new",
"config",
"based",
"on",
"the",
"old",
"config",
"with",
"the",
"new",
"variables",
"provided",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L32-L39 | train |
remind101/empire | configs.go | configsFind | func configsFind(db *gorm.DB, scope scope) (*Config, error) {
var config Config
scope = composedScope{order("created_at desc"), scope}
return &config, first(db, scope, &config)
} | go | func configsFind(db *gorm.DB, scope scope) (*Config, error) {
var config Config
scope = composedScope{order("created_at desc"), scope}
return &config, first(db, scope, &config)
} | [
"func",
"configsFind",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"var",
"config",
"Config",
"\n",
"scope",
"=",
"composedScope",
"{",
"order",
"(",
"\"",
"\"",
")",
",",
"scope",
"}",... | // configsFind returns the first matching config. | [
"configsFind",
"returns",
"the",
"first",
"matching",
"config",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L112-L116 | train |
remind101/empire | configs.go | configsCreate | func configsCreate(db *gorm.DB, config *Config) (*Config, error) {
return config, db.Create(config).Error
} | go | func configsCreate(db *gorm.DB, config *Config) (*Config, error) {
return config, db.Create(config).Error
} | [
"func",
"configsCreate",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"config",
"*",
"Config",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"return",
"config",
",",
"db",
".",
"Create",
"(",
"config",
")",
".",
"Error",
"\n",
"}"
] | // ConfigsCreate inserts a Config in the database. | [
"ConfigsCreate",
"inserts",
"a",
"Config",
"in",
"the",
"database",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L119-L121 | train |
remind101/empire | configs.go | Config | func (s *configsService) Config(db *gorm.DB, app *App) (*Config, error) {
r, err := releasesFind(db, ReleasesQuery{App: app})
if err != nil {
if err == gorm.RecordNotFound {
// It's possible to have config without releases, this handles that.
c, err := configsFind(db, ConfigsQuery{App: app})
if err != nil ... | go | func (s *configsService) Config(db *gorm.DB, app *App) (*Config, error) {
r, err := releasesFind(db, ReleasesQuery{App: app})
if err != nil {
if err == gorm.RecordNotFound {
// It's possible to have config without releases, this handles that.
c, err := configsFind(db, ConfigsQuery{App: app})
if err != nil ... | [
"func",
"(",
"s",
"*",
"configsService",
")",
"Config",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"app",
"*",
"App",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"releasesFind",
"(",
"db",
",",
"ReleasesQuery",
"{",
"App"... | // Returns configs for latest release or the latest configs if there are no releases. | [
"Returns",
"configs",
"for",
"latest",
"release",
"or",
"the",
"latest",
"configs",
"if",
"there",
"are",
"no",
"releases",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L160-L185 | train |
remind101/empire | configs.go | mergeVars | func mergeVars(old, new Vars) Vars {
vars := make(Vars)
for n, v := range old {
vars[n] = v
}
for n, v := range new {
if v == nil {
delete(vars, n)
} else {
vars[n] = v
}
}
return vars
} | go | func mergeVars(old, new Vars) Vars {
vars := make(Vars)
for n, v := range old {
vars[n] = v
}
for n, v := range new {
if v == nil {
delete(vars, n)
} else {
vars[n] = v
}
}
return vars
} | [
"func",
"mergeVars",
"(",
"old",
",",
"new",
"Vars",
")",
"Vars",
"{",
"vars",
":=",
"make",
"(",
"Vars",
")",
"\n\n",
"for",
"n",
",",
"v",
":=",
"range",
"old",
"{",
"vars",
"[",
"n",
"]",
"=",
"v",
"\n",
"}",
"\n\n",
"for",
"n",
",",
"v",
... | // mergeVars copies all of the vars from a, and merges b into them, returning a
// new Vars. | [
"mergeVars",
"copies",
"all",
"of",
"the",
"vars",
"from",
"a",
"and",
"merges",
"b",
"into",
"them",
"returning",
"a",
"new",
"Vars",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L189-L205 | train |
remind101/empire | configs.go | configsApplyReleaseDesc | func configsApplyReleaseDesc(opts SetOpts) string {
vars := opts.Vars
verb := "Set"
plural := ""
if len(vars) > 1 {
plural = "s"
}
keys := make(sort.StringSlice, 0, len(vars))
for k, v := range vars {
keys = append(keys, string(k))
if v == nil {
verb = "Unset"
}
}
keys.Sort()
desc := fmt.Sprintf("... | go | func configsApplyReleaseDesc(opts SetOpts) string {
vars := opts.Vars
verb := "Set"
plural := ""
if len(vars) > 1 {
plural = "s"
}
keys := make(sort.StringSlice, 0, len(vars))
for k, v := range vars {
keys = append(keys, string(k))
if v == nil {
verb = "Unset"
}
}
keys.Sort()
desc := fmt.Sprintf("... | [
"func",
"configsApplyReleaseDesc",
"(",
"opts",
"SetOpts",
")",
"string",
"{",
"vars",
":=",
"opts",
".",
"Vars",
"\n",
"verb",
":=",
"\"",
"\"",
"\n",
"plural",
":=",
"\"",
"\"",
"\n",
"if",
"len",
"(",
"vars",
")",
">",
"1",
"{",
"plural",
"=",
"... | // configsApplyReleaseDesc formats a release description based on the config variables
// being applied. | [
"configsApplyReleaseDesc",
"formats",
"a",
"release",
"description",
"based",
"on",
"the",
"config",
"variables",
"being",
"applied",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/configs.go#L209-L227 | train |
remind101/empire | stats/stats.go | WithStats | func WithStats(ctx context.Context, stats Stats) context.Context {
return context.WithValue(ctx, statsKey, stats)
} | go | func WithStats(ctx context.Context, stats Stats) context.Context {
return context.WithValue(ctx, statsKey, stats)
} | [
"func",
"WithStats",
"(",
"ctx",
"context",
".",
"Context",
",",
"stats",
"Stats",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"statsKey",
",",
"stats",
")",
"\n",
"}"
] | // WithStats returns a new context.Context with the Stats implementation
// embedded. | [
"WithStats",
"returns",
"a",
"new",
"context",
".",
"Context",
"with",
"the",
"Stats",
"implementation",
"embedded",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/stats.go#L63-L65 | train |
remind101/empire | stats/stats.go | FromContext | func FromContext(ctx context.Context) (Stats, bool) {
stats, ok := ctx.Value(statsKey).(Stats)
return stats, ok
} | go | func FromContext(ctx context.Context) (Stats, bool) {
stats, ok := ctx.Value(statsKey).(Stats)
return stats, ok
} | [
"func",
"FromContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"Stats",
",",
"bool",
")",
"{",
"stats",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"statsKey",
")",
".",
"(",
"Stats",
")",
"\n",
"return",
"stats",
",",
"ok",
"\n",
"}"
] | // FromContext returns the Stats implementation that's embedded in the context. | [
"FromContext",
"returns",
"the",
"Stats",
"implementation",
"that",
"s",
"embedded",
"in",
"the",
"context",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/stats.go#L68-L71 | train |
remind101/empire | stats/stats.go | WithTags | func WithTags(ctx context.Context, tags []string) context.Context {
stats, ok := FromContext(ctx)
if !ok {
return ctx
}
return WithStats(ctx, &taggedStats{tags, stats})
} | go | func WithTags(ctx context.Context, tags []string) context.Context {
stats, ok := FromContext(ctx)
if !ok {
return ctx
}
return WithStats(ctx, &taggedStats{tags, stats})
} | [
"func",
"WithTags",
"(",
"ctx",
"context",
".",
"Context",
",",
"tags",
"[",
"]",
"string",
")",
"context",
".",
"Context",
"{",
"stats",
",",
"ok",
":=",
"FromContext",
"(",
"ctx",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"ctx",
"\n",
"}",
"\n",... | // WithTags will return a context.Context where all metrics recorded with the
// embedded Stats implementation will include the given stats. | [
"WithTags",
"will",
"return",
"a",
"context",
".",
"Context",
"where",
"all",
"metrics",
"recorded",
"with",
"the",
"embedded",
"Stats",
"implementation",
"will",
"include",
"the",
"given",
"stats",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/stats.go#L75-L81 | train |
remind101/empire | domains.go | domainsFind | func domainsFind(db *gorm.DB, scope scope) (*Domain, error) {
var domain Domain
return &domain, first(db, scope, &domain)
} | go | func domainsFind(db *gorm.DB, scope scope) (*Domain, error) {
var domain Domain
return &domain, first(db, scope, &domain)
} | [
"func",
"domainsFind",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"var",
"domain",
"Domain",
"\n",
"return",
"&",
"domain",
",",
"first",
"(",
"db",
",",
"scope",
",",
"&",
"domain",
... | // domainsFind returns the first matching domain. | [
"domainsFind",
"returns",
"the",
"first",
"matching",
"domain",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/domains.go#L103-L106 | train |
remind101/empire | domains.go | domains | func domains(db *gorm.DB, scope scope) ([]*Domain, error) {
var domains []*Domain
return domains, find(db, scope, &domains)
} | go | func domains(db *gorm.DB, scope scope) ([]*Domain, error) {
var domains []*Domain
return domains, find(db, scope, &domains)
} | [
"func",
"domains",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"scope",
"scope",
")",
"(",
"[",
"]",
"*",
"Domain",
",",
"error",
")",
"{",
"var",
"domains",
"[",
"]",
"*",
"Domain",
"\n",
"return",
"domains",
",",
"find",
"(",
"db",
",",
"scope",
... | // domains returns all domains matching the scope. | [
"domains",
"returns",
"all",
"domains",
"matching",
"the",
"scope",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/domains.go#L109-L112 | train |
remind101/empire | pkg/heroku/config_var.go | ConfigVarInfo | func (c *Client) ConfigVarInfo(appIdentity string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, "/apps/"+appIdentity+"/config-vars")
} | go | func (c *Client) ConfigVarInfo(appIdentity string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, "/apps/"+appIdentity+"/config-vars")
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ConfigVarInfo",
"(",
"appIdentity",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"configVar",
"map",
"[",
"string",
"]",
"string",
"\n",
"return",
"configVar",
",",
"c",
... | // Get config-vars for app.
//
// appIdentity is the unique identifier of the ConfigVar's App. | [
"Get",
"config",
"-",
"vars",
"for",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"ConfigVar",
"s",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/config_var.go#L12-L15 | train |
remind101/empire | pkg/heroku/config_var.go | ConfigVarInfoByReleaseVersion | func (c *Client) ConfigVarInfoByReleaseVersion(appIdentity, version string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, fmt.Sprintf("/apps/%s/config-vars/%s", appIdentity, version))
} | go | func (c *Client) ConfigVarInfoByReleaseVersion(appIdentity, version string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, fmt.Sprintf("/apps/%s/config-vars/%s", appIdentity, version))
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ConfigVarInfoByReleaseVersion",
"(",
"appIdentity",
",",
"version",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"configVar",
"map",
"[",
"string",
"]",
"string",
"\n",
"re... | // Get config-vars for app and release.
//
// appIdentity is the unique identifier of the ConfigVar's App.
// version is the release version of the app. | [
"Get",
"config",
"-",
"vars",
"for",
"app",
"and",
"release",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"ConfigVar",
"s",
"App",
".",
"version",
"is",
"the",
"release",
"version",
"of",
"the",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/config_var.go#L21-L24 | train |
remind101/empire | cmd/emp/dynos.go | quote | func quote(s string) string {
b, _ := json.Marshal(s)
return string(b)
} | go | func quote(s string) string {
b, _ := json.Marshal(s)
return string(b)
} | [
"func",
"quote",
"(",
"s",
"string",
")",
"string",
"{",
"b",
",",
"_",
":=",
"json",
".",
"Marshal",
"(",
"s",
")",
"\n",
"return",
"string",
"(",
"b",
")",
"\n",
"}"
] | // quotes s as a json string | [
"quotes",
"s",
"as",
"a",
"json",
"string"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/cmd/emp/dynos.go#L80-L83 | train |
remind101/empire | pkg/heroku/account_feature.go | AccountFeatureInfo | func (c *Client) AccountFeatureInfo(accountFeatureIdentity string) (*AccountFeature, error) {
var accountFeature AccountFeature
return &accountFeature, c.Get(&accountFeature, "/account/features/"+accountFeatureIdentity)
} | go | func (c *Client) AccountFeatureInfo(accountFeatureIdentity string) (*AccountFeature, error) {
var accountFeature AccountFeature
return &accountFeature, c.Get(&accountFeature, "/account/features/"+accountFeatureIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AccountFeatureInfo",
"(",
"accountFeatureIdentity",
"string",
")",
"(",
"*",
"AccountFeature",
",",
"error",
")",
"{",
"var",
"accountFeature",
"AccountFeature",
"\n",
"return",
"&",
"accountFeature",
",",
"c",
".",
"Get"... | // Info for an existing account feature.
//
// accountFeatureIdentity is the unique identifier of the AccountFeature. | [
"Info",
"for",
"an",
"existing",
"account",
"feature",
".",
"accountFeatureIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AccountFeature",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/account_feature.go#L42-L45 | train |
remind101/empire | pkg/heroku/account_feature.go | AccountFeatureList | func (c *Client) AccountFeatureList(lr *ListRange) ([]AccountFeature, error) {
req, err := c.NewRequest("GET", "/account/features", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var accountFeaturesRes []AccountFeature
return accountFeaturesRes, c.DoReq(req, &accountFeatures... | go | func (c *Client) AccountFeatureList(lr *ListRange) ([]AccountFeature, error) {
req, err := c.NewRequest("GET", "/account/features", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var accountFeaturesRes []AccountFeature
return accountFeaturesRes, c.DoReq(req, &accountFeatures... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AccountFeatureList",
"(",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"AccountFeature",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
... | // List existing account features.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results. | [
"List",
"existing",
"account",
"features",
".",
"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/account_feature.go#L51-L63 | train |
remind101/empire | pkg/heroku/account_feature.go | AccountFeatureUpdate | func (c *Client) AccountFeatureUpdate(accountFeatureIdentity string, enabled bool) (*AccountFeature, error) {
params := struct {
Enabled bool `json:"enabled"`
}{
Enabled: enabled,
}
var accountFeatureRes AccountFeature
return &accountFeatureRes, c.Patch(&accountFeatureRes, "/account/features/"+accountFeatureId... | go | func (c *Client) AccountFeatureUpdate(accountFeatureIdentity string, enabled bool) (*AccountFeature, error) {
params := struct {
Enabled bool `json:"enabled"`
}{
Enabled: enabled,
}
var accountFeatureRes AccountFeature
return &accountFeatureRes, c.Patch(&accountFeatureRes, "/account/features/"+accountFeatureId... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AccountFeatureUpdate",
"(",
"accountFeatureIdentity",
"string",
",",
"enabled",
"bool",
")",
"(",
"*",
"AccountFeature",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"Enabled",
"bool",
"`json:\"enabled\"`",
"\n"... | // Update an existing account feature.
//
// accountFeatureIdentity is the unique identifier of the AccountFeature.
// enabled is the whether or not account feature has been enabled. | [
"Update",
"an",
"existing",
"account",
"feature",
".",
"accountFeatureIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AccountFeature",
".",
"enabled",
"is",
"the",
"whether",
"or",
"not",
"account",
"feature",
"has",
"been",
"enabled",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/account_feature.go#L69-L77 | train |
remind101/empire | db.go | OpenDB | func OpenDB(uri string) (*DB, error) {
_, err := url.Parse(uri)
if err != nil {
return nil, err
}
conn, err := sql.Open(DBDriver, uri)
if err != nil {
return nil, err
}
return NewDB(conn)
} | go | func OpenDB(uri string) (*DB, error) {
_, err := url.Parse(uri)
if err != nil {
return nil, err
}
conn, err := sql.Open(DBDriver, uri)
if err != nil {
return nil, err
}
return NewDB(conn)
} | [
"func",
"OpenDB",
"(",
"uri",
"string",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"uri",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"conn",
","... | // OpenDB returns a new gorm.DB instance. | [
"OpenDB",
"returns",
"a",
"new",
"gorm",
".",
"DB",
"instance",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L42-L54 | train |
remind101/empire | db.go | NewDB | func NewDB(conn *sql.DB) (*DB, error) {
db, err := gorm.Open(DBDriver, conn)
if err != nil {
return nil, err
}
m := migrate.NewPostgresMigrator(conn)
// Run all migrations in a single transaction, so they will be rolled
// back as one. This is almost always the behavior that users would want
// when upgrading... | go | func NewDB(conn *sql.DB) (*DB, error) {
db, err := gorm.Open(DBDriver, conn)
if err != nil {
return nil, err
}
m := migrate.NewPostgresMigrator(conn)
// Run all migrations in a single transaction, so they will be rolled
// back as one. This is almost always the behavior that users would want
// when upgrading... | [
"func",
"NewDB",
"(",
"conn",
"*",
"sql",
".",
"DB",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"db",
",",
"err",
":=",
"gorm",
".",
"Open",
"(",
"DBDriver",
",",
"conn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err"... | // NewDB wraps a sql.DB instance as a DB. | [
"NewDB",
"wraps",
"a",
"sql",
".",
"DB",
"instance",
"as",
"a",
"DB",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L57-L75 | train |
remind101/empire | db.go | MigrateUp | func (db *DB) MigrateUp() error {
return db.migrator.Exec(migrate.Up, db.migrations()...)
} | go | func (db *DB) MigrateUp() error {
return db.migrator.Exec(migrate.Up, db.migrations()...)
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"MigrateUp",
"(",
")",
"error",
"{",
"return",
"db",
".",
"migrator",
".",
"Exec",
"(",
"migrate",
".",
"Up",
",",
"db",
".",
"migrations",
"(",
")",
"...",
")",
"\n",
"}"
] | // MigrateUp migrates the database to the latest version of the schema. | [
"MigrateUp",
"migrates",
"the",
"database",
"to",
"the",
"latest",
"version",
"of",
"the",
"schema",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L78-L80 | train |
remind101/empire | db.go | Reset | func (db *DB) Reset() error {
var err error
exec := func(sql string) {
if err == nil {
err = db.Exec(sql).Error
}
}
exec(`TRUNCATE TABLE apps CASCADE`)
exec(`TRUNCATE TABLE ports CASCADE`)
exec(`TRUNCATE TABLE slugs CASCADE`)
exec(`UPDATE ports SET app_id = NULL`)
return err
} | go | func (db *DB) Reset() error {
var err error
exec := func(sql string) {
if err == nil {
err = db.Exec(sql).Error
}
}
exec(`TRUNCATE TABLE apps CASCADE`)
exec(`TRUNCATE TABLE ports CASCADE`)
exec(`TRUNCATE TABLE slugs CASCADE`)
exec(`UPDATE ports SET app_id = NULL`)
return err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Reset",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"exec",
":=",
"func",
"(",
"sql",
"string",
")",
"{",
"if",
"err",
"==",
"nil",
"{",
"err",
"=",
"db",
".",
"Exec",
"(",
"sql",
")",
".",
"Error"... | // Reset resets the database to a pristine state. | [
"Reset",
"resets",
"the",
"database",
"to",
"a",
"pristine",
"state",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L87-L101 | train |
remind101/empire | db.go | IsHealthy | func (db *DB) IsHealthy() error {
if err := db.DB.DB().Ping(); err != nil {
return err
}
if err := db.CheckSchemaVersion(); err != nil {
return err
}
return nil
} | go | func (db *DB) IsHealthy() error {
if err := db.DB.DB().Ping(); err != nil {
return err
}
if err := db.CheckSchemaVersion(); err != nil {
return err
}
return nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"IsHealthy",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"db",
".",
"DB",
".",
"DB",
"(",
")",
".",
"Ping",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"db... | // IsHealthy checks that we can connect to the database. | [
"IsHealthy",
"checks",
"that",
"we",
"can",
"connect",
"to",
"the",
"database",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L104-L114 | train |
remind101/empire | db.go | CheckSchemaVersion | func (db *DB) CheckSchemaVersion() error {
schemaVersion, err := db.SchemaVersion()
if err != nil {
return fmt.Errorf("error fetching schema version: %v", err)
}
expectedSchemaVersion := db.schema().latestSchema()
if schemaVersion != expectedSchemaVersion {
return &IncompatibleSchemaError{
SchemaVersion: ... | go | func (db *DB) CheckSchemaVersion() error {
schemaVersion, err := db.SchemaVersion()
if err != nil {
return fmt.Errorf("error fetching schema version: %v", err)
}
expectedSchemaVersion := db.schema().latestSchema()
if schemaVersion != expectedSchemaVersion {
return &IncompatibleSchemaError{
SchemaVersion: ... | [
"func",
"(",
"db",
"*",
"DB",
")",
"CheckSchemaVersion",
"(",
")",
"error",
"{",
"schemaVersion",
",",
"err",
":=",
"db",
".",
"SchemaVersion",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"er... | // CheckSchemaVersion verifies that the actual database schema matches the
// version that this version of Empire expects. | [
"CheckSchemaVersion",
"verifies",
"that",
"the",
"actual",
"database",
"schema",
"matches",
"the",
"version",
"that",
"this",
"version",
"of",
"Empire",
"expects",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L118-L133 | train |
remind101/empire | db.go | SchemaVersion | func (db *DB) SchemaVersion() (int, error) {
sql := `select version from schema_migrations order by version desc limit 1`
var schemaVersion int
err := db.DB.DB().QueryRow(sql).Scan(&schemaVersion)
return schemaVersion, err
} | go | func (db *DB) SchemaVersion() (int, error) {
sql := `select version from schema_migrations order by version desc limit 1`
var schemaVersion int
err := db.DB.DB().QueryRow(sql).Scan(&schemaVersion)
return schemaVersion, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"SchemaVersion",
"(",
")",
"(",
"int",
",",
"error",
")",
"{",
"sql",
":=",
"`select version from schema_migrations order by version desc limit 1`",
"\n",
"var",
"schemaVersion",
"int",
"\n",
"err",
":=",
"db",
".",
"DB",
"."... | // SchemaVersion returns the current schema version. | [
"SchemaVersion",
"returns",
"the",
"current",
"schema",
"version",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L136-L141 | train |
remind101/empire | db.go | fieldEquals | func fieldEquals(field string, v interface{}) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Where(fmt.Sprintf("%s = ?", field), v)
})
} | go | func fieldEquals(field string, v interface{}) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Where(fmt.Sprintf("%s = ?", field), v)
})
} | [
"func",
"fieldEquals",
"(",
"field",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"scope",
"{",
"return",
"scopeFunc",
"(",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
"db",
".",
"Where",
"(",
"fmt",
... | // fieldEquals returns a scope that filters on a field. | [
"fieldEquals",
"returns",
"a",
"scope",
"that",
"filters",
"on",
"a",
"field",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L193-L197 | train |
remind101/empire | db.go | preload | func preload(associations ...string) scope {
var scope composedScope
for _, a := range associations {
aa := a
scope = append(scope, scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Preload(aa)
}))
}
return scope
} | go | func preload(associations ...string) scope {
var scope composedScope
for _, a := range associations {
aa := a
scope = append(scope, scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Preload(aa)
}))
}
return scope
} | [
"func",
"preload",
"(",
"associations",
"...",
"string",
")",
"scope",
"{",
"var",
"scope",
"composedScope",
"\n\n",
"for",
"_",
",",
"a",
":=",
"range",
"associations",
"{",
"aa",
":=",
"a",
"\n",
"scope",
"=",
"append",
"(",
"scope",
",",
"scopeFunc",
... | // preload returns a scope that preloads the associations. | [
"preload",
"returns",
"a",
"scope",
"that",
"preloads",
"the",
"associations",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L206-L217 | train |
remind101/empire | db.go | order | func order(order string) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Order(order)
})
} | go | func order(order string) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Order(order)
})
} | [
"func",
"order",
"(",
"order",
"string",
")",
"scope",
"{",
"return",
"scopeFunc",
"(",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
"db",
".",
"Order",
"(",
"order",
")",
"\n",
"}",
")",
"\n",
"}"
] | // order returns a scope that orders the results. | [
"order",
"returns",
"a",
"scope",
"that",
"orders",
"the",
"results",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L220-L224 | train |
remind101/empire | db.go | limit | func limit(limit int) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Limit(limit)
})
} | go | func limit(limit int) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Limit(limit)
})
} | [
"func",
"limit",
"(",
"limit",
"int",
")",
"scope",
"{",
"return",
"scopeFunc",
"(",
"func",
"(",
"db",
"*",
"gorm",
".",
"DB",
")",
"*",
"gorm",
".",
"DB",
"{",
"return",
"db",
".",
"Limit",
"(",
"limit",
")",
"\n",
"}",
")",
"\n",
"}"
] | // limit returns a scope that limits the results. | [
"limit",
"returns",
"a",
"scope",
"that",
"limits",
"the",
"results",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L227-L231 | train |
remind101/empire | db.go | inRange | func inRange(r headerutil.Range) scope {
var scope composedScope
if r.Max != nil {
scope = append(scope, limit(*r.Max))
}
if r.Sort != nil && r.Order != nil {
o := fmt.Sprintf("%s %s", *r.Sort, *r.Order)
scope = append(scope, order(o))
}
return scope
} | go | func inRange(r headerutil.Range) scope {
var scope composedScope
if r.Max != nil {
scope = append(scope, limit(*r.Max))
}
if r.Sort != nil && r.Order != nil {
o := fmt.Sprintf("%s %s", *r.Sort, *r.Order)
scope = append(scope, order(o))
}
return scope
} | [
"func",
"inRange",
"(",
"r",
"headerutil",
".",
"Range",
")",
"scope",
"{",
"var",
"scope",
"composedScope",
"\n\n",
"if",
"r",
".",
"Max",
"!=",
"nil",
"{",
"scope",
"=",
"append",
"(",
"scope",
",",
"limit",
"(",
"*",
"r",
".",
"Max",
")",
")",
... | // inRange returns a scope that limits and orders the results. | [
"inRange",
"returns",
"a",
"scope",
"that",
"limits",
"and",
"orders",
"the",
"results",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/db.go#L234-L247 | train |
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(... | 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(... | [
"func",
"FakePull",
"(",
"img",
"image",
".",
"Image",
",",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"messages",
":=",
"[",
"]",
"jsonmessage",
".",
"JSONMessage",
"{",
"{",
"Status",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"img",
"."... | // 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.D... | 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.D... | [
"func",
"PullImageOptions",
"(",
"img",
"image",
".",
"Image",
")",
"(",
"docker",
".",
"PullImageOptions",
",",
"error",
")",
"{",
"var",
"options",
"docker",
".",
"PullImageOptions",
"\n\n",
"// From the Docker API docs:",
"//",
"//\tTag or digest. If empty when pul... | // 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",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"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"`
}{
Pa... | 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"`
}{
Pa... | [
"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(&accountR... | 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(&accountR... | [
"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
}... | 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
}... | [
"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, &format... | 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, &format... | [
"func",
"(",
"c",
"*",
"Client",
")",
"FormationList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"Formation",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
... | // 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 f... | 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 f... | [
"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
... | 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
... | [
"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",
"(",
"\"",
"\"",
"+",
"appIdentity",
"+",
"\"",
"\"",
"+",
"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 |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.