id int32 0 167k | 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 listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
123,800 | manifoldco/torus-cli | registry/orgs.go | Create | func (o *OrgsClient) Create(ctx context.Context, name string) (*envelope.Org, error) {
org := orgCreateRequest{}
org.Body.Name = name
res := envelope.Org{}
err := o.client.RoundTrip(ctx, "POST", "/orgs", nil, &org, &res)
return &res, err
} | go | func (o *OrgsClient) Create(ctx context.Context, name string) (*envelope.Org, error) {
org := orgCreateRequest{}
org.Body.Name = name
res := envelope.Org{}
err := o.client.RoundTrip(ctx, "POST", "/orgs", nil, &org, &res)
return &res, err
} | [
"func",
"(",
"o",
"*",
"OrgsClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"envelope",
".",
"Org",
",",
"error",
")",
"{",
"org",
":=",
"orgCreateRequest",
"{",
"}",
"\n",
"org",
".",
"Body",
".... | // Create creates a new org with the given name. It returns the newly-created org. | [
"Create",
"creates",
"a",
"new",
"org",
"with",
"the",
"given",
"name",
".",
"It",
"returns",
"the",
"newly",
"-",
"created",
"org",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/orgs.go#L38-L45 |
123,801 | manifoldco/torus-cli | registry/orgs.go | Get | func (o *OrgsClient) Get(ctx context.Context, orgID *identity.ID) (*envelope.Org, error) {
org := envelope.Org{}
err := o.client.RoundTrip(ctx, "GET", "/orgs/"+orgID.String(), nil, nil, &org)
return &org, err
} | go | func (o *OrgsClient) Get(ctx context.Context, orgID *identity.ID) (*envelope.Org, error) {
org := envelope.Org{}
err := o.client.RoundTrip(ctx, "GET", "/orgs/"+orgID.String(), nil, nil, &org)
return &org, err
} | [
"func",
"(",
"o",
"*",
"OrgsClient",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"*",
"identity",
".",
"ID",
")",
"(",
"*",
"envelope",
".",
"Org",
",",
"error",
")",
"{",
"org",
":=",
"envelope",
".",
"Org",
"{",
"}",
"\n",
... | // Get returns the organization with the given ID. | [
"Get",
"returns",
"the",
"organization",
"with",
"the",
"given",
"ID",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/orgs.go#L48-L52 |
123,802 | manifoldco/torus-cli | registry/orgs.go | List | func (o *OrgsClient) List(ctx context.Context) ([]envelope.Org, error) {
var orgs []envelope.Org
err := o.client.RoundTrip(ctx, "GET", "/orgs", nil, nil, &orgs)
return orgs, err
} | go | func (o *OrgsClient) List(ctx context.Context) ([]envelope.Org, error) {
var orgs []envelope.Org
err := o.client.RoundTrip(ctx, "GET", "/orgs", nil, nil, &orgs)
return orgs, err
} | [
"func",
"(",
"o",
"*",
"OrgsClient",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"envelope",
".",
"Org",
",",
"error",
")",
"{",
"var",
"orgs",
"[",
"]",
"envelope",
".",
"Org",
"\n",
"err",
":=",
"o",
".",
"client",
... | // List returns all organizations that the signed-in user has access to | [
"List",
"returns",
"all",
"organizations",
"that",
"the",
"signed",
"-",
"in",
"user",
"has",
"access",
"to"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/orgs.go#L75-L79 |
123,803 | manifoldco/torus-cli | registry/orgs.go | RemoveMember | func (o *OrgsClient) RemoveMember(ctx context.Context, orgID identity.ID,
userID identity.ID) error {
path := "/orgs/" + orgID.String() + "/members/" + userID.String()
return o.client.RoundTrip(ctx, "DELETE", path, nil, nil, nil)
} | go | func (o *OrgsClient) RemoveMember(ctx context.Context, orgID identity.ID,
userID identity.ID) error {
path := "/orgs/" + orgID.String() + "/members/" + userID.String()
return o.client.RoundTrip(ctx, "DELETE", path, nil, nil, nil)
} | [
"func",
"(",
"o",
"*",
"OrgsClient",
")",
"RemoveMember",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"identity",
".",
"ID",
",",
"userID",
"identity",
".",
"ID",
")",
"error",
"{",
"path",
":=",
"\"",
"\"",
"+",
"orgID",
".",
"String",
"(",... | // RemoveMember removes a user from an org | [
"RemoveMember",
"removes",
"a",
"user",
"from",
"an",
"org"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/orgs.go#L82-L87 |
123,804 | manifoldco/torus-cli | registry/orgs.go | GetTree | func (o *OrgsClient) GetTree(ctx context.Context, orgID identity.ID) ([]OrgTreeSegment, error) {
v := &url.Values{}
v.Set("org_id", orgID.String())
var segments []OrgTreeSegment
err := o.client.RoundTrip(ctx, "GET", "/orgtree", v, nil, &segments)
return segments, err
} | go | func (o *OrgsClient) GetTree(ctx context.Context, orgID identity.ID) ([]OrgTreeSegment, error) {
v := &url.Values{}
v.Set("org_id", orgID.String())
var segments []OrgTreeSegment
err := o.client.RoundTrip(ctx, "GET", "/orgtree", v, nil, &segments)
return segments, err
} | [
"func",
"(",
"o",
"*",
"OrgsClient",
")",
"GetTree",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"identity",
".",
"ID",
")",
"(",
"[",
"]",
"OrgTreeSegment",
",",
"error",
")",
"{",
"v",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n",
"... | // GetTree returns an org tree | [
"GetTree",
"returns",
"an",
"org",
"tree"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/orgs.go#L90-L97 |
123,805 | manifoldco/torus-cli | daemon/logic/machine.go | CreateToken | func (m *Machine) CreateToken(ctx context.Context, notifier *observer.Notifier,
machine *envelope.Machine, secret *base64.Value) (*registry.MachineTokenCreationSegment, error) {
n := notifier.Notifier(2)
n.Notify(observer.Progress, "Generating machine token", true)
salt, err := crypto.GenerateSalt(ctx)
if err != ... | go | func (m *Machine) CreateToken(ctx context.Context, notifier *observer.Notifier,
machine *envelope.Machine, secret *base64.Value) (*registry.MachineTokenCreationSegment, error) {
n := notifier.Notifier(2)
n.Notify(observer.Progress, "Generating machine token", true)
salt, err := crypto.GenerateSalt(ctx)
if err != ... | [
"func",
"(",
"m",
"*",
"Machine",
")",
"CreateToken",
"(",
"ctx",
"context",
".",
"Context",
",",
"notifier",
"*",
"observer",
".",
"Notifier",
",",
"machine",
"*",
"envelope",
".",
"Machine",
",",
"secret",
"*",
"base64",
".",
"Value",
")",
"(",
"*",
... | // CreateToken generates a new machine token given a machine and a secret value. | [
"CreateToken",
"generates",
"a",
"new",
"machine",
"token",
"given",
"a",
"machine",
"and",
"a",
"secret",
"value",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/machine.go#L33-L107 |
123,806 | manifoldco/torus-cli | daemon/logic/machine.go | EncodeToken | func (m *Machine) EncodeToken(ctx context.Context, notifier *observer.Notifier,
token *envelope.MachineToken) error {
n := notifier.Notifier(2)
n.Notify(observer.Progress, "Creating keyring memberships for token", true)
v1members, v2members, err := createKeyringMemberships(ctx, m.engine.crypto,
m.engine.client... | go | func (m *Machine) EncodeToken(ctx context.Context, notifier *observer.Notifier,
token *envelope.MachineToken) error {
n := notifier.Notifier(2)
n.Notify(observer.Progress, "Creating keyring memberships for token", true)
v1members, v2members, err := createKeyringMemberships(ctx, m.engine.crypto,
m.engine.client... | [
"func",
"(",
"m",
"*",
"Machine",
")",
"EncodeToken",
"(",
"ctx",
"context",
".",
"Context",
",",
"notifier",
"*",
"observer",
".",
"Notifier",
",",
"token",
"*",
"envelope",
".",
"MachineToken",
")",
"error",
"{",
"n",
":=",
"notifier",
".",
"Notifier",... | // EncodeToken creates KeyringMemberships for the provided Machine Token. Used
// during the machine creation process | [
"EncodeToken",
"creates",
"KeyringMemberships",
"for",
"the",
"provided",
"Machine",
"Token",
".",
"Used",
"during",
"the",
"machine",
"creation",
"process"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/machine.go#L111-L143 |
123,807 | manifoldco/torus-cli | daemon/logic/credential_graph_set.go | Active | func (cgs *credentialGraphSet) Active() ([]registry.CredentialGraph, error) {
active := make([]registry.CredentialGraph, 0, len(cgs.graphs))
for _, graphs := range cgs.graphs {
// parents is the slice of IDs already seen in Previous fields.
// they cannot be active as they have been overwritten.
var parents [... | go | func (cgs *credentialGraphSet) Active() ([]registry.CredentialGraph, error) {
active := make([]registry.CredentialGraph, 0, len(cgs.graphs))
for _, graphs := range cgs.graphs {
// parents is the slice of IDs already seen in Previous fields.
// they cannot be active as they have been overwritten.
var parents [... | [
"func",
"(",
"cgs",
"*",
"credentialGraphSet",
")",
"Active",
"(",
")",
"(",
"[",
"]",
"registry",
".",
"CredentialGraph",
",",
"error",
")",
"{",
"active",
":=",
"make",
"(",
"[",
"]",
"registry",
".",
"CredentialGraph",
",",
"0",
",",
"len",
"(",
"... | // Active returns a slice of CredentialGraphs that contain credentials that
// are still reachable.
// A credential is reachable if a newer version of the CredentialGraph has not
// replaced its value, and it is not an `unset` Credential. | [
"Active",
"returns",
"a",
"slice",
"of",
"CredentialGraphs",
"that",
"contain",
"credentials",
"that",
"are",
"still",
"reachable",
".",
"A",
"credential",
"is",
"reachable",
"if",
"a",
"newer",
"version",
"of",
"the",
"CredentialGraph",
"has",
"not",
"replaced"... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/credential_graph_set.go#L92-L119 |
123,808 | manifoldco/torus-cli | daemon/logic/credential_graph_set.go | NeedRotation | func (cgs *credentialGraphSet) NeedRotation() ([]RotationReason, error) {
var needRotation []RotationReason
typ := (&primitive.User{}).Type()
for _, graphs := range cgs.graphs {
var parents []identity.ID
sort.Sort(graphSorter(graphs))
for _, graph := range graphs {
var activeCreds []envelope.CredentialInf... | go | func (cgs *credentialGraphSet) NeedRotation() ([]RotationReason, error) {
var needRotation []RotationReason
typ := (&primitive.User{}).Type()
for _, graphs := range cgs.graphs {
var parents []identity.ID
sort.Sort(graphSorter(graphs))
for _, graph := range graphs {
var activeCreds []envelope.CredentialInf... | [
"func",
"(",
"cgs",
"*",
"credentialGraphSet",
")",
"NeedRotation",
"(",
")",
"(",
"[",
"]",
"RotationReason",
",",
"error",
")",
"{",
"var",
"needRotation",
"[",
"]",
"RotationReason",
"\n\n",
"typ",
":=",
"(",
"&",
"primitive",
".",
"User",
"{",
"}",
... | // NeedRotation returns a slice of Credentials that need to be rotated.
//
// A Credential needs to be rotated if its most recent set version is in a
// CredentialGraph version that contains a revocation of a user's share to
// that Keyring. | [
"NeedRotation",
"returns",
"a",
"slice",
"of",
"Credentials",
"that",
"need",
"to",
"be",
"rotated",
".",
"A",
"Credential",
"needs",
"to",
"be",
"rotated",
"if",
"its",
"most",
"recent",
"set",
"version",
"is",
"in",
"a",
"CredentialGraph",
"version",
"that... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/credential_graph_set.go#L173-L211 |
123,809 | manifoldco/torus-cli | daemon/logic/credential_graph_set.go | Head | func (cgs *credentialGraphSet) Head(pe *pathexp.PathExp) (registry.CredentialGraph, error) {
gpe, err := pe.WithInstance("*")
if err != nil {
return nil, err
}
graphs, ok := cgs.graphs[gpe.String()]
if !ok {
return nil, nil
}
sort.Sort(graphSorter(graphs))
return graphs[0], nil
} | go | func (cgs *credentialGraphSet) Head(pe *pathexp.PathExp) (registry.CredentialGraph, error) {
gpe, err := pe.WithInstance("*")
if err != nil {
return nil, err
}
graphs, ok := cgs.graphs[gpe.String()]
if !ok {
return nil, nil
}
sort.Sort(graphSorter(graphs))
return graphs[0], nil
} | [
"func",
"(",
"cgs",
"*",
"credentialGraphSet",
")",
"Head",
"(",
"pe",
"*",
"pathexp",
".",
"PathExp",
")",
"(",
"registry",
".",
"CredentialGraph",
",",
"error",
")",
"{",
"gpe",
",",
"err",
":=",
"pe",
".",
"WithInstance",
"(",
"\"",
"\"",
")",
"\n... | // Head returns the most recent version of a CredentialGraph that would contain
// the given PathExp. | [
"Head",
"returns",
"the",
"most",
"recent",
"version",
"of",
"a",
"CredentialGraph",
"that",
"would",
"contain",
"the",
"given",
"PathExp",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/credential_graph_set.go#L215-L229 |
123,810 | manifoldco/torus-cli | daemon/logic/credential_graph_set.go | HeadCredential | func (cgs *credentialGraphSet) HeadCredential(pe *pathexp.PathExp, name string) (envelope.CredentialInf, error) {
var head envelope.CredentialInf
version := -1
gpe, err := pe.WithInstance("*")
if err != nil {
return nil, err
}
graphs, ok := cgs.graphs[gpe.String()]
if !ok {
return nil, nil
}
sort.Sort(g... | go | func (cgs *credentialGraphSet) HeadCredential(pe *pathexp.PathExp, name string) (envelope.CredentialInf, error) {
var head envelope.CredentialInf
version := -1
gpe, err := pe.WithInstance("*")
if err != nil {
return nil, err
}
graphs, ok := cgs.graphs[gpe.String()]
if !ok {
return nil, nil
}
sort.Sort(g... | [
"func",
"(",
"cgs",
"*",
"credentialGraphSet",
")",
"HeadCredential",
"(",
"pe",
"*",
"pathexp",
".",
"PathExp",
",",
"name",
"string",
")",
"(",
"envelope",
".",
"CredentialInf",
",",
"error",
")",
"{",
"var",
"head",
"envelope",
".",
"CredentialInf",
"\n... | // HeadCredential returns the most recent version of a Credential that shares
// the provided PathExp and Name
//
// A Head Credential need not be in the Head of the CredentialGraph. | [
"HeadCredential",
"returns",
"the",
"most",
"recent",
"version",
"of",
"a",
"Credential",
"that",
"shares",
"the",
"provided",
"PathExp",
"and",
"Name",
"A",
"Head",
"Credential",
"need",
"not",
"be",
"in",
"the",
"Head",
"of",
"the",
"CredentialGraph",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/logic/credential_graph_set.go#L235-L262 |
123,811 | manifoldco/torus-cli | api/client.go | NewDaemonRequest | func (rt *apiRoundTripper) NewDaemonRequest(method, path string,
query *url.Values, body interface{}) (*http.Request, string, error) {
return rt.newRequest(method, daemonAPIVersion, path, query, body)
} | go | func (rt *apiRoundTripper) NewDaemonRequest(method, path string,
query *url.Values, body interface{}) (*http.Request, string, error) {
return rt.newRequest(method, daemonAPIVersion, path, query, body)
} | [
"func",
"(",
"rt",
"*",
"apiRoundTripper",
")",
"NewDaemonRequest",
"(",
"method",
",",
"path",
"string",
",",
"query",
"*",
"url",
".",
"Values",
",",
"body",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Request",
",",
"string",
",",
"error",
... | // NewDaemonRequest constructs a new http.Request, with a body containing the json
// representation of body, if provided. Daemon requests are handled directly
// by the torus daemon. | [
"NewDaemonRequest",
"constructs",
"a",
"new",
"http",
".",
"Request",
"with",
"a",
"body",
"containing",
"the",
"json",
"representation",
"of",
"body",
"if",
"provided",
".",
"Daemon",
"requests",
"are",
"handled",
"directly",
"by",
"the",
"torus",
"daemon",
"... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/api/client.go#L91-L95 |
123,812 | manifoldco/torus-cli | api/client.go | newRequest | func (rt *apiRoundTripper) newRequest(method, prefix, path string,
query *url.Values, body interface{}) (*http.Request, string, error) {
requestID := uuid.NewV4().String()
prefixed := "/" + prefix + path
req, err := rt.DefaultRequestDoer.NewRequest(method, prefixed, query, body)
if err != nil {
return nil, req... | go | func (rt *apiRoundTripper) newRequest(method, prefix, path string,
query *url.Values, body interface{}) (*http.Request, string, error) {
requestID := uuid.NewV4().String()
prefixed := "/" + prefix + path
req, err := rt.DefaultRequestDoer.NewRequest(method, prefixed, query, body)
if err != nil {
return nil, req... | [
"func",
"(",
"rt",
"*",
"apiRoundTripper",
")",
"newRequest",
"(",
"method",
",",
"prefix",
",",
"path",
"string",
",",
"query",
"*",
"url",
".",
"Values",
",",
"body",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Request",
",",
"string",
",",... | // newRequest augments the default to set a unique request id | [
"newRequest",
"augments",
"the",
"default",
"to",
"set",
"a",
"unique",
"request",
"id"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/api/client.go#L105-L119 |
123,813 | manifoldco/torus-cli | api/client.go | DoWithProgress | func (rt *apiRoundTripper) DoWithProgress(ctx context.Context, r *http.Request, v interface{}, reqID string, progress ProgressFunc) (*http.Response, error) {
done := make(chan bool)
req, _, err := rt.newRequest("GET", daemonAPIVersion, "/observe", nil, nil)
if err != nil {
return nil, err
}
stream, err := events... | go | func (rt *apiRoundTripper) DoWithProgress(ctx context.Context, r *http.Request, v interface{}, reqID string, progress ProgressFunc) (*http.Response, error) {
done := make(chan bool)
req, _, err := rt.newRequest("GET", daemonAPIVersion, "/observe", nil, nil)
if err != nil {
return nil, err
}
stream, err := events... | [
"func",
"(",
"rt",
"*",
"apiRoundTripper",
")",
"DoWithProgress",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
",",
"v",
"interface",
"{",
"}",
",",
"reqID",
"string",
",",
"progress",
"ProgressFunc",
")",
"(",
"*",
"ht... | // DoWithProgress executes the HTTP request like Do, in addition to
// connecting the provided ProgressFunc to any server-sent event progress
// messages. | [
"DoWithProgress",
"executes",
"the",
"HTTP",
"request",
"like",
"Do",
"in",
"addition",
"to",
"connecting",
"the",
"provided",
"ProgressFunc",
"to",
"any",
"server",
"-",
"sent",
"event",
"progress",
"messages",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/api/client.go#L124-L166 |
123,814 | manifoldco/torus-cli | daemon/updates/updates.go | NewEngine | func NewEngine(cfg *config.Config, t *http.Transport, options ...func(*Engine)) *Engine {
engine := &Engine{
config: cfg,
stop: make(chan struct{}),
targetVersion: "unknown",
client: &http.Client{Transport: t},
}
for _, opt := range options {
opt(engine)
}
if engine.timeManager =... | go | func NewEngine(cfg *config.Config, t *http.Transport, options ...func(*Engine)) *Engine {
engine := &Engine{
config: cfg,
stop: make(chan struct{}),
targetVersion: "unknown",
client: &http.Client{Transport: t},
}
for _, opt := range options {
opt(engine)
}
if engine.timeManager =... | [
"func",
"NewEngine",
"(",
"cfg",
"*",
"config",
".",
"Config",
",",
"t",
"*",
"http",
".",
"Transport",
",",
"options",
"...",
"func",
"(",
"*",
"Engine",
")",
")",
"*",
"Engine",
"{",
"engine",
":=",
"&",
"Engine",
"{",
"config",
":",
"cfg",
",",
... | // NewEngine creates a new Engine based on the provided config structure.
// It can be extended by passing specific options which alter the initialization
// of the Engine itself. | [
"NewEngine",
"creates",
"a",
"new",
"Engine",
"based",
"on",
"the",
"provided",
"config",
"structure",
".",
"It",
"can",
"be",
"extended",
"by",
"passing",
"specific",
"options",
"which",
"alter",
"the",
"initialization",
"of",
"the",
"Engine",
"itself",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L60-L77 |
123,815 | manifoldco/torus-cli | daemon/updates/updates.go | SetTimeManager | func (e *Engine) SetTimeManager(manager TimeManager) func(*Engine) {
return func(engine *Engine) {
engine.timeManager = manager
}
} | go | func (e *Engine) SetTimeManager(manager TimeManager) func(*Engine) {
return func(engine *Engine) {
engine.timeManager = manager
}
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"SetTimeManager",
"(",
"manager",
"TimeManager",
")",
"func",
"(",
"*",
"Engine",
")",
"{",
"return",
"func",
"(",
"engine",
"*",
"Engine",
")",
"{",
"engine",
".",
"timeManager",
"=",
"manager",
"\n",
"}",
"\n",
... | // SetTimeManager is a configuration function for `NewEngine` which sets the
// Engine's TimeManager instance to the `manager` argument. | [
"SetTimeManager",
"is",
"a",
"configuration",
"function",
"for",
"NewEngine",
"which",
"sets",
"the",
"Engine",
"s",
"TimeManager",
"instance",
"to",
"the",
"manager",
"argument",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L99-L103 |
123,816 | manifoldco/torus-cli | daemon/updates/updates.go | performCheck | func (e *Engine) performCheck() {
log.Printf("Checking for updates to Torus")
latest, err := e.getLatestVersion()
if err != nil {
log.Printf("Could not retrieve latest version of Tours: %s", err)
return
}
e.targetVersion = latest
if err := e.storeLastCheck(); err != nil {
log.Printf("Cannot store the last... | go | func (e *Engine) performCheck() {
log.Printf("Checking for updates to Torus")
latest, err := e.getLatestVersion()
if err != nil {
log.Printf("Could not retrieve latest version of Tours: %s", err)
return
}
e.targetVersion = latest
if err := e.storeLastCheck(); err != nil {
log.Printf("Cannot store the last... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"performCheck",
"(",
")",
"{",
"log",
".",
"Printf",
"(",
"\"",
"\"",
")",
"\n\n",
"latest",
",",
"err",
":=",
"e",
".",
"getLatestVersion",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Printf"... | // performCheck retrieves the latest version of Torus from the manifest and then | [
"performCheck",
"retrieves",
"the",
"latest",
"version",
"of",
"Torus",
"from",
"the",
"manifest",
"and",
"then"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L124-L139 |
123,817 | manifoldco/torus-cli | daemon/updates/updates.go | nextCheck | func (e *Engine) nextCheck() time.Duration {
if !e.lastCheckValid() {
return minCheckDuration
}
return e.hoursToNextRelease()
} | go | func (e *Engine) nextCheck() time.Duration {
if !e.lastCheckValid() {
return minCheckDuration
}
return e.hoursToNextRelease()
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"nextCheck",
"(",
")",
"time",
".",
"Duration",
"{",
"if",
"!",
"e",
".",
"lastCheckValid",
"(",
")",
"{",
"return",
"minCheckDuration",
"\n",
"}",
"\n",
"return",
"e",
".",
"hoursToNextRelease",
"(",
")",
"\n",
... | // nextCheck returns the time duration to wait before triggering an update check.
// It is calculated based on wether there already were a check or enough time
// has passed. By default the check is performed at the `releaseHourCheck`-th hour
// of the `releaseDay` weekday. | [
"nextCheck",
"returns",
"the",
"time",
"duration",
"to",
"wait",
"before",
"triggering",
"an",
"update",
"check",
".",
"It",
"is",
"calculated",
"based",
"on",
"wether",
"there",
"already",
"were",
"a",
"check",
"or",
"enough",
"time",
"has",
"passed",
".",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L145-L150 |
123,818 | manifoldco/torus-cli | daemon/updates/updates.go | lastCheckValid | func (e *Engine) lastCheckValid() bool {
if e.lastCheck.IsZero() {
return false
}
return e.lastCheck.Unix()-e.prevReleaseDay().Unix() >= 0
} | go | func (e *Engine) lastCheckValid() bool {
if e.lastCheck.IsZero() {
return false
}
return e.lastCheck.Unix()-e.prevReleaseDay().Unix() >= 0
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"lastCheckValid",
"(",
")",
"bool",
"{",
"if",
"e",
".",
"lastCheck",
".",
"IsZero",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"e",
".",
"lastCheck",
".",
"Unix",
"(",
")",
"-",
"e",
".",
... | // lastCheckValid checks if the last update check contains the most recent
// update info. | [
"lastCheckValid",
"checks",
"if",
"the",
"last",
"update",
"check",
"contains",
"the",
"most",
"recent",
"update",
"info",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L154-L159 |
123,819 | manifoldco/torus-cli | daemon/updates/updates.go | prevReleaseDay | func (e *Engine) prevReleaseDay() time.Time {
prevRelease := e.midnight(e.timeManager.Now())
day := prevRelease.Weekday()
var dayHours int
if day < releaseDay || (day == releaseDay && prevRelease.Hour() < releaseHourCheck) {
dayHours = 24 * (7 - int(releaseDay-day))
} else if day > releaseDay || (day == releaseD... | go | func (e *Engine) prevReleaseDay() time.Time {
prevRelease := e.midnight(e.timeManager.Now())
day := prevRelease.Weekday()
var dayHours int
if day < releaseDay || (day == releaseDay && prevRelease.Hour() < releaseHourCheck) {
dayHours = 24 * (7 - int(releaseDay-day))
} else if day > releaseDay || (day == releaseD... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"prevReleaseDay",
"(",
")",
"time",
".",
"Time",
"{",
"prevRelease",
":=",
"e",
".",
"midnight",
"(",
"e",
".",
"timeManager",
".",
"Now",
"(",
")",
")",
"\n",
"day",
":=",
"prevRelease",
".",
"Weekday",
"(",
"... | // prevReleaseDay returns the date of the last release day, calculated based on
// the `releaseHourCheck`-th hour of the previous `releaseDay` weekday. | [
"prevReleaseDay",
"returns",
"the",
"date",
"of",
"the",
"last",
"release",
"day",
"calculated",
"based",
"on",
"the",
"releaseHourCheck",
"-",
"th",
"hour",
"of",
"the",
"previous",
"releaseDay",
"weekday",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L163-L175 |
123,820 | manifoldco/torus-cli | daemon/updates/updates.go | hoursToNextRelease | func (e *Engine) hoursToNextRelease() time.Duration {
return e.nextReleaseDay().Sub(e.timeManager.Now())
} | go | func (e *Engine) hoursToNextRelease() time.Duration {
return e.nextReleaseDay().Sub(e.timeManager.Now())
} | [
"func",
"(",
"e",
"*",
"Engine",
")",
"hoursToNextRelease",
"(",
")",
"time",
".",
"Duration",
"{",
"return",
"e",
".",
"nextReleaseDay",
"(",
")",
".",
"Sub",
"(",
"e",
".",
"timeManager",
".",
"Now",
"(",
")",
")",
"\n",
"}"
] | // hoursToNextRelease returns the time delta before the next update check. | [
"hoursToNextRelease",
"returns",
"the",
"time",
"delta",
"before",
"the",
"next",
"update",
"check",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L178-L180 |
123,821 | manifoldco/torus-cli | daemon/updates/updates.go | nextReleaseDay | func (e *Engine) nextReleaseDay() time.Time {
now := e.timeManager.Now()
nextRelease := e.midnight(now).Add(releaseHourCheck * time.Hour)
if nextRelease.Weekday() == releaseDay {
if nextRelease.Unix() <= now.Unix() {
nextRelease = nextRelease.Add(24 * 7 * time.Hour)
}
return nextRelease
}
daysDue := int(... | go | func (e *Engine) nextReleaseDay() time.Time {
now := e.timeManager.Now()
nextRelease := e.midnight(now).Add(releaseHourCheck * time.Hour)
if nextRelease.Weekday() == releaseDay {
if nextRelease.Unix() <= now.Unix() {
nextRelease = nextRelease.Add(24 * 7 * time.Hour)
}
return nextRelease
}
daysDue := int(... | [
"func",
"(",
"e",
"*",
"Engine",
")",
"nextReleaseDay",
"(",
")",
"time",
".",
"Time",
"{",
"now",
":=",
"e",
".",
"timeManager",
".",
"Now",
"(",
")",
"\n",
"nextRelease",
":=",
"e",
".",
"midnight",
"(",
"now",
")",
".",
"Add",
"(",
"releaseHourC... | // nextReleaseDay returns the date of the next release day, calculated based on
// the `releaseHourCheck`-th hour of the next `releaseDay` weekday | [
"nextReleaseDay",
"returns",
"the",
"date",
"of",
"the",
"next",
"release",
"day",
"calculated",
"based",
"on",
"the",
"releaseHourCheck",
"-",
"th",
"hour",
"of",
"the",
"next",
"releaseDay",
"weekday"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L184-L202 |
123,822 | manifoldco/torus-cli | daemon/updates/updates.go | midnight | func (e Engine) midnight(t time.Time) time.Time {
y, m, d := t.Date()
return time.Date(y, m, d, 0, 0, 0, 0, t.Location())
} | go | func (e Engine) midnight(t time.Time) time.Time {
y, m, d := t.Date()
return time.Date(y, m, d, 0, 0, 0, 0, t.Location())
} | [
"func",
"(",
"e",
"Engine",
")",
"midnight",
"(",
"t",
"time",
".",
"Time",
")",
"time",
".",
"Time",
"{",
"y",
",",
"m",
",",
"d",
":=",
"t",
".",
"Date",
"(",
")",
"\n",
"return",
"time",
".",
"Date",
"(",
"y",
",",
"m",
",",
"d",
",",
... | // midnight returns the date of the midnight of the provided time. | [
"midnight",
"returns",
"the",
"date",
"of",
"the",
"midnight",
"of",
"the",
"provided",
"time",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/updates/updates.go#L205-L208 |
123,823 | manifoldco/torus-cli | envelope/envelope.go | ConvertUser | func ConvertUser(e *Unsigned) (UserInf, error) {
var user UserInf
switch e.Version {
case 1:
user = &UserV1{
ID: e.ID,
Version: e.Version,
Body: e.Body.(*primitive.UserV1),
}
case 2:
user = &User{
ID: e.ID,
Version: e.Version,
Body: e.Body.(*primitive.User),
}
default:
r... | go | func ConvertUser(e *Unsigned) (UserInf, error) {
var user UserInf
switch e.Version {
case 1:
user = &UserV1{
ID: e.ID,
Version: e.Version,
Body: e.Body.(*primitive.UserV1),
}
case 2:
user = &User{
ID: e.ID,
Version: e.Version,
Body: e.Body.(*primitive.User),
}
default:
r... | [
"func",
"ConvertUser",
"(",
"e",
"*",
"Unsigned",
")",
"(",
"UserInf",
",",
"error",
")",
"{",
"var",
"user",
"UserInf",
"\n",
"switch",
"e",
".",
"Version",
"{",
"case",
"1",
":",
"user",
"=",
"&",
"UserV1",
"{",
"ID",
":",
"e",
".",
"ID",
",",
... | // ConvertUser converts an unsigned envelope to a UserInf interface which
// provides a common interface for all user versions. | [
"ConvertUser",
"converts",
"an",
"unsigned",
"envelope",
"to",
"a",
"UserInf",
"interface",
"which",
"provides",
"a",
"common",
"interface",
"for",
"all",
"user",
"versions",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/envelope/envelope.go#L138-L158 |
123,824 | manifoldco/torus-cli | envelope/envelope.go | Unset | func (c *Credential) Unset() bool {
return c.Body.State != nil && *c.Body.State == "unset"
} | go | func (c *Credential) Unset() bool {
return c.Body.State != nil && *c.Body.State == "unset"
} | [
"func",
"(",
"c",
"*",
"Credential",
")",
"Unset",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"Body",
".",
"State",
"!=",
"nil",
"&&",
"*",
"c",
".",
"Body",
".",
"State",
"==",
"\"",
"\"",
"\n",
"}"
] | // Unset returns a bool indicating if this Credential has been explicitly unset. | [
"Unset",
"returns",
"a",
"bool",
"indicating",
"if",
"this",
"Credential",
"has",
"been",
"explicitly",
"unset",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/envelope/envelope.go#L300-L302 |
123,825 | manifoldco/torus-cli | registry/keypairs.go | NewKeypairs | func NewKeypairs() *Keypairs {
return &Keypairs{
keypairs: map[identity.ID][]ClaimedKeyPair{},
idIndex: map[identity.ID]ClaimedKeyPair{},
}
} | go | func NewKeypairs() *Keypairs {
return &Keypairs{
keypairs: map[identity.ID][]ClaimedKeyPair{},
idIndex: map[identity.ID]ClaimedKeyPair{},
}
} | [
"func",
"NewKeypairs",
"(",
")",
"*",
"Keypairs",
"{",
"return",
"&",
"Keypairs",
"{",
"keypairs",
":",
"map",
"[",
"identity",
".",
"ID",
"]",
"[",
"]",
"ClaimedKeyPair",
"{",
"}",
",",
"idIndex",
":",
"map",
"[",
"identity",
".",
"ID",
"]",
"Claime... | // NewKeypairs returns an empty keypairs struct | [
"NewKeypairs",
"returns",
"an",
"empty",
"keypairs",
"struct"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L43-L48 |
123,826 | manifoldco/torus-cli | registry/keypairs.go | Add | func (kp *Keypairs) Add(keypairs ...ClaimedKeyPair) error {
for _, k := range keypairs {
kp.idIndex[*k.PublicKey.ID] = k
orgID := *k.PublicKey.Body.OrgID
_, ok := kp.keypairs[orgID]
if !ok {
kp.keypairs[orgID] = []ClaimedKeyPair{k}
continue
}
kp.keypairs[orgID] = append(kp.keypairs[orgID], k)
}
... | go | func (kp *Keypairs) Add(keypairs ...ClaimedKeyPair) error {
for _, k := range keypairs {
kp.idIndex[*k.PublicKey.ID] = k
orgID := *k.PublicKey.Body.OrgID
_, ok := kp.keypairs[orgID]
if !ok {
kp.keypairs[orgID] = []ClaimedKeyPair{k}
continue
}
kp.keypairs[orgID] = append(kp.keypairs[orgID], k)
}
... | [
"func",
"(",
"kp",
"*",
"Keypairs",
")",
"Add",
"(",
"keypairs",
"...",
"ClaimedKeyPair",
")",
"error",
"{",
"for",
"_",
",",
"k",
":=",
"range",
"keypairs",
"{",
"kp",
".",
"idIndex",
"[",
"*",
"k",
".",
"PublicKey",
".",
"ID",
"]",
"=",
"k",
"\... | // Add adds the given keypairs to the list of keypairs | [
"Add",
"adds",
"the",
"given",
"keypairs",
"to",
"the",
"list",
"of",
"keypairs"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L51-L66 |
123,827 | manifoldco/torus-cli | registry/keypairs.go | Get | func (kp *Keypairs) Get(publicKeyID *identity.ID) (*ClaimedKeyPair, error) {
if publicKeyID == nil {
return nil, errors.New("Invalid PublicKeyID provided to get keypair")
}
ckp, ok := kp.idIndex[*publicKeyID]
if !ok {
return nil, ErrPublicKeyNotFound
}
return &ckp, nil
} | go | func (kp *Keypairs) Get(publicKeyID *identity.ID) (*ClaimedKeyPair, error) {
if publicKeyID == nil {
return nil, errors.New("Invalid PublicKeyID provided to get keypair")
}
ckp, ok := kp.idIndex[*publicKeyID]
if !ok {
return nil, ErrPublicKeyNotFound
}
return &ckp, nil
} | [
"func",
"(",
"kp",
"*",
"Keypairs",
")",
"Get",
"(",
"publicKeyID",
"*",
"identity",
".",
"ID",
")",
"(",
"*",
"ClaimedKeyPair",
",",
"error",
")",
"{",
"if",
"publicKeyID",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"... | // Get returns the ClaimedKeyPair for the given public key id | [
"Get",
"returns",
"the",
"ClaimedKeyPair",
"for",
"the",
"given",
"public",
"key",
"id"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L69-L80 |
123,828 | manifoldco/torus-cli | registry/keypairs.go | All | func (kp *Keypairs) All() []ClaimedKeyPair {
out := []ClaimedKeyPair{}
for _, ckp := range kp.idIndex {
out = append(out, ckp)
}
return out
} | go | func (kp *Keypairs) All() []ClaimedKeyPair {
out := []ClaimedKeyPair{}
for _, ckp := range kp.idIndex {
out = append(out, ckp)
}
return out
} | [
"func",
"(",
"kp",
"*",
"Keypairs",
")",
"All",
"(",
")",
"[",
"]",
"ClaimedKeyPair",
"{",
"out",
":=",
"[",
"]",
"ClaimedKeyPair",
"{",
"}",
"\n",
"for",
"_",
",",
"ckp",
":=",
"range",
"kp",
".",
"idIndex",
"{",
"out",
"=",
"append",
"(",
"out"... | // All returns all keypairs including those which have been revoked. | [
"All",
"returns",
"all",
"keypairs",
"including",
"those",
"which",
"have",
"been",
"revoked",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L105-L112 |
123,829 | manifoldco/torus-cli | registry/keypairs.go | Create | func (k *KeyPairsClient) Create(ctx context.Context, pubKey *envelope.PublicKey,
privKey *envelope.PrivateKey, claim *envelope.Claim) (*envelope.PublicKey,
*envelope.PrivateKey, []envelope.Claim, error) {
req := ClaimedKeyPair{
PublicKeySegment: apitypes.PublicKeySegment{
PublicKey: pubKey,
Claims: []env... | go | func (k *KeyPairsClient) Create(ctx context.Context, pubKey *envelope.PublicKey,
privKey *envelope.PrivateKey, claim *envelope.Claim) (*envelope.PublicKey,
*envelope.PrivateKey, []envelope.Claim, error) {
req := ClaimedKeyPair{
PublicKeySegment: apitypes.PublicKeySegment{
PublicKey: pubKey,
Claims: []env... | [
"func",
"(",
"k",
"*",
"KeyPairsClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"pubKey",
"*",
"envelope",
".",
"PublicKey",
",",
"privKey",
"*",
"envelope",
".",
"PrivateKey",
",",
"claim",
"*",
"envelope",
".",
"Claim",
")",
"(",
... | // Create creates a new keypair on the registry.
//
// The keypair includes the user's public key, private key, and a self-signed
// claim on the public key.
//
// keys may be either signing or encryption keys. | [
"Create",
"creates",
"a",
"new",
"keypair",
"on",
"the",
"registry",
".",
"The",
"keypair",
"includes",
"the",
"user",
"s",
"public",
"key",
"private",
"key",
"and",
"a",
"self",
"-",
"signed",
"claim",
"on",
"the",
"public",
"key",
".",
"keys",
"may",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L133-L151 |
123,830 | manifoldco/torus-cli | registry/keypairs.go | List | func (k *KeyPairsClient) List(ctx context.Context, orgID *identity.ID) (*Keypairs, error) {
query := &url.Values{}
if orgID != nil {
query.Set("org_id", orgID.String())
}
var resp []ClaimedKeyPair
err := k.client.RoundTrip(ctx, "GET", "/keypairs", query, nil, &resp)
if err != nil {
return nil, err
}
kp :=... | go | func (k *KeyPairsClient) List(ctx context.Context, orgID *identity.ID) (*Keypairs, error) {
query := &url.Values{}
if orgID != nil {
query.Set("org_id", orgID.String())
}
var resp []ClaimedKeyPair
err := k.client.RoundTrip(ctx, "GET", "/keypairs", query, nil, &resp)
if err != nil {
return nil, err
}
kp :=... | [
"func",
"(",
"k",
"*",
"KeyPairsClient",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"*",
"identity",
".",
"ID",
")",
"(",
"*",
"Keypairs",
",",
"error",
")",
"{",
"query",
":=",
"&",
"url",
".",
"Values",
"{",
"}",
"\n",
"i... | // List returns all KeyPairs for the logged in user in the given, or all orgs
// if orgID is nil. | [
"List",
"returns",
"all",
"KeyPairs",
"for",
"the",
"logged",
"in",
"user",
"in",
"the",
"given",
"or",
"all",
"orgs",
"if",
"orgID",
"is",
"nil",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/keypairs.go#L155-L174 |
123,831 | manifoldco/torus-cli | cmd/machines.go | bootstrapCmd | func bootstrapCmd(ctx *cli.Context) error {
cloud := ctx.String("auth")
resp, err := bootstrap.Do(
bootstrap.Provider(cloud),
ctx.String("url"),
ctx.String("machine"),
ctx.String("org"),
ctx.String("role"),
ctx.String("ca"),
)
if err != nil {
return fmt.Errorf("bootstrap provision failed: %s", err)
... | go | func bootstrapCmd(ctx *cli.Context) error {
cloud := ctx.String("auth")
resp, err := bootstrap.Do(
bootstrap.Provider(cloud),
ctx.String("url"),
ctx.String("machine"),
ctx.String("org"),
ctx.String("role"),
ctx.String("ca"),
)
if err != nil {
return fmt.Errorf("bootstrap provision failed: %s", err)
... | [
"func",
"bootstrapCmd",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cloud",
":=",
"ctx",
".",
"String",
"(",
"\"",
"\"",
")",
"\n\n",
"resp",
",",
"err",
":=",
"bootstrap",
".",
"Do",
"(",
"bootstrap",
".",
"Provider",
"(",
"cloud",
... | // bootstrapCmd is the cli.Command for Bootstrapping machine configuration from the Gatekeeper | [
"bootstrapCmd",
"is",
"the",
"cli",
".",
"Command",
"for",
"Bootstrapping",
"machine",
"configuration",
"from",
"the",
"Gatekeeper"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/machines.go#L446-L469 |
123,832 | manifoldco/torus-cli | registry/machines.go | Create | func (m *MachinesClient) Create(ctx context.Context, machine *envelope.Machine,
memberships []envelope.Membership, token *MachineTokenCreationSegment) (*apitypes.MachineSegment, error) {
segment := MachineCreationSegment{
MachineSegment: apitypes.MachineSegment{
Machine: machine,
Memberships: memberships... | go | func (m *MachinesClient) Create(ctx context.Context, machine *envelope.Machine,
memberships []envelope.Membership, token *MachineTokenCreationSegment) (*apitypes.MachineSegment, error) {
segment := MachineCreationSegment{
MachineSegment: apitypes.MachineSegment{
Machine: machine,
Memberships: memberships... | [
"func",
"(",
"m",
"*",
"MachinesClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"machine",
"*",
"envelope",
".",
"Machine",
",",
"memberships",
"[",
"]",
"envelope",
".",
"Membership",
",",
"token",
"*",
"MachineTokenCreationSegment",
")"... | // Create requests the registry to create a MachineSegment.
//
// The MachineSegment includes the Machine, it's Memberships, and authorization
// tokens. | [
"Create",
"requests",
"the",
"registry",
"to",
"create",
"a",
"MachineSegment",
".",
"The",
"MachineSegment",
"includes",
"the",
"Machine",
"it",
"s",
"Memberships",
"and",
"authorization",
"tokens",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/machines.go#L36-L50 |
123,833 | manifoldco/torus-cli | registry/machines.go | Get | func (m *MachinesClient) Get(ctx context.Context, machineID *identity.ID) (*apitypes.MachineSegment, error) {
resp := &apitypes.MachineSegment{}
err := m.client.RoundTrip(ctx, "GET", "/machines/"+(*machineID).String(), nil, nil, &resp)
return resp, err
} | go | func (m *MachinesClient) Get(ctx context.Context, machineID *identity.ID) (*apitypes.MachineSegment, error) {
resp := &apitypes.MachineSegment{}
err := m.client.RoundTrip(ctx, "GET", "/machines/"+(*machineID).String(), nil, nil, &resp)
return resp, err
} | [
"func",
"(",
"m",
"*",
"MachinesClient",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"machineID",
"*",
"identity",
".",
"ID",
")",
"(",
"*",
"apitypes",
".",
"MachineSegment",
",",
"error",
")",
"{",
"resp",
":=",
"&",
"apitypes",
".",
"M... | // Get requests a single machine from the registry | [
"Get",
"requests",
"a",
"single",
"machine",
"from",
"the",
"registry"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/machines.go#L53-L57 |
123,834 | manifoldco/torus-cli | registry/machines.go | List | func (m *MachinesClient) List(ctx context.Context, orgID *identity.ID, state *string, name *string, teamID *identity.ID) ([]apitypes.MachineSegment, error) {
v := &url.Values{}
if orgID != nil {
v.Add("org_id", (*orgID).String())
}
if state != nil {
v.Add("state", *state)
}
if teamID != nil {
v.Add("team_id... | go | func (m *MachinesClient) List(ctx context.Context, orgID *identity.ID, state *string, name *string, teamID *identity.ID) ([]apitypes.MachineSegment, error) {
v := &url.Values{}
if orgID != nil {
v.Add("org_id", (*orgID).String())
}
if state != nil {
v.Add("state", *state)
}
if teamID != nil {
v.Add("team_id... | [
"func",
"(",
"m",
"*",
"MachinesClient",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
"*",
"identity",
".",
"ID",
",",
"state",
"*",
"string",
",",
"name",
"*",
"string",
",",
"teamID",
"*",
"identity",
".",
"ID",
")",
"(",
"["... | // List machines in the given org and state | [
"List",
"machines",
"in",
"the",
"given",
"org",
"and",
"state"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/machines.go#L60-L78 |
123,835 | manifoldco/torus-cli | registry/machines.go | Destroy | func (m *MachinesClient) Destroy(ctx context.Context, machineID *identity.ID) error {
return m.client.RoundTrip(ctx, "DELETE", "/machines/"+machineID.String(), nil, nil, nil)
} | go | func (m *MachinesClient) Destroy(ctx context.Context, machineID *identity.ID) error {
return m.client.RoundTrip(ctx, "DELETE", "/machines/"+machineID.String(), nil, nil, nil)
} | [
"func",
"(",
"m",
"*",
"MachinesClient",
")",
"Destroy",
"(",
"ctx",
"context",
".",
"Context",
",",
"machineID",
"*",
"identity",
".",
"ID",
")",
"error",
"{",
"return",
"m",
".",
"client",
".",
"RoundTrip",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
... | // Destroy machine by ID | [
"Destroy",
"machine",
"by",
"ID"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/machines.go#L81-L83 |
123,836 | manifoldco/torus-cli | registry/profiles.go | ListByName | func (p *ProfilesClient) ListByName(ctx context.Context, name string) (*apitypes.Profile, error) {
result := &apitypes.Profile{}
err := p.client.RoundTrip(ctx, "GET", "/profiles/"+name, nil, nil, &result)
return result, err
} | go | func (p *ProfilesClient) ListByName(ctx context.Context, name string) (*apitypes.Profile, error) {
result := &apitypes.Profile{}
err := p.client.RoundTrip(ctx, "GET", "/profiles/"+name, nil, nil, &result)
return result, err
} | [
"func",
"(",
"p",
"*",
"ProfilesClient",
")",
"ListByName",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"*",
"apitypes",
".",
"Profile",
",",
"error",
")",
"{",
"result",
":=",
"&",
"apitypes",
".",
"Profile",
"{",
"}",
"\... | // ListByName returns profiles looked up by username | [
"ListByName",
"returns",
"profiles",
"looked",
"up",
"by",
"username"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/profiles.go#L17-L21 |
123,837 | manifoldco/torus-cli | registry/profiles.go | ListByID | func (p *ProfilesClient) ListByID(ctx context.Context, userIDs []identity.ID) ([]apitypes.Profile, error) {
v := &url.Values{}
for _, id := range userIDs {
v.Add("id", id.String())
}
var results []apitypes.Profile
err := p.client.RoundTrip(ctx, "GET", "/profiles", v, nil, &results)
return results, err
} | go | func (p *ProfilesClient) ListByID(ctx context.Context, userIDs []identity.ID) ([]apitypes.Profile, error) {
v := &url.Values{}
for _, id := range userIDs {
v.Add("id", id.String())
}
var results []apitypes.Profile
err := p.client.RoundTrip(ctx, "GET", "/profiles", v, nil, &results)
return results, err
} | [
"func",
"(",
"p",
"*",
"ProfilesClient",
")",
"ListByID",
"(",
"ctx",
"context",
".",
"Context",
",",
"userIDs",
"[",
"]",
"identity",
".",
"ID",
")",
"(",
"[",
"]",
"apitypes",
".",
"Profile",
",",
"error",
")",
"{",
"v",
":=",
"&",
"url",
".",
... | // ListByID returns profiles looked up by User ID | [
"ListByID",
"returns",
"profiles",
"looked",
"up",
"by",
"User",
"ID"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/profiles.go#L24-L33 |
123,838 | manifoldco/torus-cli | cmd/daemon.go | stopDaemon | func stopDaemon(proc *os.Process) (bool, error) {
err := proc.Signal(syscall.Signal(syscall.SIGTERM))
if err == nil { // no need to wait for the SIGTERM if the signal failed
increment := 50 * time.Millisecond
for d := increment; d < 3*time.Second; d += increment {
time.Sleep(d)
if _, err := findProcess(pro... | go | func stopDaemon(proc *os.Process) (bool, error) {
err := proc.Signal(syscall.Signal(syscall.SIGTERM))
if err == nil { // no need to wait for the SIGTERM if the signal failed
increment := 50 * time.Millisecond
for d := increment; d < 3*time.Second; d += increment {
time.Sleep(d)
if _, err := findProcess(pro... | [
"func",
"stopDaemon",
"(",
"proc",
"*",
"os",
".",
"Process",
")",
"(",
"bool",
",",
"error",
")",
"{",
"err",
":=",
"proc",
".",
"Signal",
"(",
"syscall",
".",
"Signal",
"(",
"syscall",
".",
"SIGTERM",
")",
")",
"\n\n",
"if",
"err",
"==",
"nil",
... | // stopDaemon stops the daemon process. It returns a bool indicating if the
// shutdown was graceful. | [
"stopDaemon",
"stops",
"the",
"daemon",
"process",
".",
"It",
"returns",
"a",
"bool",
"indicating",
"if",
"the",
"shutdown",
"was",
"graceful",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/daemon.go#L240-L259 |
123,839 | manifoldco/torus-cli | cmd/daemon.go | findDaemon | func findDaemon(cfg *config.Config) (*os.Process, error) {
lock, err := lockfile.New(cfg.PidPath)
if err != nil {
return nil, err
}
proc, err := lock.GetOwner()
if err != nil {
// happy path cases. the pid doesn't exist, or it contains garbage,
// or the previous owner is gone.
if os.IsNotExist(err) || er... | go | func findDaemon(cfg *config.Config) (*os.Process, error) {
lock, err := lockfile.New(cfg.PidPath)
if err != nil {
return nil, err
}
proc, err := lock.GetOwner()
if err != nil {
// happy path cases. the pid doesn't exist, or it contains garbage,
// or the previous owner is gone.
if os.IsNotExist(err) || er... | [
"func",
"findDaemon",
"(",
"cfg",
"*",
"config",
".",
"Config",
")",
"(",
"*",
"os",
".",
"Process",
",",
"error",
")",
"{",
"lock",
",",
"err",
":=",
"lockfile",
".",
"New",
"(",
"cfg",
".",
"PidPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // findDaemon returns an os.Process for a running daemon, or nil if it is not
// running. It returns an error if the pid file location is invalid in the
// config, or there was an error reading the pid file. | [
"findDaemon",
"returns",
"an",
"os",
".",
"Process",
"for",
"a",
"running",
"daemon",
"or",
"nil",
"if",
"it",
"is",
"not",
"running",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"pid",
"file",
"location",
"is",
"invalid",
"in",
"the",
"config",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/daemon.go#L264-L282 |
123,840 | manifoldco/torus-cli | daemon/session/session.go | NewSession | func NewSession(guard *secure.Guard) Session {
return &session{
mutex: &sync.Mutex{},
sessionType: apitypes.NotLoggedIn,
guard: guard,
}
} | go | func NewSession(guard *secure.Guard) Session {
return &session{
mutex: &sync.Mutex{},
sessionType: apitypes.NotLoggedIn,
guard: guard,
}
} | [
"func",
"NewSession",
"(",
"guard",
"*",
"secure",
".",
"Guard",
")",
"Session",
"{",
"return",
"&",
"session",
"{",
"mutex",
":",
"&",
"sync",
".",
"Mutex",
"{",
"}",
",",
"sessionType",
":",
"apitypes",
".",
"NotLoggedIn",
",",
"guard",
":",
"guard",... | // NewSession returns the default implementation of the Session interface
// for a user or machine depending on the passed type. | [
"NewSession",
"returns",
"the",
"default",
"implementation",
"of",
"the",
"Session",
"interface",
"for",
"a",
"user",
"or",
"machine",
"depending",
"on",
"the",
"passed",
"type",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L52-L58 |
123,841 | manifoldco/torus-cli | daemon/session/session.go | Token | func (s *session) Token() []byte {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.token.Buffer()
} | go | func (s *session) Token() []byte {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.token.Buffer()
} | [
"func",
"(",
"s",
"*",
"session",
")",
"Token",
"(",
")",
"[",
"]",
"byte",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"token",
".",
"Buffer",
"(",
")"... | // Token returns the auth token stored in this session. | [
"Token",
"returns",
"the",
"auth",
"token",
"stored",
"in",
"this",
"session",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L93-L98 |
123,842 | manifoldco/torus-cli | daemon/session/session.go | Passphrase | func (s *session) Passphrase() []byte {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.passphrase.Buffer()
} | go | func (s *session) Passphrase() []byte {
s.mutex.Lock()
defer s.mutex.Unlock()
return s.passphrase.Buffer()
} | [
"func",
"(",
"s",
"*",
"session",
")",
"Passphrase",
"(",
")",
"[",
"]",
"byte",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"passphrase",
".",
"Buffer",
... | // Passphrase returns the user's passphrase. | [
"Passphrase",
"returns",
"the",
"user",
"s",
"passphrase",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L101-L106 |
123,843 | manifoldco/torus-cli | daemon/session/session.go | Set | func (s *session) Set(sessionType apitypes.SessionType, identity, auth envelope.Envelope,
passphrase []byte, token []byte) error {
s.mutex.Lock()
defer s.mutex.Unlock()
err := checkSessionType(sessionType, identity, auth)
if err != nil {
return err
}
if len(passphrase) == 0 {
return errors.New("Passphrase ... | go | func (s *session) Set(sessionType apitypes.SessionType, identity, auth envelope.Envelope,
passphrase []byte, token []byte) error {
s.mutex.Lock()
defer s.mutex.Unlock()
err := checkSessionType(sessionType, identity, auth)
if err != nil {
return err
}
if len(passphrase) == 0 {
return errors.New("Passphrase ... | [
"func",
"(",
"s",
"*",
"session",
")",
"Set",
"(",
"sessionType",
"apitypes",
".",
"SessionType",
",",
"identity",
",",
"auth",
"envelope",
".",
"Envelope",
",",
"passphrase",
"[",
"]",
"byte",
",",
"token",
"[",
"]",
"byte",
")",
"error",
"{",
"s",
... | // Set atomically sets all relevant session details.
//
// It returns an error if any values are empty. | [
"Set",
"atomically",
"sets",
"all",
"relevant",
"session",
"details",
".",
"It",
"returns",
"an",
"error",
"if",
"any",
"values",
"are",
"empty",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L156-L189 |
123,844 | manifoldco/torus-cli | daemon/session/session.go | SetIdentity | func (s *session) SetIdentity(sessionType apitypes.SessionType, identity, auth envelope.Envelope) error {
s.mutex.Lock()
defer s.mutex.Unlock()
err := checkSessionType(sessionType, identity, auth)
if err != nil {
return err
}
s.identity = identity
s.auth = auth
return nil
} | go | func (s *session) SetIdentity(sessionType apitypes.SessionType, identity, auth envelope.Envelope) error {
s.mutex.Lock()
defer s.mutex.Unlock()
err := checkSessionType(sessionType, identity, auth)
if err != nil {
return err
}
s.identity = identity
s.auth = auth
return nil
} | [
"func",
"(",
"s",
"*",
"session",
")",
"SetIdentity",
"(",
"sessionType",
"apitypes",
".",
"SessionType",
",",
"identity",
",",
"auth",
"envelope",
".",
"Envelope",
")",
"error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
... | // SetIdentity updates the session identity | [
"SetIdentity",
"updates",
"the",
"session",
"identity"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L192-L205 |
123,845 | manifoldco/torus-cli | daemon/session/session.go | MasterKey | func (s *session) MasterKey() (*base64.Value, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.Type() == apitypes.NotLoggedIn {
return nil, createNotLoggedInError()
}
if s.Type() == apitypes.UserSession {
return s.auth.(envelope.UserInf).Master().Value, nil
}
return s.auth.(*envelope.MachineToken).Body... | go | func (s *session) MasterKey() (*base64.Value, error) {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.Type() == apitypes.NotLoggedIn {
return nil, createNotLoggedInError()
}
if s.Type() == apitypes.UserSession {
return s.auth.(envelope.UserInf).Master().Value, nil
}
return s.auth.(*envelope.MachineToken).Body... | [
"func",
"(",
"s",
"*",
"session",
")",
"MasterKey",
"(",
")",
"(",
"*",
"base64",
".",
"Value",
",",
"error",
")",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".... | // Returns the base64 representation of the identities encrypted master key | [
"Returns",
"the",
"base64",
"representation",
"of",
"the",
"identities",
"encrypted",
"master",
"key"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L215-L228 |
123,846 | manifoldco/torus-cli | daemon/session/session.go | Self | func (s *session) Self() *apitypes.Self {
return &apitypes.Self{
Type: s.Type(),
Identity: s.identity,
Auth: s.auth,
}
} | go | func (s *session) Self() *apitypes.Self {
return &apitypes.Self{
Type: s.Type(),
Identity: s.identity,
Auth: s.auth,
}
} | [
"func",
"(",
"s",
"*",
"session",
")",
"Self",
"(",
")",
"*",
"apitypes",
".",
"Self",
"{",
"return",
"&",
"apitypes",
".",
"Self",
"{",
"Type",
":",
"s",
".",
"Type",
"(",
")",
",",
"Identity",
":",
"s",
".",
"identity",
",",
"Auth",
":",
"s",... | // Self returns the Self apitype which represents the current sessions state | [
"Self",
"returns",
"the",
"Self",
"apitype",
"which",
"represents",
"the",
"current",
"sessions",
"state"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L231-L237 |
123,847 | manifoldco/torus-cli | daemon/session/session.go | Logout | func (s *session) Logout() error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.Type() == apitypes.NotLoggedIn {
return createNotLoggedInError()
}
s.sessionType = apitypes.NotLoggedIn
s.identity = nil
s.auth = nil
s.token.Destroy()
s.passphrase.Destroy()
s.token = nil
s.passphrase = nil
return nil
} | go | func (s *session) Logout() error {
s.mutex.Lock()
defer s.mutex.Unlock()
if s.Type() == apitypes.NotLoggedIn {
return createNotLoggedInError()
}
s.sessionType = apitypes.NotLoggedIn
s.identity = nil
s.auth = nil
s.token.Destroy()
s.passphrase.Destroy()
s.token = nil
s.passphrase = nil
return nil
} | [
"func",
"(",
"s",
"*",
"session",
")",
"Logout",
"(",
")",
"error",
"{",
"s",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mutex",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"Type",
"(",
")",
"==",
"apitypes",
".",
"No... | // Logout resets all values to the logged out state | [
"Logout",
"resets",
"all",
"values",
"to",
"the",
"logged",
"out",
"state"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/daemon/session/session.go#L240-L258 |
123,848 | manifoldco/torus-cli | ui/ui.go | Init | func Init(preferences *prefs.Preferences) {
enableColours := preferences.Core.EnableColors
if !Attached() {
enableColours = false
}
defUI = &UI{
Indent: 0,
Cols: screenWidth(),
EnableProgress: preferences.Core.EnableProgress,
EnableHints: preferences.Core.EnableHints,
EnableColors: enableColou... | go | func Init(preferences *prefs.Preferences) {
enableColours := preferences.Core.EnableColors
if !Attached() {
enableColours = false
}
defUI = &UI{
Indent: 0,
Cols: screenWidth(),
EnableProgress: preferences.Core.EnableProgress,
EnableHints: preferences.Core.EnableHints,
EnableColors: enableColou... | [
"func",
"Init",
"(",
"preferences",
"*",
"prefs",
".",
"Preferences",
")",
"{",
"enableColours",
":=",
"preferences",
".",
"Core",
".",
"EnableColors",
"\n\n",
"if",
"!",
"Attached",
"(",
")",
"{",
"enableColours",
"=",
"false",
"\n",
"}",
"\n\n",
"defUI",... | // Init initializes a default global UI, accessible via the package functions. | [
"Init",
"initializes",
"a",
"default",
"global",
"UI",
"accessible",
"via",
"the",
"package",
"functions",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L23-L38 |
123,849 | manifoldco/torus-cli | ui/ui.go | Line | func (u *UI) Line(format string, a ...interface{}) {
u.LineIndent(0, format, a...)
} | go | func (u *UI) Line(format string, a ...interface{}) {
u.LineIndent(0, format, a...)
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"Line",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"u",
".",
"LineIndent",
"(",
"0",
",",
"format",
",",
"a",
"...",
")",
"\n",
"}"
] | // Line writes a formatted string followed by a newline to stdout. Output is
// word wrapped, and terminated by a newline. | [
"Line",
"writes",
"a",
"formatted",
"string",
"followed",
"by",
"a",
"newline",
"to",
"stdout",
".",
"Output",
"is",
"word",
"wrapped",
"and",
"terminated",
"by",
"a",
"newline",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L74-L76 |
123,850 | manifoldco/torus-cli | ui/ui.go | LineIndent | func (u *UI) LineIndent(indent int, format string, a ...interface{}) {
o := fmt.Sprintf(format, a...)
fmt.Fprintln(readline.Stdout, ansiwrap.WrapIndent(o, u.Cols, u.Indent, u.Indent+indent))
} | go | func (u *UI) LineIndent(indent int, format string, a ...interface{}) {
o := fmt.Sprintf(format, a...)
fmt.Fprintln(readline.Stdout, ansiwrap.WrapIndent(o, u.Cols, u.Indent, u.Indent+indent))
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"LineIndent",
"(",
"indent",
"int",
",",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"o",
":=",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"a",
"...",
")",
"\n",
"fmt",
".",
"Fprintln",
... | // LineIndent writes a formatted string followed by a newline to stdout. Output
// is word wrapped, and terminated by a newline. All lines after the first are
// indented by indent number of spaces (in addition to the indenting enforced
// by this UI instance. | [
"LineIndent",
"writes",
"a",
"formatted",
"string",
"followed",
"by",
"a",
"newline",
"to",
"stdout",
".",
"Output",
"is",
"word",
"wrapped",
"and",
"terminated",
"by",
"a",
"newline",
".",
"All",
"lines",
"after",
"the",
"first",
"are",
"indented",
"by",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L85-L88 |
123,851 | manifoldco/torus-cli | ui/ui.go | Info | func (u *UI) Info(format string, args ...interface{}) {
if !Attached() {
return
}
u.Line(format, args...)
} | go | func (u *UI) Info(format string, args ...interface{}) {
if !Attached() {
return
}
u.Line(format, args...)
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"Info",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"Attached",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"u",
".",
"Line",
"(",
"format",
",",
"args",
"...",
")",... | // Info handles outputting secondary information to the user such as messages
// about progress but are the actual result of an operation. For example,
// printing out that we're attempting to log a user in using the specific
// environment variables.
//
// Only printed if stdout is attached to a terminal. | [
"Info",
"handles",
"outputting",
"secondary",
"information",
"to",
"the",
"user",
"such",
"as",
"messages",
"about",
"progress",
"but",
"are",
"the",
"actual",
"result",
"of",
"an",
"operation",
".",
"For",
"example",
"printing",
"out",
"that",
"we",
"re",
"... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L130-L136 |
123,852 | manifoldco/torus-cli | ui/ui.go | Warn | func (u *UI) Warn(format string, args ...interface{}) {
var w io.Writer = readline.Stdout
icon := u.BoldColorString(Yellow, "⚠ ")
if !Attached() {
w = readline.Stderr
icon = ""
}
o := fmt.Sprintf(icon+format, args...)
fmt.Fprintln(w, ansiwrap.WrapIndent(o, u.Cols, u.Indent, u.Indent))
} | go | func (u *UI) Warn(format string, args ...interface{}) {
var w io.Writer = readline.Stdout
icon := u.BoldColorString(Yellow, "⚠ ")
if !Attached() {
w = readline.Stderr
icon = ""
}
o := fmt.Sprintf(icon+format, args...)
fmt.Fprintln(w, ansiwrap.WrapIndent(o, u.Cols, u.Indent, u.Indent))
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"Warn",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"var",
"w",
"io",
".",
"Writer",
"=",
"readline",
".",
"Stdout",
"\n",
"icon",
":=",
"u",
".",
"BoldColorString",
"(",
"Yellow",... | // Warn handles outputting warning information to the user such as
// messages about needing to be logged in.
//
// The warning is printed out to stderr if stdout is not attached to a
// terminal. | [
"Warn",
"handles",
"outputting",
"warning",
"information",
"to",
"the",
"user",
"such",
"as",
"messages",
"about",
"needing",
"to",
"be",
"logged",
"in",
".",
"The",
"warning",
"is",
"printed",
"out",
"to",
"stderr",
"if",
"stdout",
"is",
"not",
"attached",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L146-L156 |
123,853 | manifoldco/torus-cli | ui/ui.go | Child | func (u *UI) Child(indent int) *UI {
return &UI{
Indent: u.Indent + indent,
Cols: u.Cols,
EnableProgress: u.EnableProgress,
EnableHints: u.EnableHints,
}
} | go | func (u *UI) Child(indent int) *UI {
return &UI{
Indent: u.Indent + indent,
Cols: u.Cols,
EnableProgress: u.EnableProgress,
EnableHints: u.EnableHints,
}
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"Child",
"(",
"indent",
"int",
")",
"*",
"UI",
"{",
"return",
"&",
"UI",
"{",
"Indent",
":",
"u",
".",
"Indent",
"+",
"indent",
",",
"Cols",
":",
"u",
".",
"Cols",
",",
"EnableProgress",
":",
"u",
".",
"EnableP... | // Child returns a new UI, with settings from the receiver UI, and Indent
// increased by the provided value. | [
"Child",
"returns",
"a",
"new",
"UI",
"with",
"settings",
"from",
"the",
"receiver",
"UI",
"and",
"Indent",
"increased",
"by",
"the",
"provided",
"value",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L182-L190 |
123,854 | manifoldco/torus-cli | ui/ui.go | Write | func (u *UI) Write(p []byte) (n int, err error) {
parts := bytes.Split(p, []byte{'\n'})
indent := bytes.Repeat([]byte{' '}, u.Indent)
for i, part := range parts {
if len(part) > 0 {
part = append(indent, part...)
}
os.Stdout.Write(part)
if i < len(parts)-1 {
fmt.Println()
}
}
return len(p), nil
} | go | func (u *UI) Write(p []byte) (n int, err error) {
parts := bytes.Split(p, []byte{'\n'})
indent := bytes.Repeat([]byte{' '}, u.Indent)
for i, part := range parts {
if len(part) > 0 {
part = append(indent, part...)
}
os.Stdout.Write(part)
if i < len(parts)-1 {
fmt.Println()
}
}
return len(p), nil
} | [
"func",
"(",
"u",
"*",
"UI",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"parts",
":=",
"bytes",
".",
"Split",
"(",
"p",
",",
"[",
"]",
"byte",
"{",
"'\\n'",
"}",
")",
"\n\n",
"indent",
":=... | // Write implements the io.Writer interface
// The provided bytes are split on newlines, and written with the UI's
// configured indent. | [
"Write",
"implements",
"the",
"io",
".",
"Writer",
"interface",
"The",
"provided",
"bytes",
"are",
"split",
"on",
"newlines",
"and",
"written",
"with",
"the",
"UI",
"s",
"configured",
"indent",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/ui.go#L195-L210 |
123,855 | manifoldco/torus-cli | gatekeeper/bootstrap/aws/bootstrap.go | Bootstrap | func Bootstrap(url, name, org, role, caFile string) (*apitypes.BootstrapResponse, error) {
var err error
client, err := client.NewClient(url, caFile)
if err != nil {
return nil, fmt.Errorf("cannot initialize bootstrap client: %s", err)
}
identity, err := metadata()
if err != nil {
return nil, err
}
sig, e... | go | func Bootstrap(url, name, org, role, caFile string) (*apitypes.BootstrapResponse, error) {
var err error
client, err := client.NewClient(url, caFile)
if err != nil {
return nil, fmt.Errorf("cannot initialize bootstrap client: %s", err)
}
identity, err := metadata()
if err != nil {
return nil, err
}
sig, e... | [
"func",
"Bootstrap",
"(",
"url",
",",
"name",
",",
"org",
",",
"role",
",",
"caFile",
"string",
")",
"(",
"*",
"apitypes",
".",
"BootstrapResponse",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"client",
",",
"err",
":=",
"client",
".",
"NewC... | // Bootstrap bootstraps a the AWS instance into a role to a given Gatekeeper instance | [
"Bootstrap",
"bootstraps",
"a",
"the",
"AWS",
"instance",
"into",
"a",
"role",
"to",
"a",
"given",
"Gatekeeper",
"instance"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/gatekeeper/bootstrap/aws/bootstrap.go#L20-L66 |
123,856 | manifoldco/torus-cli | gatekeeper/bootstrap/bootstrap.go | Do | func Do(provider Provider, url, name, org, role, caFile string) (*apitypes.BootstrapResponse, error) {
switch provider {
case AWSPublic:
return aws.Bootstrap(url, name, org, role, caFile)
default:
return nil, fmt.Errorf("invalid provider: %s", provider)
}
} | go | func Do(provider Provider, url, name, org, role, caFile string) (*apitypes.BootstrapResponse, error) {
switch provider {
case AWSPublic:
return aws.Bootstrap(url, name, org, role, caFile)
default:
return nil, fmt.Errorf("invalid provider: %s", provider)
}
} | [
"func",
"Do",
"(",
"provider",
"Provider",
",",
"url",
",",
"name",
",",
"org",
",",
"role",
",",
"caFile",
"string",
")",
"(",
"*",
"apitypes",
".",
"BootstrapResponse",
",",
"error",
")",
"{",
"switch",
"provider",
"{",
"case",
"AWSPublic",
":",
"ret... | // Do will execute the bootstrap request for the given provider | [
"Do",
"will",
"execute",
"the",
"bootstrap",
"request",
"for",
"the",
"given",
"provider"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/gatekeeper/bootstrap/bootstrap.go#L20-L28 |
123,857 | manifoldco/torus-cli | ui/spinner.go | newSpinner | func newSpinner(text string, enabled bool) *Spinner {
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Suffix = " " + text
return &Spinner{
s,
text,
enabled,
}
} | go | func newSpinner(text string, enabled bool) *Spinner {
s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.Suffix = " " + text
return &Spinner{
s,
text,
enabled,
}
} | [
"func",
"newSpinner",
"(",
"text",
"string",
",",
"enabled",
"bool",
")",
"*",
"Spinner",
"{",
"s",
":=",
"spinner",
".",
"New",
"(",
"spinner",
".",
"CharSets",
"[",
"9",
"]",
",",
"100",
"*",
"time",
".",
"Millisecond",
")",
"\n",
"s",
".",
"Suff... | // newSpinner creates a new Spinner struct | [
"newSpinner",
"creates",
"a",
"new",
"Spinner",
"struct"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/ui/spinner.go#L17-L25 |
123,858 | manifoldco/torus-cli | registry/claims.go | Create | func (c ClaimsClient) Create(ctx context.Context, claim *envelope.Claim) (*envelope.Claim, error) {
resp := &envelope.Claim{}
err := c.client.RoundTrip(ctx, "POST", "/claims", nil, claim, &resp)
return resp, err
} | go | func (c ClaimsClient) Create(ctx context.Context, claim *envelope.Claim) (*envelope.Claim, error) {
resp := &envelope.Claim{}
err := c.client.RoundTrip(ctx, "POST", "/claims", nil, claim, &resp)
return resp, err
} | [
"func",
"(",
"c",
"ClaimsClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"claim",
"*",
"envelope",
".",
"Claim",
")",
"(",
"*",
"envelope",
".",
"Claim",
",",
"error",
")",
"{",
"resp",
":=",
"&",
"envelope",
".",
"Claim",
"{",
... | // Create creates a a new signed claim on the server | [
"Create",
"creates",
"a",
"a",
"new",
"signed",
"claim",
"on",
"the",
"server"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/claims.go#L16-L20 |
123,859 | manifoldco/torus-cli | prefs/prefs.go | CountFields | func (prefs Preferences) CountFields(fieldName string) int {
value, err := reflections.GetField(prefs, fieldName)
count := 0
if err != nil {
return count
}
items, _ := reflections.Items(value)
for i := range items {
value, _ := reflections.GetField(value, i)
if value != nil && value != "" {
count++
}
... | go | func (prefs Preferences) CountFields(fieldName string) int {
value, err := reflections.GetField(prefs, fieldName)
count := 0
if err != nil {
return count
}
items, _ := reflections.Items(value)
for i := range items {
value, _ := reflections.GetField(value, i)
if value != nil && value != "" {
count++
}
... | [
"func",
"(",
"prefs",
"Preferences",
")",
"CountFields",
"(",
"fieldName",
"string",
")",
"int",
"{",
"value",
",",
"err",
":=",
"reflections",
".",
"GetField",
"(",
"prefs",
",",
"fieldName",
")",
"\n",
"count",
":=",
"0",
"\n",
"if",
"err",
"!=",
"ni... | // CountFields returns the number of defined fields on sub-field struct | [
"CountFields",
"returns",
"the",
"number",
"of",
"defined",
"fields",
"on",
"sub",
"-",
"field",
"struct"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/prefs/prefs.go#L28-L42 |
123,860 | manifoldco/torus-cli | prefs/prefs.go | SetValue | func (prefs Preferences) SetValue(key string, value string) (Preferences, error) {
parts := strings.Split(key, ".")
section := parts[0] // [Core|Default]
key = parts[1] // Rest of the property name
// Identify category struct by ini tag name [Core|Default]
values := reflect.ValueOf(&prefs).Elem()
target := ... | go | func (prefs Preferences) SetValue(key string, value string) (Preferences, error) {
parts := strings.Split(key, ".")
section := parts[0] // [Core|Default]
key = parts[1] // Rest of the property name
// Identify category struct by ini tag name [Core|Default]
values := reflect.ValueOf(&prefs).Elem()
target := ... | [
"func",
"(",
"prefs",
"Preferences",
")",
"SetValue",
"(",
"key",
"string",
",",
"value",
"string",
")",
"(",
"Preferences",
",",
"error",
")",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"key",
",",
"\"",
"\"",
")",
"\n",
"section",
":=",
"par... | // SetValue for ini key on preferences struct | [
"SetValue",
"for",
"ini",
"key",
"on",
"preferences",
"struct"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/prefs/prefs.go#L69-L103 |
123,861 | manifoldco/torus-cli | prefs/prefs.go | NewPreferences | func NewPreferences() (*Preferences, error) {
prefs := &Preferences{
Core: Core{
RegistryURI: registryURI,
ManifestURI: manifestURI,
GatekeeperAddress: gatekeeperAddress,
Context: true,
EnableHints: true,
EnableProgress: true,
EnableCheckUpdates: true,
Ena... | go | func NewPreferences() (*Preferences, error) {
prefs := &Preferences{
Core: Core{
RegistryURI: registryURI,
ManifestURI: manifestURI,
GatekeeperAddress: gatekeeperAddress,
Context: true,
EnableHints: true,
EnableProgress: true,
EnableCheckUpdates: true,
Ena... | [
"func",
"NewPreferences",
"(",
")",
"(",
"*",
"Preferences",
",",
"error",
")",
"{",
"prefs",
":=",
"&",
"Preferences",
"{",
"Core",
":",
"Core",
"{",
"RegistryURI",
":",
"registryURI",
",",
"ManifestURI",
":",
"manifestURI",
",",
"GatekeeperAddress",
":",
... | // NewPreferences returns a new instance of preferences struct | [
"NewPreferences",
"returns",
"a",
"new",
"instance",
"of",
"preferences",
"struct"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/prefs/prefs.go#L120-L146 |
123,862 | manifoldco/torus-cli | registry/credentialgraph.go | Post | func (c *CredentialGraphClient) Post(ctx context.Context, t *CredentialGraph) (CredentialGraph, error) {
resp := rawGraph{}
err := c.client.RoundTrip(ctx, "POST", "/credentialgraph", nil, t, &resp)
if err != nil {
return nil, err
}
return resp.convert()
} | go | func (c *CredentialGraphClient) Post(ctx context.Context, t *CredentialGraph) (CredentialGraph, error) {
resp := rawGraph{}
err := c.client.RoundTrip(ctx, "POST", "/credentialgraph", nil, t, &resp)
if err != nil {
return nil, err
}
return resp.convert()
} | [
"func",
"(",
"c",
"*",
"CredentialGraphClient",
")",
"Post",
"(",
"ctx",
"context",
".",
"Context",
",",
"t",
"*",
"CredentialGraph",
")",
"(",
"CredentialGraph",
",",
"error",
")",
"{",
"resp",
":=",
"rawGraph",
"{",
"}",
"\n",
"err",
":=",
"c",
".",
... | // Post creates a new CredentialGraph on the registry.
//
// The CredentialGraph includes the keyring, it's members, and credentials. | [
"Post",
"creates",
"a",
"new",
"CredentialGraph",
"on",
"the",
"registry",
".",
"The",
"CredentialGraph",
"includes",
"the",
"keyring",
"it",
"s",
"members",
"and",
"credentials",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/credentialgraph.go#L120-L128 |
123,863 | manifoldco/torus-cli | cmd/middleware.go | chain | func chain(funcs ...actionFunc) func(*cli.Context) error {
return wrap(func(ctx *cli.Context) error {
for _, f := range funcs {
err := f(ctx)
if err != nil {
return err
}
}
return nil
})
} | go | func chain(funcs ...actionFunc) func(*cli.Context) error {
return wrap(func(ctx *cli.Context) error {
for _, f := range funcs {
err := f(ctx)
if err != nil {
return err
}
}
return nil
})
} | [
"func",
"chain",
"(",
"funcs",
"...",
"actionFunc",
")",
"func",
"(",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"return",
"wrap",
"(",
"func",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"f... | // chain allows easy sequential calling of BeforeFuncs and AfterFuncs.
// chain will exit on the first error seen. | [
"chain",
"allows",
"easy",
"sequential",
"calling",
"of",
"BeforeFuncs",
"and",
"AfterFuncs",
".",
"chain",
"will",
"exit",
"on",
"the",
"first",
"error",
"seen",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L28-L40 |
123,864 | manifoldco/torus-cli | cmd/middleware.go | wrap | func wrap(cmd actionFunc) actionFunc {
return func(ctx *cli.Context) error {
return errs.ToError(cmd(ctx))
}
} | go | func wrap(cmd actionFunc) actionFunc {
return func(ctx *cli.Context) error {
return errs.ToError(cmd(ctx))
}
} | [
"func",
"wrap",
"(",
"cmd",
"actionFunc",
")",
"actionFunc",
"{",
"return",
"func",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"return",
"errs",
".",
"ToError",
"(",
"cmd",
"(",
"ctx",
")",
")",
"\n",
"}",
"\n",
"}"
] | // wrap wraps the given actionfunc and converts any of the received errors into
// cli.ExitErrors ensuring that we never have a silent failure. | [
"wrap",
"wraps",
"the",
"given",
"actionfunc",
"and",
"converts",
"any",
"of",
"the",
"received",
"errors",
"into",
"cli",
".",
"ExitErrors",
"ensuring",
"that",
"we",
"never",
"have",
"a",
"silent",
"failure",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L44-L48 |
123,865 | manifoldco/torus-cli | cmd/middleware.go | ensureSession | func ensureSession(ctx *cli.Context) error {
cfg, err := config.LoadConfig()
if err != nil {
return err
}
bgCtx := context.Background()
client := api.NewClient(cfg)
_, err = client.Session.Get(bgCtx)
hasSession := true
if err != nil {
if cerr, ok := err.(*apitypes.Error); ok {
if cerr.Type == apitypes.... | go | func ensureSession(ctx *cli.Context) error {
cfg, err := config.LoadConfig()
if err != nil {
return err
}
bgCtx := context.Background()
client := api.NewClient(cfg)
_, err = client.Session.Get(bgCtx)
hasSession := true
if err != nil {
if cerr, ok := err.(*apitypes.Error); ok {
if cerr.Type == apitypes.... | [
"func",
"ensureSession",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cfg",
",",
"err",
":=",
"config",
".",
"LoadConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"bgCtx",
":=",
"context",
"... | // ensureSession ensures that the user is logged in with the daemon and has a
// valid session. If not, it will attempt to log the user in via environment
// variables. If they do not exist, of the login fails, it will abort the
// command. | [
"ensureSession",
"ensures",
"that",
"the",
"user",
"is",
"logged",
"in",
"with",
"the",
"daemon",
"and",
"has",
"a",
"valid",
"session",
".",
"If",
"not",
"it",
"will",
"attempt",
"to",
"log",
"the",
"user",
"in",
"via",
"environment",
"variables",
".",
... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L114-L170 |
123,866 | manifoldco/torus-cli | cmd/middleware.go | loadDirPrefs | func loadDirPrefs(ctx *cli.Context) error {
p, err := prefs.NewPreferences()
if err != nil {
return err
}
d, err := dirprefs.Load(true)
if err != nil {
return err
}
return reflectArgs(ctx, p, d, "json")
} | go | func loadDirPrefs(ctx *cli.Context) error {
p, err := prefs.NewPreferences()
if err != nil {
return err
}
d, err := dirprefs.Load(true)
if err != nil {
return err
}
return reflectArgs(ctx, p, d, "json")
} | [
"func",
"loadDirPrefs",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"p",
",",
"err",
":=",
"prefs",
".",
"NewPreferences",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"d",
",",
"err",
":=",
"d... | // loadDirPrefs loads argument values from the .torus.json file | [
"loadDirPrefs",
"loads",
"argument",
"values",
"from",
"the",
".",
"torus",
".",
"json",
"file"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L173-L185 |
123,867 | manifoldco/torus-cli | cmd/middleware.go | loadPrefDefaults | func loadPrefDefaults(ctx *cli.Context) error {
p, err := prefs.NewPreferences()
if err != nil {
return err
}
return reflectArgs(ctx, p, p.Defaults, "ini")
} | go | func loadPrefDefaults(ctx *cli.Context) error {
p, err := prefs.NewPreferences()
if err != nil {
return err
}
return reflectArgs(ctx, p, p.Defaults, "ini")
} | [
"func",
"loadPrefDefaults",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"p",
",",
"err",
":=",
"prefs",
".",
"NewPreferences",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"reflectArgs",
... | // loadPrefDefaults loads default argument values from the .torusrc
// preferences file defaults section, inserting them into any unset flag values | [
"loadPrefDefaults",
"loads",
"default",
"argument",
"values",
"from",
"the",
".",
"torusrc",
"preferences",
"file",
"defaults",
"section",
"inserting",
"them",
"into",
"any",
"unset",
"flag",
"values"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L189-L196 |
123,868 | manifoldco/torus-cli | cmd/middleware.go | setUserEnv | func setUserEnv(ctx *cli.Context) error {
argName := "environment"
// Check for env flag, just in case this middleware is misused
hasEnvFlag := false
for _, name := range ctx.FlagNames() {
if name == argName {
hasEnvFlag = true
break
}
}
if !hasEnvFlag {
return nil
}
if isSet(ctx, argName) {
retu... | go | func setUserEnv(ctx *cli.Context) error {
argName := "environment"
// Check for env flag, just in case this middleware is misused
hasEnvFlag := false
for _, name := range ctx.FlagNames() {
if name == argName {
hasEnvFlag = true
break
}
}
if !hasEnvFlag {
return nil
}
if isSet(ctx, argName) {
retu... | [
"func",
"setUserEnv",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"argName",
":=",
"\"",
"\"",
"\n",
"// Check for env flag, just in case this middleware is misused",
"hasEnvFlag",
":=",
"false",
"\n",
"for",
"_",
",",
"name",
":=",
"range",
"ctx"... | // setUserEnv populates the env argument, if present and unset,
// with dev-USERNAME | [
"setUserEnv",
"populates",
"the",
"env",
"argument",
"if",
"present",
"and",
"unset",
"with",
"dev",
"-",
"USERNAME"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L241-L275 |
123,869 | manifoldco/torus-cli | cmd/middleware.go | setSliceDefaults | func setSliceDefaults(ctx *cli.Context) error {
for _, f := range ctx.Command.Flags {
if psf, ok := f.(placeHolderStringSliceFlag); ok {
name := strings.SplitN(psf.GetName(), ",", 2)[0]
if psf.Default != "" && len(ctx.StringSlice(name)) == 0 {
ctx.Set(name, psf.Default)
}
}
}
return nil
} | go | func setSliceDefaults(ctx *cli.Context) error {
for _, f := range ctx.Command.Flags {
if psf, ok := f.(placeHolderStringSliceFlag); ok {
name := strings.SplitN(psf.GetName(), ",", 2)[0]
if psf.Default != "" && len(ctx.StringSlice(name)) == 0 {
ctx.Set(name, psf.Default)
}
}
}
return nil
} | [
"func",
"setSliceDefaults",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"ctx",
".",
"Command",
".",
"Flags",
"{",
"if",
"psf",
",",
"ok",
":=",
"f",
".",
"(",
"placeHolderStringSliceFlag",
")",
";",... | // setSliceDefaults populates any string slice flags with the default value
// if nothing else is set. This is different from the default urfave default
// Value, which will always be included in the string slice options. | [
"setSliceDefaults",
"populates",
"any",
"string",
"slice",
"flags",
"with",
"the",
"default",
"value",
"if",
"nothing",
"else",
"is",
"set",
".",
"This",
"is",
"different",
"from",
"the",
"default",
"urfave",
"default",
"Value",
"which",
"will",
"always",
"be"... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L280-L291 |
123,870 | manifoldco/torus-cli | cmd/middleware.go | checkUpdates | func checkUpdates(ctx *cli.Context) error {
cfg, err := config.LoadConfig()
if err != nil {
return err
}
client := api.NewClient(cfg)
c := context.Background()
updateInfo, err := client.Updates.Check(c)
if err != nil {
return err
}
if updateInfo.NeedsUpdate {
ui.Info("A new version of Torus is availab... | go | func checkUpdates(ctx *cli.Context) error {
cfg, err := config.LoadConfig()
if err != nil {
return err
}
client := api.NewClient(cfg)
c := context.Background()
updateInfo, err := client.Updates.Check(c)
if err != nil {
return err
}
if updateInfo.NeedsUpdate {
ui.Info("A new version of Torus is availab... | [
"func",
"checkUpdates",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"cfg",
",",
"err",
":=",
"config",
".",
"LoadConfig",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"client",
":=",
"api",
".",
... | // checkUpdates checks if there's a torus update available. If so,
// it prints a message to the stdout with the download URL if so. | [
"checkUpdates",
"checks",
"if",
"there",
"s",
"a",
"torus",
"update",
"available",
".",
"If",
"so",
"it",
"prints",
"a",
"message",
"to",
"the",
"stdout",
"with",
"the",
"download",
"URL",
"if",
"so",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/cmd/middleware.go#L348-L367 |
123,871 | manifoldco/torus-cli | apitypes/apitypes.go | LookupErrorType | func LookupErrorType(code int) ErrorType {
for t, c := range errorTypeToStatusCodeMap {
if c == code {
return t
}
}
return UnknownError
} | go | func LookupErrorType(code int) ErrorType {
for t, c := range errorTypeToStatusCodeMap {
if c == code {
return t
}
}
return UnknownError
} | [
"func",
"LookupErrorType",
"(",
"code",
"int",
")",
"ErrorType",
"{",
"for",
"t",
",",
"c",
":=",
"range",
"errorTypeToStatusCodeMap",
"{",
"if",
"c",
"==",
"code",
"{",
"return",
"t",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"UnknownError",
"\n",
"}"
] | // LookupErrorType returns the ErrorType for the given HTTP StatusCode,
// UnknownError is returned if the error type could not be found. | [
"LookupErrorType",
"returns",
"the",
"ErrorType",
"for",
"the",
"given",
"HTTP",
"StatusCode",
"UnknownError",
"is",
"returned",
"if",
"the",
"error",
"type",
"could",
"not",
"be",
"found",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L40-L48 |
123,872 | manifoldco/torus-cli | apitypes/apitypes.go | Error | func (e *Error) Error() string {
segments := strings.Split(string(e.Type), "_")
errType := strings.Join(segments, " ")
return strings.Title(errType) + ": " + strings.Join(e.Err, " ")
} | go | func (e *Error) Error() string {
segments := strings.Split(string(e.Type), "_")
errType := strings.Join(segments, " ")
return strings.Title(errType) + ": " + strings.Join(e.Err, " ")
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"segments",
":=",
"strings",
".",
"Split",
"(",
"string",
"(",
"e",
".",
"Type",
")",
",",
"\"",
"\"",
")",
"\n",
"errType",
":=",
"strings",
".",
"Join",
"(",
"segments",
","... | // Error implements the error interface for formatted API errors. | [
"Error",
"implements",
"the",
"error",
"interface",
"for",
"formatted",
"API",
"errors",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L57-L61 |
123,873 | manifoldco/torus-cli | apitypes/apitypes.go | StatusCode | func (e *Error) StatusCode() int {
code, ok := errorTypeToStatusCodeMap[e.Type]
if !ok || code == 0 {
return 500
}
return code
} | go | func (e *Error) StatusCode() int {
code, ok := errorTypeToStatusCodeMap[e.Type]
if !ok || code == 0 {
return 500
}
return code
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"StatusCode",
"(",
")",
"int",
"{",
"code",
",",
"ok",
":=",
"errorTypeToStatusCodeMap",
"[",
"e",
".",
"Type",
"]",
"\n",
"if",
"!",
"ok",
"||",
"code",
"==",
"0",
"{",
"return",
"500",
"\n",
"}",
"\n\n",
"re... | // StatusCode returns the http status code associated with the underlying error type | [
"StatusCode",
"returns",
"the",
"http",
"status",
"code",
"associated",
"with",
"the",
"underlying",
"error",
"type"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L64-L71 |
123,874 | manifoldco/torus-cli | apitypes/apitypes.go | FormatError | func FormatError(err error) error {
if err == nil {
return nil
}
if apiErr, ok := err.(*Error); ok {
if apiErr.Type == UnauthorizedError {
for _, m := range apiErr.Err {
if strings.Contains(m, "wrong identity state: unverified") {
return NewUnverifiedError()
}
}
return &Error{
Type: U... | go | func FormatError(err error) error {
if err == nil {
return nil
}
if apiErr, ok := err.(*Error); ok {
if apiErr.Type == UnauthorizedError {
for _, m := range apiErr.Err {
if strings.Contains(m, "wrong identity state: unverified") {
return NewUnverifiedError()
}
}
return &Error{
Type: U... | [
"func",
"FormatError",
"(",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"apiErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
";",
"ok",
"{",
"if",
"apiErr",
".",
"Type",
... | // FormatError updates an error to contain more context | [
"FormatError",
"updates",
"an",
"error",
"to",
"contain",
"more",
"context"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L74-L95 |
123,875 | manifoldco/torus-cli | apitypes/apitypes.go | IsNotFoundError | func IsNotFoundError(err error) bool {
if err == nil {
return false
}
if apiErr, ok := err.(*Error); ok {
return apiErr.Type == NotFoundError
}
return false
} | go | func IsNotFoundError(err error) bool {
if err == nil {
return false
}
if apiErr, ok := err.(*Error); ok {
return apiErr.Type == NotFoundError
}
return false
} | [
"func",
"IsNotFoundError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"apiErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
";",
"ok",
"{",
"return",
"apiErr",
".",
"... | // IsNotFoundError returns whether or not an error is a 404 result from the api. | [
"IsNotFoundError",
"returns",
"whether",
"or",
"not",
"an",
"error",
"is",
"a",
"404",
"result",
"from",
"the",
"api",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L108-L118 |
123,876 | manifoldco/torus-cli | apitypes/apitypes.go | IsUnauthorizedError | func IsUnauthorizedError(err error) bool {
if err == nil {
return false
}
if apiErr, ok := err.(*Error); ok {
return apiErr.Type == UnauthorizedError
}
return false
} | go | func IsUnauthorizedError(err error) bool {
if err == nil {
return false
}
if apiErr, ok := err.(*Error); ok {
return apiErr.Type == UnauthorizedError
}
return false
} | [
"func",
"IsUnauthorizedError",
"(",
"err",
"error",
")",
"bool",
"{",
"if",
"err",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"apiErr",
",",
"ok",
":=",
"err",
".",
"(",
"*",
"Error",
")",
";",
"ok",
"{",
"return",
"apiErr",
".",... | // IsUnauthorizedError returns whether or not an error is a 401 result from the api. | [
"IsUnauthorizedError",
"returns",
"whether",
"or",
"not",
"an",
"error",
"is",
"a",
"401",
"result",
"from",
"the",
"api",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L121-L131 |
123,877 | manifoldco/torus-cli | apitypes/apitypes.go | Valid | func (m *MachineLogin) Valid() bool {
return m.TokenID != nil && m.Secret != nil && m.Secret.String() != ""
} | go | func (m *MachineLogin) Valid() bool {
return m.TokenID != nil && m.Secret != nil && m.Secret.String() != ""
} | [
"func",
"(",
"m",
"*",
"MachineLogin",
")",
"Valid",
"(",
")",
"bool",
"{",
"return",
"m",
".",
"TokenID",
"!=",
"nil",
"&&",
"m",
".",
"Secret",
"!=",
"nil",
"&&",
"m",
".",
"Secret",
".",
"String",
"(",
")",
"!=",
"\"",
"\"",
"\n",
"}"
] | // Valid returns whether or not this is a valid machine login request | [
"Valid",
"returns",
"whether",
"or",
"not",
"this",
"is",
"a",
"valid",
"machine",
"login",
"request"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/apitypes/apitypes.go#L217-L219 |
123,878 | manifoldco/torus-cli | registry/credentials.go | Create | func (c *Credentials) Create(ctx context.Context, creds []envelope.CredentialInf) ([]*envelope.Credential, error) {
resp := []*envelope.Credential{}
err := c.client.RoundTrip(ctx, "POST", "/credentials", nil, creds, &resp)
return resp, err
} | go | func (c *Credentials) Create(ctx context.Context, creds []envelope.CredentialInf) ([]*envelope.Credential, error) {
resp := []*envelope.Credential{}
err := c.client.RoundTrip(ctx, "POST", "/credentials", nil, creds, &resp)
return resp, err
} | [
"func",
"(",
"c",
"*",
"Credentials",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"creds",
"[",
"]",
"envelope",
".",
"CredentialInf",
")",
"(",
"[",
"]",
"*",
"envelope",
".",
"Credential",
",",
"error",
")",
"{",
"resp",
":=",
"[",
... | // Create creates the provided credential in the registry. | [
"Create",
"creates",
"the",
"provided",
"credential",
"in",
"the",
"registry",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/credentials.go#L16-L20 |
123,879 | manifoldco/torus-cli | api/machines.go | Create | func (m *MachinesClient) Create(ctx context.Context, orgID, teamID *identity.ID,
name string, output ProgressFunc) (*apitypes.MachineSegment, *base64.Value, error) {
secret, err := createTokenSecret()
if err != nil {
return nil, nil, err
}
mcr := apitypes.MachinesCreateRequest{
Name: name,
OrgID: orgID,... | go | func (m *MachinesClient) Create(ctx context.Context, orgID, teamID *identity.ID,
name string, output ProgressFunc) (*apitypes.MachineSegment, *base64.Value, error) {
secret, err := createTokenSecret()
if err != nil {
return nil, nil, err
}
mcr := apitypes.MachinesCreateRequest{
Name: name,
OrgID: orgID,... | [
"func",
"(",
"m",
"*",
"MachinesClient",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"orgID",
",",
"teamID",
"*",
"identity",
".",
"ID",
",",
"name",
"string",
",",
"output",
"ProgressFunc",
")",
"(",
"*",
"apitypes",
".",
"MachineSegment"... | // Create a new machine in the given org | [
"Create",
"a",
"new",
"machine",
"in",
"the",
"given",
"org"
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/api/machines.go#L28-L46 |
123,880 | manifoldco/torus-cli | registry/round_tripper.go | NewRequest | func (rt *DefaultRequestDoer) NewRequest(method, path string,
query *url.Values, body interface{}) (*http.Request, error) {
b := &bytes.Buffer{}
if body != nil {
enc := json.NewEncoder(b)
err := enc.Encode(body)
if err != nil {
return nil, err
}
}
if query == nil {
query = &url.Values{}
}
if q :=... | go | func (rt *DefaultRequestDoer) NewRequest(method, path string,
query *url.Values, body interface{}) (*http.Request, error) {
b := &bytes.Buffer{}
if body != nil {
enc := json.NewEncoder(b)
err := enc.Encode(body)
if err != nil {
return nil, err
}
}
if query == nil {
query = &url.Values{}
}
if q :=... | [
"func",
"(",
"rt",
"*",
"DefaultRequestDoer",
")",
"NewRequest",
"(",
"method",
",",
"path",
"string",
",",
"query",
"*",
"url",
".",
"Values",
",",
"body",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"b",
... | // NewRequest constructs a new http.Request, with a body containing the json
// representation of body, if provided. | [
"NewRequest",
"constructs",
"a",
"new",
"http",
".",
"Request",
"with",
"a",
"body",
"containing",
"the",
"json",
"representation",
"of",
"body",
"if",
"provided",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/round_tripper.go#L40-L72 |
123,881 | manifoldco/torus-cli | registry/round_tripper.go | Do | func (rt *DefaultRequestDoer) Do(ctx context.Context, r *http.Request,
v interface{}) (*http.Response, error) {
resp, err := rt.Client.Do(r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
err = checkResponseCode(resp)
if err != nil {
return resp, err
}
if v != nil {
dec := json.NewDecoder(... | go | func (rt *DefaultRequestDoer) Do(ctx context.Context, r *http.Request,
v interface{}) (*http.Response, error) {
resp, err := rt.Client.Do(r)
if err != nil {
return nil, err
}
defer resp.Body.Close()
err = checkResponseCode(resp)
if err != nil {
return resp, err
}
if v != nil {
dec := json.NewDecoder(... | [
"func",
"(",
"rt",
"*",
"DefaultRequestDoer",
")",
"Do",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"http",
".",
"Request",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"*",
"http",
".",
"Response",
",",
"error",
")",
"{",
"resp",
",",
"... | // Do executes an http.Request, populating v with the JSON response
// on success.
//
// If the request errors with a JSON formatted response body, it will be
// unmarshaled into the returned error. | [
"Do",
"executes",
"an",
"http",
".",
"Request",
"populating",
"v",
"with",
"the",
"JSON",
"response",
"on",
"success",
".",
"If",
"the",
"request",
"errors",
"with",
"a",
"JSON",
"formatted",
"response",
"body",
"it",
"will",
"be",
"unmarshaled",
"into",
"... | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/round_tripper.go#L79-L103 |
123,882 | manifoldco/torus-cli | registry/round_tripper.go | checkResponseCode | func checkResponseCode(r *http.Response) error {
if r.StatusCode >= 200 && r.StatusCode < 300 {
return nil
}
rErr := &apitypes.Error{Type: apitypes.LookupErrorType(r.StatusCode)}
if r.ContentLength != 0 {
dec := json.NewDecoder(r.Body)
err := dec.Decode(rErr)
if err != nil {
return errBadResponse
}
... | go | func checkResponseCode(r *http.Response) error {
if r.StatusCode >= 200 && r.StatusCode < 300 {
return nil
}
rErr := &apitypes.Error{Type: apitypes.LookupErrorType(r.StatusCode)}
if r.ContentLength != 0 {
dec := json.NewDecoder(r.Body)
err := dec.Decode(rErr)
if err != nil {
return errBadResponse
}
... | [
"func",
"checkResponseCode",
"(",
"r",
"*",
"http",
".",
"Response",
")",
"error",
"{",
"if",
"r",
".",
"StatusCode",
">=",
"200",
"&&",
"r",
".",
"StatusCode",
"<",
"300",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"rErr",
":=",
"&",
"apitypes",
".",
... | // checkReponseCode checks if the response from the server is an error,
// and if so, attempts to marshal the response into the error type. | [
"checkReponseCode",
"checks",
"if",
"the",
"response",
"from",
"the",
"server",
"is",
"an",
"error",
"and",
"if",
"so",
"attempts",
"to",
"marshal",
"the",
"response",
"into",
"the",
"error",
"type",
"."
] | 137599f985e6f676c081ffb4230aaad52fb7d26c | https://github.com/manifoldco/torus-cli/blob/137599f985e6f676c081ffb4230aaad52fb7d26c/registry/round_tripper.go#L107-L125 |
123,883 | 0xAX/notificator | notification.go | CheckTermNotif | func CheckTermNotif() bool {
// Checks if terminal-notifier exists, and is accessible.
if err := exec.Command("which", "terminal-notifier").Run(); err != nil {
return false
}
// no error, so return true. (terminal-notifier exists)
return true
} | go | func CheckTermNotif() bool {
// Checks if terminal-notifier exists, and is accessible.
if err := exec.Command("which", "terminal-notifier").Run(); err != nil {
return false
}
// no error, so return true. (terminal-notifier exists)
return true
} | [
"func",
"CheckTermNotif",
"(",
")",
"bool",
"{",
"// Checks if terminal-notifier exists, and is accessible.",
"if",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
".",
"Run",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"f... | // Helper function for macOS | [
"Helper",
"function",
"for",
"macOS"
] | d81462e38c2145023f9ecf5414fc84d45d5bfe82 | https://github.com/0xAX/notificator/blob/d81462e38c2145023f9ecf5414fc84d45d5bfe82/notification.go#L137-L144 |
123,884 | prashantv/gostub | env.go | SetEnv | func (s *Stubs) SetEnv(k, v string) *Stubs {
s.checkEnvKey(k)
os.Setenv(k, v)
return s
} | go | func (s *Stubs) SetEnv(k, v string) *Stubs {
s.checkEnvKey(k)
os.Setenv(k, v)
return s
} | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"SetEnv",
"(",
"k",
",",
"v",
"string",
")",
"*",
"Stubs",
"{",
"s",
".",
"checkEnvKey",
"(",
"k",
")",
"\n\n",
"os",
".",
"Setenv",
"(",
"k",
",",
"v",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // SetEnv the specified environent variable to the specified value. | [
"SetEnv",
"the",
"specified",
"environent",
"variable",
"to",
"the",
"specified",
"value",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/env.go#L13-L18 |
123,885 | prashantv/gostub | env.go | UnsetEnv | func (s *Stubs) UnsetEnv(k string) *Stubs {
s.checkEnvKey(k)
os.Unsetenv(k)
return s
} | go | func (s *Stubs) UnsetEnv(k string) *Stubs {
s.checkEnvKey(k)
os.Unsetenv(k)
return s
} | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"UnsetEnv",
"(",
"k",
"string",
")",
"*",
"Stubs",
"{",
"s",
".",
"checkEnvKey",
"(",
"k",
")",
"\n\n",
"os",
".",
"Unsetenv",
"(",
"k",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // UnsetEnv unsets the specified environent variable. | [
"UnsetEnv",
"unsets",
"the",
"specified",
"environent",
"variable",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/env.go#L21-L26 |
123,886 | prashantv/gostub | gostub.go | New | func New() *Stubs {
return &Stubs{
stubs: make(map[reflect.Value]reflect.Value),
origEnv: make(map[string]envVal),
}
} | go | func New() *Stubs {
return &Stubs{
stubs: make(map[reflect.Value]reflect.Value),
origEnv: make(map[string]envVal),
}
} | [
"func",
"New",
"(",
")",
"*",
"Stubs",
"{",
"return",
"&",
"Stubs",
"{",
"stubs",
":",
"make",
"(",
"map",
"[",
"reflect",
".",
"Value",
"]",
"reflect",
".",
"Value",
")",
",",
"origEnv",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"envVal",
")"... | // New returns Stubs that can be used to stub out variables. | [
"New",
"returns",
"Stubs",
"that",
"can",
"be",
"used",
"to",
"stub",
"out",
"variables",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L36-L41 |
123,887 | prashantv/gostub | gostub.go | Stub | func (s *Stubs) Stub(varToStub interface{}, stubVal interface{}) *Stubs {
v := reflect.ValueOf(varToStub)
stub := reflect.ValueOf(stubVal)
// Ensure varToStub is a pointer to the variable.
if v.Type().Kind() != reflect.Ptr {
panic("variable to stub is expected to be a pointer")
}
if _, ok := s.stubs[v]; !ok {... | go | func (s *Stubs) Stub(varToStub interface{}, stubVal interface{}) *Stubs {
v := reflect.ValueOf(varToStub)
stub := reflect.ValueOf(stubVal)
// Ensure varToStub is a pointer to the variable.
if v.Type().Kind() != reflect.Ptr {
panic("variable to stub is expected to be a pointer")
}
if _, ok := s.stubs[v]; !ok {... | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"Stub",
"(",
"varToStub",
"interface",
"{",
"}",
",",
"stubVal",
"interface",
"{",
"}",
")",
"*",
"Stubs",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"varToStub",
")",
"\n",
"stub",
":=",
"reflect",
".",
"V... | // Stub replaces the value stored at varToStub with stubVal.
// varToStub must be a pointer to the variable. stubVal should have a type
// that is assignable to the variable. | [
"Stub",
"replaces",
"the",
"value",
"stored",
"at",
"varToStub",
"with",
"stubVal",
".",
"varToStub",
"must",
"be",
"a",
"pointer",
"to",
"the",
"variable",
".",
"stubVal",
"should",
"have",
"a",
"type",
"that",
"is",
"assignable",
"to",
"the",
"variable",
... | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L46-L63 |
123,888 | prashantv/gostub | gostub.go | StubFunc | func (s *Stubs) StubFunc(funcVarToStub interface{}, stubVal ...interface{}) *Stubs {
funcPtrType := reflect.TypeOf(funcVarToStub)
if funcPtrType.Kind() != reflect.Ptr ||
funcPtrType.Elem().Kind() != reflect.Func {
panic("func variable to stub must be a pointer to a function")
}
funcType := funcPtrType.Elem()
i... | go | func (s *Stubs) StubFunc(funcVarToStub interface{}, stubVal ...interface{}) *Stubs {
funcPtrType := reflect.TypeOf(funcVarToStub)
if funcPtrType.Kind() != reflect.Ptr ||
funcPtrType.Elem().Kind() != reflect.Func {
panic("func variable to stub must be a pointer to a function")
}
funcType := funcPtrType.Elem()
i... | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"StubFunc",
"(",
"funcVarToStub",
"interface",
"{",
"}",
",",
"stubVal",
"...",
"interface",
"{",
"}",
")",
"*",
"Stubs",
"{",
"funcPtrType",
":=",
"reflect",
".",
"TypeOf",
"(",
"funcVarToStub",
")",
"\n",
"if",
"f... | // StubFunc replaces a function variable with a function that returns stubVal.
// funcVarToStub must be a pointer to a function variable. If the function
// returns multiple values, then multiple values should be passed to stubFunc.
// The values must match be assignable to the return values' types. | [
"StubFunc",
"replaces",
"a",
"function",
"variable",
"with",
"a",
"function",
"that",
"returns",
"stubVal",
".",
"funcVarToStub",
"must",
"be",
"a",
"pointer",
"to",
"a",
"function",
"variable",
".",
"If",
"the",
"function",
"returns",
"multiple",
"values",
"t... | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L69-L82 |
123,889 | prashantv/gostub | gostub.go | FuncReturning | func FuncReturning(funcType reflect.Type, results ...interface{}) reflect.Value {
var resultValues []reflect.Value
for i, r := range results {
var retValue reflect.Value
if r == nil {
// We can't use reflect.ValueOf(nil), so we need to create the zero value.
retValue = reflect.Zero(funcType.Out(i))
} else... | go | func FuncReturning(funcType reflect.Type, results ...interface{}) reflect.Value {
var resultValues []reflect.Value
for i, r := range results {
var retValue reflect.Value
if r == nil {
// We can't use reflect.ValueOf(nil), so we need to create the zero value.
retValue = reflect.Zero(funcType.Out(i))
} else... | [
"func",
"FuncReturning",
"(",
"funcType",
"reflect",
".",
"Type",
",",
"results",
"...",
"interface",
"{",
"}",
")",
"reflect",
".",
"Value",
"{",
"var",
"resultValues",
"[",
"]",
"reflect",
".",
"Value",
"\n",
"for",
"i",
",",
"r",
":=",
"range",
"res... | // FuncReturning creates a new function with type funcType that returns results. | [
"FuncReturning",
"creates",
"a",
"new",
"function",
"with",
"type",
"funcType",
"that",
"returns",
"results",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L85-L107 |
123,890 | prashantv/gostub | gostub.go | Reset | func (s *Stubs) Reset() {
for v, originalVal := range s.stubs {
v.Elem().Set(originalVal)
}
s.resetEnv()
} | go | func (s *Stubs) Reset() {
for v, originalVal := range s.stubs {
v.Elem().Set(originalVal)
}
s.resetEnv()
} | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"Reset",
"(",
")",
"{",
"for",
"v",
",",
"originalVal",
":=",
"range",
"s",
".",
"stubs",
"{",
"v",
".",
"Elem",
"(",
")",
".",
"Set",
"(",
"originalVal",
")",
"\n",
"}",
"\n",
"s",
".",
"resetEnv",
"(",
"... | // Reset resets all stubbed variables back to their original values. | [
"Reset",
"resets",
"all",
"stubbed",
"variables",
"back",
"to",
"their",
"original",
"values",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L110-L115 |
123,891 | prashantv/gostub | gostub.go | ResetSingle | func (s *Stubs) ResetSingle(varToStub interface{}) {
v := reflect.ValueOf(varToStub)
originalVal, ok := s.stubs[v]
if !ok {
panic("cannot reset variable as it has not been stubbed yet")
}
v.Elem().Set(originalVal)
} | go | func (s *Stubs) ResetSingle(varToStub interface{}) {
v := reflect.ValueOf(varToStub)
originalVal, ok := s.stubs[v]
if !ok {
panic("cannot reset variable as it has not been stubbed yet")
}
v.Elem().Set(originalVal)
} | [
"func",
"(",
"s",
"*",
"Stubs",
")",
"ResetSingle",
"(",
"varToStub",
"interface",
"{",
"}",
")",
"{",
"v",
":=",
"reflect",
".",
"ValueOf",
"(",
"varToStub",
")",
"\n",
"originalVal",
",",
"ok",
":=",
"s",
".",
"stubs",
"[",
"v",
"]",
"\n",
"if",
... | // ResetSingle resets a single stubbed variable back to its original value. | [
"ResetSingle",
"resets",
"a",
"single",
"stubbed",
"variable",
"back",
"to",
"its",
"original",
"value",
"."
] | 24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3 | https://github.com/prashantv/gostub/blob/24ed9cdea43de1d52ea20cab2b7a38e7ed6886b3/gostub.go#L118-L126 |
123,892 | cloudfoundry/garden | server/streamer/streamer.go | New | func New(graceTime time.Duration) *Streamer {
return &Streamer{
graceTime: graceTime,
streams: sync.Map{},
idGen: new(syncStreamIDGenerator),
}
} | go | func New(graceTime time.Duration) *Streamer {
return &Streamer{
graceTime: graceTime,
streams: sync.Map{},
idGen: new(syncStreamIDGenerator),
}
} | [
"func",
"New",
"(",
"graceTime",
"time",
".",
"Duration",
")",
"*",
"Streamer",
"{",
"return",
"&",
"Streamer",
"{",
"graceTime",
":",
"graceTime",
",",
"streams",
":",
"sync",
".",
"Map",
"{",
"}",
",",
"idGen",
":",
"new",
"(",
"syncStreamIDGenerator",... | // New creates a Streamer with the specified grace time which limits the duration of memory consumption by a stopped stream. | [
"New",
"creates",
"a",
"Streamer",
"with",
"the",
"specified",
"grace",
"time",
"which",
"limits",
"the",
"duration",
"of",
"memory",
"consumption",
"by",
"a",
"stopped",
"stream",
"."
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/server/streamer/streamer.go#L15-L21 |
123,893 | cloudfoundry/garden | server/streamer/streamer.go | Stream | func (m *Streamer) Stream(stdout, stderr chan []byte) StreamID {
sid := m.idGen.next()
m.streams.Store(sid, newStream(stdout, stderr))
return sid
} | go | func (m *Streamer) Stream(stdout, stderr chan []byte) StreamID {
sid := m.idGen.next()
m.streams.Store(sid, newStream(stdout, stderr))
return sid
} | [
"func",
"(",
"m",
"*",
"Streamer",
")",
"Stream",
"(",
"stdout",
",",
"stderr",
"chan",
"[",
"]",
"byte",
")",
"StreamID",
"{",
"sid",
":=",
"m",
".",
"idGen",
".",
"next",
"(",
")",
"\n",
"m",
".",
"streams",
".",
"Store",
"(",
"sid",
",",
"ne... | // Stream sets up streaming for the given pair of channels and returns a StreamID to identify the pair.
// The caller must call Stop to avoid leaking memory. | [
"Stream",
"sets",
"up",
"streaming",
"for",
"the",
"given",
"pair",
"of",
"channels",
"and",
"returns",
"a",
"StreamID",
"to",
"identify",
"the",
"pair",
".",
"The",
"caller",
"must",
"call",
"Stop",
"to",
"avoid",
"leaking",
"memory",
"."
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/server/streamer/streamer.go#L45-L50 |
123,894 | cloudfoundry/garden | server/streamer/streamer.go | ServeStdout | func (m *Streamer) ServeStdout(streamID StreamID, writer io.Writer) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
m.serve(writer, strm.stdout, strm.done)
} | go | func (m *Streamer) ServeStdout(streamID StreamID, writer io.Writer) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
m.serve(writer, strm.stdout, strm.done)
} | [
"func",
"(",
"m",
"*",
"Streamer",
")",
"ServeStdout",
"(",
"streamID",
"StreamID",
",",
"writer",
"io",
".",
"Writer",
")",
"{",
"strm",
",",
"ok",
":=",
"m",
".",
"loadStream",
"(",
"streamID",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}"... | // StreamStdout streams to the specified writer from the standard output channel of the specified pair of channels. | [
"StreamStdout",
"streams",
"to",
"the",
"specified",
"writer",
"from",
"the",
"standard",
"output",
"channel",
"of",
"the",
"specified",
"pair",
"of",
"channels",
"."
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/server/streamer/streamer.go#L53-L59 |
123,895 | cloudfoundry/garden | server/streamer/streamer.go | ServeStderr | func (m *Streamer) ServeStderr(streamID StreamID, writer io.Writer) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
m.serve(writer, strm.stderr, strm.done)
} | go | func (m *Streamer) ServeStderr(streamID StreamID, writer io.Writer) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
m.serve(writer, strm.stderr, strm.done)
} | [
"func",
"(",
"m",
"*",
"Streamer",
")",
"ServeStderr",
"(",
"streamID",
"StreamID",
",",
"writer",
"io",
".",
"Writer",
")",
"{",
"strm",
",",
"ok",
":=",
"m",
".",
"loadStream",
"(",
"streamID",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}"... | // StreamStderr streams to the specified writer from the standard error channel of the specified pair of channels. | [
"StreamStderr",
"streams",
"to",
"the",
"specified",
"writer",
"from",
"the",
"standard",
"error",
"channel",
"of",
"the",
"specified",
"pair",
"of",
"channels",
"."
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/server/streamer/streamer.go#L62-L68 |
123,896 | cloudfoundry/garden | server/streamer/streamer.go | Stop | func (m *Streamer) Stop(streamID StreamID) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
close(strm.done)
go func() {
// wait some time to ensure clients have connected, once they've
// retrieved the stream from the map it's safe to delete the key
time.Sleep(m.graceTime)
m.streams.Delete(stre... | go | func (m *Streamer) Stop(streamID StreamID) {
strm, ok := m.loadStream(streamID)
if !ok {
return
}
close(strm.done)
go func() {
// wait some time to ensure clients have connected, once they've
// retrieved the stream from the map it's safe to delete the key
time.Sleep(m.graceTime)
m.streams.Delete(stre... | [
"func",
"(",
"m",
"*",
"Streamer",
")",
"Stop",
"(",
"streamID",
"StreamID",
")",
"{",
"strm",
",",
"ok",
":=",
"m",
".",
"loadStream",
"(",
"streamID",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\n",
"}",
"\n\n",
"close",
"(",
"strm",
".",
"don... | // Stop stops streaming from the specified pair of channels. | [
"Stop",
"stops",
"streaming",
"from",
"the",
"specified",
"pair",
"of",
"channels",
"."
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/server/streamer/streamer.go#L96-L111 |
123,897 | cloudfoundry/garden | net_out_rule.go | IPRangeFromIP | func IPRangeFromIP(ip net.IP) IPRange {
return IPRange{Start: ip, End: ip}
} | go | func IPRangeFromIP(ip net.IP) IPRange {
return IPRange{Start: ip, End: ip}
} | [
"func",
"IPRangeFromIP",
"(",
"ip",
"net",
".",
"IP",
")",
"IPRange",
"{",
"return",
"IPRange",
"{",
"Start",
":",
"ip",
",",
"End",
":",
"ip",
"}",
"\n",
"}"
] | // IPRangeFromIP creates an IPRange containing a single IP | [
"IPRangeFromIP",
"creates",
"an",
"IPRange",
"containing",
"a",
"single",
"IP"
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/net_out_rule.go#L50-L52 |
123,898 | cloudfoundry/garden | net_out_rule.go | IPRangeFromIPNet | func IPRangeFromIPNet(ipNet *net.IPNet) IPRange {
return IPRange{Start: ipNet.IP, End: lastIP(ipNet)}
} | go | func IPRangeFromIPNet(ipNet *net.IPNet) IPRange {
return IPRange{Start: ipNet.IP, End: lastIP(ipNet)}
} | [
"func",
"IPRangeFromIPNet",
"(",
"ipNet",
"*",
"net",
".",
"IPNet",
")",
"IPRange",
"{",
"return",
"IPRange",
"{",
"Start",
":",
"ipNet",
".",
"IP",
",",
"End",
":",
"lastIP",
"(",
"ipNet",
")",
"}",
"\n",
"}"
] | // IPRangeFromIPNet creates an IPRange containing the same IPs as a given IPNet | [
"IPRangeFromIPNet",
"creates",
"an",
"IPRange",
"containing",
"the",
"same",
"IPs",
"as",
"a",
"given",
"IPNet"
] | a4e51d29c0e54370a8a2c7ba72bae8354baab5a8 | https://github.com/cloudfoundry/garden/blob/a4e51d29c0e54370a8a2c7ba72bae8354baab5a8/net_out_rule.go#L55-L57 |
123,899 | docker/go-plugins-helpers | sdk/encoder.go | DecodeRequest | func DecodeRequest(w http.ResponseWriter, r *http.Request, req interface{}) (err error) {
if err = json.NewDecoder(r.Body).Decode(req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
return
} | go | func DecodeRequest(w http.ResponseWriter, r *http.Request, req interface{}) (err error) {
if err = json.NewDecoder(r.Body).Decode(req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
}
return
} | [
"func",
"DecodeRequest",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"req",
"interface",
"{",
"}",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
"=",
"json",
".",
"NewDecoder",
"(",
"r",
".",
"Body",
")",... | // DecodeRequest decodes an http request into a given structure. | [
"DecodeRequest",
"decodes",
"an",
"http",
"request",
"into",
"a",
"given",
"structure",
"."
] | 1e6269c305b8c75cfda1c8aa91349c38d7335814 | https://github.com/docker/go-plugins-helpers/blob/1e6269c305b8c75cfda1c8aa91349c38d7335814/sdk/encoder.go#L14-L19 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.