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 | processes.go | Merge | func (f Formation) Merge(other Formation) Formation {
new := make(Formation)
for name, p := range f {
if existing, found := other[name]; found {
// If the existing Formation already had a process
// configuration for this process type, copy over the
// instance count.
p.Quantity = existing.Quantity
... | go | func (f Formation) Merge(other Formation) Formation {
new := make(Formation)
for name, p := range f {
if existing, found := other[name]; found {
// If the existing Formation already had a process
// configuration for this process type, copy over the
// instance count.
p.Quantity = existing.Quantity
... | [
"func",
"(",
"f",
"Formation",
")",
"Merge",
"(",
"other",
"Formation",
")",
"Formation",
"{",
"new",
":=",
"make",
"(",
"Formation",
")",
"\n\n",
"for",
"name",
",",
"p",
":=",
"range",
"f",
"{",
"if",
"existing",
",",
"found",
":=",
"other",
"[",
... | // Merge merges in the existing quantity and constraints from the old Formation
// into this Formation. | [
"Merge",
"merges",
"in",
"the",
"existing",
"quantity",
"and",
"constraints",
"from",
"the",
"old",
"Formation",
"into",
"this",
"Formation",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/processes.go#L186-L205 | train |
remind101/empire | empire.go | New | func New(db *DB) *Empire {
e := &Empire{
LogsStreamer: logsDisabled,
EventStream: NullEventStream,
DB: db,
db: db.DB,
}
e.apps = &appsService{Empire: e}
e.configs = &configsService{Empire: e}
e.deployer = &deployerService{Empire: e}
e.domains = &domainsService{Empire: e}
e.slugs = &slugsService{Empire... | go | func New(db *DB) *Empire {
e := &Empire{
LogsStreamer: logsDisabled,
EventStream: NullEventStream,
DB: db,
db: db.DB,
}
e.apps = &appsService{Empire: e}
e.configs = &configsService{Empire: e}
e.deployer = &deployerService{Empire: e}
e.domains = &domainsService{Empire: e}
e.slugs = &slugsService{Empire... | [
"func",
"New",
"(",
"db",
"*",
"DB",
")",
"*",
"Empire",
"{",
"e",
":=",
"&",
"Empire",
"{",
"LogsStreamer",
":",
"logsDisabled",
",",
"EventStream",
":",
"NullEventStream",
",",
"DB",
":",
"db",
",",
"db",
":",
"db",
".",
"DB",
",",
"}",
"\n\n",
... | // New returns a new Empire instance. | [
"New",
"returns",
"a",
"new",
"Empire",
"instance",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L113-L132 | train |
remind101/empire | empire.go | AppsFind | func (e *Empire) AppsFind(q AppsQuery) (*App, error) {
return appsFind(e.db, q)
} | go | func (e *Empire) AppsFind(q AppsQuery) (*App, error) {
return appsFind(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"AppsFind",
"(",
"q",
"AppsQuery",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"return",
"appsFind",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // AppsFind finds the first app matching the query. | [
"AppsFind",
"finds",
"the",
"first",
"app",
"matching",
"the",
"query",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L135-L137 | train |
remind101/empire | empire.go | Apps | func (e *Empire) Apps(q AppsQuery) ([]*App, error) {
return apps(e.db, q)
} | go | func (e *Empire) Apps(q AppsQuery) ([]*App, error) {
return apps(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Apps",
"(",
"q",
"AppsQuery",
")",
"(",
"[",
"]",
"*",
"App",
",",
"error",
")",
"{",
"return",
"apps",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // Apps returns all Apps. | [
"Apps",
"returns",
"all",
"Apps",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L140-L142 | train |
remind101/empire | empire.go | Create | func (e *Empire) Create(ctx context.Context, opts CreateOpts) (*App, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
a, err := appsCreate(e.db, &App{Name: opts.Name})
if err != nil {
return a, err
}
return a, e.PublishEvent(opts.Event())
} | go | func (e *Empire) Create(ctx context.Context, opts CreateOpts) (*App, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
a, err := appsCreate(e.db, &App{Name: opts.Name})
if err != nil {
return a, err
}
return a, e.PublishEvent(opts.Event())
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"CreateOpts",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
... | // Create creates a new app. | [
"Create",
"creates",
"a",
"new",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L176-L187 | train |
remind101/empire | empire.go | Destroy | func (e *Empire) Destroy(ctx context.Context, opts DestroyOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
tx := e.db.Begin()
if err := e.apps.Destroy(ctx, tx, opts.App); err != nil {
tx.Rollback()
return err
}
if err := tx.Commit().Error; err != nil {
return err
}
return e.Publis... | go | func (e *Empire) Destroy(ctx context.Context, opts DestroyOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
tx := e.db.Begin()
if err := e.apps.Destroy(ctx, tx, opts.App); err != nil {
tx.Rollback()
return err
}
if err := tx.Commit().Error; err != nil {
return err
}
return e.Publis... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Destroy",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"DestroyOpts",
")",
"error",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // Destroy destroys an app. | [
"Destroy",
"destroys",
"an",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L214-L231 | train |
remind101/empire | empire.go | Config | func (e *Empire) Config(app *App) (*Config, error) {
tx := e.db.Begin()
c, err := e.configs.Config(tx, app)
if err != nil {
tx.Rollback()
return c, err
}
if err := tx.Commit().Error; err != nil {
return c, err
}
return c, nil
} | go | func (e *Empire) Config(app *App) (*Config, error) {
tx := e.db.Begin()
c, err := e.configs.Config(tx, app)
if err != nil {
tx.Rollback()
return c, err
}
if err := tx.Commit().Error; err != nil {
return c, err
}
return c, nil
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Config",
"(",
"app",
"*",
"App",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"tx",
":=",
"e",
".",
"db",
".",
"Begin",
"(",
")",
"\n\n",
"c",
",",
"err",
":=",
"e",
".",
"configs",
".",
"Config",
... | // Config returns the current Config for a given app. | [
"Config",
"returns",
"the",
"current",
"Config",
"for",
"a",
"given",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L234-L248 | train |
remind101/empire | empire.go | SetMaintenanceMode | func (e *Empire) SetMaintenanceMode(ctx context.Context, opts SetMaintenanceModeOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
tx := e.db.Begin()
app := opts.App
app.Maintenance = opts.Maintenance
if err := appsUpdate(tx, app); err != nil {
tx.Rollback()
return err
}
if err := e.... | go | func (e *Empire) SetMaintenanceMode(ctx context.Context, opts SetMaintenanceModeOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
tx := e.db.Begin()
app := opts.App
app.Maintenance = opts.Maintenance
if err := appsUpdate(tx, app); err != nil {
tx.Rollback()
return err
}
if err := e.... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"SetMaintenanceMode",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"SetMaintenanceModeOpts",
")",
"error",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
"{",
"retur... | // SetMaintenanceMode enables or disables "maintenance mode" on the app. When an
// app is in maintenance mode, all processes will be scaled down to 0. When
// taken out of maintenance mode, all processes will be scaled up back to their
// existing values. | [
"SetMaintenanceMode",
"enables",
"or",
"disables",
"maintenance",
"mode",
"on",
"the",
"app",
".",
"When",
"an",
"app",
"is",
"in",
"maintenance",
"mode",
"all",
"processes",
"will",
"be",
"scaled",
"down",
"to",
"0",
".",
"When",
"taken",
"out",
"of",
"ma... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L281-L311 | train |
remind101/empire | empire.go | Set | func (e *Empire) Set(ctx context.Context, opts SetOpts) (*Config, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
c, err := e.configs.Set(ctx, tx, opts)
if err != nil {
tx.Rollback()
return c, err
}
if err := tx.Commit().Error; err != nil {
return c, err
}
ret... | go | func (e *Empire) Set(ctx context.Context, opts SetOpts) (*Config, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
c, err := e.configs.Set(ctx, tx, opts)
if err != nil {
tx.Rollback()
return c, err
}
if err := tx.Commit().Error; err != nil {
return c, err
}
ret... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"SetOpts",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
"{"... | // Set applies the new config vars to the apps current Config, returning the new
// Config. If the app has a running release, a new release will be created and
// run. | [
"Set",
"applies",
"the",
"new",
"config",
"vars",
"to",
"the",
"apps",
"current",
"Config",
"returning",
"the",
"new",
"Config",
".",
"If",
"the",
"app",
"has",
"a",
"running",
"release",
"a",
"new",
"release",
"will",
"be",
"created",
"and",
"run",
"."
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L350-L368 | train |
remind101/empire | empire.go | DomainsFind | func (e *Empire) DomainsFind(q DomainsQuery) (*Domain, error) {
return domainsFind(e.db, q)
} | go | func (e *Empire) DomainsFind(q DomainsQuery) (*Domain, error) {
return domainsFind(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"DomainsFind",
"(",
"q",
"DomainsQuery",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"return",
"domainsFind",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // DomainsFind returns the first domain matching the query. | [
"DomainsFind",
"returns",
"the",
"first",
"domain",
"matching",
"the",
"query",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L371-L373 | train |
remind101/empire | empire.go | Domains | func (e *Empire) Domains(q DomainsQuery) ([]*Domain, error) {
return domains(e.db, q)
} | go | func (e *Empire) Domains(q DomainsQuery) ([]*Domain, error) {
return domains(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Domains",
"(",
"q",
"DomainsQuery",
")",
"(",
"[",
"]",
"*",
"Domain",
",",
"error",
")",
"{",
"return",
"domains",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // Domains returns all domains matching the query. | [
"Domains",
"returns",
"all",
"domains",
"matching",
"the",
"query",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L376-L378 | train |
remind101/empire | empire.go | DomainsCreate | func (e *Empire) DomainsCreate(ctx context.Context, domain *Domain) (*Domain, error) {
tx := e.db.Begin()
d, err := e.domains.DomainsCreate(ctx, tx, domain)
if err != nil {
tx.Rollback()
return d, err
}
if err := tx.Commit().Error; err != nil {
return d, err
}
return d, nil
} | go | func (e *Empire) DomainsCreate(ctx context.Context, domain *Domain) (*Domain, error) {
tx := e.db.Begin()
d, err := e.domains.DomainsCreate(ctx, tx, domain)
if err != nil {
tx.Rollback()
return d, err
}
if err := tx.Commit().Error; err != nil {
return d, err
}
return d, nil
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"DomainsCreate",
"(",
"ctx",
"context",
".",
"Context",
",",
"domain",
"*",
"Domain",
")",
"(",
"*",
"Domain",
",",
"error",
")",
"{",
"tx",
":=",
"e",
".",
"db",
".",
"Begin",
"(",
")",
"\n\n",
"d",
",",
"... | // DomainsCreate adds a new Domain for an App. | [
"DomainsCreate",
"adds",
"a",
"new",
"Domain",
"for",
"an",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L381-L395 | train |
remind101/empire | empire.go | Tasks | func (e *Empire) Tasks(ctx context.Context, app *App) ([]*Task, error) {
return e.tasks.Tasks(ctx, app)
} | go | func (e *Empire) Tasks(ctx context.Context, app *App) ([]*Task, error) {
return e.tasks.Tasks(ctx, app)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Tasks",
"(",
"ctx",
"context",
".",
"Context",
",",
"app",
"*",
"App",
")",
"(",
"[",
"]",
"*",
"Task",
",",
"error",
")",
"{",
"return",
"e",
".",
"tasks",
".",
"Tasks",
"(",
"ctx",
",",
"app",
")",
"\n... | // Tasks returns the Tasks for the given app. | [
"Tasks",
"returns",
"the",
"Tasks",
"for",
"the",
"given",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L414-L416 | train |
remind101/empire | empire.go | Restart | func (e *Empire) Restart(ctx context.Context, opts RestartOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
if err := e.apps.Restart(ctx, e.db, opts); err != nil {
return err
}
return e.PublishEvent(opts.Event())
} | go | func (e *Empire) Restart(ctx context.Context, opts RestartOpts) error {
if err := opts.Validate(e); err != nil {
return err
}
if err := e.apps.Restart(ctx, e.db, opts); err != nil {
return err
}
return e.PublishEvent(opts.Event())
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Restart",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"RestartOpts",
")",
"error",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // Restart restarts processes matching the given prefix for the given Release.
// If the prefix is empty, it will match all processes for the release. | [
"Restart",
"restarts",
"processes",
"matching",
"the",
"given",
"prefix",
"for",
"the",
"given",
"Release",
".",
"If",
"the",
"prefix",
"is",
"empty",
"it",
"will",
"match",
"all",
"processes",
"for",
"the",
"release",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L450-L461 | train |
remind101/empire | empire.go | Run | func (e *Empire) Run(ctx context.Context, opts RunOpts) error {
event := opts.Event()
if err := opts.Validate(e); err != nil {
return err
}
if e.RunRecorder != nil && (opts.Stdout != nil || opts.Stderr != nil) {
w, err := e.RunRecorder()
if err != nil {
return err
}
// Add the log url to the event, ... | go | func (e *Empire) Run(ctx context.Context, opts RunOpts) error {
event := opts.Event()
if err := opts.Validate(e); err != nil {
return err
}
if e.RunRecorder != nil && (opts.Stdout != nil || opts.Stderr != nil) {
w, err := e.RunRecorder()
if err != nil {
return err
}
// Add the log url to the event, ... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"RunOpts",
")",
"error",
"{",
"event",
":=",
"opts",
".",
"Event",
"(",
")",
"\n\n",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
... | // Run runs a one-off process for a given App and command. | [
"Run",
"runs",
"a",
"one",
"-",
"off",
"process",
"for",
"a",
"given",
"App",
"and",
"command",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L510-L554 | train |
remind101/empire | empire.go | Releases | func (e *Empire) Releases(q ReleasesQuery) ([]*Release, error) {
return releases(e.db, q)
} | go | func (e *Empire) Releases(q ReleasesQuery) ([]*Release, error) {
return releases(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Releases",
"(",
"q",
"ReleasesQuery",
")",
"(",
"[",
"]",
"*",
"Release",
",",
"error",
")",
"{",
"return",
"releases",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // Releases returns all Releases for a given App. | [
"Releases",
"returns",
"all",
"Releases",
"for",
"a",
"given",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L557-L559 | train |
remind101/empire | empire.go | ReleasesFind | func (e *Empire) ReleasesFind(q ReleasesQuery) (*Release, error) {
return releasesFind(e.db, q)
} | go | func (e *Empire) ReleasesFind(q ReleasesQuery) (*Release, error) {
return releasesFind(e.db, q)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"ReleasesFind",
"(",
"q",
"ReleasesQuery",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"return",
"releasesFind",
"(",
"e",
".",
"db",
",",
"q",
")",
"\n",
"}"
] | // ReleasesFind returns the first releases for a given App. | [
"ReleasesFind",
"returns",
"the",
"first",
"releases",
"for",
"a",
"given",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L562-L564 | train |
remind101/empire | empire.go | Rollback | func (e *Empire) Rollback(ctx context.Context, opts RollbackOpts) (*Release, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
r, err := e.releases.Rollback(ctx, tx, opts)
if err != nil {
tx.Rollback()
return r, err
}
if err := tx.Commit().Error; err != nil {
retur... | go | func (e *Empire) Rollback(ctx context.Context, opts RollbackOpts) (*Release, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
r, err := e.releases.Rollback(ctx, tx, opts)
if err != nil {
tx.Rollback()
return r, err
}
if err := tx.Commit().Error; err != nil {
retur... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Rollback",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"RollbackOpts",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"... | // Rollback rolls an app back to a specific release version. Returns a
// new release. | [
"Rollback",
"rolls",
"an",
"app",
"back",
"to",
"a",
"specific",
"release",
"version",
".",
"Returns",
"a",
"new",
"release",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L597-L615 | train |
remind101/empire | empire.go | Deploy | func (e *Empire) Deploy(ctx context.Context, opts DeployOpts) (*Release, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
r, err := e.deployer.Deploy(ctx, opts)
if err != nil {
return r, err
}
event := opts.Event()
event.Release = r.Version
event.Environment = e.Environment
// Deals wi... | go | func (e *Empire) Deploy(ctx context.Context, opts DeployOpts) (*Release, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
r, err := e.deployer.Deploy(ctx, opts)
if err != nil {
return r, err
}
event := opts.Event()
event.Release = r.Version
event.Environment = e.Environment
// Deals wi... | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Deploy",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"DeployOpts",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"!=",
"nil"... | // Deploy deploys an image and streams the output to w. | [
"Deploy",
"deploys",
"an",
"image",
"and",
"streams",
"the",
"output",
"to",
"w",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L662-L682 | train |
remind101/empire | empire.go | Scale | func (e *Empire) Scale(ctx context.Context, opts ScaleOpts) ([]*Process, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
ps, err := e.apps.Scale(ctx, tx, opts)
if err != nil {
tx.Rollback()
return ps, err
}
return ps, tx.Commit().Error
} | go | func (e *Empire) Scale(ctx context.Context, opts ScaleOpts) ([]*Process, error) {
if err := opts.Validate(e); err != nil {
return nil, err
}
tx := e.db.Begin()
ps, err := e.apps.Scale(ctx, tx, opts)
if err != nil {
tx.Rollback()
return ps, err
}
return ps, tx.Commit().Error
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"Scale",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"ScaleOpts",
")",
"(",
"[",
"]",
"*",
"Process",
",",
"error",
")",
"{",
"if",
"err",
":=",
"opts",
".",
"Validate",
"(",
"e",
")",
";",
"err",
"... | // Scale scales an apps processes. | [
"Scale",
"scales",
"an",
"apps",
"processes",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L737-L751 | train |
remind101/empire | empire.go | ListScale | func (e *Empire) ListScale(ctx context.Context, app *App) (Formation, error) {
return currentFormation(e.db, app)
} | go | func (e *Empire) ListScale(ctx context.Context, app *App) (Formation, error) {
return currentFormation(e.db, app)
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"ListScale",
"(",
"ctx",
"context",
".",
"Context",
",",
"app",
"*",
"App",
")",
"(",
"Formation",
",",
"error",
")",
"{",
"return",
"currentFormation",
"(",
"e",
".",
"db",
",",
"app",
")",
"\n",
"}"
] | // ListScale lists the current scale settings for a given App | [
"ListScale",
"lists",
"the",
"current",
"scale",
"settings",
"for",
"a",
"given",
"App"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L754-L756 | train |
remind101/empire | empire.go | StreamLogs | func (e *Empire) StreamLogs(app *App, w io.Writer, duration time.Duration) error {
if err := e.LogsStreamer.StreamLogs(app, w, duration); err != nil {
return fmt.Errorf("error streaming logs: %v", err)
}
return nil
} | go | func (e *Empire) StreamLogs(app *App, w io.Writer, duration time.Duration) error {
if err := e.LogsStreamer.StreamLogs(app, w, duration); err != nil {
return fmt.Errorf("error streaming logs: %v", err)
}
return nil
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"StreamLogs",
"(",
"app",
"*",
"App",
",",
"w",
"io",
".",
"Writer",
",",
"duration",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"err",
":=",
"e",
".",
"LogsStreamer",
".",
"StreamLogs",
"(",
"app",
",",... | // Streamlogs streams logs from an app. | [
"Streamlogs",
"streams",
"logs",
"from",
"an",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L759-L765 | train |
remind101/empire | empire.go | CertsAttach | func (e *Empire) CertsAttach(ctx context.Context, opts CertsAttachOpts) error {
tx := e.db.Begin()
if err := e.certs.CertsAttach(ctx, tx, opts); err != nil {
tx.Rollback()
return err
}
return tx.Commit().Error
} | go | func (e *Empire) CertsAttach(ctx context.Context, opts CertsAttachOpts) error {
tx := e.db.Begin()
if err := e.certs.CertsAttach(ctx, tx, opts); err != nil {
tx.Rollback()
return err
}
return tx.Commit().Error
} | [
"func",
"(",
"e",
"*",
"Empire",
")",
"CertsAttach",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"CertsAttachOpts",
")",
"error",
"{",
"tx",
":=",
"e",
".",
"db",
".",
"Begin",
"(",
")",
"\n\n",
"if",
"err",
":=",
"e",
".",
"certs",
".",
... | // CertsAttach attaches an SSL certificate to the app. | [
"CertsAttach",
"attaches",
"an",
"SSL",
"certificate",
"to",
"the",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/empire.go#L779-L788 | train |
remind101/empire | scheduler/cloudformation/clients.go | ecsWithCaching | func ecsWithCaching(ecs *ECS) *cachingECSClient {
return &cachingECSClient{
ecsClient: ecs,
taskDefinitions: cache.New(defaultExpiration, defaultPurge),
}
} | go | func ecsWithCaching(ecs *ECS) *cachingECSClient {
return &cachingECSClient{
ecsClient: ecs,
taskDefinitions: cache.New(defaultExpiration, defaultPurge),
}
} | [
"func",
"ecsWithCaching",
"(",
"ecs",
"*",
"ECS",
")",
"*",
"cachingECSClient",
"{",
"return",
"&",
"cachingECSClient",
"{",
"ecsClient",
":",
"ecs",
",",
"taskDefinitions",
":",
"cache",
".",
"New",
"(",
"defaultExpiration",
",",
"defaultPurge",
")",
",",
"... | // ecsWithCaching wraps an ecs.ECS client with caching. | [
"ecsWithCaching",
"wraps",
"an",
"ecs",
".",
"ECS",
"client",
"with",
"caching",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/clients.go#L34-L39 | train |
remind101/empire | scheduler/cloudformation/clients.go | DescribeTaskDefinition | func (c *cachingECSClient) DescribeTaskDefinition(input *ecs.DescribeTaskDefinitionInput) (*ecs.DescribeTaskDefinitionOutput, error) {
if _, err := arn.Parse(*input.TaskDefinition); err != nil {
return c.ecsClient.DescribeTaskDefinition(input)
}
if v, ok := c.taskDefinitions.Get(*input.TaskDefinition); ok {
ret... | go | func (c *cachingECSClient) DescribeTaskDefinition(input *ecs.DescribeTaskDefinitionInput) (*ecs.DescribeTaskDefinitionOutput, error) {
if _, err := arn.Parse(*input.TaskDefinition); err != nil {
return c.ecsClient.DescribeTaskDefinition(input)
}
if v, ok := c.taskDefinitions.Get(*input.TaskDefinition); ok {
ret... | [
"func",
"(",
"c",
"*",
"cachingECSClient",
")",
"DescribeTaskDefinition",
"(",
"input",
"*",
"ecs",
".",
"DescribeTaskDefinitionInput",
")",
"(",
"*",
"ecs",
".",
"DescribeTaskDefinitionOutput",
",",
"error",
")",
"{",
"if",
"_",
",",
"err",
":=",
"arn",
"."... | // DescribeTaskDefinition will use the task definition from cache if provided
// with a task definition ARN. | [
"DescribeTaskDefinition",
"will",
"use",
"the",
"task",
"definition",
"from",
"cache",
"if",
"provided",
"with",
"a",
"task",
"definition",
"ARN",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/clients.go#L43-L62 | train |
remind101/empire | scheduler/cloudformation/clients.go | WaitUntilTasksNotPending | func (c *ECS) WaitUntilTasksNotPending(input *ecs.DescribeTasksInput) error {
waiterCfg := awswaiter.Config{
Operation: "DescribeTasks",
Delay: 6,
MaxAttempts: 100,
Acceptors: []awswaiter.WaitAcceptor{
{
State: "failure",
Matcher: "pathAny",
Argument: "failures[].reason",
Expecte... | go | func (c *ECS) WaitUntilTasksNotPending(input *ecs.DescribeTasksInput) error {
waiterCfg := awswaiter.Config{
Operation: "DescribeTasks",
Delay: 6,
MaxAttempts: 100,
Acceptors: []awswaiter.WaitAcceptor{
{
State: "failure",
Matcher: "pathAny",
Argument: "failures[].reason",
Expecte... | [
"func",
"(",
"c",
"*",
"ECS",
")",
"WaitUntilTasksNotPending",
"(",
"input",
"*",
"ecs",
".",
"DescribeTasksInput",
")",
"error",
"{",
"waiterCfg",
":=",
"awswaiter",
".",
"Config",
"{",
"Operation",
":",
"\"",
"\"",
",",
"Delay",
":",
"6",
",",
"MaxAtte... | // WaitUntilTasksNotPending waits until all the given tasks are either RUNNING
// or STOPPED. | [
"WaitUntilTasksNotPending",
"waits",
"until",
"all",
"the",
"given",
"tasks",
"are",
"either",
"RUNNING",
"or",
"STOPPED",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/clients.go#L71-L104 | train |
remind101/empire | pkg/heroku/oauth_token.go | OAuthTokenCreate | func (c *Client) OAuthTokenCreate(grant OAuthTokenCreateGrant, client OAuthTokenCreateClient, refreshToken OAuthTokenCreateRefreshToken) (*OAuthToken, error) {
params := struct {
Grant OAuthTokenCreateGrant `json:"grant"`
Client OAuthTokenCreateClient `json:"client"`
RefreshToken OAuthT... | go | func (c *Client) OAuthTokenCreate(grant OAuthTokenCreateGrant, client OAuthTokenCreateClient, refreshToken OAuthTokenCreateRefreshToken) (*OAuthToken, error) {
params := struct {
Grant OAuthTokenCreateGrant `json:"grant"`
Client OAuthTokenCreateClient `json:"client"`
RefreshToken OAuthT... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OAuthTokenCreate",
"(",
"grant",
"OAuthTokenCreateGrant",
",",
"client",
"OAuthTokenCreateClient",
",",
"refreshToken",
"OAuthTokenCreateRefreshToken",
")",
"(",
"*",
"OAuthToken",
",",
"error",
")",
"{",
"params",
":=",
"str... | // Create a new OAuth token.
//
// grant is the grant used on the underlying authorization. client is the OAuth
// client secret used to obtain token. refreshToken is the refresh token for
// this authorization. | [
"Create",
"a",
"new",
"OAuth",
"token",
".",
"grant",
"is",
"the",
"grant",
"used",
"on",
"the",
"underlying",
"authorization",
".",
"client",
"is",
"the",
"OAuth",
"client",
"secret",
"used",
"to",
"obtain",
"token",
".",
"refreshToken",
"is",
"the",
"ref... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/oauth_token.go#L70-L82 | train |
remind101/empire | pkg/heroku/app_feature.go | AppFeatureInfo | func (c *Client) AppFeatureInfo(appIdentity string, appFeatureIdentity string) (*AppFeature, error) {
var appFeature AppFeature
return &appFeature, c.Get(&appFeature, "/apps/"+appIdentity+"/features/"+appFeatureIdentity)
} | go | func (c *Client) AppFeatureInfo(appIdentity string, appFeatureIdentity string) (*AppFeature, error) {
var appFeature AppFeature
return &appFeature, c.Get(&appFeature, "/apps/"+appIdentity+"/features/"+appFeatureIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppFeatureInfo",
"(",
"appIdentity",
"string",
",",
"appFeatureIdentity",
"string",
")",
"(",
"*",
"AppFeature",
",",
"error",
")",
"{",
"var",
"appFeature",
"AppFeature",
"\n",
"return",
"&",
"appFeature",
",",
"c",
... | // Info for an existing app feature.
//
// appIdentity is the unique identifier of the AppFeature's App.
// appFeatureIdentity is the unique identifier of the AppFeature. | [
"Info",
"for",
"an",
"existing",
"app",
"feature",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AppFeature",
"s",
"App",
".",
"appFeatureIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AppFeature",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_feature.go#L43-L46 | train |
remind101/empire | pkg/heroku/app_feature.go | AppFeatureList | func (c *Client) AppFeatureList(appIdentity string, lr *ListRange) ([]AppFeature, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/features", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var appFeaturesRes []AppFeature
return appFeaturesRes, c.DoReq(req, &ap... | go | func (c *Client) AppFeatureList(appIdentity string, lr *ListRange) ([]AppFeature, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/features", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var appFeaturesRes []AppFeature
return appFeaturesRes, c.DoReq(req, &ap... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppFeatureList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"AppFeature",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\""... | // List existing app features.
//
// appIdentity is the unique identifier of the AppFeature's App. lr is an
// optional ListRange that sets the Range options for the paginated list of
// results. | [
"List",
"existing",
"app",
"features",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AppFeature",
"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/app_feature.go#L53-L65 | train |
remind101/empire | pkg/heroku/app_feature.go | AppFeatureUpdate | func (c *Client) AppFeatureUpdate(appIdentity string, appFeatureIdentity string, enabled bool) (*AppFeature, error) {
params := struct {
Enabled bool `json:"enabled"`
}{
Enabled: enabled,
}
var appFeatureRes AppFeature
return &appFeatureRes, c.Patch(&appFeatureRes, "/apps/"+appIdentity+"/features/"+appFeatureI... | go | func (c *Client) AppFeatureUpdate(appIdentity string, appFeatureIdentity string, enabled bool) (*AppFeature, error) {
params := struct {
Enabled bool `json:"enabled"`
}{
Enabled: enabled,
}
var appFeatureRes AppFeature
return &appFeatureRes, c.Patch(&appFeatureRes, "/apps/"+appIdentity+"/features/"+appFeatureI... | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppFeatureUpdate",
"(",
"appIdentity",
"string",
",",
"appFeatureIdentity",
"string",
",",
"enabled",
"bool",
")",
"(",
"*",
"AppFeature",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"Enabled",
"bool",
"`js... | // Update an existing app feature.
//
// appIdentity is the unique identifier of the AppFeature's App.
// appFeatureIdentity is the unique identifier of the AppFeature. enabled is the
// whether or not app feature has been enabled. | [
"Update",
"an",
"existing",
"app",
"feature",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AppFeature",
"s",
"App",
".",
"appFeatureIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AppFeature",
".",
"enabled",
"is",
"the"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app_feature.go#L72-L80 | train |
remind101/empire | server/middleware/request.go | WithRequest | func WithRequest(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctx = httpx.WithRequest(ctx, r)
// Add the request to the context.
reporter.AddRequest(ctx, r)
// Add the request id
reporter.AddContext(ctx, "request_id", httpx.Requ... | go | func WithRequest(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctx = httpx.WithRequest(ctx, r)
// Add the request to the context.
reporter.AddRequest(ctx, r)
// Add the request id
reporter.AddContext(ctx, "request_id", httpx.Requ... | [
"func",
"WithRequest",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r",
... | // WithRequest adds information about the http.Request to reported errors. | [
"WithRequest",
"adds",
"information",
"about",
"the",
"http",
".",
"Request",
"to",
"reported",
"errors",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/middleware/request.go#L11-L25 | train |
remind101/empire | pkg/troposphere/troposphere.go | NewTemplate | func NewTemplate() *Template {
return &Template{
Conditions: make(map[string]interface{}),
Outputs: make(map[string]Output),
Parameters: make(map[string]Parameter),
Resources: make(map[string]Resource),
}
} | go | func NewTemplate() *Template {
return &Template{
Conditions: make(map[string]interface{}),
Outputs: make(map[string]Output),
Parameters: make(map[string]Parameter),
Resources: make(map[string]Resource),
}
} | [
"func",
"NewTemplate",
"(",
")",
"*",
"Template",
"{",
"return",
"&",
"Template",
"{",
"Conditions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
",",
"Outputs",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"Output",
")",
... | // NewTemplate returns an initialized Template. | [
"NewTemplate",
"returns",
"an",
"initialized",
"Template",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/troposphere/troposphere.go#L16-L23 | train |
remind101/empire | pkg/troposphere/troposphere.go | AddResource | func (t *Template) AddResource(resource NamedResource) {
if _, ok := t.Resources[resource.Name]; ok {
panic(fmt.Sprintf("%s is already defined in the template", resource.Name))
}
t.Resources[resource.Name] = resource.Resource
} | go | func (t *Template) AddResource(resource NamedResource) {
if _, ok := t.Resources[resource.Name]; ok {
panic(fmt.Sprintf("%s is already defined in the template", resource.Name))
}
t.Resources[resource.Name] = resource.Resource
} | [
"func",
"(",
"t",
"*",
"Template",
")",
"AddResource",
"(",
"resource",
"NamedResource",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"t",
".",
"Resources",
"[",
"resource",
".",
"Name",
"]",
";",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",... | // AddResource adds a named resource to the template. | [
"AddResource",
"adds",
"a",
"named",
"resource",
"to",
"the",
"template",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/troposphere/troposphere.go#L26-L31 | train |
remind101/empire | pkg/arn/arn.go | Parse | func Parse(arn string) (*ARN, error) {
p := strings.SplitN(arn, delimiter, 6)
// Ensure that we have all the components that make up an ARN.
if len(p) < 6 {
return nil, ErrInvalidARN
}
a := &ARN{
ARN: p[0],
AWS: p[1],
Service: p[2],
Region: p[3],
Account: p[4],
Resource: p[5],
}
//... | go | func Parse(arn string) (*ARN, error) {
p := strings.SplitN(arn, delimiter, 6)
// Ensure that we have all the components that make up an ARN.
if len(p) < 6 {
return nil, ErrInvalidARN
}
a := &ARN{
ARN: p[0],
AWS: p[1],
Service: p[2],
Region: p[3],
Account: p[4],
Resource: p[5],
}
//... | [
"func",
"Parse",
"(",
"arn",
"string",
")",
"(",
"*",
"ARN",
",",
"error",
")",
"{",
"p",
":=",
"strings",
".",
"SplitN",
"(",
"arn",
",",
"delimiter",
",",
"6",
")",
"\n\n",
"// Ensure that we have all the components that make up an ARN.",
"if",
"len",
"(",... | // Parse parses an Amazon Resource Name from a String into an ARN. | [
"Parse",
"parses",
"an",
"Amazon",
"Resource",
"Name",
"from",
"a",
"String",
"into",
"an",
"ARN",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/arn/arn.go#L30-L53 | train |
remind101/empire | pkg/arn/arn.go | String | func (a *ARN) String() string {
return strings.Join(
[]string{a.ARN, a.AWS, a.Service, a.Region, a.Account, a.Resource},
delimiter,
)
} | go | func (a *ARN) String() string {
return strings.Join(
[]string{a.ARN, a.AWS, a.Service, a.Region, a.Account, a.Resource},
delimiter,
)
} | [
"func",
"(",
"a",
"*",
"ARN",
")",
"String",
"(",
")",
"string",
"{",
"return",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"a",
".",
"ARN",
",",
"a",
".",
"AWS",
",",
"a",
".",
"Service",
",",
"a",
".",
"Region",
",",
"a",
".",
"... | // String returns the string representation of an Amazon Resource Name. | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"an",
"Amazon",
"Resource",
"Name",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/arn/arn.go#L56-L61 | train |
remind101/empire | pkg/arn/arn.go | SplitResource | func SplitResource(r string) (resource, id string, err error) {
p := strings.Split(r, "/")
if len(p) != 2 {
err = ErrInvalidResource
return
}
resource = p[0]
id = p[1]
return
} | go | func SplitResource(r string) (resource, id string, err error) {
p := strings.Split(r, "/")
if len(p) != 2 {
err = ErrInvalidResource
return
}
resource = p[0]
id = p[1]
return
} | [
"func",
"SplitResource",
"(",
"r",
"string",
")",
"(",
"resource",
",",
"id",
"string",
",",
"err",
"error",
")",
"{",
"p",
":=",
"strings",
".",
"Split",
"(",
"r",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"p",
")",
"!=",
"2",
"{",
"err"... | // SplitResource splits the Resource section of an ARN into its type and id
// components. | [
"SplitResource",
"splits",
"the",
"Resource",
"section",
"of",
"an",
"ARN",
"into",
"its",
"type",
"and",
"id",
"components",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/arn/arn.go#L65-L77 | train |
remind101/empire | pkg/arn/arn.go | ResourceID | func ResourceID(arn string) (string, error) {
a, err := Parse(arn)
if err != nil {
return "", err
}
_, id, err := SplitResource(a.Resource)
return id, err
} | go | func ResourceID(arn string) (string, error) {
a, err := Parse(arn)
if err != nil {
return "", err
}
_, id, err := SplitResource(a.Resource)
return id, err
} | [
"func",
"ResourceID",
"(",
"arn",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"a",
",",
"err",
":=",
"Parse",
"(",
"arn",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
"_",
",",
"id",
... | // ResourceID takes an ARN string and returns the resource ID from it. | [
"ResourceID",
"takes",
"an",
"ARN",
"string",
"and",
"returns",
"the",
"resource",
"ID",
"from",
"it",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/arn/arn.go#L80-L88 | train |
remind101/empire | server/middleware/middleware.go | LogRequests | func LogRequests(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger.Info(ctx, "request.start",
"method", r.Method,
"path", r.URL.Path,
"user_agent", r.Header.Get("User-Agent"),
"remote_ip", realip.RealIP(r),
)
h.ServeHTTP... | go | func LogRequests(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
logger.Info(ctx, "request.start",
"method", r.Method,
"path", r.URL.Path,
"user_agent", r.Header.Get("User-Agent"),
"remote_ip", realip.RealIP(r),
)
h.ServeHTTP... | [
"func",
"LogRequests",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"r",
... | // LogRequests logs the requests to the embedded logger. | [
"LogRequests",
"logs",
"the",
"requests",
"to",
"the",
"embedded",
"logger",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/middleware/middleware.go#L32-L46 | train |
remind101/empire | server/middleware/middleware.go | PrefixRequestID | func PrefixRequestID(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if l, ok := logger.FromContext(ctx); ok {
if l, ok := l.(log15.Logger); ok {
ctx = logger.WithLogger(ctx, l.New("request_id", httpx.RequestID(ctx)))
}
}
h.Se... | go | func PrefixRequestID(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
if l, ok := logger.FromContext(ctx); ok {
if l, ok := l.(log15.Logger); ok {
ctx = logger.WithLogger(ctx, l.New("request_id", httpx.RequestID(ctx)))
}
}
h.Se... | [
"func",
"PrefixRequestID",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"ctx",
":=",
"... | // PrefixRequestID adds the request as a prefix to the log15.Logger. | [
"PrefixRequestID",
"adds",
"the",
"request",
"as",
"a",
"prefix",
"to",
"the",
"log15",
".",
"Logger",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/middleware/middleware.go#L49-L61 | train |
remind101/empire | stats/dogstatsd.go | NewDogstatsd | func NewDogstatsd(addr string) (*Dogstatsd, error) {
c, err := statsd.New(addr)
if err != nil {
return nil, err
}
return &Dogstatsd{
Client: c,
}, nil
} | go | func NewDogstatsd(addr string) (*Dogstatsd, error) {
c, err := statsd.New(addr)
if err != nil {
return nil, err
}
return &Dogstatsd{
Client: c,
}, nil
} | [
"func",
"NewDogstatsd",
"(",
"addr",
"string",
")",
"(",
"*",
"Dogstatsd",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"statsd",
".",
"New",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",... | // NewDogstatsd returns a new Dogstatsd instance that sends statsd metrics to addr. | [
"NewDogstatsd",
"returns",
"a",
"new",
"Dogstatsd",
"instance",
"that",
"sends",
"statsd",
"metrics",
"to",
"addr",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/stats/dogstatsd.go#L16-L25 | train |
remind101/empire | pkg/heroku/collaborator.go | CollaboratorCreate | func (c *Client) CollaboratorCreate(appIdentity string, user string, options *CollaboratorCreateOpts) (*Collaborator, error) {
params := struct {
User string `json:"user"`
Silent *bool `json:"silent,omitempty"`
}{
User: user,
}
if options != nil {
params.Silent = options.Silent
}
var collaboratorRes Co... | go | func (c *Client) CollaboratorCreate(appIdentity string, user string, options *CollaboratorCreateOpts) (*Collaborator, error) {
params := struct {
User string `json:"user"`
Silent *bool `json:"silent,omitempty"`
}{
User: user,
}
if options != nil {
params.Silent = options.Silent
}
var collaboratorRes Co... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CollaboratorCreate",
"(",
"appIdentity",
"string",
",",
"user",
"string",
",",
"options",
"*",
"CollaboratorCreateOpts",
")",
"(",
"*",
"Collaborator",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"User",
"s... | // Create a new collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App. user is the
// unique email address of account or unique identifier of an account. options
// is the struct of optional parameters for this action. | [
"Create",
"a",
"new",
"collaborator",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"s",
"App",
".",
"user",
"is",
"the",
"unique",
"email",
"address",
"of",
"account",
"or",
"unique",
"identifier",
"of",
"an",
"accoun... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/collaborator.go#L35-L47 | train |
remind101/empire | pkg/heroku/collaborator.go | CollaboratorDelete | func (c *Client) CollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
} | go | func (c *Client) CollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CollaboratorDelete",
"(",
"appIdentity",
"string",
",",
"collaboratorIdentity",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Delete",
"(",
"\"",
"\"",
"+",
"appIdentity",
"+",
"\"",
"\"",
"+",
"collaboratorIdentity... | // Delete an existing collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App.
// collaboratorIdentity is the unique identifier of the Collaborator. | [
"Delete",
"an",
"existing",
"collaborator",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"s",
"App",
".",
"collaboratorIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/collaborator.go#L59-L61 | train |
remind101/empire | pkg/heroku/collaborator.go | CollaboratorInfo | func (c *Client) CollaboratorInfo(appIdentity string, collaboratorIdentity string) (*Collaborator, error) {
var collaborator Collaborator
return &collaborator, c.Get(&collaborator, "/apps/"+appIdentity+"/collaborators/"+collaboratorIdentity)
} | go | func (c *Client) CollaboratorInfo(appIdentity string, collaboratorIdentity string) (*Collaborator, error) {
var collaborator Collaborator
return &collaborator, c.Get(&collaborator, "/apps/"+appIdentity+"/collaborators/"+collaboratorIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CollaboratorInfo",
"(",
"appIdentity",
"string",
",",
"collaboratorIdentity",
"string",
")",
"(",
"*",
"Collaborator",
",",
"error",
")",
"{",
"var",
"collaborator",
"Collaborator",
"\n",
"return",
"&",
"collaborator",
",... | // Info for existing collaborator.
//
// appIdentity is the unique identifier of the Collaborator's App.
// collaboratorIdentity is the unique identifier of the Collaborator. | [
"Info",
"for",
"existing",
"collaborator",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"s",
"App",
".",
"collaboratorIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/collaborator.go#L67-L70 | train |
remind101/empire | pkg/heroku/collaborator.go | CollaboratorList | func (c *Client) CollaboratorList(appIdentity string, lr *ListRange) ([]Collaborator, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/collaborators", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var collaboratorsRes []Collaborator
return collaboratorsRes, c... | go | func (c *Client) CollaboratorList(appIdentity string, lr *ListRange) ([]Collaborator, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/collaborators", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var collaboratorsRes []Collaborator
return collaboratorsRes, c... | [
"func",
"(",
"c",
"*",
"Client",
")",
"CollaboratorList",
"(",
"appIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"Collaborator",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
... | // List existing collaborators.
//
// appIdentity is the unique identifier of the Collaborator's App. lr is an
// optional ListRange that sets the Range options for the paginated list of
// results. | [
"List",
"existing",
"collaborators",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Collaborator",
"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/collaborator.go#L77-L89 | train |
remind101/empire | pkg/heroku/slug.go | SlugInfo | func (c *Client) SlugInfo(appIdentity string, slugIdentity string) (*Slug, error) {
var slug Slug
return &slug, c.Get(&slug, "/apps/"+appIdentity+"/slugs/"+slugIdentity)
} | go | func (c *Client) SlugInfo(appIdentity string, slugIdentity string) (*Slug, error) {
var slug Slug
return &slug, c.Get(&slug, "/apps/"+appIdentity+"/slugs/"+slugIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SlugInfo",
"(",
"appIdentity",
"string",
",",
"slugIdentity",
"string",
")",
"(",
"*",
"Slug",
",",
"error",
")",
"{",
"var",
"slug",
"Slug",
"\n",
"return",
"&",
"slug",
",",
"c",
".",
"Get",
"(",
"&",
"slug"... | // Info for existing slug.
//
// appIdentity is the unique identifier of the Slug's App. slugIdentity is the
// unique identifier of the Slug. | [
"Info",
"for",
"existing",
"slug",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Slug",
"s",
"App",
".",
"slugIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Slug",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/slug.go#L46-L49 | train |
remind101/empire | pkg/heroku/slug.go | SlugCreate | func (c *Client) SlugCreate(appIdentity string, processTypes map[string]string, options *SlugCreateOpts) (*Slug, error) {
params := struct {
ProcessTypes map[string]string `json:"process_types"`
BuildpackProvidedDescription *string `json:"buildpack_provided_description,omitempty"`
Commi... | go | func (c *Client) SlugCreate(appIdentity string, processTypes map[string]string, options *SlugCreateOpts) (*Slug, error) {
params := struct {
ProcessTypes map[string]string `json:"process_types"`
BuildpackProvidedDescription *string `json:"buildpack_provided_description,omitempty"`
Commi... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SlugCreate",
"(",
"appIdentity",
"string",
",",
"processTypes",
"map",
"[",
"string",
"]",
"string",
",",
"options",
"*",
"SlugCreateOpts",
")",
"(",
"*",
"Slug",
",",
"error",
")",
"{",
"params",
":=",
"struct",
... | // Create a new slug. For more information please refer to Deploying Slugs using
// the Platform API.
//
// appIdentity is the unique identifier of the Slug's App. processTypes is the
// hash mapping process type names to their respective command. options is the
// struct of optional parameters for this action. | [
"Create",
"a",
"new",
"slug",
".",
"For",
"more",
"information",
"please",
"refer",
"to",
"Deploying",
"Slugs",
"using",
"the",
"Platform",
"API",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Slug",
"s",
"App",
".",
"processTypes",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/slug.go#L57-L71 | train |
remind101/empire | pkg/dockerutil/client.go | NewDockerClient | func NewDockerClient(host, certPath string) (*docker.Client, error) {
if certPath != "" {
cert := certPath + "/cert.pem"
key := certPath + "/key.pem"
ca := certPath + "/ca.pem"
return docker.NewTLSClient(host, cert, key, ca)
}
return docker.NewClient(host)
} | go | func NewDockerClient(host, certPath string) (*docker.Client, error) {
if certPath != "" {
cert := certPath + "/cert.pem"
key := certPath + "/key.pem"
ca := certPath + "/ca.pem"
return docker.NewTLSClient(host, cert, key, ca)
}
return docker.NewClient(host)
} | [
"func",
"NewDockerClient",
"(",
"host",
",",
"certPath",
"string",
")",
"(",
"*",
"docker",
".",
"Client",
",",
"error",
")",
"{",
"if",
"certPath",
"!=",
"\"",
"\"",
"{",
"cert",
":=",
"certPath",
"+",
"\"",
"\"",
"\n",
"key",
":=",
"certPath",
"+",... | // NewDockerClient returns a new docker.Client using the given host and certificate path. | [
"NewDockerClient",
"returns",
"a",
"new",
"docker",
".",
"Client",
"using",
"the",
"given",
"host",
"and",
"certificate",
"path",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/client.go#L17-L26 | train |
remind101/empire | pkg/dockerutil/client.go | NewClient | func NewClient(authProvider dockerauth.AuthProvider, host, certPath string) (*Client, error) {
c, err := NewDockerClient(host, certPath)
if err != nil {
return nil, err
}
return newClient(authProvider, c)
} | go | func NewClient(authProvider dockerauth.AuthProvider, host, certPath string) (*Client, error) {
c, err := NewDockerClient(host, certPath)
if err != nil {
return nil, err
}
return newClient(authProvider, c)
} | [
"func",
"NewClient",
"(",
"authProvider",
"dockerauth",
".",
"AuthProvider",
",",
"host",
",",
"certPath",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"NewDockerClient",
"(",
"host",
",",
"certPath",
")",
"\n",
"if",... | // NewClient returns a new Client instance. | [
"NewClient",
"returns",
"a",
"new",
"Client",
"instance",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/client.go#L40-L46 | train |
remind101/empire | pkg/dockerutil/client.go | PullImage | func (c *Client) PullImage(ctx context.Context, opts docker.PullImageOptions) error {
// This is to workaround an issue in the Docker API, where it doesn't
// respect the registry param. We have to put the registry in the
// repository field.
if opts.Registry != "" {
opts.Repository = fmt.Sprintf("%s/%s", opts.Re... | go | func (c *Client) PullImage(ctx context.Context, opts docker.PullImageOptions) error {
// This is to workaround an issue in the Docker API, where it doesn't
// respect the registry param. We have to put the registry in the
// repository field.
if opts.Registry != "" {
opts.Repository = fmt.Sprintf("%s/%s", opts.Re... | [
"func",
"(",
"c",
"*",
"Client",
")",
"PullImage",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"docker",
".",
"PullImageOptions",
")",
"error",
"{",
"// This is to workaround an issue in the Docker API, where it doesn't",
"// respect the registry param. We have to p... | // PullImage wraps the docker clients PullImage to handle authentication. | [
"PullImage",
"wraps",
"the",
"docker",
"clients",
"PullImage",
"to",
"handle",
"authentication",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/dockerutil/client.go#L71-L85 | train |
remind101/empire | pkg/heroku/addon_service.go | AddonServiceInfo | func (c *Client) AddonServiceInfo(addonServiceIdentity string) (*AddonService, error) {
var addonService AddonService
return &addonService, c.Get(&addonService, "/addon-services/"+addonServiceIdentity)
} | go | func (c *Client) AddonServiceInfo(addonServiceIdentity string) (*AddonService, error) {
var addonService AddonService
return &addonService, c.Get(&addonService, "/addon-services/"+addonServiceIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddonServiceInfo",
"(",
"addonServiceIdentity",
"string",
")",
"(",
"*",
"AddonService",
",",
"error",
")",
"{",
"var",
"addonService",
"AddonService",
"\n",
"return",
"&",
"addonService",
",",
"c",
".",
"Get",
"(",
"... | // Info for existing addon-service.
//
// addonServiceIdentity is the unique identifier of the AddonService. | [
"Info",
"for",
"existing",
"addon",
"-",
"service",
".",
"addonServiceIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"AddonService",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/addon_service.go#L29-L32 | train |
remind101/empire | pkg/heroku/addon_service.go | AddonServiceList | func (c *Client) AddonServiceList(lr *ListRange) ([]AddonService, error) {
req, err := c.NewRequest("GET", "/addon-services", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var addonServicesRes []AddonService
return addonServicesRes, c.DoReq(req, &addonServicesRes)
} | go | func (c *Client) AddonServiceList(lr *ListRange) ([]AddonService, error) {
req, err := c.NewRequest("GET", "/addon-services", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var addonServicesRes []AddonService
return addonServicesRes, c.DoReq(req, &addonServicesRes)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddonServiceList",
"(",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"AddonService",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",... | // List existing addon-services.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results. | [
"List",
"existing",
"addon",
"-",
"services",
".",
"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/addon_service.go#L38-L50 | train |
remind101/empire | procfile/procfile.go | ParsePort | func ParsePort(s string) (p Port, err error) {
if strings.Contains(s, ":") {
return portFromHostContainer(s)
}
var port int
port, err = toPort(s)
if err != nil {
return
}
p.Host = port
p.Container = port
return
} | go | func ParsePort(s string) (p Port, err error) {
if strings.Contains(s, ":") {
return portFromHostContainer(s)
}
var port int
port, err = toPort(s)
if err != nil {
return
}
p.Host = port
p.Container = port
return
} | [
"func",
"ParsePort",
"(",
"s",
"string",
")",
"(",
"p",
"Port",
",",
"err",
"error",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"s",
",",
"\"",
"\"",
")",
"{",
"return",
"portFromHostContainer",
"(",
"s",
")",
"\n",
"}",
"\n\n",
"var",
"port"... | // ParsePort parses a string into a Port. | [
"ParsePort",
"parses",
"a",
"string",
"into",
"a",
"Port",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/procfile/procfile.go#L51-L64 | train |
remind101/empire | procfile/procfile.go | Parse | func Parse(r io.Reader) (Procfile, error) {
raw, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
return ParseProcfile(raw)
} | go | func Parse(r io.Reader) (Procfile, error) {
raw, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
return ParseProcfile(raw)
} | [
"func",
"Parse",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"Procfile",
",",
"error",
")",
"{",
"raw",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",... | // Parse parses the Procfile by reading from r. | [
"Parse",
"parses",
"the",
"Procfile",
"by",
"reading",
"from",
"r",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/procfile/procfile.go#L139-L146 | train |
remind101/empire | procfile/procfile.go | ParseProcfile | func ParseProcfile(b []byte) (Procfile, error) {
p, err := parseStandardProcfile(b)
if err != nil {
p, err = parseExtendedProcfile(b)
}
return p, err
} | go | func ParseProcfile(b []byte) (Procfile, error) {
p, err := parseStandardProcfile(b)
if err != nil {
p, err = parseExtendedProcfile(b)
}
return p, err
} | [
"func",
"ParseProcfile",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"Procfile",
",",
"error",
")",
"{",
"p",
",",
"err",
":=",
"parseStandardProcfile",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"p",
",",
"err",
"=",
"parseExtendedProcfile",
"(",... | // ParseProcfile takes a byte slice representing a YAML Procfile and parses it
// into a Procfile. | [
"ParseProcfile",
"takes",
"a",
"byte",
"slice",
"representing",
"a",
"YAML",
"Procfile",
"and",
"parses",
"it",
"into",
"a",
"Procfile",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/procfile/procfile.go#L150-L156 | train |
remind101/empire | pkg/heroku/oauth_client.go | OAuthClientCreate | func (c *Client) OAuthClientCreate(name string, redirectUri string) (*OAuthClient, error) {
params := struct {
Name string `json:"name"`
RedirectUri string `json:"redirect_uri"`
}{
Name: name,
RedirectUri: redirectUri,
}
var oauthClientRes OAuthClient
return &oauthClientRes, c.Post(&oauthClie... | go | func (c *Client) OAuthClientCreate(name string, redirectUri string) (*OAuthClient, error) {
params := struct {
Name string `json:"name"`
RedirectUri string `json:"redirect_uri"`
}{
Name: name,
RedirectUri: redirectUri,
}
var oauthClientRes OAuthClient
return &oauthClientRes, c.Post(&oauthClie... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OAuthClientCreate",
"(",
"name",
"string",
",",
"redirectUri",
"string",
")",
"(",
"*",
"OAuthClient",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"Name",
"string",
"`json:\"name\"`",
"\n",
"RedirectUri",
"... | // Create a new OAuth client.
//
// name is the OAuth client name. redirectUri is the endpoint for redirection
// after authorization with OAuth client. | [
"Create",
"a",
"new",
"OAuth",
"client",
".",
"name",
"is",
"the",
"OAuth",
"client",
"name",
".",
"redirectUri",
"is",
"the",
"endpoint",
"for",
"redirection",
"after",
"authorization",
"with",
"OAuth",
"client",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/oauth_client.go#L41-L51 | train |
remind101/empire | pkg/heroku/oauth_client.go | OAuthClientInfo | func (c *Client) OAuthClientInfo(oauthClientIdentity string) (*OAuthClient, error) {
var oauthClient OAuthClient
return &oauthClient, c.Get(&oauthClient, "/oauth/clients/"+oauthClientIdentity)
} | go | func (c *Client) OAuthClientInfo(oauthClientIdentity string) (*OAuthClient, error) {
var oauthClient OAuthClient
return &oauthClient, c.Get(&oauthClient, "/oauth/clients/"+oauthClientIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OAuthClientInfo",
"(",
"oauthClientIdentity",
"string",
")",
"(",
"*",
"OAuthClient",
",",
"error",
")",
"{",
"var",
"oauthClient",
"OAuthClient",
"\n",
"return",
"&",
"oauthClient",
",",
"c",
".",
"Get",
"(",
"&",
... | // Info for an OAuth client
//
// oauthClientIdentity is the unique identifier of the OAuthClient. | [
"Info",
"for",
"an",
"OAuth",
"client",
"oauthClientIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OAuthClient",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/oauth_client.go#L63-L66 | train |
remind101/empire | pkg/heroku/oauth_client.go | OAuthClientList | func (c *Client) OAuthClientList(lr *ListRange) ([]OAuthClient, error) {
req, err := c.NewRequest("GET", "/oauth/clients", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var oauthClientsRes []OAuthClient
return oauthClientsRes, c.DoReq(req, &oauthClientsRes)
} | go | func (c *Client) OAuthClientList(lr *ListRange) ([]OAuthClient, error) {
req, err := c.NewRequest("GET", "/oauth/clients", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var oauthClientsRes []OAuthClient
return oauthClientsRes, c.DoReq(req, &oauthClientsRes)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OAuthClientList",
"(",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"OAuthClient",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
... | // List OAuth clients
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results. | [
"List",
"OAuth",
"clients",
"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/oauth_client.go#L72-L84 | train |
remind101/empire | pkg/heroku/oauth_client.go | OAuthClientUpdate | func (c *Client) OAuthClientUpdate(oauthClientIdentity string, options *OAuthClientUpdateOpts) (*OAuthClient, error) {
var oauthClientRes OAuthClient
return &oauthClientRes, c.Patch(&oauthClientRes, "/oauth/clients/"+oauthClientIdentity, options)
} | go | func (c *Client) OAuthClientUpdate(oauthClientIdentity string, options *OAuthClientUpdateOpts) (*OAuthClient, error) {
var oauthClientRes OAuthClient
return &oauthClientRes, c.Patch(&oauthClientRes, "/oauth/clients/"+oauthClientIdentity, options)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OAuthClientUpdate",
"(",
"oauthClientIdentity",
"string",
",",
"options",
"*",
"OAuthClientUpdateOpts",
")",
"(",
"*",
"OAuthClient",
",",
"error",
")",
"{",
"var",
"oauthClientRes",
"OAuthClient",
"\n",
"return",
"&",
"o... | // Update OAuth client
//
// oauthClientIdentity is the unique identifier of the OAuthClient. options is
// the struct of optional parameters for this action. | [
"Update",
"OAuth",
"client",
"oauthClientIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OAuthClient",
".",
"options",
"is",
"the",
"struct",
"of",
"optional",
"parameters",
"for",
"this",
"action",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/oauth_client.go#L90-L93 | train |
remind101/empire | pkg/heroku/log_session.go | LogSessionCreate | func (c *Client) LogSessionCreate(appIdentity string, options *LogSessionCreateOpts) (*LogSession, error) {
var logSessionRes LogSession
return &logSessionRes, c.Post(&logSessionRes, "/apps/"+appIdentity+"/log-sessions", options)
} | go | func (c *Client) LogSessionCreate(appIdentity string, options *LogSessionCreateOpts) (*LogSession, error) {
var logSessionRes LogSession
return &logSessionRes, c.Post(&logSessionRes, "/apps/"+appIdentity+"/log-sessions", options)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"LogSessionCreate",
"(",
"appIdentity",
"string",
",",
"options",
"*",
"LogSessionCreateOpts",
")",
"(",
"*",
"LogSession",
",",
"error",
")",
"{",
"var",
"logSessionRes",
"LogSession",
"\n",
"return",
"&",
"logSessionRes"... | // Create a new log session.
//
// appIdentity is the unique identifier of the LogSession's App. options is the
// struct of optional parameters for this action. | [
"Create",
"a",
"new",
"log",
"session",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"LogSession",
"s",
"App",
".",
"options",
"is",
"the",
"struct",
"of",
"optional",
"parameters",
"for",
"this",
"action",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/log_session.go#L30-L33 | train |
remind101/empire | server/server.go | newDeployer | func newDeployer(e *empire.Empire, options Options) github.Deployer {
ed := github.NewEmpireDeployer(e)
ed.ImageBuilder = options.GitHub.Deployments.ImageBuilder
var d github.Deployer = ed
// Enables the Tugboat integration, which will send logs to a Tugboat
// instance.
if url := options.GitHub.Deployments.Tug... | go | func newDeployer(e *empire.Empire, options Options) github.Deployer {
ed := github.NewEmpireDeployer(e)
ed.ImageBuilder = options.GitHub.Deployments.ImageBuilder
var d github.Deployer = ed
// Enables the Tugboat integration, which will send logs to a Tugboat
// instance.
if url := options.GitHub.Deployments.Tug... | [
"func",
"newDeployer",
"(",
"e",
"*",
"empire",
".",
"Empire",
",",
"options",
"Options",
")",
"github",
".",
"Deployer",
"{",
"ed",
":=",
"github",
".",
"NewEmpireDeployer",
"(",
"e",
")",
"\n",
"ed",
".",
"ImageBuilder",
"=",
"options",
".",
"GitHub",
... | // newDeployer generates a new github.Deployer implementation for the given
// options. | [
"newDeployer",
"generates",
"a",
"new",
"github",
".",
"Deployer",
"implementation",
"for",
"the",
"given",
"options",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/server.go#L132-L149 | train |
remind101/empire | pkg/heroku/organization_member.go | OrganizationMemberCreateOrUpdate | func (c *Client) OrganizationMemberCreateOrUpdate(organizationIdentity string, email string, role string) (*OrganizationMember, error) {
params := struct {
Email string `json:"email"`
Role string `json:"role"`
}{
Email: email,
Role: role,
}
var organizationMemberRes OrganizationMember
return &organizatio... | go | func (c *Client) OrganizationMemberCreateOrUpdate(organizationIdentity string, email string, role string) (*OrganizationMember, error) {
params := struct {
Email string `json:"email"`
Role string `json:"role"`
}{
Email: email,
Role: role,
}
var organizationMemberRes OrganizationMember
return &organizatio... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationMemberCreateOrUpdate",
"(",
"organizationIdentity",
"string",
",",
"email",
"string",
",",
"role",
"string",
")",
"(",
"*",
"OrganizationMember",
",",
"error",
")",
"{",
"params",
":=",
"struct",
"{",
"Email",... | // Create a new organization member, or update their role.
//
// organizationIdentity is the unique identifier of the OrganizationMember's
// Organization. email is the email address of the organization member. role is
// the role in the organization. | [
"Create",
"a",
"new",
"organization",
"member",
"or",
"update",
"their",
"role",
".",
"organizationIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationMember",
"s",
"Organization",
".",
"email",
"is",
"the",
"email",
"address",
"of",
"the",... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_member.go#L31-L41 | train |
remind101/empire | pkg/heroku/organization_member.go | OrganizationMemberDelete | func (c *Client) OrganizationMemberDelete(organizationIdentity string, organizationMemberIdentity string) error {
return c.Delete("/organizations/" + organizationIdentity + "/members/" + organizationIdentity)
} | go | func (c *Client) OrganizationMemberDelete(organizationIdentity string, organizationMemberIdentity string) error {
return c.Delete("/organizations/" + organizationIdentity + "/members/" + organizationIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationMemberDelete",
"(",
"organizationIdentity",
"string",
",",
"organizationMemberIdentity",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Delete",
"(",
"\"",
"\"",
"+",
"organizationIdentity",
"+",
"\"",
"\"",
... | // Remove a member from the organization.
//
// organizationIdentity is the unique identifier of the OrganizationMember's
// Organization. organizationMemberIdentity is the unique identifier of the
// OrganizationMember. | [
"Remove",
"a",
"member",
"from",
"the",
"organization",
".",
"organizationIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationMember",
"s",
"Organization",
".",
"organizationMemberIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"Or... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_member.go#L48-L50 | train |
remind101/empire | pkg/heroku/organization_member.go | OrganizationMemberList | func (c *Client) OrganizationMemberList(organizationIdentity string, lr *ListRange) ([]OrganizationMember, error) {
req, err := c.NewRequest("GET", "/organizations/"+organizationIdentity+"/members", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationMembersRes []O... | go | func (c *Client) OrganizationMemberList(organizationIdentity string, lr *ListRange) ([]OrganizationMember, error) {
req, err := c.NewRequest("GET", "/organizations/"+organizationIdentity+"/members", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationMembersRes []O... | [
"func",
"(",
"c",
"*",
"Client",
")",
"OrganizationMemberList",
"(",
"organizationIdentity",
"string",
",",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"OrganizationMember",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\... | // List members of the organization.
//
// organizationIdentity is the unique identifier of the OrganizationMember's
// Organization. lr is an optional ListRange that sets the Range options for the
// paginated list of results. | [
"List",
"members",
"of",
"the",
"organization",
".",
"organizationIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"OrganizationMember",
"s",
"Organization",
".",
"lr",
"is",
"an",
"optional",
"ListRange",
"that",
"sets",
"the",
"Range",
"options",
"... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/organization_member.go#L57-L69 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | NewScheduler | func NewScheduler(db *sql.DB, config client.ConfigProvider) *Scheduler {
return &Scheduler{
cloudformation: cloudformation.New(config),
ecs: ecsWithCaching(&ECS{ecs.New(config)}),
s3: s3.New(config),
ec2: ec2.New(config),
db: db,
after: time.After,
}
... | go | func NewScheduler(db *sql.DB, config client.ConfigProvider) *Scheduler {
return &Scheduler{
cloudformation: cloudformation.New(config),
ecs: ecsWithCaching(&ECS{ecs.New(config)}),
s3: s3.New(config),
ec2: ec2.New(config),
db: db,
after: time.After,
}
... | [
"func",
"NewScheduler",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"config",
"client",
".",
"ConfigProvider",
")",
"*",
"Scheduler",
"{",
"return",
"&",
"Scheduler",
"{",
"cloudformation",
":",
"cloudformation",
".",
"New",
"(",
"config",
")",
",",
"ecs",
":... | // NewScheduler returns a new Scheduler instance. | [
"NewScheduler",
"returns",
"a",
"new",
"Scheduler",
"instance",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L190-L199 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | createTemplate | func (s *Scheduler) createTemplate(ctx context.Context, app *twelvefactor.Manifest, stackTags []*cloudformation.Tag) (*cloudformationTemplate, error) {
data := &TemplateData{
Manifest: app,
StackTags: stackTags,
}
buf := new(bytes.Buffer)
if err := s.Template.Execute(buf, data); err != nil {
return nil, err... | go | func (s *Scheduler) createTemplate(ctx context.Context, app *twelvefactor.Manifest, stackTags []*cloudformation.Tag) (*cloudformationTemplate, error) {
data := &TemplateData{
Manifest: app,
StackTags: stackTags,
}
buf := new(bytes.Buffer)
if err := s.Template.Execute(buf, data); err != nil {
return nil, err... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"createTemplate",
"(",
"ctx",
"context",
".",
"Context",
",",
"app",
"*",
"twelvefactor",
".",
"Manifest",
",",
"stackTags",
"[",
"]",
"*",
"cloudformation",
".",
"Tag",
")",
"(",
"*",
"cloudformationTemplate",
",",... | // createTemplate takes a scheduler.App, and returns a validated cloudformation
// template. | [
"createTemplate",
"takes",
"a",
"scheduler",
".",
"App",
"and",
"returns",
"a",
"validated",
"cloudformation",
"template",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L426-L464 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | createStack | func (s *Scheduler) createStack(ctx context.Context, input *createStackInput, output chan stackOperationOutput, ss twelvefactor.StatusStream) error {
waiter := s.waitFor(ctx, createStack, ss)
submitted := make(chan error)
fn := func() error {
_, err := s.cloudformation.CreateStack(&cloudformation.CreateStackInput... | go | func (s *Scheduler) createStack(ctx context.Context, input *createStackInput, output chan stackOperationOutput, ss twelvefactor.StatusStream) error {
waiter := s.waitFor(ctx, createStack, ss)
submitted := make(chan error)
fn := func() error {
_, err := s.cloudformation.CreateStack(&cloudformation.CreateStackInput... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"createStack",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"createStackInput",
",",
"output",
"chan",
"stackOperationOutput",
",",
"ss",
"twelvefactor",
".",
"StatusStream",
")",
"error",
"{",
"waiter",
... | // createStack creates a new CloudFormation stack with the given input. This
// function returns as soon as the stack creation has been submitted. It does
// not wait for the stack creation to complete. | [
"createStack",
"creates",
"a",
"new",
"CloudFormation",
"stack",
"with",
"the",
"given",
"input",
".",
"This",
"function",
"returns",
"as",
"soon",
"as",
"the",
"stack",
"creation",
"has",
"been",
"submitted",
".",
"It",
"does",
"not",
"wait",
"for",
"the",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L484-L504 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | updateStack | func (s *Scheduler) updateStack(ctx context.Context, input *updateStackInput, output chan stackOperationOutput, ss twelvefactor.StatusStream) error {
waiter := s.waitFor(ctx, updateStack, ss)
locked := make(chan struct{})
submitted := make(chan error, 1)
fn := func() error {
close(locked)
err := s.executeStack... | go | func (s *Scheduler) updateStack(ctx context.Context, input *updateStackInput, output chan stackOperationOutput, ss twelvefactor.StatusStream) error {
waiter := s.waitFor(ctx, updateStack, ss)
locked := make(chan struct{})
submitted := make(chan error, 1)
fn := func() error {
close(locked)
err := s.executeStack... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"updateStack",
"(",
"ctx",
"context",
".",
"Context",
",",
"input",
"*",
"updateStackInput",
",",
"output",
"chan",
"stackOperationOutput",
",",
"ss",
"twelvefactor",
".",
"StatusStream",
")",
"error",
"{",
"waiter",
... | // updateStack updates an existing CloudFormation stack with the given input.
// If there are no other active updates, this function returns as soon as the
// stack update has been submitted. If there are other updates, the function
// returns after `lockTimeout` and the update continues in the background. | [
"updateStack",
"updates",
"an",
"existing",
"CloudFormation",
"stack",
"with",
"the",
"given",
"input",
".",
"If",
"there",
"are",
"no",
"other",
"active",
"updates",
"this",
"function",
"returns",
"as",
"soon",
"as",
"the",
"stack",
"update",
"has",
"been",
... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L518-L553 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | waitUntilStackOperationComplete | func (s *Scheduler) waitUntilStackOperationComplete(lock *pglock.AdvisoryLock, wait func() error) error {
errCh := make(chan error)
go func() { errCh <- wait() }()
var err error
select {
case <-s.after(stackOperationTimeout):
err = errors.New("timed out waiting for stack operation to complete")
case err = <-er... | go | func (s *Scheduler) waitUntilStackOperationComplete(lock *pglock.AdvisoryLock, wait func() error) error {
errCh := make(chan error)
go func() { errCh <- wait() }()
var err error
select {
case <-s.after(stackOperationTimeout):
err = errors.New("timed out waiting for stack operation to complete")
case err = <-er... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"waitUntilStackOperationComplete",
"(",
"lock",
"*",
"pglock",
".",
"AdvisoryLock",
",",
"wait",
"func",
"(",
")",
"error",
")",
"error",
"{",
"errCh",
":=",
"make",
"(",
"chan",
"error",
")",
"\n",
"go",
"func",
... | // waitUntilStackOperationComplete waits until wait returns, or it times out. | [
"waitUntilStackOperationComplete",
"waits",
"until",
"wait",
"returns",
"or",
"it",
"times",
"out",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L615-L627 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | executeStackUpdate | func (s *Scheduler) executeStackUpdate(input *updateStackInput) error {
stack, err := s.stack(input.StackName)
if err != nil {
return err
}
i := &cloudformation.UpdateStackInput{
StackName: input.StackName,
Parameters: updateParameters(input.Parameters, stack, input.Template),
Tags: input.Tags,
}
... | go | func (s *Scheduler) executeStackUpdate(input *updateStackInput) error {
stack, err := s.stack(input.StackName)
if err != nil {
return err
}
i := &cloudformation.UpdateStackInput{
StackName: input.StackName,
Parameters: updateParameters(input.Parameters, stack, input.Template),
Tags: input.Tags,
}
... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"executeStackUpdate",
"(",
"input",
"*",
"updateStackInput",
")",
"error",
"{",
"stack",
",",
"err",
":=",
"s",
".",
"stack",
"(",
"input",
".",
"StackName",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // executeStackUpdate performs a stack update. | [
"executeStackUpdate",
"performs",
"a",
"stack",
"update",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L630-L659 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | stack | func (s *Scheduler) stack(stackName *string) (*cloudformation.Stack, error) {
resp, err := s.cloudformation.DescribeStacks(&cloudformation.DescribeStacksInput{
StackName: stackName,
})
if err != nil {
return nil, err
}
return resp.Stacks[0], nil
} | go | func (s *Scheduler) stack(stackName *string) (*cloudformation.Stack, error) {
resp, err := s.cloudformation.DescribeStacks(&cloudformation.DescribeStacksInput{
StackName: stackName,
})
if err != nil {
return nil, err
}
return resp.Stacks[0], nil
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"stack",
"(",
"stackName",
"*",
"string",
")",
"(",
"*",
"cloudformation",
".",
"Stack",
",",
"error",
")",
"{",
"resp",
",",
"err",
":=",
"s",
".",
"cloudformation",
".",
"DescribeStacks",
"(",
"&",
"cloudforma... | // stack returns the cloudformation.Stack for the given stack name. | [
"stack",
"returns",
"the",
"cloudformation",
".",
"Stack",
"for",
"the",
"given",
"stack",
"name",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L662-L670 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | Remove | func (s *Scheduler) Remove(ctx context.Context, appID string) error {
tx, err := s.db.Begin()
if err != nil {
return err
}
err = s.remove(ctx, tx, appID)
if err != nil {
tx.Rollback()
return err
}
return tx.Commit()
} | go | func (s *Scheduler) Remove(ctx context.Context, appID string) error {
tx, err := s.db.Begin()
if err != nil {
return err
}
err = s.remove(ctx, tx, appID)
if err != nil {
tx.Rollback()
return err
}
return tx.Commit()
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Remove",
"(",
"ctx",
"context",
".",
"Context",
",",
"appID",
"string",
")",
"error",
"{",
"tx",
",",
"err",
":=",
"s",
".",
"db",
".",
"Begin",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // Remove removes the CloudFormation stack for the given app. | [
"Remove",
"removes",
"the",
"CloudFormation",
"stack",
"for",
"the",
"given",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L673-L686 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | remove | func (s *Scheduler) remove(_ context.Context, tx *sql.Tx, appID string) error {
stackName, err := s.stackName(appID)
// if there's no stack entry in the db for this app, nothing to remove
if err == errNoStack {
return nil
}
if err != nil {
return err
}
_, err = tx.Exec(`DELETE FROM stacks WHERE app_id = $1... | go | func (s *Scheduler) remove(_ context.Context, tx *sql.Tx, appID string) error {
stackName, err := s.stackName(appID)
// if there's no stack entry in the db for this app, nothing to remove
if err == errNoStack {
return nil
}
if err != nil {
return err
}
_, err = tx.Exec(`DELETE FROM stacks WHERE app_id = $1... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"remove",
"(",
"_",
"context",
".",
"Context",
",",
"tx",
"*",
"sql",
".",
"Tx",
",",
"appID",
"string",
")",
"error",
"{",
"stackName",
",",
"err",
":=",
"s",
".",
"stackName",
"(",
"appID",
")",
"\n\n",
... | // Remove removes the CloudFormation stack for the given app, if it exists. | [
"Remove",
"removes",
"the",
"CloudFormation",
"stack",
"for",
"the",
"given",
"app",
"if",
"it",
"exists",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L689-L719 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | tasks | func (s *Scheduler) tasks(app string) ([]*ecs.Task, error) {
services, err := s.Services(app)
if err != nil {
return nil, err
}
var arns []*string
// Find all of the tasks started by the ECS services.
for process, serviceArn := range services {
id, err := arn.ResourceID(serviceArn)
if err != nil {
retu... | go | func (s *Scheduler) tasks(app string) ([]*ecs.Task, error) {
services, err := s.Services(app)
if err != nil {
return nil, err
}
var arns []*string
// Find all of the tasks started by the ECS services.
for process, serviceArn := range services {
id, err := arn.ResourceID(serviceArn)
if err != nil {
retu... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"tasks",
"(",
"app",
"string",
")",
"(",
"[",
"]",
"*",
"ecs",
".",
"Task",
",",
"error",
")",
"{",
"services",
",",
"err",
":=",
"s",
".",
"Services",
"(",
"app",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // tasks returns all of the ECS tasks for this app. | [
"tasks",
"returns",
"all",
"of",
"the",
"ECS",
"tasks",
"for",
"this",
"app",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L829-L887 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | Stop | func (s *Scheduler) Stop(ctx context.Context, taskID string) error {
_, err := s.ecs.StopTask(&ecs.StopTaskInput{
Cluster: aws.String(s.Cluster),
Task: aws.String(taskID),
})
return err
} | go | func (s *Scheduler) Stop(ctx context.Context, taskID string) error {
_, err := s.ecs.StopTask(&ecs.StopTaskInput{
Cluster: aws.String(s.Cluster),
Task: aws.String(taskID),
})
return err
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"Stop",
"(",
"ctx",
"context",
".",
"Context",
",",
"taskID",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"s",
".",
"ecs",
".",
"StopTask",
"(",
"&",
"ecs",
".",
"StopTaskInput",
"{",
"Cluster",
":",... | // Stop stops the given ECS task. | [
"Stop",
"stops",
"the",
"given",
"ECS",
"task",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L916-L922 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | Run | func (m *Scheduler) Run(ctx context.Context, app *twelvefactor.Manifest) error {
for _, process := range app.Processes {
var attached bool
if process.Stdout != nil || process.Stderr != nil {
attached = true
}
t, ok := m.Template.(interface {
ContainerDefinition(*twelvefactor.Manifest, *twelvefactor.Proc... | go | func (m *Scheduler) Run(ctx context.Context, app *twelvefactor.Manifest) error {
for _, process := range app.Processes {
var attached bool
if process.Stdout != nil || process.Stderr != nil {
attached = true
}
t, ok := m.Template.(interface {
ContainerDefinition(*twelvefactor.Manifest, *twelvefactor.Proc... | [
"func",
"(",
"m",
"*",
"Scheduler",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"app",
"*",
"twelvefactor",
".",
"Manifest",
")",
"error",
"{",
"for",
"_",
",",
"process",
":=",
"range",
"app",
".",
"Processes",
"{",
"var",
"attached",
"b... | // Run registers a TaskDefinition for the process, and calls RunTask. | [
"Run",
"registers",
"a",
"TaskDefinition",
"for",
"the",
"process",
"and",
"calls",
"RunTask",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L925-L1002 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | attach | func (m *Scheduler) attach(ctx context.Context, task *ecs.Task, stdin io.Reader, stdout, stderr io.Writer) error {
if a, _ := arn.Parse(aws.StringValue(task.TaskArn)); a != nil {
fmt.Fprintf(stderr, "Attaching to %s...\r\n", a.Resource)
}
descContainerInstanceResp, err := m.ecs.DescribeContainerInstances(&ecs.Des... | go | func (m *Scheduler) attach(ctx context.Context, task *ecs.Task, stdin io.Reader, stdout, stderr io.Writer) error {
if a, _ := arn.Parse(aws.StringValue(task.TaskArn)); a != nil {
fmt.Fprintf(stderr, "Attaching to %s...\r\n", a.Resource)
}
descContainerInstanceResp, err := m.ecs.DescribeContainerInstances(&ecs.Des... | [
"func",
"(",
"m",
"*",
"Scheduler",
")",
"attach",
"(",
"ctx",
"context",
".",
"Context",
",",
"task",
"*",
"ecs",
".",
"Task",
",",
"stdin",
"io",
".",
"Reader",
",",
"stdout",
",",
"stderr",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"a",
",... | // attach attaches to the given ECS task. | [
"attach",
"attaches",
"to",
"the",
"given",
"ECS",
"task",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1005-L1080 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | stackName | func (s *Scheduler) stackName(appID string) (string, error) {
var stackName string
err := s.db.QueryRow(`SELECT stack_name FROM stacks WHERE app_id = $1`, appID).Scan(&stackName)
if err == sql.ErrNoRows {
return "", errNoStack
}
return stackName, err
} | go | func (s *Scheduler) stackName(appID string) (string, error) {
var stackName string
err := s.db.QueryRow(`SELECT stack_name FROM stacks WHERE app_id = $1`, appID).Scan(&stackName)
if err == sql.ErrNoRows {
return "", errNoStack
}
return stackName, err
} | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"stackName",
"(",
"appID",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"var",
"stackName",
"string",
"\n",
"err",
":=",
"s",
".",
"db",
".",
"QueryRow",
"(",
"`SELECT stack_name FROM stacks WHERE app_id = $1... | // stackName returns the name of the CloudFormation stack for the app id. | [
"stackName",
"returns",
"the",
"name",
"of",
"the",
"CloudFormation",
"stack",
"for",
"the",
"app",
"id",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1083-L1090 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | waitFor | func (s *Scheduler) waitFor(ctx context.Context, op stackOperation, ss twelvefactor.StatusStream) func(*cloudformation.DescribeStacksInput) error {
waiter := waiters[op]
wait := waiter.wait(s.cloudformation)
return func(input *cloudformation.DescribeStacksInput) error {
tags := []string{
fmt.Sprintf("stack:%s"... | go | func (s *Scheduler) waitFor(ctx context.Context, op stackOperation, ss twelvefactor.StatusStream) func(*cloudformation.DescribeStacksInput) error {
waiter := waiters[op]
wait := waiter.wait(s.cloudformation)
return func(input *cloudformation.DescribeStacksInput) error {
tags := []string{
fmt.Sprintf("stack:%s"... | [
"func",
"(",
"s",
"*",
"Scheduler",
")",
"waitFor",
"(",
"ctx",
"context",
".",
"Context",
",",
"op",
"stackOperation",
",",
"ss",
"twelvefactor",
".",
"StatusStream",
")",
"func",
"(",
"*",
"cloudformation",
".",
"DescribeStacksInput",
")",
"error",
"{",
... | // waitFor returns a wait function that will wait for the given stack operation
// to complete, and sends status messages to the status stream, and also records
// metrics for how long the operation took. | [
"waitFor",
"returns",
"a",
"wait",
"function",
"that",
"will",
"wait",
"for",
"the",
"given",
"stack",
"operation",
"to",
"complete",
"and",
"sends",
"status",
"messages",
"to",
"the",
"status",
"stream",
"and",
"also",
"records",
"metrics",
"for",
"how",
"l... | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1128-L1145 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | extractProcessData | func extractProcessData(value string) map[string]string {
data := make(map[string]string)
pairs := strings.Split(value, ",")
for _, p := range pairs {
parts := strings.Split(p, "=")
data[parts[0]] = parts[1]
}
return data
} | go | func extractProcessData(value string) map[string]string {
data := make(map[string]string)
pairs := strings.Split(value, ",")
for _, p := range pairs {
parts := strings.Split(p, "=")
data[parts[0]] = parts[1]
}
return data
} | [
"func",
"extractProcessData",
"(",
"value",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"data",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"pairs",
":=",
"strings",
".",
"Split",
"(",
"value",
",",
"\"",
"\"",
")"... | // extractProcessData extracts a map that maps the process name to some
// corresponding value. | [
"extractProcessData",
"extracts",
"a",
"map",
"that",
"maps",
"the",
"process",
"name",
"to",
"some",
"corresponding",
"value",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1149-L1159 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | taskDefinitionToProcess | func taskDefinitionToProcess(td *ecs.TaskDefinition) (*twelvefactor.Process, error) {
// If this task definition has no container definitions, then something
// funky is up.
if len(td.ContainerDefinitions) == 0 {
return nil, errors.New("task definition had no container definitions")
}
container := td.ContainerD... | go | func taskDefinitionToProcess(td *ecs.TaskDefinition) (*twelvefactor.Process, error) {
// If this task definition has no container definitions, then something
// funky is up.
if len(td.ContainerDefinitions) == 0 {
return nil, errors.New("task definition had no container definitions")
}
container := td.ContainerD... | [
"func",
"taskDefinitionToProcess",
"(",
"td",
"*",
"ecs",
".",
"TaskDefinition",
")",
"(",
"*",
"twelvefactor",
".",
"Process",
",",
"error",
")",
"{",
"// If this task definition has no container definitions, then something",
"// funky is up.",
"if",
"len",
"(",
"td",
... | // taskDefinitionToProcess takes an ECS Task Definition and converts it to a
// Process. | [
"taskDefinitionToProcess",
"takes",
"an",
"ECS",
"Task",
"Definition",
"and",
"converts",
"it",
"to",
"a",
"Process",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1163-L1192 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | chunkStrings | func chunkStrings(s []*string, size int) [][]*string {
var chunks [][]*string
for len(s) > 0 {
end := size
if len(s) < size {
end = len(s)
}
chunks = append(chunks, s[0:end])
s = s[end:]
}
return chunks
} | go | func chunkStrings(s []*string, size int) [][]*string {
var chunks [][]*string
for len(s) > 0 {
end := size
if len(s) < size {
end = len(s)
}
chunks = append(chunks, s[0:end])
s = s[end:]
}
return chunks
} | [
"func",
"chunkStrings",
"(",
"s",
"[",
"]",
"*",
"string",
",",
"size",
"int",
")",
"[",
"]",
"[",
"]",
"*",
"string",
"{",
"var",
"chunks",
"[",
"]",
"[",
"]",
"*",
"string",
"\n",
"for",
"len",
"(",
"s",
")",
">",
"0",
"{",
"end",
":=",
"... | // chunkStrings slices a slice of string pointers in equal length chunks, with
// the last slice being the leftovers. | [
"chunkStrings",
"slices",
"a",
"slice",
"of",
"string",
"pointers",
"in",
"equal",
"length",
"chunks",
"with",
"the",
"last",
"slice",
"being",
"the",
"leftovers",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1210-L1222 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | updateParameters | func updateParameters(provided []*cloudformation.Parameter, stack *cloudformation.Stack, template *cloudformationTemplate) []*cloudformation.Parameter {
parameters := provided[:]
// This tracks the names of the parameters that have pre-existing values
// on the stack.
existingParams := make(map[string]bool)
for _... | go | func updateParameters(provided []*cloudformation.Parameter, stack *cloudformation.Stack, template *cloudformationTemplate) []*cloudformation.Parameter {
parameters := provided[:]
// This tracks the names of the parameters that have pre-existing values
// on the stack.
existingParams := make(map[string]bool)
for _... | [
"func",
"updateParameters",
"(",
"provided",
"[",
"]",
"*",
"cloudformation",
".",
"Parameter",
",",
"stack",
"*",
"cloudformation",
".",
"Stack",
",",
"template",
"*",
"cloudformationTemplate",
")",
"[",
"]",
"*",
"cloudformation",
".",
"Parameter",
"{",
"par... | // updateParameters returns the parameters that should be provided in an
// UpdateStack operation. | [
"updateParameters",
"returns",
"the",
"parameters",
"that",
"should",
"be",
"provided",
"in",
"an",
"UpdateStack",
"operation",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1226-L1274 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | stackLockKey | func stackLockKey(stackName string) uint32 {
return crc32.ChecksumIEEE([]byte(fmt.Sprintf("stack_%s", stackName)))
} | go | func stackLockKey(stackName string) uint32 {
return crc32.ChecksumIEEE([]byte(fmt.Sprintf("stack_%s", stackName)))
} | [
"func",
"stackLockKey",
"(",
"stackName",
"string",
")",
"uint32",
"{",
"return",
"crc32",
".",
"ChecksumIEEE",
"(",
"[",
"]",
"byte",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"stackName",
")",
")",
")",
"\n",
"}"
] | // stackLackKey returns the key to use when obtaining an advisory lock for a
// CloudFormation stack. | [
"stackLackKey",
"returns",
"the",
"key",
"to",
"use",
"when",
"obtaining",
"an",
"advisory",
"lock",
"for",
"a",
"CloudFormation",
"stack",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1278-L1280 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | newAdvisoryLock | func newAdvisoryLock(db *sql.DB, stackName string) (*pglock.AdvisoryLock, error) {
l, err := pglock.NewAdvisoryLock(db, stackLockKey(stackName))
if err != nil {
return l, err
}
l.LockTimeout = lockTimeout
l.Context = fmt.Sprintf("stack %s", stackName)
return l, nil
} | go | func newAdvisoryLock(db *sql.DB, stackName string) (*pglock.AdvisoryLock, error) {
l, err := pglock.NewAdvisoryLock(db, stackLockKey(stackName))
if err != nil {
return l, err
}
l.LockTimeout = lockTimeout
l.Context = fmt.Sprintf("stack %s", stackName)
return l, nil
} | [
"func",
"newAdvisoryLock",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"stackName",
"string",
")",
"(",
"*",
"pglock",
".",
"AdvisoryLock",
",",
"error",
")",
"{",
"l",
",",
"err",
":=",
"pglock",
".",
"NewAdvisoryLock",
"(",
"db",
",",
"stackLockKey",
"(",... | // newAdvsiroyLock returns a new AdvisoryLock suitable for obtaining a lock to
// perform the stack update. | [
"newAdvsiroyLock",
"returns",
"a",
"new",
"AdvisoryLock",
"suitable",
"for",
"obtaining",
"a",
"lock",
"to",
"perform",
"the",
"stack",
"update",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1284-L1292 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | output | func output(stack *cloudformation.Stack, key string) (output *cloudformation.Output) {
for _, o := range stack.Outputs {
if *o.OutputKey == key {
output = o
}
}
return
} | go | func output(stack *cloudformation.Stack, key string) (output *cloudformation.Output) {
for _, o := range stack.Outputs {
if *o.OutputKey == key {
output = o
}
}
return
} | [
"func",
"output",
"(",
"stack",
"*",
"cloudformation",
".",
"Stack",
",",
"key",
"string",
")",
"(",
"output",
"*",
"cloudformation",
".",
"Output",
")",
"{",
"for",
"_",
",",
"o",
":=",
"range",
"stack",
".",
"Outputs",
"{",
"if",
"*",
"o",
".",
"... | // output returns the cloudformation.Output that matches the given key. | [
"output",
"returns",
"the",
"cloudformation",
".",
"Output",
"that",
"matches",
"the",
"given",
"key",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1310-L1317 | train |
remind101/empire | scheduler/cloudformation/cloudformation.go | deploymentsToWatch | func deploymentsToWatch(stack *cloudformation.Stack) (map[string]*ecsDeployment, error) {
deployments := output(stack, deploymentsOutput)
services := output(stack, servicesOutput)
if deployments == nil {
return nil, fmt.Errorf("deployments output missing from stack")
}
if services == nil {
return nil, fmt.Erro... | go | func deploymentsToWatch(stack *cloudformation.Stack) (map[string]*ecsDeployment, error) {
deployments := output(stack, deploymentsOutput)
services := output(stack, servicesOutput)
if deployments == nil {
return nil, fmt.Errorf("deployments output missing from stack")
}
if services == nil {
return nil, fmt.Erro... | [
"func",
"deploymentsToWatch",
"(",
"stack",
"*",
"cloudformation",
".",
"Stack",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"ecsDeployment",
",",
"error",
")",
"{",
"deployments",
":=",
"output",
"(",
"stack",
",",
"deploymentsOutput",
")",
"\n",
"services",
... | // deploymentsToWatch returns an array of ecsDeployments for the given cloudformation stack | [
"deploymentsToWatch",
"returns",
"an",
"array",
"of",
"ecsDeployments",
"for",
"the",
"given",
"cloudformation",
"stack"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/scheduler/cloudformation/cloudformation.go#L1325-L1357 | train |
remind101/empire | server/cloudformation/queue.go | Start | func (q *SQSDispatcher) Start(handle func(context.Context, *sqs.Message) error) {
var wg sync.WaitGroup
for i := 0; i < q.NumWorkers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
q.start(handle)
}()
}
wg.Wait()
} | go | func (q *SQSDispatcher) Start(handle func(context.Context, *sqs.Message) error) {
var wg sync.WaitGroup
for i := 0; i < q.NumWorkers; i++ {
wg.Add(1)
go func() {
defer wg.Done()
q.start(handle)
}()
}
wg.Wait()
} | [
"func",
"(",
"q",
"*",
"SQSDispatcher",
")",
"Start",
"(",
"handle",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"sqs",
".",
"Message",
")",
"error",
")",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<... | // Start starts multiple goroutines pulling messages off of the queue. | [
"Start",
"starts",
"multiple",
"goroutines",
"pulling",
"messages",
"off",
"of",
"the",
"queue",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/queue.go#L65-L76 | train |
remind101/empire | server/cloudformation/queue.go | start | func (q *SQSDispatcher) start(handle func(context.Context, *sqs.Message) error) {
var wg sync.WaitGroup
for {
select {
case <-q.stopped:
wg.Wait()
return
default:
ctx := q.Context
resp, err := q.sqs.ReceiveMessage(&sqs.ReceiveMessageInput{
QueueUrl: aws.String(q.QueueURL),
WaitTimeSe... | go | func (q *SQSDispatcher) start(handle func(context.Context, *sqs.Message) error) {
var wg sync.WaitGroup
for {
select {
case <-q.stopped:
wg.Wait()
return
default:
ctx := q.Context
resp, err := q.sqs.ReceiveMessage(&sqs.ReceiveMessageInput{
QueueUrl: aws.String(q.QueueURL),
WaitTimeSe... | [
"func",
"(",
"q",
"*",
"SQSDispatcher",
")",
"start",
"(",
"handle",
"func",
"(",
"context",
".",
"Context",
",",
"*",
"sqs",
".",
"Message",
")",
"error",
")",
"{",
"var",
"wg",
"sync",
".",
"WaitGroup",
"\n",
"for",
"{",
"select",
"{",
"case",
"<... | // start starts a pulling messages off of the queue and passing them to the
// handler. | [
"start",
"starts",
"a",
"pulling",
"messages",
"off",
"of",
"the",
"queue",
"and",
"passing",
"them",
"to",
"the",
"handler",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/queue.go#L84-L114 | train |
remind101/empire | server/cloudformation/queue.go | extendMessageVisibilityTimeout | func (q *SQSDispatcher) extendMessageVisibilityTimeout(receiptHandle *string) (<-chan time.Time, error) {
visibilityTimeout := int64(float64(q.VisibilityHeartbeat) / float64(time.Second))
_, err := q.sqs.ChangeMessageVisibility(&sqs.ChangeMessageVisibilityInput{
QueueUrl: aws.String(q.QueueURL),
Receipt... | go | func (q *SQSDispatcher) extendMessageVisibilityTimeout(receiptHandle *string) (<-chan time.Time, error) {
visibilityTimeout := int64(float64(q.VisibilityHeartbeat) / float64(time.Second))
_, err := q.sqs.ChangeMessageVisibility(&sqs.ChangeMessageVisibilityInput{
QueueUrl: aws.String(q.QueueURL),
Receipt... | [
"func",
"(",
"q",
"*",
"SQSDispatcher",
")",
"extendMessageVisibilityTimeout",
"(",
"receiptHandle",
"*",
"string",
")",
"(",
"<-",
"chan",
"time",
".",
"Time",
",",
"error",
")",
"{",
"visibilityTimeout",
":=",
"int64",
"(",
"float64",
"(",
"q",
".",
"Vis... | // extendMessageVisibilityTimeout extends the messages visibility timeout by
// VisibilityHeartbeat, and returns a channel that will receive after half of
// VisibilityTimeout has elapsed. | [
"extendMessageVisibilityTimeout",
"extends",
"the",
"messages",
"visibility",
"timeout",
"by",
"VisibilityHeartbeat",
"and",
"returns",
"a",
"channel",
"that",
"will",
"receive",
"after",
"half",
"of",
"VisibilityTimeout",
"has",
"elapsed",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/server/cloudformation/queue.go#L155-L168 | train |
remind101/empire | pkg/heroku/app.go | AppCreate | func (c *Client) AppCreate(options *AppCreateOpts) (*App, error) {
var appRes App
return &appRes, c.Post(&appRes, "/apps", options)
} | go | func (c *Client) AppCreate(options *AppCreateOpts) (*App, error) {
var appRes App
return &appRes, c.Post(&appRes, "/apps", options)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppCreate",
"(",
"options",
"*",
"AppCreateOpts",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"var",
"appRes",
"App",
"\n",
"return",
"&",
"appRes",
",",
"c",
".",
"Post",
"(",
"&",
"appRes",
",",
"\"",
"\... | // Create a new app.
//
// options is the struct of optional parameters for this action. | [
"Create",
"a",
"new",
"app",
".",
"options",
"is",
"the",
"struct",
"of",
"optional",
"parameters",
"for",
"this",
"action",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app.go#L78-L81 | train |
remind101/empire | pkg/heroku/app.go | AppInfo | func (c *Client) AppInfo(appIdentity string) (*App, error) {
var app App
return &app, c.Get(&app, "/apps/"+appIdentity)
} | go | func (c *Client) AppInfo(appIdentity string) (*App, error) {
var app App
return &app, c.Get(&app, "/apps/"+appIdentity)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppInfo",
"(",
"appIdentity",
"string",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"var",
"app",
"App",
"\n",
"return",
"&",
"app",
",",
"c",
".",
"Get",
"(",
"&",
"app",
",",
"\"",
"\"",
"+",
"appIdent... | // Info for existing app.
//
// appIdentity is the unique identifier of the App. | [
"Info",
"for",
"existing",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"App",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app.go#L104-L107 | train |
remind101/empire | pkg/heroku/app.go | AppList | func (c *Client) AppList(lr *ListRange) ([]App, error) {
req, err := c.NewRequest("GET", "/apps", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var appsRes []App
return appsRes, c.DoReq(req, &appsRes)
} | go | func (c *Client) AppList(lr *ListRange) ([]App, error) {
req, err := c.NewRequest("GET", "/apps", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var appsRes []App
return appsRes, c.DoReq(req, &appsRes)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppList",
"(",
"lr",
"*",
"ListRange",
")",
"(",
"[",
"]",
"App",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"c",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"nil",
",",
"nil",
")",
... | // List existing apps.
//
// lr is an optional ListRange that sets the Range options for the paginated
// list of results. | [
"List",
"existing",
"apps",
".",
"lr",
"is",
"an",
"optional",
"ListRange",
"that",
"sets",
"the",
"Range",
"options",
"for",
"the",
"paginated",
"list",
"of",
"results",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app.go#L113-L125 | train |
remind101/empire | pkg/heroku/app.go | AppUpdate | func (c *Client) AppUpdate(appIdentity string, options *AppUpdateOpts, message string) (*App, error) {
rh := RequestHeaders{CommitMessage: message}
var appRes App
return &appRes, c.PatchWithHeaders(&appRes, "/apps/"+appIdentity, options, rh.Headers())
} | go | func (c *Client) AppUpdate(appIdentity string, options *AppUpdateOpts, message string) (*App, error) {
rh := RequestHeaders{CommitMessage: message}
var appRes App
return &appRes, c.PatchWithHeaders(&appRes, "/apps/"+appIdentity, options, rh.Headers())
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AppUpdate",
"(",
"appIdentity",
"string",
",",
"options",
"*",
"AppUpdateOpts",
",",
"message",
"string",
")",
"(",
"*",
"App",
",",
"error",
")",
"{",
"rh",
":=",
"RequestHeaders",
"{",
"CommitMessage",
":",
"messa... | // Update an existing app.
//
// appIdentity is the unique identifier of the App. options is the struct of
// optional parameters for this action. | [
"Update",
"an",
"existing",
"app",
".",
"appIdentity",
"is",
"the",
"unique",
"identifier",
"of",
"the",
"App",
".",
"options",
"is",
"the",
"struct",
"of",
"optional",
"parameters",
"for",
"this",
"action",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/heroku/app.go#L131-L135 | train |
remind101/empire | pkg/image/image.go | Decode | func Decode(in string) (image Image, err error) {
repo, tag := parseRepositoryTag(in)
image.Registry, image.Repository = splitRepository(repo)
if strings.Contains(tag, ":") {
image.Digest = tag
} else {
image.Tag = tag
}
if image.Repository == "" {
err = ErrInvalidImage
return
}
return
} | go | func Decode(in string) (image Image, err error) {
repo, tag := parseRepositoryTag(in)
image.Registry, image.Repository = splitRepository(repo)
if strings.Contains(tag, ":") {
image.Digest = tag
} else {
image.Tag = tag
}
if image.Repository == "" {
err = ErrInvalidImage
return
}
return
} | [
"func",
"Decode",
"(",
"in",
"string",
")",
"(",
"image",
"Image",
",",
"err",
"error",
")",
"{",
"repo",
",",
"tag",
":=",
"parseRepositoryTag",
"(",
"in",
")",
"\n",
"image",
".",
"Registry",
",",
"image",
".",
"Repository",
"=",
"splitRepository",
"... | // Decode decodes the string representation of an image into an Image structure. | [
"Decode",
"decodes",
"the",
"string",
"representation",
"of",
"an",
"image",
"into",
"an",
"Image",
"structure",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/image/image.go#L87-L103 | train |
remind101/empire | pkg/image/image.go | Encode | func Encode(image Image) string {
repo := image.Repository
if image.Registry != "" {
repo = fmt.Sprintf("%s/%s", image.Registry, repo)
}
if image.Digest != "" {
return fmt.Sprintf("%s@%s", repo, image.Digest)
} else if image.Tag != "" {
return fmt.Sprintf("%s:%s", repo, image.Tag)
}
return repo
} | go | func Encode(image Image) string {
repo := image.Repository
if image.Registry != "" {
repo = fmt.Sprintf("%s/%s", image.Registry, repo)
}
if image.Digest != "" {
return fmt.Sprintf("%s@%s", repo, image.Digest)
} else if image.Tag != "" {
return fmt.Sprintf("%s:%s", repo, image.Tag)
}
return repo
} | [
"func",
"Encode",
"(",
"image",
"Image",
")",
"string",
"{",
"repo",
":=",
"image",
".",
"Repository",
"\n",
"if",
"image",
".",
"Registry",
"!=",
"\"",
"\"",
"{",
"repo",
"=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"image",
".",
"Registry",
... | // Encode encodes an Image to it's string representation. | [
"Encode",
"encodes",
"an",
"Image",
"to",
"it",
"s",
"string",
"representation",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/image/image.go#L106-L119 | train |
remind101/empire | pkg/image/image.go | splitRepository | func splitRepository(fullRepo string) (registry string, path string) {
parts := strings.Split(fullRepo, "/")
if len(parts) < 2 {
return "", parts[0]
}
if len(parts) == 2 {
return "", strings.Join(parts, "/")
}
return parts[0], strings.Join(parts[1:], "/")
} | go | func splitRepository(fullRepo string) (registry string, path string) {
parts := strings.Split(fullRepo, "/")
if len(parts) < 2 {
return "", parts[0]
}
if len(parts) == 2 {
return "", strings.Join(parts, "/")
}
return parts[0], strings.Join(parts[1:], "/")
} | [
"func",
"splitRepository",
"(",
"fullRepo",
"string",
")",
"(",
"registry",
"string",
",",
"path",
"string",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"fullRepo",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"parts",
")",
"<",
"2",
"{... | // splitRepository splits a full docker repo into registry and path segments. | [
"splitRepository",
"splits",
"a",
"full",
"docker",
"repo",
"into",
"registry",
"and",
"path",
"segments",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/pkg/image/image.go#L122-L134 | train |
remind101/empire | deployments.go | createRelease | func (s *deployerService) createRelease(ctx context.Context, db *gorm.DB, ss twelvefactor.StatusStream, opts DeployOpts) (*Release, error) {
app, img := opts.App, opts.Image
// If no app is specified, attempt to find the app that relates to this
// images repository, or create it if not found.
if app == nil {
va... | go | func (s *deployerService) createRelease(ctx context.Context, db *gorm.DB, ss twelvefactor.StatusStream, opts DeployOpts) (*Release, error) {
app, img := opts.App, opts.Image
// If no app is specified, attempt to find the app that relates to this
// images repository, or create it if not found.
if app == nil {
va... | [
"func",
"(",
"s",
"*",
"deployerService",
")",
"createRelease",
"(",
"ctx",
"context",
".",
"Context",
",",
"db",
"*",
"gorm",
".",
"DB",
",",
"ss",
"twelvefactor",
".",
"StatusStream",
",",
"opts",
"DeployOpts",
")",
"(",
"*",
"Release",
",",
"error",
... | // createRelease creates a new release that can be deployed | [
"createRelease",
"creates",
"a",
"new",
"release",
"that",
"can",
"be",
"deployed"
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/deployments.go#L20-L63 | train |
remind101/empire | deployments.go | Deploy | func (s *deployerService) Deploy(ctx context.Context, opts DeployOpts) (*Release, error) {
w := opts.Output
var stream twelvefactor.StatusStream
if opts.Stream {
stream = w
}
r, err := s.createInTransaction(ctx, stream, opts)
if err != nil {
return r, w.Error(err)
}
if err := w.Status(fmt.Sprintf("Create... | go | func (s *deployerService) Deploy(ctx context.Context, opts DeployOpts) (*Release, error) {
w := opts.Output
var stream twelvefactor.StatusStream
if opts.Stream {
stream = w
}
r, err := s.createInTransaction(ctx, stream, opts)
if err != nil {
return r, w.Error(err)
}
if err := w.Status(fmt.Sprintf("Create... | [
"func",
"(",
"s",
"*",
"deployerService",
")",
"Deploy",
"(",
"ctx",
"context",
".",
"Context",
",",
"opts",
"DeployOpts",
")",
"(",
"*",
"Release",
",",
"error",
")",
"{",
"w",
":=",
"opts",
".",
"Output",
"\n\n",
"var",
"stream",
"twelvefactor",
".",... | // Deploy is a thin wrapper around deploy to that adds the error to the
// jsonmessage stream. | [
"Deploy",
"is",
"a",
"thin",
"wrapper",
"around",
"deploy",
"to",
"that",
"adds",
"the",
"error",
"to",
"the",
"jsonmessage",
"stream",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/deployments.go#L77-L99 | train |
remind101/empire | deployments.go | Publish | func (w *DeploymentStream) Publish(status twelvefactor.Status) error {
return w.Status(status.Message)
} | go | func (w *DeploymentStream) Publish(status twelvefactor.Status) error {
return w.Status(status.Message)
} | [
"func",
"(",
"w",
"*",
"DeploymentStream",
")",
"Publish",
"(",
"status",
"twelvefactor",
".",
"Status",
")",
"error",
"{",
"return",
"w",
".",
"Status",
"(",
"status",
".",
"Message",
")",
"\n",
"}"
] | // Publish implements the scheduler.StatusStream interface. | [
"Publish",
"implements",
"the",
"scheduler",
".",
"StatusStream",
"interface",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/deployments.go#L113-L115 | train |
remind101/empire | deployments.go | Status | func (w *DeploymentStream) Status(message string) error {
m := jsonmessage.JSONMessage{Status: fmt.Sprintf("Status: %s", message)}
return w.Encode(m)
} | go | func (w *DeploymentStream) Status(message string) error {
m := jsonmessage.JSONMessage{Status: fmt.Sprintf("Status: %s", message)}
return w.Encode(m)
} | [
"func",
"(",
"w",
"*",
"DeploymentStream",
")",
"Status",
"(",
"message",
"string",
")",
"error",
"{",
"m",
":=",
"jsonmessage",
".",
"JSONMessage",
"{",
"Status",
":",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"message",
")",
"}",
"\n",
"return",
... | // Status writes a simple status update to the jsonmessage stream. | [
"Status",
"writes",
"a",
"simple",
"status",
"update",
"to",
"the",
"jsonmessage",
"stream",
"."
] | 3daba389f6b07b5d219246bfc7d901fcec664161 | https://github.com/remind101/empire/blob/3daba389f6b07b5d219246bfc7d901fcec664161/deployments.go#L118-L121 | 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.