_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q36300 | DynoInfo | train | func (c *Client) DynoInfo(appIdentity string, dynoIdentity string) (*Dyno, error) {
var dyno Dyno
return &dyno, c.Get(&dyno, "/apps/"+appIdentity+"/dynos/"+dynoIdentity)
} | go | {
"resource": ""
} |
q36301 | DynoList | train | func (c *Client) DynoList(appIdentity string, lr *ListRange) ([]Dyno, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/dynos", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var dynosRes []Dyno
return dynosRes, c.DoReq(req, &dynosRes)
} | go | {
"resource": ""
} |
q36302 | IsValid | train | func (a *App) IsValid() error {
if !NamePattern.Match([]byte(a.Name)) {
return ErrInvalidName
}
return nil
} | go | {
"resource": ""
} |
q36303 | Destroy | train | func (s *appsService) Destroy(ctx context.Context, db *gorm.DB, app *App) error {
if err := appsDestroy(db, app); err != nil {
return err
}
return s.Scheduler.Remove(ctx, app.ID)
} | go | {
"resource": ""
} |
q36304 | appsEnsureRepo | train | func appsEnsureRepo(db *gorm.DB, app *App, repo string) error {
if app.Repo != nil {
return nil
}
app.Repo = &repo
return appsUpdate(db, app)
} | go | {
"resource": ""
} |
q36305 | appsFindOrCreateByRepo | train | func appsFindOrCreateByRepo(db *gorm.DB, repo string) (*App, error) {
n := appNameFromRepo(repo)
a, err := appsFind(db, AppsQuery{Name: &n})
if err != nil && err != gorm.RecordNotFound {
return a, err
}
// If the app wasn't found, create a new app.
if err != gorm.RecordNotFound {
return a, appsEnsureRepo(db,... | go | {
"resource": ""
} |
q36306 | appsFind | train | func appsFind(db *gorm.DB, scope scope) (*App, error) {
var app App
return &app, first(db, scope, &app)
} | go | {
"resource": ""
} |
q36307 | apps | train | func apps(db *gorm.DB, scope scope) ([]*App, error) {
var apps []*App
// Default to ordering by name.
scope = composedScope{order("name"), scope}
return apps, find(db, scope, &apps)
} | go | {
"resource": ""
} |
q36308 | appsCreate | train | func appsCreate(db *gorm.DB, app *App) (*App, error) {
return app, db.Create(app).Error
} | go | {
"resource": ""
} |
q36309 | appsUpdate | train | func appsUpdate(db *gorm.DB, app *App) error {
return db.Save(app).Error
} | go | {
"resource": ""
} |
q36310 | appsDestroy | train | func appsDestroy(db *gorm.DB, app *App) error {
now := timex.Now()
app.DeletedAt = &now
return appsUpdate(db, app)
} | go | {
"resource": ""
} |
q36311 | NewServeReplay | train | func NewServeReplay(t *testing.T) *ServeReplay {
return &ServeReplay{
t: t,
Handlers: make([]http.Handler, 0),
NoneLeftFunc: defaultNoneLeftFunc,
}
} | go | {
"resource": ""
} |
q36312 | Add | train | func (h *ServeReplay) Add(handler http.Handler) *ServeReplay {
h.Handlers = append(h.Handlers, handler)
return h
} | go | {
"resource": ""
} |
q36313 | ServeHTTP | train | func (h *ServeReplay) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.i >= len(h.Handlers) {
h.NoneLeftFunc(h.t, r)
} else {
h.Handlers[h.i].ServeHTTP(w, r)
h.i++
}
} | go | {
"resource": ""
} |
q36314 | OrganizationAppCollaboratorDelete | train | func (c *Client) OrganizationAppCollaboratorDelete(appIdentity string, collaboratorIdentity string) error {
return c.Delete("/organizations/apps/" + appIdentity + "/collaborators/" + collaboratorIdentity)
} | go | {
"resource": ""
} |
q36315 | OrganizationAppCollaboratorInfo | train | func (c *Client) OrganizationAppCollaboratorInfo(appIdentity string, collaboratorIdentity string) (*OrganizationAppCollaborator, error) {
var organizationAppCollaborator OrganizationAppCollaborator
return &organizationAppCollaborator, c.Get(&organizationAppCollaborator, "/organizations/apps/"+appIdentity+"/collaborat... | go | {
"resource": ""
} |
q36316 | OrganizationAppCollaboratorList | train | func (c *Client) OrganizationAppCollaboratorList(appIdentity string, lr *ListRange) ([]OrganizationAppCollaborator, error) {
req, err := c.NewRequest("GET", "/organizations/apps/"+appIdentity+"/collaborators", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationApp... | go | {
"resource": ""
} |
q36317 | Transform | train | func Transform(s Scheduler, fn func(*Manifest) *Manifest) Scheduler {
return &transformer{s, fn}
} | go | {
"resource": ""
} |
q36318 | Env | train | func Env(app *Manifest, process *Process) map[string]string {
return merge(app.Env, process.Env)
} | go | {
"resource": ""
} |
q36319 | Labels | train | func Labels(app *Manifest, process *Process) map[string]string {
return merge(app.Labels, process.Labels)
} | go | {
"resource": ""
} |
q36320 | merge | train | func merge(envs ...map[string]string) map[string]string {
merged := make(map[string]string)
for _, env := range envs {
for k, v := range env {
merged[k] = v
}
}
return merged
} | go | {
"resource": ""
} |
q36321 | matchesCommand | train | func matchesCommand(cmd *Command, want string) bool {
if cmd.Alias != "" && cmd.Alias == want {
return true
}
return cmd.Name() == want
} | go | {
"resource": ""
} |
q36322 | UnixTime | train | func (t Time) UnixTime() (sec, nsec int64) {
sec = int64(t - g1582ns100)
nsec = (sec % 10000000) * 100
sec /= 10000000
return sec, nsec
} | go | {
"resource": ""
} |
q36323 | Time | train | func (uuid UUID) Time() (Time, bool) {
if len(uuid) != 16 {
return 0, false
}
time := int64(binary.BigEndian.Uint32(uuid[0:4]))
time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
return Time(time), true
} | go | {
"resource": ""
} |
q36324 | ClockSequence | train | func (uuid UUID) ClockSequence() (int, bool) {
if len(uuid) != 16 {
return 0, false
}
return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true
} | go | {
"resource": ""
} |
q36325 | newConfig | train | func newConfig(old *Config, vars Vars) *Config {
v := mergeVars(old.Vars, vars)
return &Config{
AppID: old.AppID,
Vars: v,
}
} | go | {
"resource": ""
} |
q36326 | configsFind | train | func configsFind(db *gorm.DB, scope scope) (*Config, error) {
var config Config
scope = composedScope{order("created_at desc"), scope}
return &config, first(db, scope, &config)
} | go | {
"resource": ""
} |
q36327 | configsCreate | train | func configsCreate(db *gorm.DB, config *Config) (*Config, error) {
return config, db.Create(config).Error
} | go | {
"resource": ""
} |
q36328 | Config | train | func (s *configsService) Config(db *gorm.DB, app *App) (*Config, error) {
r, err := releasesFind(db, ReleasesQuery{App: app})
if err != nil {
if err == gorm.RecordNotFound {
// It's possible to have config without releases, this handles that.
c, err := configsFind(db, ConfigsQuery{App: app})
if err != nil ... | go | {
"resource": ""
} |
q36329 | mergeVars | train | func mergeVars(old, new Vars) Vars {
vars := make(Vars)
for n, v := range old {
vars[n] = v
}
for n, v := range new {
if v == nil {
delete(vars, n)
} else {
vars[n] = v
}
}
return vars
} | go | {
"resource": ""
} |
q36330 | configsApplyReleaseDesc | train | func configsApplyReleaseDesc(opts SetOpts) string {
vars := opts.Vars
verb := "Set"
plural := ""
if len(vars) > 1 {
plural = "s"
}
keys := make(sort.StringSlice, 0, len(vars))
for k, v := range vars {
keys = append(keys, string(k))
if v == nil {
verb = "Unset"
}
}
keys.Sort()
desc := fmt.Sprintf("... | go | {
"resource": ""
} |
q36331 | WithStats | train | func WithStats(ctx context.Context, stats Stats) context.Context {
return context.WithValue(ctx, statsKey, stats)
} | go | {
"resource": ""
} |
q36332 | FromContext | train | func FromContext(ctx context.Context) (Stats, bool) {
stats, ok := ctx.Value(statsKey).(Stats)
return stats, ok
} | go | {
"resource": ""
} |
q36333 | WithTags | train | func WithTags(ctx context.Context, tags []string) context.Context {
stats, ok := FromContext(ctx)
if !ok {
return ctx
}
return WithStats(ctx, &taggedStats{tags, stats})
} | go | {
"resource": ""
} |
q36334 | domainsFind | train | func domainsFind(db *gorm.DB, scope scope) (*Domain, error) {
var domain Domain
return &domain, first(db, scope, &domain)
} | go | {
"resource": ""
} |
q36335 | domains | train | func domains(db *gorm.DB, scope scope) ([]*Domain, error) {
var domains []*Domain
return domains, find(db, scope, &domains)
} | go | {
"resource": ""
} |
q36336 | ConfigVarInfo | train | func (c *Client) ConfigVarInfo(appIdentity string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, "/apps/"+appIdentity+"/config-vars")
} | go | {
"resource": ""
} |
q36337 | ConfigVarInfoByReleaseVersion | train | func (c *Client) ConfigVarInfoByReleaseVersion(appIdentity, version string) (map[string]string, error) {
var configVar map[string]string
return configVar, c.Get(&configVar, fmt.Sprintf("/apps/%s/config-vars/%s", appIdentity, version))
} | go | {
"resource": ""
} |
q36338 | quote | train | func quote(s string) string {
b, _ := json.Marshal(s)
return string(b)
} | go | {
"resource": ""
} |
q36339 | AccountFeatureInfo | train | func (c *Client) AccountFeatureInfo(accountFeatureIdentity string) (*AccountFeature, error) {
var accountFeature AccountFeature
return &accountFeature, c.Get(&accountFeature, "/account/features/"+accountFeatureIdentity)
} | go | {
"resource": ""
} |
q36340 | AccountFeatureList | train | func (c *Client) AccountFeatureList(lr *ListRange) ([]AccountFeature, error) {
req, err := c.NewRequest("GET", "/account/features", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var accountFeaturesRes []AccountFeature
return accountFeaturesRes, c.DoReq(req, &accountFeatures... | go | {
"resource": ""
} |
q36341 | AccountFeatureUpdate | train | func (c *Client) AccountFeatureUpdate(accountFeatureIdentity string, enabled bool) (*AccountFeature, error) {
params := struct {
Enabled bool `json:"enabled"`
}{
Enabled: enabled,
}
var accountFeatureRes AccountFeature
return &accountFeatureRes, c.Patch(&accountFeatureRes, "/account/features/"+accountFeatureId... | go | {
"resource": ""
} |
q36342 | OpenDB | train | func OpenDB(uri string) (*DB, error) {
_, err := url.Parse(uri)
if err != nil {
return nil, err
}
conn, err := sql.Open(DBDriver, uri)
if err != nil {
return nil, err
}
return NewDB(conn)
} | go | {
"resource": ""
} |
q36343 | NewDB | train | func NewDB(conn *sql.DB) (*DB, error) {
db, err := gorm.Open(DBDriver, conn)
if err != nil {
return nil, err
}
m := migrate.NewPostgresMigrator(conn)
// Run all migrations in a single transaction, so they will be rolled
// back as one. This is almost always the behavior that users would want
// when upgrading... | go | {
"resource": ""
} |
q36344 | MigrateUp | train | func (db *DB) MigrateUp() error {
return db.migrator.Exec(migrate.Up, db.migrations()...)
} | go | {
"resource": ""
} |
q36345 | Reset | train | func (db *DB) Reset() error {
var err error
exec := func(sql string) {
if err == nil {
err = db.Exec(sql).Error
}
}
exec(`TRUNCATE TABLE apps CASCADE`)
exec(`TRUNCATE TABLE ports CASCADE`)
exec(`TRUNCATE TABLE slugs CASCADE`)
exec(`UPDATE ports SET app_id = NULL`)
return err
} | go | {
"resource": ""
} |
q36346 | IsHealthy | train | func (db *DB) IsHealthy() error {
if err := db.DB.DB().Ping(); err != nil {
return err
}
if err := db.CheckSchemaVersion(); err != nil {
return err
}
return nil
} | go | {
"resource": ""
} |
q36347 | CheckSchemaVersion | train | func (db *DB) CheckSchemaVersion() error {
schemaVersion, err := db.SchemaVersion()
if err != nil {
return fmt.Errorf("error fetching schema version: %v", err)
}
expectedSchemaVersion := db.schema().latestSchema()
if schemaVersion != expectedSchemaVersion {
return &IncompatibleSchemaError{
SchemaVersion: ... | go | {
"resource": ""
} |
q36348 | SchemaVersion | train | func (db *DB) SchemaVersion() (int, error) {
sql := `select version from schema_migrations order by version desc limit 1`
var schemaVersion int
err := db.DB.DB().QueryRow(sql).Scan(&schemaVersion)
return schemaVersion, err
} | go | {
"resource": ""
} |
q36349 | fieldEquals | train | func fieldEquals(field string, v interface{}) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Where(fmt.Sprintf("%s = ?", field), v)
})
} | go | {
"resource": ""
} |
q36350 | preload | train | func preload(associations ...string) scope {
var scope composedScope
for _, a := range associations {
aa := a
scope = append(scope, scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Preload(aa)
}))
}
return scope
} | go | {
"resource": ""
} |
q36351 | order | train | func order(order string) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Order(order)
})
} | go | {
"resource": ""
} |
q36352 | limit | train | func limit(limit int) scope {
return scopeFunc(func(db *gorm.DB) *gorm.DB {
return db.Limit(limit)
})
} | go | {
"resource": ""
} |
q36353 | inRange | train | func inRange(r headerutil.Range) scope {
var scope composedScope
if r.Max != nil {
scope = append(scope, limit(*r.Max))
}
if r.Sort != nil && r.Order != nil {
o := fmt.Sprintf("%s %s", *r.Sort, *r.Order)
scope = append(scope, order(o))
}
return scope
} | go | {
"resource": ""
} |
q36354 | first | train | func first(db *gorm.DB, scope scope, v interface{}) error {
return scope.scope(db).First(v).Error
} | go | {
"resource": ""
} |
q36355 | find | train | func find(db *gorm.DB, scope scope, v interface{}) error {
return scope.scope(db).Find(v).Error
} | go | {
"resource": ""
} |
q36356 | FakePull | train | func FakePull(img image.Image, w io.Writer) error {
messages := []jsonmessage.JSONMessage{
{Status: fmt.Sprintf("Pulling repository %s", img.Repository)},
{Status: fmt.Sprintf("Pulling image (%s) from %s", img.Tag, img.Repository), Progress: &jsonmessage.JSONProgress{}, ID: "345c7524bc96"},
{Status: fmt.Sprintf(... | go | {
"resource": ""
} |
q36357 | PullImageOptions | train | func PullImageOptions(img image.Image) (docker.PullImageOptions, error) {
var options docker.PullImageOptions
// From the Docker API docs:
//
// Tag or digest. If empty when pulling an image, this
// causes all tags for the given image to be pulled.
//
// So, we prefer the digest if it's provided.
tag := img.D... | go | {
"resource": ""
} |
q36358 | DecodeJSONMessageStream | train | func DecodeJSONMessageStream(w io.Writer) *DecodedJSONMessageWriter {
outFd, _ := term.GetFdInfo(w)
return &DecodedJSONMessageWriter{
w: w,
fd: outFd,
}
} | go | {
"resource": ""
} |
q36359 | Write | train | func (w *DecodedJSONMessageWriter) Write(b []byte) (int, error) {
err := jsonmessage.DisplayJSONMessagesStream(bytes.NewReader(b), w.w, w.fd, false, nil)
if err != nil {
if err, ok := err.(*jsonmessage.JSONError); ok {
w.err = err
return len(b), nil
}
}
return len(b), err
} | go | {
"resource": ""
} |
q36360 | OrganizationList | train | func (c *Client) OrganizationList(lr *ListRange) ([]Organization, error) {
req, err := c.NewRequest("GET", "/organizations", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var organizationsRes []Organization
return organizationsRes, c.DoReq(req, &organizationsRes)
} | go | {
"resource": ""
} |
q36361 | OrganizationUpdate | train | func (c *Client) OrganizationUpdate(organizationIdentity string, options *OrganizationUpdateOpts) (*Organization, error) {
var organizationRes Organization
return &organizationRes, c.Patch(&organizationRes, "/organizations/"+organizationIdentity, options)
} | go | {
"resource": ""
} |
q36362 | AccountUpdate | train | func (c *Client) AccountUpdate(password string, options *AccountUpdateOpts) (*Account, error) {
params := struct {
Password string `json:"password"`
AllowTracking *bool `json:"allow_tracking,omitempty"`
Beta *bool `json:"beta,omitempty"`
Name *string `json:"name,omitempty"`
}{
Pa... | go | {
"resource": ""
} |
q36363 | AccountChangeEmail | train | func (c *Client) AccountChangeEmail(password string, email string) (*Account, error) {
params := struct {
Password string `json:"password"`
Email string `json:"email"`
}{
Password: password,
Email: email,
}
var accountRes Account
return &accountRes, c.Patch(&accountRes, "/account", params)
} | go | {
"resource": ""
} |
q36364 | AccountChangePassword | train | func (c *Client) AccountChangePassword(newPassword string, password string) (*Account, error) {
params := struct {
NewPassword string `json:"new_password"`
Password string `json:"password"`
}{
NewPassword: newPassword,
Password: password,
}
var accountRes Account
return &accountRes, c.Patch(&accountR... | go | {
"resource": ""
} |
q36365 | newContext | train | func newContext(c *cli.Context) (ctx *Context, err error) {
ctx = &Context{
Context: c,
netCtx: context.Background(),
}
ctx.reporter, err = newReporter(ctx)
if err != nil {
return
}
ctx.logger, err = newLogger(ctx)
if err != nil {
return
}
ctx.stats, err = newStats(ctx)
if err != nil {
return
}... | go | {
"resource": ""
} |
q36366 | ClientConfig | train | func (c *Context) ClientConfig(serviceName string, cfgs ...*aws.Config) client.Config {
if c.awsConfigProvider == nil {
c.awsConfigProvider = newConfigProvider(c)
}
return c.awsConfigProvider.ClientConfig(serviceName, cfgs...)
} | go | {
"resource": ""
} |
q36367 | FormationInfo | train | func (c *Client) FormationInfo(appIdentity string, formationIdentity string) (*Formation, error) {
var formation Formation
return &formation, c.Get(&formation, "/apps/"+appIdentity+"/formation/"+formationIdentity)
} | go | {
"resource": ""
} |
q36368 | FormationList | train | func (c *Client) FormationList(appIdentity string, lr *ListRange) ([]Formation, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/formation", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var formationsRes []Formation
return formationsRes, c.DoReq(req, &format... | go | {
"resource": ""
} |
q36369 | FormationBatchUpdate | train | func (c *Client) FormationBatchUpdate(appIdentity string, updates []FormationBatchUpdateOpts, message string) ([]Formation, error) {
params := struct {
Updates []FormationBatchUpdateOpts `json:"updates"`
}{
Updates: updates,
}
rh := RequestHeaders{CommitMessage: message}
var formationsRes []Formation
return f... | go | {
"resource": ""
} |
q36370 | FormationUpdate | train | func (c *Client) FormationUpdate(appIdentity string, formationIdentity string, options *FormationUpdateOpts) (*Formation, error) {
var formationRes Formation
return &formationRes, c.Patch(&formationRes, "/apps/"+appIdentity+"/formation/"+formationIdentity, options)
} | go | {
"resource": ""
} |
q36371 | NotifyTugboat | train | func NotifyTugboat(d Deployer, url string) *TugboatDeployer {
c := tugboat.NewClient(nil)
c.URL = url
return &TugboatDeployer{
deployer: d,
client: c,
}
} | go | {
"resource": ""
} |
q36372 | DeployAsync | train | func DeployAsync(d Deployer) Deployer {
return DeployerFunc(func(ctx context.Context, event events.Deployment, w io.Writer) error {
go d.Deploy(ctx, event, w)
return nil
})
} | go | {
"resource": ""
} |
q36373 | AddonCreate | train | func (c *Client) AddonCreate(appIdentity string, plan string, options *AddonCreateOpts) (*Addon, error) {
params := struct {
Plan string `json:"plan"`
Config *map[string]string `json:"config,omitempty"`
}{
Plan: plan,
}
if options != nil {
params.Config = options.Config
}
var addonRes Addon
... | go | {
"resource": ""
} |
q36374 | AddonDelete | train | func (c *Client) AddonDelete(appIdentity string, addonIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/addons/" + addonIdentity)
} | go | {
"resource": ""
} |
q36375 | AddonInfo | train | func (c *Client) AddonInfo(appIdentity string, addonIdentity string) (*Addon, error) {
var addon Addon
return &addon, c.Get(&addon, "/apps/"+appIdentity+"/addons/"+addonIdentity)
} | go | {
"resource": ""
} |
q36376 | AddonList | train | func (c *Client) AddonList(appIdentity string, lr *ListRange) ([]Addon, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/addons", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var addonsRes []Addon
return addonsRes, c.DoReq(req, &addonsRes)
} | go | {
"resource": ""
} |
q36377 | AddonUpdate | train | func (c *Client) AddonUpdate(appIdentity string, addonIdentity string, plan string) (*Addon, error) {
params := struct {
Plan string `json:"plan"`
}{
Plan: plan,
}
var addonRes Addon
return &addonRes, c.Patch(&addonRes, "/apps/"+appIdentity+"/addons/"+addonIdentity, params)
} | go | {
"resource": ""
} |
q36378 | StackInfo | train | func (c *Client) StackInfo(stackIdentity string) (*Stack, error) {
var stack Stack
return &stack, c.Get(&stack, "/stacks/"+stackIdentity)
} | go | {
"resource": ""
} |
q36379 | StackList | train | func (c *Client) StackList(lr *ListRange) ([]Stack, error) {
req, err := c.NewRequest("GET", "/stacks", nil, nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var stacksRes []Stack
return stacksRes, c.DoReq(req, &stacksRes)
} | go | {
"resource": ""
} |
q36380 | ParsedProcfile | train | func (s *Slug) ParsedProcfile() (procfile.Procfile, error) {
return procfile.ParseProcfile(s.Procfile)
} | go | {
"resource": ""
} |
q36381 | Formation | train | func (s *Slug) Formation() (Formation, error) {
p, err := s.ParsedProcfile()
if err != nil {
return nil, err
}
return formationFromProcfile(p)
} | go | {
"resource": ""
} |
q36382 | Create | train | func (s *slugsService) Create(ctx context.Context, db *gorm.DB, img image.Image, w *DeploymentStream) (*Slug, error) {
return slugsCreateByImage(ctx, db, s.ImageRegistry, img, w)
} | go | {
"resource": ""
} |
q36383 | slugsCreate | train | func slugsCreate(db *gorm.DB, slug *Slug) (*Slug, error) {
return slug, db.Create(slug).Error
} | go | {
"resource": ""
} |
q36384 | slugsCreateByImage | train | func slugsCreateByImage(ctx context.Context, db *gorm.DB, r ImageRegistry, img image.Image, w *DeploymentStream) (*Slug, error) {
var (
slug Slug
err error
)
slug.Image, err = r.Resolve(ctx, img, w.Stream)
if err != nil {
return nil, fmt.Errorf("resolving %s: %v", img, err)
}
slug.Procfile, err = r.Extra... | go | {
"resource": ""
} |
q36385 | Get | train | func (a *dbPortAllocator) Get() (int64, error) {
sql := `UPDATE ports SET taken = true WHERE port = (SELECT port FROM ports WHERE taken IS NULL ORDER BY port ASC LIMIT 1) RETURNING port`
var port int64
err := a.db.QueryRow(sql).Scan(&port)
return port, err
} | go | {
"resource": ""
} |
q36386 | Put | train | func (a *dbPortAllocator) Put(port int64) error {
sql := `UPDATE ports SET taken = NULL WHERE port = $1`
_, err := a.db.Exec(sql, port)
return err
} | go | {
"resource": ""
} |
q36387 | newECSClient | train | func newECSClient(config client.ConfigProvider) *ecs.ECS {
return ecs.New(config, &aws.Config{
Retryer: newRetryer(),
})
} | go | {
"resource": ""
} |
q36388 | New | train | func New(e *empire.Empire) *Server {
r := &Server{
Empire: e,
mux: mux.NewRouter(),
}
// Apps
r.handle("GET", "/apps", r.GetApps) // hk apps
r.handle("GET", "/apps/{app}", r.GetAppInfo) // hk info
r.handle("DELETE", "/apps/{app}", r.DeleteApp) // hk destroy
r.handle("PATCH"... | go | {
"resource": ""
} |
q36389 | AuthWith | train | func (r *route) AuthWith(strategies ...string) *route {
r.authStrategies = strategies
return r
} | go | {
"resource": ""
} |
q36390 | handle | train | func (s *Server) handle(method, path string, h handlerFunc, authStrategy ...string) *route {
r := s.route(h)
s.mux.Handle(path, r).Methods(method)
return r
} | go | {
"resource": ""
} |
q36391 | route | train | func (s *Server) route(h handlerFunc) *route {
name := handlerName(h)
return &route{Name: name, handler: h, s: s}
} | go | {
"resource": ""
} |
q36392 | Encode | train | func Encode(w http.ResponseWriter, v interface{}) error {
if v == nil {
// Empty JSON body "{}"
v = map[string]interface{}{}
}
return json.NewEncoder(w).Encode(v)
} | go | {
"resource": ""
} |
q36393 | DecodeRequest | train | func DecodeRequest(r *http.Request, v interface{}, ignoreEOF bool) error {
if err := json.NewDecoder(r.Body).Decode(v); err != nil {
if err == io.EOF && ignoreEOF {
return nil
}
return fmt.Errorf("error decoding request body: %v", err)
}
return nil
} | go | {
"resource": ""
} |
q36394 | Decode | train | func Decode(r *http.Request, v interface{}) error {
return DecodeRequest(r, v, false)
} | go | {
"resource": ""
} |
q36395 | Stream | train | func Stream(w http.ResponseWriter, v interface{}) error {
if err := Encode(w, v); err != nil {
return err
}
if f, ok := w.(http.Flusher); ok {
f.Flush()
}
return nil
} | go | {
"resource": ""
} |
q36396 | NoContent | train | func NoContent(w http.ResponseWriter) error {
w.WriteHeader(http.StatusNoContent)
return nil
} | go | {
"resource": ""
} |
q36397 | RangeHeader | train | func RangeHeader(r *http.Request) (headerutil.Range, error) {
header := r.Header.Get("Range")
if header == "" {
return headerutil.Range{}, nil
}
rangeHeader, err := headerutil.ParseRange(header)
if err != nil {
return headerutil.Range{}, err
}
return *rangeHeader, nil
} | go | {
"resource": ""
} |
q36398 | handlerName | train | func handlerName(h handlerFunc) string {
name := runtime.FuncForPC(reflect.ValueOf(h).Pointer()).Name()
parts := nameRegexp.FindStringSubmatch(name)
if len(parts) != 2 {
return ""
}
return parts[1]
} | go | {
"resource": ""
} |
q36399 | SAMLLogin | train | func (s *Server) SAMLLogin(w http.ResponseWriter, r *http.Request) {
if s.ServiceProvider == nil {
http.NotFound(w, r)
return
}
// TODO(ejholmes): Handle error
_ = s.ServiceProvider.InitiateLogin(w)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.