repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
lxc/lxd | lxd/api.go | queryParam | func queryParam(request *http.Request, key string) string {
var values url.Values
var err error
if request.URL != nil {
values, err = url.ParseQuery(request.URL.RawQuery)
if err != nil {
logger.Warnf("Failed to parse query string %q: %v", request.URL.RawQuery, err)
return ""
}
}
if values == nil {
... | go | func queryParam(request *http.Request, key string) string {
var values url.Values
var err error
if request.URL != nil {
values, err = url.ParseQuery(request.URL.RawQuery)
if err != nil {
logger.Warnf("Failed to parse query string %q: %v", request.URL.RawQuery, err)
return ""
}
}
if values == nil {
... | [
"func",
"queryParam",
"(",
"request",
"*",
"http",
".",
"Request",
",",
"key",
"string",
")",
"string",
"{",
"var",
"values",
"url",
".",
"Values",
"\n",
"var",
"err",
"error",
"\n",
"if",
"request",
".",
"URL",
"!=",
"nil",
"{",
"values",
",",
"err"... | // Extract the given query parameter directly from the URL, never from an
// encoded body. | [
"Extract",
"the",
"given",
"query",
"parameter",
"directly",
"from",
"the",
"URL",
"never",
"from",
"an",
"encoded",
"body",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/api.go#L123-L140 | test |
lxc/lxd | shared/generate/db.go | newDb | func newDb() *cobra.Command {
cmd := &cobra.Command{
Use: "db [sub-command]",
Short: "Database-related code generation.",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Not implemented")
},
}
cmd.AddCommand(newDbSchema())
cmd.AddCommand(newDbMapper())
return cmd
} | go | func newDb() *cobra.Command {
cmd := &cobra.Command{
Use: "db [sub-command]",
Short: "Database-related code generation.",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Not implemented")
},
}
cmd.AddCommand(newDbSchema())
cmd.AddCommand(newDbMapper())
return cmd
} | [
"func",
"newDb",
"(",
")",
"*",
"cobra",
".",
"Command",
"{",
"cmd",
":=",
"&",
"cobra",
".",
"Command",
"{",
"Use",
":",
"\"db [sub-command]\"",
",",
"Short",
":",
"\"Database-related code generation.\"",
",",
"RunE",
":",
"func",
"(",
"cmd",
"*",
"cobra"... | // Return a new db command. | [
"Return",
"a",
"new",
"db",
"command",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db.go#L15-L28 | test |
lxc/lxd | lxd/db/operations.go | Description | func (t OperationType) Description() string {
switch t {
case OperationClusterBootstrap:
return "Creating bootstrap node"
case OperationClusterJoin:
return "Joining cluster"
case OperationBackupCreate:
return "Backing up container"
case OperationBackupRename:
return "Renaming container backup"
case Operat... | go | func (t OperationType) Description() string {
switch t {
case OperationClusterBootstrap:
return "Creating bootstrap node"
case OperationClusterJoin:
return "Joining cluster"
case OperationBackupCreate:
return "Backing up container"
case OperationBackupRename:
return "Renaming container backup"
case Operat... | [
"func",
"(",
"t",
"OperationType",
")",
"Description",
"(",
")",
"string",
"{",
"switch",
"t",
"{",
"case",
"OperationClusterBootstrap",
":",
"return",
"\"Creating bootstrap node\"",
"\n",
"case",
"OperationClusterJoin",
":",
"return",
"\"Joining cluster\"",
"\n",
"... | // Description return a human-readable description of the operation type. | [
"Description",
"return",
"a",
"human",
"-",
"readable",
"description",
"of",
"the",
"operation",
"type",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L68-L163 | test |
lxc/lxd | lxd/db/operations.go | Permission | func (t OperationType) Permission() string {
switch t {
case OperationBackupCreate:
return "operate-containers"
case OperationBackupRename:
return "operate-containers"
case OperationBackupRestore:
return "operate-containers"
case OperationBackupRemove:
return "operate-containers"
case OperationConsoleShow... | go | func (t OperationType) Permission() string {
switch t {
case OperationBackupCreate:
return "operate-containers"
case OperationBackupRename:
return "operate-containers"
case OperationBackupRestore:
return "operate-containers"
case OperationBackupRemove:
return "operate-containers"
case OperationConsoleShow... | [
"func",
"(",
"t",
"OperationType",
")",
"Permission",
"(",
")",
"string",
"{",
"switch",
"t",
"{",
"case",
"OperationBackupCreate",
":",
"return",
"\"operate-containers\"",
"\n",
"case",
"OperationBackupRename",
":",
"return",
"\"operate-containers\"",
"\n",
"case",... | // Permission returns the needed RBAC permission to cancel the oepration | [
"Permission",
"returns",
"the",
"needed",
"RBAC",
"permission",
"to",
"cancel",
"the",
"oepration"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L166-L231 | test |
lxc/lxd | lxd/db/operations.go | OperationsUUIDs | func (c *ClusterTx) OperationsUUIDs() ([]string, error) {
stmt := "SELECT uuid FROM operations WHERE node_id=?"
return query.SelectStrings(c.tx, stmt, c.nodeID)
} | go | func (c *ClusterTx) OperationsUUIDs() ([]string, error) {
stmt := "SELECT uuid FROM operations WHERE node_id=?"
return query.SelectStrings(c.tx, stmt, c.nodeID)
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationsUUIDs",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"\"SELECT uuid FROM operations WHERE node_id=?\"",
"\n",
"return",
"query",
".",
"SelectStrings",
"(",
"c",
".",
"tx",
",",
... | // OperationsUUIDs returns the UUIDs of all operations associated with this
// node. | [
"OperationsUUIDs",
"returns",
"the",
"UUIDs",
"of",
"all",
"operations",
"associated",
"with",
"this",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L249-L252 | test |
lxc/lxd | lxd/db/operations.go | OperationNodes | func (c *ClusterTx) OperationNodes(project string) ([]string, error) {
stmt := `
SELECT DISTINCT nodes.address
FROM operations
LEFT OUTER JOIN projects ON projects.id = operations.project_id
JOIN nodes ON nodes.id = operations.node_id
WHERE projects.name = ? OR operations.project_id IS NULL
`
return query.Sele... | go | func (c *ClusterTx) OperationNodes(project string) ([]string, error) {
stmt := `
SELECT DISTINCT nodes.address
FROM operations
LEFT OUTER JOIN projects ON projects.id = operations.project_id
JOIN nodes ON nodes.id = operations.node_id
WHERE projects.name = ? OR operations.project_id IS NULL
`
return query.Sele... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationNodes",
"(",
"project",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"`SELECT DISTINCT nodes.address FROM operations LEFT OUTER JOIN projects ON projects.id = operations.project_id JOIN n... | // OperationNodes returns a list of nodes that have running operations | [
"OperationNodes",
"returns",
"a",
"list",
"of",
"nodes",
"that",
"have",
"running",
"operations"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L255-L264 | test |
lxc/lxd | lxd/db/operations.go | OperationByUUID | func (c *ClusterTx) OperationByUUID(uuid string) (Operation, error) {
null := Operation{}
operations, err := c.operations("uuid=?", uuid)
if err != nil {
return null, err
}
switch len(operations) {
case 0:
return null, ErrNoSuchObject
case 1:
return operations[0], nil
default:
return null, fmt.Errorf("m... | go | func (c *ClusterTx) OperationByUUID(uuid string) (Operation, error) {
null := Operation{}
operations, err := c.operations("uuid=?", uuid)
if err != nil {
return null, err
}
switch len(operations) {
case 0:
return null, ErrNoSuchObject
case 1:
return operations[0], nil
default:
return null, fmt.Errorf("m... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationByUUID",
"(",
"uuid",
"string",
")",
"(",
"Operation",
",",
"error",
")",
"{",
"null",
":=",
"Operation",
"{",
"}",
"\n",
"operations",
",",
"err",
":=",
"c",
".",
"operations",
"(",
"\"uuid=?\"",
",",... | // OperationByUUID returns the operation with the given UUID. | [
"OperationByUUID",
"returns",
"the",
"operation",
"with",
"the",
"given",
"UUID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L267-L281 | test |
lxc/lxd | lxd/db/operations.go | OperationAdd | func (c *ClusterTx) OperationAdd(project, uuid string, typ OperationType) (int64, error) {
var projectID interface{}
if project != "" {
var err error
projectID, err = c.ProjectID(project)
if err != nil {
return -1, errors.Wrap(err, "Fetch project ID")
}
} else {
projectID = nil
}
columns := []string... | go | func (c *ClusterTx) OperationAdd(project, uuid string, typ OperationType) (int64, error) {
var projectID interface{}
if project != "" {
var err error
projectID, err = c.ProjectID(project)
if err != nil {
return -1, errors.Wrap(err, "Fetch project ID")
}
} else {
projectID = nil
}
columns := []string... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationAdd",
"(",
"project",
",",
"uuid",
"string",
",",
"typ",
"OperationType",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"projectID",
"interface",
"{",
"}",
"\n",
"if",
"project",
"!=",
"\"\"",
"{",... | // OperationAdd adds a new operations to the table. | [
"OperationAdd",
"adds",
"a",
"new",
"operations",
"to",
"the",
"table",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L284-L300 | test |
lxc/lxd | lxd/db/operations.go | OperationRemove | func (c *ClusterTx) OperationRemove(uuid string) error {
result, err := c.tx.Exec("DELETE FROM operations WHERE uuid=?", uuid)
if err != nil {
return err
}
n, err := result.RowsAffected()
if err != nil {
return err
}
if n != 1 {
return fmt.Errorf("query deleted %d rows instead of 1", n)
}
return nil
} | go | func (c *ClusterTx) OperationRemove(uuid string) error {
result, err := c.tx.Exec("DELETE FROM operations WHERE uuid=?", uuid)
if err != nil {
return err
}
n, err := result.RowsAffected()
if err != nil {
return err
}
if n != 1 {
return fmt.Errorf("query deleted %d rows instead of 1", n)
}
return nil
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"OperationRemove",
"(",
"uuid",
"string",
")",
"error",
"{",
"result",
",",
"err",
":=",
"c",
".",
"tx",
".",
"Exec",
"(",
"\"DELETE FROM operations WHERE uuid=?\"",
",",
"uuid",
")",
"\n",
"if",
"err",
"!=",
"nil... | // OperationRemove removes the operation with the given UUID. | [
"OperationRemove",
"removes",
"the",
"operation",
"with",
"the",
"given",
"UUID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L303-L316 | test |
lxc/lxd | lxd/db/operations.go | operations | func (c *ClusterTx) operations(where string, args ...interface{}) ([]Operation, error) {
operations := []Operation{}
dest := func(i int) []interface{} {
operations = append(operations, Operation{})
return []interface{}{
&operations[i].ID,
&operations[i].UUID,
&operations[i].NodeAddress,
&operations[i]... | go | func (c *ClusterTx) operations(where string, args ...interface{}) ([]Operation, error) {
operations := []Operation{}
dest := func(i int) []interface{} {
operations = append(operations, Operation{})
return []interface{}{
&operations[i].ID,
&operations[i].UUID,
&operations[i].NodeAddress,
&operations[i]... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"operations",
"(",
"where",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"Operation",
",",
"error",
")",
"{",
"operations",
":=",
"[",
"]",
"Operation",
"{",
"}",
"\n",
"dest",
":... | // Operations returns all operations in the cluster, filtered by the given clause. | [
"Operations",
"returns",
"all",
"operations",
"in",
"the",
"cluster",
"filtered",
"by",
"the",
"given",
"clause",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/operations.go#L319-L346 | test |
lxc/lxd | lxd/logging.go | expireLogsTask | func expireLogsTask(state *state.State) (task.Func, task.Schedule) {
f := func(ctx context.Context) {
opRun := func(op *operation) error {
return expireLogs(ctx, state)
}
op, err := operationCreate(state.Cluster, "", operationClassTask, db.OperationLogsExpire, nil, nil, opRun, nil, nil)
if err != nil {
... | go | func expireLogsTask(state *state.State) (task.Func, task.Schedule) {
f := func(ctx context.Context) {
opRun := func(op *operation) error {
return expireLogs(ctx, state)
}
op, err := operationCreate(state.Cluster, "", operationClassTask, db.OperationLogsExpire, nil, nil, opRun, nil, nil)
if err != nil {
... | [
"func",
"expireLogsTask",
"(",
"state",
"*",
"state",
".",
"State",
")",
"(",
"task",
".",
"Func",
",",
"task",
".",
"Schedule",
")",
"{",
"f",
":=",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"opRun",
":=",
"func",
"(",
"op",
"*",
... | // This task function expires logs when executed. It's started by the Daemon
// and will run once every 24h. | [
"This",
"task",
"function",
"expires",
"logs",
"when",
"executed",
".",
"It",
"s",
"started",
"by",
"the",
"Daemon",
"and",
"will",
"run",
"once",
"every",
"24h",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/logging.go#L20-L41 | test |
lxc/lxd | shared/generate/file/path.go | absPath | func absPath(path string) string {
// We expect to be called by code within the lxd package itself.
_, filename, _, _ := runtime.Caller(1)
elems := strings.Split(filename, string(filepath.Separator))
for i := len(elems) - 1; i >= 0; i-- {
if elems[i] == "lxd" {
elems = append([]string{string(filepath.Separato... | go | func absPath(path string) string {
// We expect to be called by code within the lxd package itself.
_, filename, _, _ := runtime.Caller(1)
elems := strings.Split(filename, string(filepath.Separator))
for i := len(elems) - 1; i >= 0; i-- {
if elems[i] == "lxd" {
elems = append([]string{string(filepath.Separato... | [
"func",
"absPath",
"(",
"path",
"string",
")",
"string",
"{",
"_",
",",
"filename",
",",
"_",
",",
"_",
":=",
"runtime",
".",
"Caller",
"(",
"1",
")",
"\n",
"elems",
":=",
"strings",
".",
"Split",
"(",
"filename",
",",
"string",
"(",
"filepath",
".... | // Given its relative path with respect to the LXD surce tree, return the full
// path of a file. | [
"Given",
"its",
"relative",
"path",
"with",
"respect",
"to",
"the",
"LXD",
"surce",
"tree",
"return",
"the",
"full",
"path",
"of",
"a",
"file",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/file/path.go#L12-L28 | test |
lxc/lxd | lxd/config/schema.go | Keys | func (s Schema) Keys() []string {
keys := make([]string, len(s))
i := 0
for key := range s {
keys[i] = key
i++
}
sort.Strings(keys)
return keys
} | go | func (s Schema) Keys() []string {
keys := make([]string, len(s))
i := 0
for key := range s {
keys[i] = key
i++
}
sort.Strings(keys)
return keys
} | [
"func",
"(",
"s",
"Schema",
")",
"Keys",
"(",
")",
"[",
"]",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"s",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"key",
":=",
"range",
"s",
"{",
"keys",
"[",
"i",
... | // Keys returns all keys defined in the schema | [
"Keys",
"returns",
"all",
"keys",
"defined",
"in",
"the",
"schema"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/schema.go#L17-L26 | test |
lxc/lxd | lxd/config/schema.go | Defaults | func (s Schema) Defaults() map[string]interface{} {
values := make(map[string]interface{}, len(s))
for name, key := range s {
values[name] = key.Default
}
return values
} | go | func (s Schema) Defaults() map[string]interface{} {
values := make(map[string]interface{}, len(s))
for name, key := range s {
values[name] = key.Default
}
return values
} | [
"func",
"(",
"s",
"Schema",
")",
"Defaults",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"values",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
",",
"len",
"(",
"s",
")",
")",
"\n",
"for",
"name",
",... | // Defaults returns a map of all key names in the schema along with their default
// values. | [
"Defaults",
"returns",
"a",
"map",
"of",
"all",
"key",
"names",
"in",
"the",
"schema",
"along",
"with",
"their",
"default",
"values",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/schema.go#L30-L36 | test |
lxc/lxd | lxd/config/schema.go | mustGetKey | func (s Schema) mustGetKey(name string) Key {
key, ok := s[name]
if !ok {
panic(fmt.Sprintf("attempt to access unknown key '%s'", name))
}
return key
} | go | func (s Schema) mustGetKey(name string) Key {
key, ok := s[name]
if !ok {
panic(fmt.Sprintf("attempt to access unknown key '%s'", name))
}
return key
} | [
"func",
"(",
"s",
"Schema",
")",
"mustGetKey",
"(",
"name",
"string",
")",
"Key",
"{",
"key",
",",
"ok",
":=",
"s",
"[",
"name",
"]",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"attempt to access unknown key '%s'\"",
",",
... | // Get the Key associated with the given name, or panic. | [
"Get",
"the",
"Key",
"associated",
"with",
"the",
"given",
"name",
"or",
"panic",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/schema.go#L39-L45 | test |
lxc/lxd | lxd/config/schema.go | assertKeyType | func (s Schema) assertKeyType(name string, code Type) {
key := s.mustGetKey(name)
if key.Type != code {
panic(fmt.Sprintf("key '%s' has type code %d, not %d", name, key.Type, code))
}
} | go | func (s Schema) assertKeyType(name string, code Type) {
key := s.mustGetKey(name)
if key.Type != code {
panic(fmt.Sprintf("key '%s' has type code %d, not %d", name, key.Type, code))
}
} | [
"func",
"(",
"s",
"Schema",
")",
"assertKeyType",
"(",
"name",
"string",
",",
"code",
"Type",
")",
"{",
"key",
":=",
"s",
".",
"mustGetKey",
"(",
"name",
")",
"\n",
"if",
"key",
".",
"Type",
"!=",
"code",
"{",
"panic",
"(",
"fmt",
".",
"Sprintf",
... | // Assert that the Key with the given name as the given type. Panic if no Key
// with such name exists, or if it does not match the tiven type. | [
"Assert",
"that",
"the",
"Key",
"with",
"the",
"given",
"name",
"as",
"the",
"given",
"type",
".",
"Panic",
"if",
"no",
"Key",
"with",
"such",
"name",
"exists",
"or",
"if",
"it",
"does",
"not",
"match",
"the",
"tiven",
"type",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/schema.go#L49-L54 | test |
lxc/lxd | lxd/config/schema.go | validate | func (v *Key) validate(value string) error {
validator := v.Validator
if validator == nil {
// Dummy validator
validator = func(string) error { return nil }
}
// Handle unsetting
if value == "" {
return validator(v.Default)
}
switch v.Type {
case String:
case Bool:
if !shared.StringInSlice(strings.To... | go | func (v *Key) validate(value string) error {
validator := v.Validator
if validator == nil {
// Dummy validator
validator = func(string) error { return nil }
}
// Handle unsetting
if value == "" {
return validator(v.Default)
}
switch v.Type {
case String:
case Bool:
if !shared.StringInSlice(strings.To... | [
"func",
"(",
"v",
"*",
"Key",
")",
"validate",
"(",
"value",
"string",
")",
"error",
"{",
"validator",
":=",
"v",
".",
"Validator",
"\n",
"if",
"validator",
"==",
"nil",
"{",
"validator",
"=",
"func",
"(",
"string",
")",
"error",
"{",
"return",
"nil"... | // Tells if the given value can be assigned to this particular Value instance. | [
"Tells",
"if",
"the",
"given",
"value",
"can",
"be",
"assigned",
"to",
"this",
"particular",
"Value",
"instance",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/schema.go#L87-L120 | test |
lxc/lxd | client/lxd_storage_volumes.go | GetStoragePoolVolumes | func (r *ProtocolLXD) GetStoragePoolVolumes(pool string) ([]api.StorageVolume, error) {
if !r.HasExtension("storage") {
return nil, fmt.Errorf("The server is missing the required \"storage\" API extension")
}
volumes := []api.StorageVolume{}
// Fetch the raw value
_, err := r.queryStruct("GET", fmt.Sprintf("/s... | go | func (r *ProtocolLXD) GetStoragePoolVolumes(pool string) ([]api.StorageVolume, error) {
if !r.HasExtension("storage") {
return nil, fmt.Errorf("The server is missing the required \"storage\" API extension")
}
volumes := []api.StorageVolume{}
// Fetch the raw value
_, err := r.queryStruct("GET", fmt.Sprintf("/s... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolVolumes",
"(",
"pool",
"string",
")",
"(",
"[",
"]",
"api",
".",
"StorageVolume",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"storage\"",
")",
"{",
"return",
"nil",
",",... | // GetStoragePoolVolumes returns a list of StorageVolume entries for the provided pool | [
"GetStoragePoolVolumes",
"returns",
"a",
"list",
"of",
"StorageVolume",
"entries",
"for",
"the",
"provided",
"pool"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L38-L52 | test |
lxc/lxd | client/lxd_storage_volumes.go | GetStoragePoolVolume | func (r *ProtocolLXD) GetStoragePoolVolume(pool string, volType string, name string) (*api.StorageVolume, string, error) {
if !r.HasExtension("storage") {
return nil, "", fmt.Errorf("The server is missing the required \"storage\" API extension")
}
volume := api.StorageVolume{}
// Fetch the raw value
path := fm... | go | func (r *ProtocolLXD) GetStoragePoolVolume(pool string, volType string, name string) (*api.StorageVolume, string, error) {
if !r.HasExtension("storage") {
return nil, "", fmt.Errorf("The server is missing the required \"storage\" API extension")
}
volume := api.StorageVolume{}
// Fetch the raw value
path := fm... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolVolume",
"(",
"pool",
"string",
",",
"volType",
"string",
",",
"name",
"string",
")",
"(",
"*",
"api",
".",
"StorageVolume",
",",
"string",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExten... | // GetStoragePoolVolume returns a StorageVolume entry for the provided pool and volume name | [
"GetStoragePoolVolume",
"returns",
"a",
"StorageVolume",
"entry",
"for",
"the",
"provided",
"pool",
"and",
"volume",
"name"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L55-L70 | test |
lxc/lxd | client/lxd_storage_volumes.go | CreateStoragePoolVolume | func (r *ProtocolLXD) CreateStoragePoolVolume(pool string, volume api.StorageVolumesPost) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
// Send the request
path := fmt.Sprintf("/storage-pools/%s/volumes/%s", url.QueryEscape(pool), url.... | go | func (r *ProtocolLXD) CreateStoragePoolVolume(pool string, volume api.StorageVolumesPost) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
// Send the request
path := fmt.Sprintf("/storage-pools/%s/volumes/%s", url.QueryEscape(pool), url.... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"CreateStoragePoolVolume",
"(",
"pool",
"string",
",",
"volume",
"api",
".",
"StorageVolumesPost",
")",
"error",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"storage\"",
")",
"{",
"return",
"fmt",
".",
"Error... | // CreateStoragePoolVolume defines a new storage volume | [
"CreateStoragePoolVolume",
"defines",
"a",
"new",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L73-L86 | test |
lxc/lxd | client/lxd_storage_volumes.go | CreateStoragePoolVolumeSnapshot | func (r *ProtocolLXD) CreateStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshot api.StorageVolumeSnapshotsPost) (Operation, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\" API e... | go | func (r *ProtocolLXD) CreateStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshot api.StorageVolumeSnapshotsPost) (Operation, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\" API e... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"CreateStoragePoolVolumeSnapshot",
"(",
"pool",
"string",
",",
"volumeType",
"string",
",",
"volumeName",
"string",
",",
"snapshot",
"api",
".",
"StorageVolumeSnapshotsPost",
")",
"(",
"Operation",
",",
"error",
")",
"{... | // CreateStoragePoolVolumeSnapshot defines a new storage volume | [
"CreateStoragePoolVolumeSnapshot",
"defines",
"a",
"new",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L89-L105 | test |
lxc/lxd | client/lxd_storage_volumes.go | GetStoragePoolVolumeSnapshots | func (r *ProtocolLXD) GetStoragePoolVolumeSnapshots(pool string, volumeType string, volumeName string) ([]api.StorageVolumeSnapshot, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\" API extension")
}
snapshots... | go | func (r *ProtocolLXD) GetStoragePoolVolumeSnapshots(pool string, volumeType string, volumeName string) ([]api.StorageVolumeSnapshot, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\" API extension")
}
snapshots... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolVolumeSnapshots",
"(",
"pool",
"string",
",",
"volumeType",
"string",
",",
"volumeName",
"string",
")",
"(",
"[",
"]",
"api",
".",
"StorageVolumeSnapshot",
",",
"error",
")",
"{",
"if",
"!",
"r",
".... | // GetStoragePoolVolumeSnapshots returns a list of snapshots for the storage
// volume | [
"GetStoragePoolVolumeSnapshots",
"returns",
"a",
"list",
"of",
"snapshots",
"for",
"the",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L138-L155 | test |
lxc/lxd | client/lxd_storage_volumes.go | GetStoragePoolVolumeSnapshot | func (r *ProtocolLXD) GetStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshotName string) (*api.StorageVolumeSnapshot, string, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, "", fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\"... | go | func (r *ProtocolLXD) GetStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshotName string) (*api.StorageVolumeSnapshot, string, error) {
if !r.HasExtension("storage_api_volume_snapshots") {
return nil, "", fmt.Errorf("The server is missing the required \"storage_api_volume_snapshots\"... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"GetStoragePoolVolumeSnapshot",
"(",
"pool",
"string",
",",
"volumeType",
"string",
",",
"volumeName",
"string",
",",
"snapshotName",
"string",
")",
"(",
"*",
"api",
".",
"StorageVolumeSnapshot",
",",
"string",
",",
"... | // GetStoragePoolVolumeSnapshot returns a snapshots for the storage volume | [
"GetStoragePoolVolumeSnapshot",
"returns",
"a",
"snapshots",
"for",
"the",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L158-L176 | test |
lxc/lxd | client/lxd_storage_volumes.go | UpdateStoragePoolVolumeSnapshot | func (r *ProtocolLXD) UpdateStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshotName string, volume api.StorageVolumeSnapshotPut, ETag string) error {
if !r.HasExtension("storage_api_volume_snapshots") {
return fmt.Errorf("The server is missing the required \"storage_api_volume_snaps... | go | func (r *ProtocolLXD) UpdateStoragePoolVolumeSnapshot(pool string, volumeType string, volumeName string, snapshotName string, volume api.StorageVolumeSnapshotPut, ETag string) error {
if !r.HasExtension("storage_api_volume_snapshots") {
return fmt.Errorf("The server is missing the required \"storage_api_volume_snaps... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"UpdateStoragePoolVolumeSnapshot",
"(",
"pool",
"string",
",",
"volumeType",
"string",
",",
"volumeName",
"string",
",",
"snapshotName",
"string",
",",
"volume",
"api",
".",
"StorageVolumeSnapshotPut",
",",
"ETag",
"strin... | // UpdateStoragePoolVolumeSnapshot updates the volume to match the provided StoragePoolVolume struct | [
"UpdateStoragePoolVolumeSnapshot",
"updates",
"the",
"volume",
"to",
"match",
"the",
"provided",
"StoragePoolVolume",
"struct"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L214-L227 | test |
lxc/lxd | client/lxd_storage_volumes.go | MigrateStoragePoolVolume | func (r *ProtocolLXD) MigrateStoragePoolVolume(pool string, volume api.StorageVolumePost) (Operation, error) {
if !r.HasExtension("storage_api_remote_volume_handling") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_remote_volume_handling\" API extension")
}
// Sanity check
if !volume.... | go | func (r *ProtocolLXD) MigrateStoragePoolVolume(pool string, volume api.StorageVolumePost) (Operation, error) {
if !r.HasExtension("storage_api_remote_volume_handling") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_remote_volume_handling\" API extension")
}
// Sanity check
if !volume.... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"MigrateStoragePoolVolume",
"(",
"pool",
"string",
",",
"volume",
"api",
".",
"StorageVolumePost",
")",
"(",
"Operation",
",",
"error",
")",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"storage_api_remote_volume_... | // MigrateStoragePoolVolume requests that LXD prepares for a storage volume migration | [
"MigrateStoragePoolVolume",
"requests",
"that",
"LXD",
"prepares",
"for",
"a",
"storage",
"volume",
"migration"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L230-L248 | test |
lxc/lxd | client/lxd_storage_volumes.go | MoveStoragePoolVolume | func (r *ProtocolLXD) MoveStoragePoolVolume(pool string, source ContainerServer, sourcePool string, volume api.StorageVolume, args *StoragePoolVolumeMoveArgs) (RemoteOperation, error) {
if !r.HasExtension("storage_api_local_volume_handling") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_... | go | func (r *ProtocolLXD) MoveStoragePoolVolume(pool string, source ContainerServer, sourcePool string, volume api.StorageVolume, args *StoragePoolVolumeMoveArgs) (RemoteOperation, error) {
if !r.HasExtension("storage_api_local_volume_handling") {
return nil, fmt.Errorf("The server is missing the required \"storage_api_... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"MoveStoragePoolVolume",
"(",
"pool",
"string",
",",
"source",
"ContainerServer",
",",
"sourcePool",
"string",
",",
"volume",
"api",
".",
"StorageVolume",
",",
"args",
"*",
"StoragePoolVolumeMoveArgs",
")",
"(",
"Remote... | // MoveStoragePoolVolume renames or moves an existing storage volume | [
"MoveStoragePoolVolume",
"renames",
"or",
"moves",
"an",
"existing",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L523-L555 | test |
lxc/lxd | client/lxd_storage_volumes.go | UpdateStoragePoolVolume | func (r *ProtocolLXD) UpdateStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePut, ETag string) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
if volume.Restore != "" && !r.HasExtension("storage_api_volu... | go | func (r *ProtocolLXD) UpdateStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePut, ETag string) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
if volume.Restore != "" && !r.HasExtension("storage_api_volu... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"UpdateStoragePoolVolume",
"(",
"pool",
"string",
",",
"volType",
"string",
",",
"name",
"string",
",",
"volume",
"api",
".",
"StorageVolumePut",
",",
"ETag",
"string",
")",
"error",
"{",
"if",
"!",
"r",
".",
"H... | // UpdateStoragePoolVolume updates the volume to match the provided StoragePoolVolume struct | [
"UpdateStoragePoolVolume",
"updates",
"the",
"volume",
"to",
"match",
"the",
"provided",
"StoragePoolVolume",
"struct"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L558-L575 | test |
lxc/lxd | client/lxd_storage_volumes.go | DeleteStoragePoolVolume | func (r *ProtocolLXD) DeleteStoragePoolVolume(pool string, volType string, name string) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
// Send the request
path := fmt.Sprintf("/storage-pools/%s/volumes/%s/%s", url.QueryEscape(pool), url... | go | func (r *ProtocolLXD) DeleteStoragePoolVolume(pool string, volType string, name string) error {
if !r.HasExtension("storage") {
return fmt.Errorf("The server is missing the required \"storage\" API extension")
}
// Send the request
path := fmt.Sprintf("/storage-pools/%s/volumes/%s/%s", url.QueryEscape(pool), url... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"DeleteStoragePoolVolume",
"(",
"pool",
"string",
",",
"volType",
"string",
",",
"name",
"string",
")",
"error",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"storage\"",
")",
"{",
"return",
"fmt",
".",
"Err... | // DeleteStoragePoolVolume deletes a storage pool | [
"DeleteStoragePoolVolume",
"deletes",
"a",
"storage",
"pool"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L578-L591 | test |
lxc/lxd | client/lxd_storage_volumes.go | RenameStoragePoolVolume | func (r *ProtocolLXD) RenameStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePost) error {
if !r.HasExtension("storage_api_volume_rename") {
return fmt.Errorf("The server is missing the required \"storage_api_volume_rename\" API extension")
}
path := fmt.Sprintf("/storage-pools/%... | go | func (r *ProtocolLXD) RenameStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePost) error {
if !r.HasExtension("storage_api_volume_rename") {
return fmt.Errorf("The server is missing the required \"storage_api_volume_rename\" API extension")
}
path := fmt.Sprintf("/storage-pools/%... | [
"func",
"(",
"r",
"*",
"ProtocolLXD",
")",
"RenameStoragePoolVolume",
"(",
"pool",
"string",
",",
"volType",
"string",
",",
"name",
"string",
",",
"volume",
"api",
".",
"StorageVolumePost",
")",
"error",
"{",
"if",
"!",
"r",
".",
"HasExtension",
"(",
"\"st... | // RenameStoragePoolVolume renames a storage volume | [
"RenameStoragePoolVolume",
"renames",
"a",
"storage",
"volume"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_volumes.go#L594-L607 | test |
lxc/lxd | lxd/storage_pools_utils.go | doStoragePoolCreateInternal | func doStoragePoolCreateInternal(state *state.State, poolName, poolDescription string, driver string, config map[string]string, isNotification bool) error {
tryUndo := true
s, err := storagePoolInit(state, poolName)
if err != nil {
return err
}
// If this is a clustering notification for a ceph storage, we don'... | go | func doStoragePoolCreateInternal(state *state.State, poolName, poolDescription string, driver string, config map[string]string, isNotification bool) error {
tryUndo := true
s, err := storagePoolInit(state, poolName)
if err != nil {
return err
}
// If this is a clustering notification for a ceph storage, we don'... | [
"func",
"doStoragePoolCreateInternal",
"(",
"state",
"*",
"state",
".",
"State",
",",
"poolName",
",",
"poolDescription",
"string",
",",
"driver",
"string",
",",
"config",
"map",
"[",
"string",
"]",
"string",
",",
"isNotification",
"bool",
")",
"error",
"{",
... | // This performs all non-db related work needed to create the pool. | [
"This",
"performs",
"all",
"non",
"-",
"db",
"related",
"work",
"needed",
"to",
"create",
"the",
"pool",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_pools_utils.go#L232-L279 | test |
lxc/lxd | lxd/container.go | containerGetParentAndSnapshotName | func containerGetParentAndSnapshotName(name string) (string, string, bool) {
fields := strings.SplitN(name, shared.SnapshotDelimiter, 2)
if len(fields) == 1 {
return name, "", false
}
return fields[0], fields[1], true
} | go | func containerGetParentAndSnapshotName(name string) (string, string, bool) {
fields := strings.SplitN(name, shared.SnapshotDelimiter, 2)
if len(fields) == 1 {
return name, "", false
}
return fields[0], fields[1], true
} | [
"func",
"containerGetParentAndSnapshotName",
"(",
"name",
"string",
")",
"(",
"string",
",",
"string",
",",
"bool",
")",
"{",
"fields",
":=",
"strings",
".",
"SplitN",
"(",
"name",
",",
"shared",
".",
"SnapshotDelimiter",
",",
"2",
")",
"\n",
"if",
"len",
... | // Helper functions
// Returns the parent container name, snapshot name, and whether it actually was
// a snapshot name. | [
"Helper",
"functions",
"Returns",
"the",
"parent",
"container",
"name",
"snapshot",
"name",
"and",
"whether",
"it",
"actually",
"was",
"a",
"snapshot",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container.go#L39-L46 | test |
lxc/lxd | lxd/container.go | containerLoadFromAllProjects | func containerLoadFromAllProjects(s *state.State) ([]container, error) {
var projects []string
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
projects, err = tx.ProjectNames()
return err
})
if err != nil {
return nil, err
}
containers := []container{}
for _, project := range ... | go | func containerLoadFromAllProjects(s *state.State) ([]container, error) {
var projects []string
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
projects, err = tx.ProjectNames()
return err
})
if err != nil {
return nil, err
}
containers := []container{}
for _, project := range ... | [
"func",
"containerLoadFromAllProjects",
"(",
"s",
"*",
"state",
".",
"State",
")",
"(",
"[",
"]",
"container",
",",
"error",
")",
"{",
"var",
"projects",
"[",
"]",
"string",
"\n",
"err",
":=",
"s",
".",
"Cluster",
".",
"Transaction",
"(",
"func",
"(",
... | // Load all containers across all projects. | [
"Load",
"all",
"containers",
"across",
"all",
"projects",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container.go#L1427-L1449 | test |
lxc/lxd | lxd/container.go | containerLoadNodeAll | func containerLoadNodeAll(s *state.State) ([]container, error) {
// Get all the container arguments
var cts []db.Container
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
cts, err = tx.ContainerNodeList()
if err != nil {
return err
}
return nil
})
if err != nil {
return ni... | go | func containerLoadNodeAll(s *state.State) ([]container, error) {
// Get all the container arguments
var cts []db.Container
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
cts, err = tx.ContainerNodeList()
if err != nil {
return err
}
return nil
})
if err != nil {
return ni... | [
"func",
"containerLoadNodeAll",
"(",
"s",
"*",
"state",
".",
"State",
")",
"(",
"[",
"]",
"container",
",",
"error",
")",
"{",
"var",
"cts",
"[",
"]",
"db",
".",
"Container",
"\n",
"err",
":=",
"s",
".",
"Cluster",
".",
"Transaction",
"(",
"func",
... | // Load all containers of this nodes. | [
"Load",
"all",
"containers",
"of",
"this",
"nodes",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container.go#L1457-L1474 | test |
lxc/lxd | lxd/container.go | containerLoadNodeProjectAll | func containerLoadNodeProjectAll(s *state.State, project string) ([]container, error) {
// Get all the container arguments
var cts []db.Container
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
cts, err = tx.ContainerNodeProjectList(project)
if err != nil {
return err
}
return... | go | func containerLoadNodeProjectAll(s *state.State, project string) ([]container, error) {
// Get all the container arguments
var cts []db.Container
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
cts, err = tx.ContainerNodeProjectList(project)
if err != nil {
return err
}
return... | [
"func",
"containerLoadNodeProjectAll",
"(",
"s",
"*",
"state",
".",
"State",
",",
"project",
"string",
")",
"(",
"[",
"]",
"container",
",",
"error",
")",
"{",
"var",
"cts",
"[",
"]",
"db",
".",
"Container",
"\n",
"err",
":=",
"s",
".",
"Cluster",
".... | // Load all containers of this nodes under the given project. | [
"Load",
"all",
"containers",
"of",
"this",
"nodes",
"under",
"the",
"given",
"project",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container.go#L1477-L1494 | test |
lxc/lxd | lxd/cluster/heartbeat.go | heartbeatNode | func heartbeatNode(taskCtx context.Context, address string, cert *shared.CertInfo, raftNodes []db.RaftNode) error {
logger.Debugf("Sending heartbeat request to %s", address)
config, err := tlsClientConfig(cert)
if err != nil {
return err
}
url := fmt.Sprintf("https://%s%s", address, databaseEndpoint)
client :=... | go | func heartbeatNode(taskCtx context.Context, address string, cert *shared.CertInfo, raftNodes []db.RaftNode) error {
logger.Debugf("Sending heartbeat request to %s", address)
config, err := tlsClientConfig(cert)
if err != nil {
return err
}
url := fmt.Sprintf("https://%s%s", address, databaseEndpoint)
client :=... | [
"func",
"heartbeatNode",
"(",
"taskCtx",
"context",
".",
"Context",
",",
"address",
"string",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
",",
"raftNodes",
"[",
"]",
"db",
".",
"RaftNode",
")",
"error",
"{",
"logger",
".",
"Debugf",
"(",
"\"Sending heartb... | // Perform a single heartbeat request against the node with the given address. | [
"Perform",
"a",
"single",
"heartbeat",
"request",
"against",
"the",
"node",
"with",
"the",
"given",
"address",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/heartbeat.go#L158-L205 | test |
lxc/lxd | lxc/list.go | dotPrefixMatch | func (c *cmdList) dotPrefixMatch(short string, full string) bool {
fullMembs := strings.Split(full, ".")
shortMembs := strings.Split(short, ".")
if len(fullMembs) != len(shortMembs) {
return false
}
for i := range fullMembs {
if !strings.HasPrefix(fullMembs[i], shortMembs[i]) {
return false
}
}
retur... | go | func (c *cmdList) dotPrefixMatch(short string, full string) bool {
fullMembs := strings.Split(full, ".")
shortMembs := strings.Split(short, ".")
if len(fullMembs) != len(shortMembs) {
return false
}
for i := range fullMembs {
if !strings.HasPrefix(fullMembs[i], shortMembs[i]) {
return false
}
}
retur... | [
"func",
"(",
"c",
"*",
"cmdList",
")",
"dotPrefixMatch",
"(",
"short",
"string",
",",
"full",
"string",
")",
"bool",
"{",
"fullMembs",
":=",
"strings",
".",
"Split",
"(",
"full",
",",
"\".\"",
")",
"\n",
"shortMembs",
":=",
"strings",
".",
"Split",
"("... | // This seems a little excessive. | [
"This",
"seems",
"a",
"little",
"excessive",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/list.go#L127-L142 | test |
lxc/lxd | lxd/storage_zfs.go | ContainerMount | func (s *storageZfs) ContainerMount(c container) (bool, error) {
return s.doContainerMount(c.Project(), c.Name(), c.IsPrivileged())
} | go | func (s *storageZfs) ContainerMount(c container) (bool, error) {
return s.doContainerMount(c.Project(), c.Name(), c.IsPrivileged())
} | [
"func",
"(",
"s",
"*",
"storageZfs",
")",
"ContainerMount",
"(",
"c",
"container",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"s",
".",
"doContainerMount",
"(",
"c",
".",
"Project",
"(",
")",
",",
"c",
".",
"Name",
"(",
")",
",",
"c",
".... | // Things we don't need to care about | [
"Things",
"we",
"don",
"t",
"need",
"to",
"care",
"about"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_zfs.go#L777-L779 | test |
lxc/lxd | lxd/storage_zfs.go | ContainerStorageReady | func (s *storageZfs) ContainerStorageReady(container container) bool {
volumeName := projectPrefix(container.Project(), container.Name())
fs := fmt.Sprintf("containers/%s", volumeName)
return zfsFilesystemEntityExists(s.getOnDiskPoolName(), fs)
} | go | func (s *storageZfs) ContainerStorageReady(container container) bool {
volumeName := projectPrefix(container.Project(), container.Name())
fs := fmt.Sprintf("containers/%s", volumeName)
return zfsFilesystemEntityExists(s.getOnDiskPoolName(), fs)
} | [
"func",
"(",
"s",
"*",
"storageZfs",
")",
"ContainerStorageReady",
"(",
"container",
"container",
")",
"bool",
"{",
"volumeName",
":=",
"projectPrefix",
"(",
"container",
".",
"Project",
"(",
")",
",",
"container",
".",
"Name",
"(",
")",
")",
"\n",
"fs",
... | // Things we do have to care about | [
"Things",
"we",
"do",
"have",
"to",
"care",
"about"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_zfs.go#L826-L830 | test |
lxc/lxd | shared/cmd/ask.go | AskChoice | func AskChoice(question string, choices []string, defaultAnswer string) string {
for {
answer := askQuestion(question, defaultAnswer)
if shared.StringInSlice(answer, choices) {
return answer
}
invalidInput()
}
} | go | func AskChoice(question string, choices []string, defaultAnswer string) string {
for {
answer := askQuestion(question, defaultAnswer)
if shared.StringInSlice(answer, choices) {
return answer
}
invalidInput()
}
} | [
"func",
"AskChoice",
"(",
"question",
"string",
",",
"choices",
"[",
"]",
"string",
",",
"defaultAnswer",
"string",
")",
"string",
"{",
"for",
"{",
"answer",
":=",
"askQuestion",
"(",
"question",
",",
"defaultAnswer",
")",
"\n",
"if",
"shared",
".",
"Strin... | // AskChoice asks the user to select one of multiple options | [
"AskChoice",
"asks",
"the",
"user",
"to",
"select",
"one",
"of",
"multiple",
"options"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L33-L43 | test |
lxc/lxd | shared/cmd/ask.go | AskInt | func AskInt(question string, min int64, max int64, defaultAnswer string) int64 {
for {
answer := askQuestion(question, defaultAnswer)
result, err := strconv.ParseInt(answer, 10, 64)
if err == nil && (min == -1 || result >= min) && (max == -1 || result <= max) {
return result
}
invalidInput()
}
} | go | func AskInt(question string, min int64, max int64, defaultAnswer string) int64 {
for {
answer := askQuestion(question, defaultAnswer)
result, err := strconv.ParseInt(answer, 10, 64)
if err == nil && (min == -1 || result >= min) && (max == -1 || result <= max) {
return result
}
invalidInput()
}
} | [
"func",
"AskInt",
"(",
"question",
"string",
",",
"min",
"int64",
",",
"max",
"int64",
",",
"defaultAnswer",
"string",
")",
"int64",
"{",
"for",
"{",
"answer",
":=",
"askQuestion",
"(",
"question",
",",
"defaultAnswer",
")",
"\n",
"result",
",",
"err",
"... | // AskInt asks the user to enter an integer between a min and max value | [
"AskInt",
"asks",
"the",
"user",
"to",
"enter",
"an",
"integer",
"between",
"a",
"min",
"and",
"max",
"value"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L46-L58 | test |
lxc/lxd | shared/cmd/ask.go | AskString | func AskString(question string, defaultAnswer string, validate func(string) error) string {
for {
answer := askQuestion(question, defaultAnswer)
if validate != nil {
error := validate(answer)
if error != nil {
fmt.Fprintf(os.Stderr, "Invalid input: %s\n\n", error)
continue
}
return answer
}... | go | func AskString(question string, defaultAnswer string, validate func(string) error) string {
for {
answer := askQuestion(question, defaultAnswer)
if validate != nil {
error := validate(answer)
if error != nil {
fmt.Fprintf(os.Stderr, "Invalid input: %s\n\n", error)
continue
}
return answer
}... | [
"func",
"AskString",
"(",
"question",
"string",
",",
"defaultAnswer",
"string",
",",
"validate",
"func",
"(",
"string",
")",
"error",
")",
"string",
"{",
"for",
"{",
"answer",
":=",
"askQuestion",
"(",
"question",
",",
"defaultAnswer",
")",
"\n",
"if",
"va... | // AskString asks the user to enter a string, which optionally
// conforms to a validation function. | [
"AskString",
"asks",
"the",
"user",
"to",
"enter",
"a",
"string",
"which",
"optionally",
"conforms",
"to",
"a",
"validation",
"function",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L62-L82 | test |
lxc/lxd | shared/cmd/ask.go | AskPassword | func AskPassword(question string) string {
for {
fmt.Printf(question)
pwd, _ := terminal.ReadPassword(0)
fmt.Println("")
inFirst := string(pwd)
inFirst = strings.TrimSuffix(inFirst, "\n")
fmt.Printf("Again: ")
pwd, _ = terminal.ReadPassword(0)
fmt.Println("")
inSecond := string(pwd)
inSecond = st... | go | func AskPassword(question string) string {
for {
fmt.Printf(question)
pwd, _ := terminal.ReadPassword(0)
fmt.Println("")
inFirst := string(pwd)
inFirst = strings.TrimSuffix(inFirst, "\n")
fmt.Printf("Again: ")
pwd, _ = terminal.ReadPassword(0)
fmt.Println("")
inSecond := string(pwd)
inSecond = st... | [
"func",
"AskPassword",
"(",
"question",
"string",
")",
"string",
"{",
"for",
"{",
"fmt",
".",
"Printf",
"(",
"question",
")",
"\n",
"pwd",
",",
"_",
":=",
"terminal",
".",
"ReadPassword",
"(",
"0",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"\"",
")",
... | // AskPassword asks the user to enter a password. | [
"AskPassword",
"asks",
"the",
"user",
"to",
"enter",
"a",
"password",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L85-L106 | test |
lxc/lxd | shared/cmd/ask.go | AskPasswordOnce | func AskPasswordOnce(question string) string {
fmt.Printf(question)
pwd, _ := terminal.ReadPassword(0)
fmt.Println("")
return string(pwd)
} | go | func AskPasswordOnce(question string) string {
fmt.Printf(question)
pwd, _ := terminal.ReadPassword(0)
fmt.Println("")
return string(pwd)
} | [
"func",
"AskPasswordOnce",
"(",
"question",
"string",
")",
"string",
"{",
"fmt",
".",
"Printf",
"(",
"question",
")",
"\n",
"pwd",
",",
"_",
":=",
"terminal",
".",
"ReadPassword",
"(",
"0",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"\"",
")",
"\n",
"r... | // AskPasswordOnce asks the user to enter a password.
//
// It's the same as AskPassword, but it won't ask to enter it again. | [
"AskPasswordOnce",
"asks",
"the",
"user",
"to",
"enter",
"a",
"password",
".",
"It",
"s",
"the",
"same",
"as",
"AskPassword",
"but",
"it",
"won",
"t",
"ask",
"to",
"enter",
"it",
"again",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L111-L117 | test |
lxc/lxd | shared/cmd/ask.go | askQuestion | func askQuestion(question, defaultAnswer string) string {
fmt.Printf(question)
return readAnswer(defaultAnswer)
} | go | func askQuestion(question, defaultAnswer string) string {
fmt.Printf(question)
return readAnswer(defaultAnswer)
} | [
"func",
"askQuestion",
"(",
"question",
",",
"defaultAnswer",
"string",
")",
"string",
"{",
"fmt",
".",
"Printf",
"(",
"question",
")",
"\n",
"return",
"readAnswer",
"(",
"defaultAnswer",
")",
"\n",
"}"
] | // Ask a question on the output stream and read the answer from the input stream | [
"Ask",
"a",
"question",
"on",
"the",
"output",
"stream",
"and",
"read",
"the",
"answer",
"from",
"the",
"input",
"stream"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L120-L124 | test |
lxc/lxd | shared/cmd/ask.go | readAnswer | func readAnswer(defaultAnswer string) string {
answer, _ := stdin.ReadString('\n')
answer = strings.TrimSuffix(answer, "\n")
answer = strings.TrimSpace(answer)
if answer == "" {
answer = defaultAnswer
}
return answer
} | go | func readAnswer(defaultAnswer string) string {
answer, _ := stdin.ReadString('\n')
answer = strings.TrimSuffix(answer, "\n")
answer = strings.TrimSpace(answer)
if answer == "" {
answer = defaultAnswer
}
return answer
} | [
"func",
"readAnswer",
"(",
"defaultAnswer",
"string",
")",
"string",
"{",
"answer",
",",
"_",
":=",
"stdin",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"answer",
"=",
"strings",
".",
"TrimSuffix",
"(",
"answer",
",",
"\"\\n\"",
")",
"\n",
"\\n",
"\n",
... | // Read the user's answer from the input stream, trimming newline and providing a default. | [
"Read",
"the",
"user",
"s",
"answer",
"from",
"the",
"input",
"stream",
"trimming",
"newline",
"and",
"providing",
"a",
"default",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L127-L136 | test |
lxc/lxd | lxd/profiles.go | profilePost | func profilePost(d *Daemon, r *http.Request) Response {
project := projectParam(r)
name := mux.Vars(r)["name"]
if name == "default" {
return Forbidden(errors.New("The 'default' profile cannot be renamed"))
}
req := api.ProfilePost{}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return BadRequ... | go | func profilePost(d *Daemon, r *http.Request) Response {
project := projectParam(r)
name := mux.Vars(r)["name"]
if name == "default" {
return Forbidden(errors.New("The 'default' profile cannot be renamed"))
}
req := api.ProfilePost{}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return BadRequ... | [
"func",
"profilePost",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"project",
":=",
"projectParam",
"(",
"r",
")",
"\n",
"name",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"[",
"\"name\"",
"]",
"\n",
"if",
... | // The handler for the post operation. | [
"The",
"handler",
"for",
"the",
"post",
"operation",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles.go#L362-L411 | test |
lxc/lxd | lxd/profiles.go | profileDelete | func profileDelete(d *Daemon, r *http.Request) Response {
project := projectParam(r)
name := mux.Vars(r)["name"]
if name == "default" {
return Forbidden(errors.New("The 'default' profile cannot be deleted"))
}
err := d.cluster.Transaction(func(tx *db.ClusterTx) error {
hasProfiles, err := tx.ProjectHasProfil... | go | func profileDelete(d *Daemon, r *http.Request) Response {
project := projectParam(r)
name := mux.Vars(r)["name"]
if name == "default" {
return Forbidden(errors.New("The 'default' profile cannot be deleted"))
}
err := d.cluster.Transaction(func(tx *db.ClusterTx) error {
hasProfiles, err := tx.ProjectHasProfil... | [
"func",
"profileDelete",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"project",
":=",
"projectParam",
"(",
"r",
")",
"\n",
"name",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"[",
"\"name\"",
"]",
"\n",
"if",
... | // The handler for the delete operation. | [
"The",
"handler",
"for",
"the",
"delete",
"operation",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles.go#L414-L447 | test |
lxc/lxd | shared/container.go | IsRootDiskDevice | func IsRootDiskDevice(device map[string]string) bool {
if device["type"] == "disk" && device["path"] == "/" && device["source"] == "" {
return true
}
return false
} | go | func IsRootDiskDevice(device map[string]string) bool {
if device["type"] == "disk" && device["path"] == "/" && device["source"] == "" {
return true
}
return false
} | [
"func",
"IsRootDiskDevice",
"(",
"device",
"map",
"[",
"string",
"]",
"string",
")",
"bool",
"{",
"if",
"device",
"[",
"\"type\"",
"]",
"==",
"\"disk\"",
"&&",
"device",
"[",
"\"path\"",
"]",
"==",
"\"/\"",
"&&",
"device",
"[",
"\"source\"",
"]",
"==",
... | // IsRootDiskDevice returns true if the given device representation is
// configured as root disk for a container. It typically get passed a specific
// entry of api.Container.Devices. | [
"IsRootDiskDevice",
"returns",
"true",
"if",
"the",
"given",
"device",
"representation",
"is",
"configured",
"as",
"root",
"disk",
"for",
"a",
"container",
".",
"It",
"typically",
"get",
"passed",
"a",
"specific",
"entry",
"of",
"api",
".",
"Container",
".",
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/container.go#L111-L117 | test |
lxc/lxd | shared/container.go | GetRootDiskDevice | func GetRootDiskDevice(devices map[string]map[string]string) (string, map[string]string, error) {
var devName string
var dev map[string]string
for n, d := range devices {
if IsRootDiskDevice(d) {
if devName != "" {
return "", nil, fmt.Errorf("More than one root device found")
}
devName = n
dev = ... | go | func GetRootDiskDevice(devices map[string]map[string]string) (string, map[string]string, error) {
var devName string
var dev map[string]string
for n, d := range devices {
if IsRootDiskDevice(d) {
if devName != "" {
return "", nil, fmt.Errorf("More than one root device found")
}
devName = n
dev = ... | [
"func",
"GetRootDiskDevice",
"(",
"devices",
"map",
"[",
"string",
"]",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"string",
",",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"devName",
"string",
"\n",
"var",
"dev",
"map",
... | // GetRootDiskDevice returns the container device that is configured as root disk | [
"GetRootDiskDevice",
"returns",
"the",
"container",
"device",
"that",
"is",
"configured",
"as",
"root",
"disk"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/container.go#L120-L140 | test |
lxc/lxd | lxd/response.go | ForwardedResponse | func ForwardedResponse(client lxd.ContainerServer, request *http.Request) Response {
return &forwardedResponse{
client: client,
request: request,
}
} | go | func ForwardedResponse(client lxd.ContainerServer, request *http.Request) Response {
return &forwardedResponse{
client: client,
request: request,
}
} | [
"func",
"ForwardedResponse",
"(",
"client",
"lxd",
".",
"ContainerServer",
",",
"request",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"return",
"&",
"forwardedResponse",
"{",
"client",
":",
"client",
",",
"request",
":",
"request",
",",
"}",
"\n",
... | // ForwardedResponse takes a request directed to a node and forwards it to
// another node, writing back the response it gegs. | [
"ForwardedResponse",
"takes",
"a",
"request",
"directed",
"to",
"a",
"node",
"and",
"forwards",
"it",
"to",
"another",
"node",
"writing",
"back",
"the",
"response",
"it",
"gegs",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/response.go#L156-L161 | test |
lxc/lxd | lxd/response.go | ForwardedResponseIfTargetIsRemote | func ForwardedResponseIfTargetIsRemote(d *Daemon, request *http.Request) Response {
targetNode := queryParam(request, "target")
if targetNode == "" {
return nil
}
// Figure out the address of the target node (which is possibly
// this very same node).
address, err := cluster.ResolveTarget(d.cluster, targetNode... | go | func ForwardedResponseIfTargetIsRemote(d *Daemon, request *http.Request) Response {
targetNode := queryParam(request, "target")
if targetNode == "" {
return nil
}
// Figure out the address of the target node (which is possibly
// this very same node).
address, err := cluster.ResolveTarget(d.cluster, targetNode... | [
"func",
"ForwardedResponseIfTargetIsRemote",
"(",
"d",
"*",
"Daemon",
",",
"request",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"targetNode",
":=",
"queryParam",
"(",
"request",
",",
"\"target\"",
")",
"\n",
"if",
"targetNode",
"==",
"\"\"",
"{",
"r... | // ForwardedResponseIfTargetIsRemote redirects a request to the request has a
// targetNode parameter pointing to a node which is not the local one. | [
"ForwardedResponseIfTargetIsRemote",
"redirects",
"a",
"request",
"to",
"the",
"request",
"has",
"a",
"targetNode",
"parameter",
"pointing",
"to",
"a",
"node",
"which",
"is",
"not",
"the",
"local",
"one",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/response.go#L165-L189 | test |
lxc/lxd | lxd/response.go | ForwardedResponseIfContainerIsRemote | func ForwardedResponseIfContainerIsRemote(d *Daemon, r *http.Request, project, name string) (Response, error) {
cert := d.endpoints.NetworkCert()
client, err := cluster.ConnectIfContainerIsRemote(d.cluster, project, name, cert)
if err != nil {
return nil, err
}
if client == nil {
return nil, nil
}
return For... | go | func ForwardedResponseIfContainerIsRemote(d *Daemon, r *http.Request, project, name string) (Response, error) {
cert := d.endpoints.NetworkCert()
client, err := cluster.ConnectIfContainerIsRemote(d.cluster, project, name, cert)
if err != nil {
return nil, err
}
if client == nil {
return nil, nil
}
return For... | [
"func",
"ForwardedResponseIfContainerIsRemote",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
",",
"project",
",",
"name",
"string",
")",
"(",
"Response",
",",
"error",
")",
"{",
"cert",
":=",
"d",
".",
"endpoints",
".",
"NetworkCert",
... | // ForwardedResponseIfContainerIsRemote redirects a request to the node running
// the container with the given name. If the container is local, nothing gets
// done and nil is returned. | [
"ForwardedResponseIfContainerIsRemote",
"redirects",
"a",
"request",
"to",
"the",
"node",
"running",
"the",
"container",
"with",
"the",
"given",
"name",
".",
"If",
"the",
"container",
"is",
"local",
"nothing",
"gets",
"done",
"and",
"nil",
"is",
"returned",
"."
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/response.go#L194-L204 | test |
lxc/lxd | lxd/response.go | ForwardedOperationResponse | func ForwardedOperationResponse(project string, op *api.Operation) Response {
return &forwardedOperationResponse{
op: op,
project: project,
}
} | go | func ForwardedOperationResponse(project string, op *api.Operation) Response {
return &forwardedOperationResponse{
op: op,
project: project,
}
} | [
"func",
"ForwardedOperationResponse",
"(",
"project",
"string",
",",
"op",
"*",
"api",
".",
"Operation",
")",
"Response",
"{",
"return",
"&",
"forwardedOperationResponse",
"{",
"op",
":",
"op",
",",
"project",
":",
"project",
",",
"}",
"\n",
"}"
] | // ForwardedOperationResponse creates a response that forwards the metadata of
// an operation created on another node. | [
"ForwardedOperationResponse",
"creates",
"a",
"response",
"that",
"forwards",
"the",
"metadata",
"of",
"an",
"operation",
"created",
"on",
"another",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/response.go#L419-L424 | test |
lxc/lxd | lxc/utils/progress.go | Done | func (p *ProgressRenderer) Done(msg string) {
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Mark this renderer as done
p.done = true
// Handle quiet mode
if p.Quiet {
msg = ""
}
// Truncate msg to terminal length
msg = p.truncat... | go | func (p *ProgressRenderer) Done(msg string) {
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Mark this renderer as done
p.done = true
// Handle quiet mode
if p.Quiet {
msg = ""
}
// Truncate msg to terminal length
msg = p.truncat... | [
"func",
"(",
"p",
"*",
"ProgressRenderer",
")",
"Done",
"(",
"msg",
"string",
")",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"p",
".",
"done",
"{",
"return",
"\n",
"}",
... | // Done prints the final status and prevents any update | [
"Done",
"prints",
"the",
"final",
"status",
"and",
"prevents",
"any",
"update"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/utils/progress.go#L42-L81 | test |
lxc/lxd | lxc/utils/progress.go | Update | func (p *ProgressRenderer) Update(status string) {
// Wait if needed
timeout := p.wait.Sub(time.Now())
if timeout.Seconds() > 0 {
time.Sleep(timeout)
}
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Handle quiet mode
if p.Quiet {
... | go | func (p *ProgressRenderer) Update(status string) {
// Wait if needed
timeout := p.wait.Sub(time.Now())
if timeout.Seconds() > 0 {
time.Sleep(timeout)
}
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Handle quiet mode
if p.Quiet {
... | [
"func",
"(",
"p",
"*",
"ProgressRenderer",
")",
"Update",
"(",
"status",
"string",
")",
"{",
"timeout",
":=",
"p",
".",
"wait",
".",
"Sub",
"(",
"time",
".",
"Now",
"(",
")",
")",
"\n",
"if",
"timeout",
".",
"Seconds",
"(",
")",
">",
"0",
"{",
... | // Update changes the status message to the provided string | [
"Update",
"changes",
"the",
"status",
"message",
"to",
"the",
"provided",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/utils/progress.go#L84-L141 | test |
lxc/lxd | lxc/utils/progress.go | Warn | func (p *ProgressRenderer) Warn(status string, timeout time.Duration) {
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Render the new message
p.wait = time.Now().Add(timeout)
msg := fmt.Sprintf("%s", status)
// Truncate msg to terminal... | go | func (p *ProgressRenderer) Warn(status string, timeout time.Duration) {
// Acquire rendering lock
p.lock.Lock()
defer p.lock.Unlock()
// Check if we're already done
if p.done {
return
}
// Render the new message
p.wait = time.Now().Add(timeout)
msg := fmt.Sprintf("%s", status)
// Truncate msg to terminal... | [
"func",
"(",
"p",
"*",
"ProgressRenderer",
")",
"Warn",
"(",
"status",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"{",
"p",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"p"... | // Warn shows a temporary message instead of the status | [
"Warn",
"shows",
"a",
"temporary",
"message",
"instead",
"of",
"the",
"status"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/utils/progress.go#L144-L173 | test |
lxc/lxd | lxc/utils/progress.go | UpdateProgress | func (p *ProgressRenderer) UpdateProgress(progress ioprogress.ProgressData) {
p.Update(progress.Text)
} | go | func (p *ProgressRenderer) UpdateProgress(progress ioprogress.ProgressData) {
p.Update(progress.Text)
} | [
"func",
"(",
"p",
"*",
"ProgressRenderer",
")",
"UpdateProgress",
"(",
"progress",
"ioprogress",
".",
"ProgressData",
")",
"{",
"p",
".",
"Update",
"(",
"progress",
".",
"Text",
")",
"\n",
"}"
] | // UpdateProgress is a helper to update the status using an iopgress instance | [
"UpdateProgress",
"is",
"a",
"helper",
"to",
"update",
"the",
"status",
"using",
"an",
"iopgress",
"instance"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/utils/progress.go#L176-L178 | test |
lxc/lxd | lxc/utils/progress.go | UpdateOp | func (p *ProgressRenderer) UpdateOp(op api.Operation) {
if op.Metadata == nil {
return
}
for key, value := range op.Metadata {
if !strings.HasSuffix(key, "_progress") {
continue
}
p.Update(value.(string))
break
}
} | go | func (p *ProgressRenderer) UpdateOp(op api.Operation) {
if op.Metadata == nil {
return
}
for key, value := range op.Metadata {
if !strings.HasSuffix(key, "_progress") {
continue
}
p.Update(value.(string))
break
}
} | [
"func",
"(",
"p",
"*",
"ProgressRenderer",
")",
"UpdateOp",
"(",
"op",
"api",
".",
"Operation",
")",
"{",
"if",
"op",
".",
"Metadata",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"op",
".",
"Metadata",
"{... | // UpdateOp is a helper to update the status using a LXD API operation | [
"UpdateOp",
"is",
"a",
"helper",
"to",
"update",
"the",
"status",
"using",
"a",
"LXD",
"API",
"operation"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/utils/progress.go#L181-L194 | test |
lxc/lxd | lxd/db/cluster/update.go | updateFromV6 | func updateFromV6(tx *sql.Tx) error {
// Fetch the IDs of all existing nodes.
nodeIDs, err := query.SelectIntegers(tx, "SELECT id FROM nodes")
if err != nil {
return errors.Wrap(err, "failed to get IDs of current nodes")
}
// Fetch the IDs of all existing zfs pools.
poolIDs, err := query.SelectIntegers(tx, `
S... | go | func updateFromV6(tx *sql.Tx) error {
// Fetch the IDs of all existing nodes.
nodeIDs, err := query.SelectIntegers(tx, "SELECT id FROM nodes")
if err != nil {
return errors.Wrap(err, "failed to get IDs of current nodes")
}
// Fetch the IDs of all existing zfs pools.
poolIDs, err := query.SelectIntegers(tx, `
S... | [
"func",
"updateFromV6",
"(",
"tx",
"*",
"sql",
".",
"Tx",
")",
"error",
"{",
"nodeIDs",
",",
"err",
":=",
"query",
".",
"SelectIntegers",
"(",
"tx",
",",
"\"SELECT id FROM nodes\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wr... | // The zfs.pool_name config key is node-specific, and needs to be linked to
// nodes. | [
"The",
"zfs",
".",
"pool_name",
"config",
"key",
"is",
"node",
"-",
"specific",
"and",
"needs",
"to",
"be",
"linked",
"to",
"nodes",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/update.go#L636-L684 | test |
lxc/lxd | lxd/endpoints/local.go | localCreateListener | func localCreateListener(path string, group string) (net.Listener, error) {
err := CheckAlreadyRunning(path)
if err != nil {
return nil, err
}
err = socketUnixRemoveStale(path)
if err != nil {
return nil, err
}
listener, err := socketUnixListen(path)
if err != nil {
return nil, err
}
err = localSetAc... | go | func localCreateListener(path string, group string) (net.Listener, error) {
err := CheckAlreadyRunning(path)
if err != nil {
return nil, err
}
err = socketUnixRemoveStale(path)
if err != nil {
return nil, err
}
listener, err := socketUnixListen(path)
if err != nil {
return nil, err
}
err = localSetAc... | [
"func",
"localCreateListener",
"(",
"path",
"string",
",",
"group",
"string",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"err",
":=",
"CheckAlreadyRunning",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"er... | // Create a new net.Listener bound to the unix socket of the local endpoint. | [
"Create",
"a",
"new",
"net",
".",
"Listener",
"bound",
"to",
"the",
"unix",
"socket",
"of",
"the",
"local",
"endpoint",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/local.go#L8-L31 | test |
lxc/lxd | shared/generate/db/stmt.go | NewStmt | func NewStmt(database, pkg, entity, kind string, config map[string]string) (*Stmt, error) {
packages, err := Packages()
if err != nil {
return nil, err
}
stmt := &Stmt{
db: database,
pkg: pkg,
entity: entity,
kind: kind,
config: config,
packages: packages,
}
return stmt, nil
} | go | func NewStmt(database, pkg, entity, kind string, config map[string]string) (*Stmt, error) {
packages, err := Packages()
if err != nil {
return nil, err
}
stmt := &Stmt{
db: database,
pkg: pkg,
entity: entity,
kind: kind,
config: config,
packages: packages,
}
return stmt, nil
} | [
"func",
"NewStmt",
"(",
"database",
",",
"pkg",
",",
"entity",
",",
"kind",
"string",
",",
"config",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"*",
"Stmt",
",",
"error",
")",
"{",
"packages",
",",
"err",
":=",
"Packages",
"(",
")",
"\n",
"if",... | // NewStmt return a new statement code snippet for running the given kind of
// query against the given database entity. | [
"NewStmt",
"return",
"a",
"new",
"statement",
"code",
"snippet",
"for",
"running",
"the",
"given",
"kind",
"of",
"query",
"against",
"the",
"given",
"database",
"entity",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/stmt.go#L25-L41 | test |
lxc/lxd | shared/generate/db/stmt.go | Generate | func (s *Stmt) Generate(buf *file.Buffer) error {
if strings.HasPrefix(s.kind, "objects") {
return s.objects(buf)
}
if strings.HasPrefix(s.kind, "create") && strings.HasSuffix(s.kind, "-ref") {
return s.createRef(buf)
}
if strings.HasSuffix(s.kind, "-ref") || strings.Contains(s.kind, "-ref-by-") {
return s... | go | func (s *Stmt) Generate(buf *file.Buffer) error {
if strings.HasPrefix(s.kind, "objects") {
return s.objects(buf)
}
if strings.HasPrefix(s.kind, "create") && strings.HasSuffix(s.kind, "-ref") {
return s.createRef(buf)
}
if strings.HasSuffix(s.kind, "-ref") || strings.Contains(s.kind, "-ref-by-") {
return s... | [
"func",
"(",
"s",
"*",
"Stmt",
")",
"Generate",
"(",
"buf",
"*",
"file",
".",
"Buffer",
")",
"error",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"s",
".",
"kind",
",",
"\"objects\"",
")",
"{",
"return",
"s",
".",
"objects",
"(",
"buf",
")",
"\n... | // Generate plumbing and wiring code for the desired statement. | [
"Generate",
"plumbing",
"and",
"wiring",
"code",
"for",
"the",
"desired",
"statement",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/stmt.go#L44-L75 | test |
lxc/lxd | shared/generate/db/stmt.go | register | func (s *Stmt) register(buf *file.Buffer, sql string, filters ...string) {
kind := strings.Replace(s.kind, "-", "_", -1)
if kind == "id" {
kind = "ID" // silence go lints
}
buf.L("var %s = %s.RegisterStmt(`\n%s\n`)", stmtCodeVar(s.entity, kind, filters...), s.db, sql)
} | go | func (s *Stmt) register(buf *file.Buffer, sql string, filters ...string) {
kind := strings.Replace(s.kind, "-", "_", -1)
if kind == "id" {
kind = "ID" // silence go lints
}
buf.L("var %s = %s.RegisterStmt(`\n%s\n`)", stmtCodeVar(s.entity, kind, filters...), s.db, sql)
} | [
"func",
"(",
"s",
"*",
"Stmt",
")",
"register",
"(",
"buf",
"*",
"file",
".",
"Buffer",
",",
"sql",
"string",
",",
"filters",
"...",
"string",
")",
"{",
"kind",
":=",
"strings",
".",
"Replace",
"(",
"s",
".",
"kind",
",",
"\"-\"",
",",
"\"_\"",
"... | // Output a line of code that registers the given statement and declares the
// associated statement code global variable. | [
"Output",
"a",
"line",
"of",
"code",
"that",
"registers",
"the",
"given",
"statement",
"and",
"declares",
"the",
"associated",
"statement",
"code",
"global",
"variable",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/stmt.go#L541-L547 | test |
lxc/lxd | client/connection.go | httpsLXD | func httpsLXD(url string, args *ConnectionArgs) (ContainerServer, error) {
// Use empty args if not specified
if args == nil {
args = &ConnectionArgs{}
}
// Initialize the client struct
server := ProtocolLXD{
httpCertificate: args.TLSServerCert,
httpHost: url,
httpProtocol: "https",
httpUse... | go | func httpsLXD(url string, args *ConnectionArgs) (ContainerServer, error) {
// Use empty args if not specified
if args == nil {
args = &ConnectionArgs{}
}
// Initialize the client struct
server := ProtocolLXD{
httpCertificate: args.TLSServerCert,
httpHost: url,
httpProtocol: "https",
httpUse... | [
"func",
"httpsLXD",
"(",
"url",
"string",
",",
"args",
"*",
"ConnectionArgs",
")",
"(",
"ContainerServer",
",",
"error",
")",
"{",
"if",
"args",
"==",
"nil",
"{",
"args",
"=",
"&",
"ConnectionArgs",
"{",
"}",
"\n",
"}",
"\n",
"server",
":=",
"ProtocolL... | // Internal function called by ConnectLXD and ConnectPublicLXD | [
"Internal",
"function",
"called",
"by",
"ConnectLXD",
"and",
"ConnectPublicLXD"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/connection.go#L173-L214 | test |
lxc/lxd | shared/api/container.go | IsActive | func (c Container) IsActive() bool {
switch c.StatusCode {
case Stopped:
return false
case Error:
return false
default:
return true
}
} | go | func (c Container) IsActive() bool {
switch c.StatusCode {
case Stopped:
return false
case Error:
return false
default:
return true
}
} | [
"func",
"(",
"c",
"Container",
")",
"IsActive",
"(",
")",
"bool",
"{",
"switch",
"c",
".",
"StatusCode",
"{",
"case",
"Stopped",
":",
"return",
"false",
"\n",
"case",
"Error",
":",
"return",
"false",
"\n",
"default",
":",
"return",
"true",
"\n",
"}",
... | // IsActive checks whether the container state indicates the container is active | [
"IsActive",
"checks",
"whether",
"the",
"container",
"state",
"indicates",
"the",
"container",
"is",
"active"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/container.go#L95-L104 | test |
lxc/lxd | lxd/db/raft.go | RaftNodeAddress | func (n *NodeTx) RaftNodeAddress(id int64) (string, error) {
stmt := "SELECT address FROM raft_nodes WHERE id=?"
addresses, err := query.SelectStrings(n.tx, stmt, id)
if err != nil {
return "", err
}
switch len(addresses) {
case 0:
return "", ErrNoSuchObject
case 1:
return addresses[0], nil
default:
// ... | go | func (n *NodeTx) RaftNodeAddress(id int64) (string, error) {
stmt := "SELECT address FROM raft_nodes WHERE id=?"
addresses, err := query.SelectStrings(n.tx, stmt, id)
if err != nil {
return "", err
}
switch len(addresses) {
case 0:
return "", ErrNoSuchObject
case 1:
return addresses[0], nil
default:
// ... | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodeAddress",
"(",
"id",
"int64",
")",
"(",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"\"SELECT address FROM raft_nodes WHERE id=?\"",
"\n",
"addresses",
",",
"err",
":=",
"query",
".",
"SelectStrings",
"(",
"... | // RaftNodeAddress returns the address of the LXD raft node with the given ID,
// if any matching row exists. | [
"RaftNodeAddress",
"returns",
"the",
"address",
"of",
"the",
"LXD",
"raft",
"node",
"with",
"the",
"given",
"ID",
"if",
"any",
"matching",
"row",
"exists",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/raft.go#L46-L62 | test |
lxc/lxd | lxd/db/raft.go | RaftNodeFirst | func (n *NodeTx) RaftNodeFirst(address string) error {
columns := []string{"id", "address"}
values := []interface{}{int64(1), address}
id, err := query.UpsertObject(n.tx, "raft_nodes", columns, values)
if err != nil {
return err
}
if id != 1 {
return fmt.Errorf("could not set raft node ID to 1")
}
return ni... | go | func (n *NodeTx) RaftNodeFirst(address string) error {
columns := []string{"id", "address"}
values := []interface{}{int64(1), address}
id, err := query.UpsertObject(n.tx, "raft_nodes", columns, values)
if err != nil {
return err
}
if id != 1 {
return fmt.Errorf("could not set raft node ID to 1")
}
return ni... | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodeFirst",
"(",
"address",
"string",
")",
"error",
"{",
"columns",
":=",
"[",
"]",
"string",
"{",
"\"id\"",
",",
"\"address\"",
"}",
"\n",
"values",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"int64",
"(",... | // RaftNodeFirst adds a the first node of the cluster. It ensures that the
// database ID is 1, to match the server ID of first raft log entry.
//
// This method is supposed to be called when there are no rows in raft_nodes,
// and it will replace whatever existing row has ID 1. | [
"RaftNodeFirst",
"adds",
"a",
"the",
"first",
"node",
"of",
"the",
"cluster",
".",
"It",
"ensures",
"that",
"the",
"database",
"ID",
"is",
"1",
"to",
"match",
"the",
"server",
"ID",
"of",
"first",
"raft",
"log",
"entry",
".",
"This",
"method",
"is",
"s... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/raft.go#L69-L80 | test |
lxc/lxd | lxd/db/raft.go | RaftNodeAdd | func (n *NodeTx) RaftNodeAdd(address string) (int64, error) {
columns := []string{"address"}
values := []interface{}{address}
return query.UpsertObject(n.tx, "raft_nodes", columns, values)
} | go | func (n *NodeTx) RaftNodeAdd(address string) (int64, error) {
columns := []string{"address"}
values := []interface{}{address}
return query.UpsertObject(n.tx, "raft_nodes", columns, values)
} | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodeAdd",
"(",
"address",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"columns",
":=",
"[",
"]",
"string",
"{",
"\"address\"",
"}",
"\n",
"values",
":=",
"[",
"]",
"interface",
"{",
"}",
"{",
"add... | // RaftNodeAdd adds a node to the current list of LXD nodes that are part of the
// dqlite Raft cluster. It returns the ID of the newly inserted row. | [
"RaftNodeAdd",
"adds",
"a",
"node",
"to",
"the",
"current",
"list",
"of",
"LXD",
"nodes",
"that",
"are",
"part",
"of",
"the",
"dqlite",
"Raft",
"cluster",
".",
"It",
"returns",
"the",
"ID",
"of",
"the",
"newly",
"inserted",
"row",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/raft.go#L84-L88 | test |
lxc/lxd | lxd/db/raft.go | RaftNodeDelete | func (n *NodeTx) RaftNodeDelete(id int64) error {
deleted, err := query.DeleteObject(n.tx, "raft_nodes", id)
if err != nil {
return err
}
if !deleted {
return ErrNoSuchObject
}
return nil
} | go | func (n *NodeTx) RaftNodeDelete(id int64) error {
deleted, err := query.DeleteObject(n.tx, "raft_nodes", id)
if err != nil {
return err
}
if !deleted {
return ErrNoSuchObject
}
return nil
} | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodeDelete",
"(",
"id",
"int64",
")",
"error",
"{",
"deleted",
",",
"err",
":=",
"query",
".",
"DeleteObject",
"(",
"n",
".",
"tx",
",",
"\"raft_nodes\"",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{... | // RaftNodeDelete removes a node from the current list of LXD nodes that are
// part of the dqlite Raft cluster. | [
"RaftNodeDelete",
"removes",
"a",
"node",
"from",
"the",
"current",
"list",
"of",
"LXD",
"nodes",
"that",
"are",
"part",
"of",
"the",
"dqlite",
"Raft",
"cluster",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/raft.go#L92-L101 | test |
lxc/lxd | lxd/db/raft.go | RaftNodesReplace | func (n *NodeTx) RaftNodesReplace(nodes []RaftNode) error {
_, err := n.tx.Exec("DELETE FROM raft_nodes")
if err != nil {
return err
}
columns := []string{"id", "address"}
for _, node := range nodes {
values := []interface{}{node.ID, node.Address}
_, err := query.UpsertObject(n.tx, "raft_nodes", columns, va... | go | func (n *NodeTx) RaftNodesReplace(nodes []RaftNode) error {
_, err := n.tx.Exec("DELETE FROM raft_nodes")
if err != nil {
return err
}
columns := []string{"id", "address"}
for _, node := range nodes {
values := []interface{}{node.ID, node.Address}
_, err := query.UpsertObject(n.tx, "raft_nodes", columns, va... | [
"func",
"(",
"n",
"*",
"NodeTx",
")",
"RaftNodesReplace",
"(",
"nodes",
"[",
"]",
"RaftNode",
")",
"error",
"{",
"_",
",",
"err",
":=",
"n",
".",
"tx",
".",
"Exec",
"(",
"\"DELETE FROM raft_nodes\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return"... | // RaftNodesReplace replaces the current list of raft nodes. | [
"RaftNodesReplace",
"replaces",
"the",
"current",
"list",
"of",
"raft",
"nodes",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/raft.go#L104-L119 | test |
lxc/lxd | lxd/sys/cgroup.go | initCGroup | func (s *OS) initCGroup() {
flags := []*bool{
&s.CGroupBlkioController,
&s.CGroupCPUController,
&s.CGroupCPUacctController,
&s.CGroupCPUsetController,
&s.CGroupDevicesController,
&s.CGroupFreezerController,
&s.CGroupMemoryController,
&s.CGroupNetPrioController,
&s.CGroupPidsController,
&s.CGroupSwa... | go | func (s *OS) initCGroup() {
flags := []*bool{
&s.CGroupBlkioController,
&s.CGroupCPUController,
&s.CGroupCPUacctController,
&s.CGroupCPUsetController,
&s.CGroupDevicesController,
&s.CGroupFreezerController,
&s.CGroupMemoryController,
&s.CGroupNetPrioController,
&s.CGroupPidsController,
&s.CGroupSwa... | [
"func",
"(",
"s",
"*",
"OS",
")",
"initCGroup",
"(",
")",
"{",
"flags",
":=",
"[",
"]",
"*",
"bool",
"{",
"&",
"s",
".",
"CGroupBlkioController",
",",
"&",
"s",
".",
"CGroupCPUController",
",",
"&",
"s",
".",
"CGroupCPUacctController",
",",
"&",
"s",... | // Detect CGroup support. | [
"Detect",
"CGroup",
"support",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/sys/cgroup.go#L11-L30 | test |
lxc/lxd | lxd/main_activateifneeded.go | sqliteDirectAccess | func sqliteDirectAccess(conn *sqlite3.SQLiteConn) error {
// Ensure journal mode is set to WAL, as this is a requirement for
// replication.
_, err := conn.Exec("PRAGMA journal_mode=wal", nil)
if err != nil {
return err
}
// Ensure we don't truncate or checkpoint the WAL on exit, as this
// would bork replica... | go | func sqliteDirectAccess(conn *sqlite3.SQLiteConn) error {
// Ensure journal mode is set to WAL, as this is a requirement for
// replication.
_, err := conn.Exec("PRAGMA journal_mode=wal", nil)
if err != nil {
return err
}
// Ensure we don't truncate or checkpoint the WAL on exit, as this
// would bork replica... | [
"func",
"sqliteDirectAccess",
"(",
"conn",
"*",
"sqlite3",
".",
"SQLiteConn",
")",
"error",
"{",
"_",
",",
"err",
":=",
"conn",
".",
"Exec",
"(",
"\"PRAGMA journal_mode=wal\"",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // Configure the sqlite connection so that it's safe to access the
// dqlite-managed sqlite file, also without setting up raft. | [
"Configure",
"the",
"sqlite",
"connection",
"so",
"that",
"it",
"s",
"safe",
"to",
"access",
"the",
"dqlite",
"-",
"managed",
"sqlite",
"file",
"also",
"without",
"setting",
"up",
"raft",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/main_activateifneeded.go#L156-L180 | test |
lxc/lxd | lxd/db/containers.mapper.go | ContainerGet | func (c *ClusterTx) ContainerGet(project string, name string) (*Container, error) {
filter := ContainerFilter{}
filter.Project = project
filter.Name = name
filter.Type = -1
objects, err := c.ContainerList(filter)
if err != nil {
return nil, errors.Wrap(err, "Failed to fetch Container")
}
switch len(objects)... | go | func (c *ClusterTx) ContainerGet(project string, name string) (*Container, error) {
filter := ContainerFilter{}
filter.Project = project
filter.Name = name
filter.Type = -1
objects, err := c.ContainerList(filter)
if err != nil {
return nil, errors.Wrap(err, "Failed to fetch Container")
}
switch len(objects)... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerGet",
"(",
"project",
"string",
",",
"name",
"string",
")",
"(",
"*",
"Container",
",",
"error",
")",
"{",
"filter",
":=",
"ContainerFilter",
"{",
"}",
"\n",
"filter",
".",
"Project",
"=",
"project",
"... | // ContainerGet returns the container with the given key. | [
"ContainerGet",
"returns",
"the",
"container",
"with",
"the",
"given",
"key",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.mapper.go#L322-L341 | test |
lxc/lxd | lxd/db/containers.mapper.go | ContainerID | func (c *ClusterTx) ContainerID(project string, name string) (int64, error) {
stmt := c.stmt(containerID)
rows, err := stmt.Query(project, name)
if err != nil {
return -1, errors.Wrap(err, "Failed to get container ID")
}
defer rows.Close()
// For sanity, make sure we read one and only one row.
if !rows.Next()... | go | func (c *ClusterTx) ContainerID(project string, name string) (int64, error) {
stmt := c.stmt(containerID)
rows, err := stmt.Query(project, name)
if err != nil {
return -1, errors.Wrap(err, "Failed to get container ID")
}
defer rows.Close()
// For sanity, make sure we read one and only one row.
if !rows.Next()... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerID",
"(",
"project",
"string",
",",
"name",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"stmt",
":=",
"c",
".",
"stmt",
"(",
"containerID",
")",
"\n",
"rows",
",",
"err",
":=",
"stmt",
"."... | // ContainerID return the ID of the container with the given key. | [
"ContainerID",
"return",
"the",
"ID",
"of",
"the",
"container",
"with",
"the",
"given",
"key",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.mapper.go#L344-L370 | test |
lxc/lxd | lxd/db/containers.mapper.go | ContainerExists | func (c *ClusterTx) ContainerExists(project string, name string) (bool, error) {
_, err := c.ContainerID(project, name)
if err != nil {
if err == ErrNoSuchObject {
return false, nil
}
return false, err
}
return true, nil
} | go | func (c *ClusterTx) ContainerExists(project string, name string) (bool, error) {
_, err := c.ContainerID(project, name)
if err != nil {
if err == ErrNoSuchObject {
return false, nil
}
return false, err
}
return true, nil
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerExists",
"(",
"project",
"string",
",",
"name",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ContainerID",
"(",
"project",
",",
"name",
")",
"\n",
"if",
"er... | // ContainerExists checks if a container with the given key exists. | [
"ContainerExists",
"checks",
"if",
"a",
"container",
"with",
"the",
"given",
"key",
"exists",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.mapper.go#L373-L383 | test |
lxc/lxd | shared/generate/db/mapping.go | ContainsFields | func (m *Mapping) ContainsFields(fields []*Field) bool {
matches := map[*Field]bool{}
for _, field := range m.Fields {
for _, other := range fields {
if field.Name == other.Name && field.Type.Name == other.Type.Name {
matches[field] = true
}
}
}
return len(matches) == len(fields)
} | go | func (m *Mapping) ContainsFields(fields []*Field) bool {
matches := map[*Field]bool{}
for _, field := range m.Fields {
for _, other := range fields {
if field.Name == other.Name && field.Type.Name == other.Type.Name {
matches[field] = true
}
}
}
return len(matches) == len(fields)
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"ContainsFields",
"(",
"fields",
"[",
"]",
"*",
"Field",
")",
"bool",
"{",
"matches",
":=",
"map",
"[",
"*",
"Field",
"]",
"bool",
"{",
"}",
"\n",
"for",
"_",
",",
"field",
":=",
"range",
"m",
".",
"Fields",... | // ContainsFields checks that the mapping contains fields with the same type
// and name of given ones. | [
"ContainsFields",
"checks",
"that",
"the",
"mapping",
"contains",
"fields",
"with",
"the",
"same",
"type",
"and",
"name",
"of",
"given",
"ones",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L43-L55 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldByName | func (m *Mapping) FieldByName(name string) *Field {
for _, field := range m.Fields {
if field.Name == name {
return field
}
}
return nil
} | go | func (m *Mapping) FieldByName(name string) *Field {
for _, field := range m.Fields {
if field.Name == name {
return field
}
}
return nil
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"FieldByName",
"(",
"name",
"string",
")",
"*",
"Field",
"{",
"for",
"_",
",",
"field",
":=",
"range",
"m",
".",
"Fields",
"{",
"if",
"field",
".",
"Name",
"==",
"name",
"{",
"return",
"field",
"\n",
"}",
"\... | // FieldByName returns the field with the given name, if any. | [
"FieldByName",
"returns",
"the",
"field",
"with",
"the",
"given",
"name",
"if",
"any",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L58-L66 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldColumnName | func (m *Mapping) FieldColumnName(name string) string {
field := m.FieldByName(name)
return fmt.Sprintf("%s.%s", entityTable(m.Name), field.Column())
} | go | func (m *Mapping) FieldColumnName(name string) string {
field := m.FieldByName(name)
return fmt.Sprintf("%s.%s", entityTable(m.Name), field.Column())
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"FieldColumnName",
"(",
"name",
"string",
")",
"string",
"{",
"field",
":=",
"m",
".",
"FieldByName",
"(",
"name",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s.%s\"",
",",
"entityTable",
"(",
"m",
".",
... | // FieldColumnName returns the column name of the field with the given name,
// prefixed with the entity's table name. | [
"FieldColumnName",
"returns",
"the",
"column",
"name",
"of",
"the",
"field",
"with",
"the",
"given",
"name",
"prefixed",
"with",
"the",
"entity",
"s",
"table",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L70-L73 | test |
lxc/lxd | shared/generate/db/mapping.go | FilterFieldByName | func (m *Mapping) FilterFieldByName(name string) (*Field, error) {
field := m.FieldByName(name)
if field == nil {
return nil, fmt.Errorf("Unknown filter %q", name)
}
if field.Type.Code != TypeColumn {
return nil, fmt.Errorf("Unknown filter %q not a column", name)
}
return field, nil
} | go | func (m *Mapping) FilterFieldByName(name string) (*Field, error) {
field := m.FieldByName(name)
if field == nil {
return nil, fmt.Errorf("Unknown filter %q", name)
}
if field.Type.Code != TypeColumn {
return nil, fmt.Errorf("Unknown filter %q not a column", name)
}
return field, nil
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"FilterFieldByName",
"(",
"name",
"string",
")",
"(",
"*",
"Field",
",",
"error",
")",
"{",
"field",
":=",
"m",
".",
"FieldByName",
"(",
"name",
")",
"\n",
"if",
"field",
"==",
"nil",
"{",
"return",
"nil",
","... | // FilterFieldByName returns the field with the given name if that field can be
// used as query filter, an error otherwise. | [
"FilterFieldByName",
"returns",
"the",
"field",
"with",
"the",
"given",
"name",
"if",
"that",
"field",
"can",
"be",
"used",
"as",
"query",
"filter",
"an",
"error",
"otherwise",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L77-L88 | test |
lxc/lxd | shared/generate/db/mapping.go | ColumnFields | func (m *Mapping) ColumnFields(exclude ...string) []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if shared.StringInSlice(field.Name, exclude) {
continue
}
if field.Type.Code == TypeColumn {
fields = append(fields, field)
}
}
return fields
} | go | func (m *Mapping) ColumnFields(exclude ...string) []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if shared.StringInSlice(field.Name, exclude) {
continue
}
if field.Type.Code == TypeColumn {
fields = append(fields, field)
}
}
return fields
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"ColumnFields",
"(",
"exclude",
"...",
"string",
")",
"[",
"]",
"*",
"Field",
"{",
"fields",
":=",
"[",
"]",
"*",
"Field",
"{",
"}",
"\n",
"for",
"_",
",",
"field",
":=",
"range",
"m",
".",
"Fields",
"{",
... | // ColumnFields returns the fields that map directly to a database column,
// either on this table or on a joined one. | [
"ColumnFields",
"returns",
"the",
"fields",
"that",
"map",
"directly",
"to",
"a",
"database",
"column",
"either",
"on",
"this",
"table",
"or",
"on",
"a",
"joined",
"one",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L92-L105 | test |
lxc/lxd | shared/generate/db/mapping.go | ScalarFields | func (m *Mapping) ScalarFields() []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if field.Config.Get("join") != "" {
fields = append(fields, field)
}
}
return fields
} | go | func (m *Mapping) ScalarFields() []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if field.Config.Get("join") != "" {
fields = append(fields, field)
}
}
return fields
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"ScalarFields",
"(",
")",
"[",
"]",
"*",
"Field",
"{",
"fields",
":=",
"[",
"]",
"*",
"Field",
"{",
"}",
"\n",
"for",
"_",
",",
"field",
":=",
"range",
"m",
".",
"Fields",
"{",
"if",
"field",
".",
"Config"... | // ScalarFields returns the fields that map directly to a single database
// column on another table that can be joined to this one. | [
"ScalarFields",
"returns",
"the",
"fields",
"that",
"map",
"directly",
"to",
"a",
"single",
"database",
"column",
"on",
"another",
"table",
"that",
"can",
"be",
"joined",
"to",
"this",
"one",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L109-L119 | test |
lxc/lxd | shared/generate/db/mapping.go | RefFields | func (m *Mapping) RefFields() []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if field.Type.Code == TypeSlice || field.Type.Code == TypeMap {
fields = append(fields, field)
}
}
return fields
} | go | func (m *Mapping) RefFields() []*Field {
fields := []*Field{}
for _, field := range m.Fields {
if field.Type.Code == TypeSlice || field.Type.Code == TypeMap {
fields = append(fields, field)
}
}
return fields
} | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"RefFields",
"(",
")",
"[",
"]",
"*",
"Field",
"{",
"fields",
":=",
"[",
"]",
"*",
"Field",
"{",
"}",
"\n",
"for",
"_",
",",
"field",
":=",
"range",
"m",
".",
"Fields",
"{",
"if",
"field",
".",
"Type",
"... | // RefFields returns the fields that are one-to-many references to other
// tables. | [
"RefFields",
"returns",
"the",
"fields",
"that",
"are",
"one",
"-",
"to",
"-",
"many",
"references",
"to",
"other",
"tables",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L123-L133 | test |
lxc/lxd | shared/generate/db/mapping.go | Column | func (f *Field) Column() string {
if f.Type.Code != TypeColumn {
panic("attempt to get column name of non-column field")
}
column := lex.Snake(f.Name)
join := f.Config.Get("join")
if join != "" {
column = fmt.Sprintf("%s AS %s", join, column)
}
return column
} | go | func (f *Field) Column() string {
if f.Type.Code != TypeColumn {
panic("attempt to get column name of non-column field")
}
column := lex.Snake(f.Name)
join := f.Config.Get("join")
if join != "" {
column = fmt.Sprintf("%s AS %s", join, column)
}
return column
} | [
"func",
"(",
"f",
"*",
"Field",
")",
"Column",
"(",
")",
"string",
"{",
"if",
"f",
".",
"Type",
".",
"Code",
"!=",
"TypeColumn",
"{",
"panic",
"(",
"\"attempt to get column name of non-column field\"",
")",
"\n",
"}",
"\n",
"column",
":=",
"lex",
".",
"S... | // Column returns the name of the database column the field maps to. The type
// code of the field must be TypeColumn. | [
"Column",
"returns",
"the",
"name",
"of",
"the",
"database",
"column",
"the",
"field",
"maps",
"to",
".",
"The",
"type",
"code",
"of",
"the",
"field",
"must",
"be",
"TypeColumn",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L168-L182 | test |
lxc/lxd | shared/generate/db/mapping.go | ZeroValue | func (f *Field) ZeroValue() string {
if f.Type.Code != TypeColumn {
panic("attempt to get zero value of non-column field")
}
switch f.Type.Name {
case "string":
return `""`
case "int":
// FIXME: we use -1 since at the moment integer criteria are
// required to be positive.
return "-1"
default:
panic(... | go | func (f *Field) ZeroValue() string {
if f.Type.Code != TypeColumn {
panic("attempt to get zero value of non-column field")
}
switch f.Type.Name {
case "string":
return `""`
case "int":
// FIXME: we use -1 since at the moment integer criteria are
// required to be positive.
return "-1"
default:
panic(... | [
"func",
"(",
"f",
"*",
"Field",
")",
"ZeroValue",
"(",
")",
"string",
"{",
"if",
"f",
".",
"Type",
".",
"Code",
"!=",
"TypeColumn",
"{",
"panic",
"(",
"\"attempt to get zero value of non-column field\"",
")",
"\n",
"}",
"\n",
"switch",
"f",
".",
"Type",
... | // ZeroValue returns the literal representing the zero value for this field. The type
// code of the field must be TypeColumn. | [
"ZeroValue",
"returns",
"the",
"literal",
"representing",
"the",
"zero",
"value",
"for",
"this",
"field",
".",
"The",
"type",
"code",
"of",
"the",
"field",
"must",
"be",
"TypeColumn",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L186-L201 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldColumns | func FieldColumns(fields []*Field) string {
columns := make([]string, len(fields))
for i, field := range fields {
columns[i] = field.Column()
}
return strings.Join(columns, ", ")
} | go | func FieldColumns(fields []*Field) string {
columns := make([]string, len(fields))
for i, field := range fields {
columns[i] = field.Column()
}
return strings.Join(columns, ", ")
} | [
"func",
"FieldColumns",
"(",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"columns",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"fields",
")",
")",
"\n",
"for",
"i",
",",
"field",
":=",
"range",
"fields",
"{",
"columns",
"[",
... | // FieldColumns converts thegiven fields to list of column names separated
// by a comma. | [
"FieldColumns",
"converts",
"thegiven",
"fields",
"to",
"list",
"of",
"column",
"names",
"separated",
"by",
"a",
"comma",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L205-L213 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldArgs | func FieldArgs(fields []*Field) string {
args := make([]string, len(fields))
for i, field := range fields {
args[i] = fmt.Sprintf("%s %s", lex.Minuscule(field.Name), field.Type.Name)
}
return strings.Join(args, ", ")
} | go | func FieldArgs(fields []*Field) string {
args := make([]string, len(fields))
for i, field := range fields {
args[i] = fmt.Sprintf("%s %s", lex.Minuscule(field.Name), field.Type.Name)
}
return strings.Join(args, ", ")
} | [
"func",
"FieldArgs",
"(",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"args",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"fields",
")",
")",
"\n",
"for",
"i",
",",
"field",
":=",
"range",
"fields",
"{",
"args",
"[",
"i",
... | // FieldArgs converts the given fields to function arguments, rendering their
// name and type. | [
"FieldArgs",
"converts",
"the",
"given",
"fields",
"to",
"function",
"arguments",
"rendering",
"their",
"name",
"and",
"type",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L217-L224 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldParams | func FieldParams(fields []*Field) string {
args := make([]string, len(fields))
for i, field := range fields {
args[i] = lex.Minuscule(field.Name)
}
return strings.Join(args, ", ")
} | go | func FieldParams(fields []*Field) string {
args := make([]string, len(fields))
for i, field := range fields {
args[i] = lex.Minuscule(field.Name)
}
return strings.Join(args, ", ")
} | [
"func",
"FieldParams",
"(",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"args",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"fields",
")",
")",
"\n",
"for",
"i",
",",
"field",
":=",
"range",
"fields",
"{",
"args",
"[",
"i",
... | // FieldParams converts the given fields to function parameters, rendering their
// name. | [
"FieldParams",
"converts",
"the",
"given",
"fields",
"to",
"function",
"parameters",
"rendering",
"their",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L228-L235 | test |
lxc/lxd | shared/generate/db/mapping.go | FieldCriteria | func FieldCriteria(fields []*Field) string {
criteria := make([]string, len(fields))
for i, field := range fields {
criteria[i] = fmt.Sprintf("%s = ?", field.Column())
}
return strings.Join(criteria, " AND ")
} | go | func FieldCriteria(fields []*Field) string {
criteria := make([]string, len(fields))
for i, field := range fields {
criteria[i] = fmt.Sprintf("%s = ?", field.Column())
}
return strings.Join(criteria, " AND ")
} | [
"func",
"FieldCriteria",
"(",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"criteria",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"fields",
")",
")",
"\n",
"for",
"i",
",",
"field",
":=",
"range",
"fields",
"{",
"criteria",
"[... | // FieldCriteria converts the given fields to AND-separated WHERE criteria. | [
"FieldCriteria",
"converts",
"the",
"given",
"fields",
"to",
"AND",
"-",
"separated",
"WHERE",
"criteria",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L238-L246 | test |
lxc/lxd | lxd/init.go | initDataClusterApply | func initDataClusterApply(d lxd.ContainerServer, config *initDataCluster) error {
if config == nil || !config.Enabled {
return nil
}
// Get the current cluster configuration
currentCluster, etag, err := d.GetCluster()
if err != nil {
return errors.Wrap(err, "Failed to retrieve current cluster config")
}
//... | go | func initDataClusterApply(d lxd.ContainerServer, config *initDataCluster) error {
if config == nil || !config.Enabled {
return nil
}
// Get the current cluster configuration
currentCluster, etag, err := d.GetCluster()
if err != nil {
return errors.Wrap(err, "Failed to retrieve current cluster config")
}
//... | [
"func",
"initDataClusterApply",
"(",
"d",
"lxd",
".",
"ContainerServer",
",",
"config",
"*",
"initDataCluster",
")",
"error",
"{",
"if",
"config",
"==",
"nil",
"||",
"!",
"config",
".",
"Enabled",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"currentCluster",
",... | // Helper to initialize LXD clustering.
//
// Used by the 'lxd init' command. | [
"Helper",
"to",
"initialize",
"LXD",
"clustering",
".",
"Used",
"by",
"the",
"lxd",
"init",
"command",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/init.go#L342-L368 | test |
lxc/lxd | shared/log15/format.go | JsonFormatEx | func JsonFormatEx(pretty, lineSeparated bool) Format {
jsonMarshal := json.Marshal
if pretty {
jsonMarshal = func(v interface{}) ([]byte, error) {
return json.MarshalIndent(v, "", " ")
}
}
return FormatFunc(func(r *Record) []byte {
props := make(map[string]interface{})
props[r.KeyNames.Time] = r.Tim... | go | func JsonFormatEx(pretty, lineSeparated bool) Format {
jsonMarshal := json.Marshal
if pretty {
jsonMarshal = func(v interface{}) ([]byte, error) {
return json.MarshalIndent(v, "", " ")
}
}
return FormatFunc(func(r *Record) []byte {
props := make(map[string]interface{})
props[r.KeyNames.Time] = r.Tim... | [
"func",
"JsonFormatEx",
"(",
"pretty",
",",
"lineSeparated",
"bool",
")",
"Format",
"{",
"jsonMarshal",
":=",
"json",
".",
"Marshal",
"\n",
"if",
"pretty",
"{",
"jsonMarshal",
"=",
"func",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",... | // JsonFormatEx formats log records as JSON objects. If pretty is true,
// records will be pretty-printed. If lineSeparated is true, records
// will be logged with a new line between each record. | [
"JsonFormatEx",
"formats",
"log",
"records",
"as",
"JSON",
"objects",
".",
"If",
"pretty",
"is",
"true",
"records",
"will",
"be",
"pretty",
"-",
"printed",
".",
"If",
"lineSeparated",
"is",
"true",
"records",
"will",
"be",
"logged",
"with",
"a",
"new",
"li... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/format.go#L127-L164 | test |
lxc/lxd | shared/log15/format.go | formatLogfmtValue | func formatLogfmtValue(value interface{}) string {
if value == nil {
return "nil"
}
value = formatShared(value)
switch v := value.(type) {
case bool:
return strconv.FormatBool(v)
case float32:
return strconv.FormatFloat(float64(v), floatFormat, 3, 64)
case float64:
return strconv.FormatFloat(v, floatFor... | go | func formatLogfmtValue(value interface{}) string {
if value == nil {
return "nil"
}
value = formatShared(value)
switch v := value.(type) {
case bool:
return strconv.FormatBool(v)
case float32:
return strconv.FormatFloat(float64(v), floatFormat, 3, 64)
case float64:
return strconv.FormatFloat(v, floatFor... | [
"func",
"formatLogfmtValue",
"(",
"value",
"interface",
"{",
"}",
")",
"string",
"{",
"if",
"value",
"==",
"nil",
"{",
"return",
"\"nil\"",
"\n",
"}",
"\n",
"value",
"=",
"formatShared",
"(",
"value",
")",
"\n",
"switch",
"v",
":=",
"value",
".",
"(",
... | // formatValue formats a value for serialization | [
"formatValue",
"formats",
"a",
"value",
"for",
"serialization"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/format.go#L203-L223 | test |
lxc/lxd | lxd/cluster/resolve.go | ResolveTarget | func ResolveTarget(cluster *db.Cluster, target string) (string, error) {
address := ""
err := cluster.Transaction(func(tx *db.ClusterTx) error {
name, err := tx.NodeName()
if err != nil {
return err
}
if target == name {
return nil
}
node, err := tx.NodeByName(target)
if err != nil {
if err =... | go | func ResolveTarget(cluster *db.Cluster, target string) (string, error) {
address := ""
err := cluster.Transaction(func(tx *db.ClusterTx) error {
name, err := tx.NodeName()
if err != nil {
return err
}
if target == name {
return nil
}
node, err := tx.NodeByName(target)
if err != nil {
if err =... | [
"func",
"ResolveTarget",
"(",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"target",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"address",
":=",
"\"\"",
"\n",
"err",
":=",
"cluster",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"db",
"."... | // ResolveTarget is a convenience for handling the value ?targetNode query
// parameter. It returns the address of the given node, or the empty string if
// the given node is the local one. | [
"ResolveTarget",
"is",
"a",
"convenience",
"for",
"handling",
"the",
"value",
"?targetNode",
"query",
"parameter",
".",
"It",
"returns",
"the",
"address",
"of",
"the",
"given",
"node",
"or",
"the",
"empty",
"string",
"if",
"the",
"given",
"node",
"is",
"the"... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/resolve.go#L12-L41 | test |
lxc/lxd | shared/ioprogress/writer.go | Write | func (pt *ProgressWriter) Write(p []byte) (int, error) {
// Do normal writer tasks
n, err := pt.WriteCloser.Write(p)
// Do the actual progress tracking
if pt.Tracker != nil {
pt.Tracker.total += int64(n)
pt.Tracker.update(n)
}
return n, err
} | go | func (pt *ProgressWriter) Write(p []byte) (int, error) {
// Do normal writer tasks
n, err := pt.WriteCloser.Write(p)
// Do the actual progress tracking
if pt.Tracker != nil {
pt.Tracker.total += int64(n)
pt.Tracker.update(n)
}
return n, err
} | [
"func",
"(",
"pt",
"*",
"ProgressWriter",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"n",
",",
"err",
":=",
"pt",
".",
"WriteCloser",
".",
"Write",
"(",
"p",
")",
"\n",
"if",
"pt",
".",
"Tracker",
"!=",
... | // Write in ProgressWriter is the same as io.Write | [
"Write",
"in",
"ProgressWriter",
"is",
"the",
"same",
"as",
"io",
".",
"Write"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/ioprogress/writer.go#L14-L25 | test |
lxc/lxd | lxd/db/cluster/query.go | updateNodeVersion | func updateNodeVersion(tx *sql.Tx, address string, apiExtensions int) error {
stmt := "UPDATE nodes SET schema=?, api_extensions=? WHERE address=?"
result, err := tx.Exec(stmt, len(updates), apiExtensions, address)
if err != nil {
return err
}
n, err := result.RowsAffected()
if err != nil {
return err
}
if ... | go | func updateNodeVersion(tx *sql.Tx, address string, apiExtensions int) error {
stmt := "UPDATE nodes SET schema=?, api_extensions=? WHERE address=?"
result, err := tx.Exec(stmt, len(updates), apiExtensions, address)
if err != nil {
return err
}
n, err := result.RowsAffected()
if err != nil {
return err
}
if ... | [
"func",
"updateNodeVersion",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"address",
"string",
",",
"apiExtensions",
"int",
")",
"error",
"{",
"stmt",
":=",
"\"UPDATE nodes SET schema=?, api_extensions=? WHERE address=?\"",
"\n",
"result",
",",
"err",
":=",
"tx",
".",
... | // Update the schema and api_extensions columns of the row in the nodes table
// that matches the given id.
//
// If not such row is found, an error is returned. | [
"Update",
"the",
"schema",
"and",
"api_extensions",
"columns",
"of",
"the",
"row",
"in",
"the",
"nodes",
"table",
"that",
"matches",
"the",
"given",
"id",
".",
"If",
"not",
"such",
"row",
"is",
"found",
"an",
"error",
"is",
"returned",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/query.go#L14-L28 | test |
lxc/lxd | lxd/db/cluster/query.go | selectNodesVersions | func selectNodesVersions(tx *sql.Tx) ([][2]int, error) {
versions := [][2]int{}
dest := func(i int) []interface{} {
versions = append(versions, [2]int{})
return []interface{}{&versions[i][0], &versions[i][1]}
}
stmt, err := tx.Prepare("SELECT schema, api_extensions FROM nodes")
if err != nil {
return nil, ... | go | func selectNodesVersions(tx *sql.Tx) ([][2]int, error) {
versions := [][2]int{}
dest := func(i int) []interface{} {
versions = append(versions, [2]int{})
return []interface{}{&versions[i][0], &versions[i][1]}
}
stmt, err := tx.Prepare("SELECT schema, api_extensions FROM nodes")
if err != nil {
return nil, ... | [
"func",
"selectNodesVersions",
"(",
"tx",
"*",
"sql",
".",
"Tx",
")",
"(",
"[",
"]",
"[",
"2",
"]",
"int",
",",
"error",
")",
"{",
"versions",
":=",
"[",
"]",
"[",
"2",
"]",
"int",
"{",
"}",
"\n",
"dest",
":=",
"func",
"(",
"i",
"int",
")",
... | // Return a slice of binary integer tuples. Each tuple contains the schema
// version and number of api extensions of a node in the cluster. | [
"Return",
"a",
"slice",
"of",
"binary",
"integer",
"tuples",
".",
"Each",
"tuple",
"contains",
"the",
"schema",
"version",
"and",
"number",
"of",
"api",
"extensions",
"of",
"a",
"node",
"in",
"the",
"cluster",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/query.go#L38-L56 | test |
lxc/lxd | lxd/util/sys.go | GetArchitectures | func GetArchitectures() ([]int, error) {
architectures := []int{}
architectureName, err := osarch.ArchitectureGetLocal()
if err != nil {
return nil, err
}
architecture, err := osarch.ArchitectureId(architectureName)
if err != nil {
return nil, err
}
architectures = append(architectures, architecture)
pe... | go | func GetArchitectures() ([]int, error) {
architectures := []int{}
architectureName, err := osarch.ArchitectureGetLocal()
if err != nil {
return nil, err
}
architecture, err := osarch.ArchitectureId(architectureName)
if err != nil {
return nil, err
}
architectures = append(architectures, architecture)
pe... | [
"func",
"GetArchitectures",
"(",
")",
"(",
"[",
"]",
"int",
",",
"error",
")",
"{",
"architectures",
":=",
"[",
"]",
"int",
"{",
"}",
"\n",
"architectureName",
",",
"err",
":=",
"osarch",
".",
"ArchitectureGetLocal",
"(",
")",
"\n",
"if",
"err",
"!=",
... | // GetArchitectures returns the list of supported architectures. | [
"GetArchitectures",
"returns",
"the",
"list",
"of",
"supported",
"architectures",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/sys.go#L18-L40 | test |
lxc/lxd | lxd/util/sys.go | RuntimeLiblxcVersionAtLeast | func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool {
version := golxc.Version()
version = strings.Replace(version, " (devel)", "-devel", 1)
parts := strings.Split(version, ".")
partsLen := len(parts)
if partsLen == 0 {
return false
}
develParts := strings.Split(parts[partsLen-1], "-")
if ... | go | func RuntimeLiblxcVersionAtLeast(major int, minor int, micro int) bool {
version := golxc.Version()
version = strings.Replace(version, " (devel)", "-devel", 1)
parts := strings.Split(version, ".")
partsLen := len(parts)
if partsLen == 0 {
return false
}
develParts := strings.Split(parts[partsLen-1], "-")
if ... | [
"func",
"RuntimeLiblxcVersionAtLeast",
"(",
"major",
"int",
",",
"minor",
"int",
",",
"micro",
"int",
")",
"bool",
"{",
"version",
":=",
"golxc",
".",
"Version",
"(",
")",
"\n",
"version",
"=",
"strings",
".",
"Replace",
"(",
"version",
",",
"\" (devel)\""... | // RuntimeLiblxcVersionAtLeast checks if the system's liblxc matches the
// provided version requirement | [
"RuntimeLiblxcVersionAtLeast",
"checks",
"if",
"the",
"system",
"s",
"liblxc",
"matches",
"the",
"provided",
"version",
"requirement"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/sys.go#L89-L155 | test |
lxc/lxd | lxd/util/sys.go | GetExecPath | func GetExecPath() string {
execPath := os.Getenv("LXD_EXEC_PATH")
if execPath != "" {
return execPath
}
execPath, err := os.Readlink("/proc/self/exe")
if err != nil {
execPath = "bad-exec-path"
}
return execPath
} | go | func GetExecPath() string {
execPath := os.Getenv("LXD_EXEC_PATH")
if execPath != "" {
return execPath
}
execPath, err := os.Readlink("/proc/self/exe")
if err != nil {
execPath = "bad-exec-path"
}
return execPath
} | [
"func",
"GetExecPath",
"(",
")",
"string",
"{",
"execPath",
":=",
"os",
".",
"Getenv",
"(",
"\"LXD_EXEC_PATH\"",
")",
"\n",
"if",
"execPath",
"!=",
"\"\"",
"{",
"return",
"execPath",
"\n",
"}",
"\n",
"execPath",
",",
"err",
":=",
"os",
".",
"Readlink",
... | // GetExecPath returns the path to the current binary | [
"GetExecPath",
"returns",
"the",
"path",
"to",
"the",
"current",
"binary"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/sys.go#L158-L169 | test |
lxc/lxd | lxd/cluster/connect.go | Connect | func Connect(address string, cert *shared.CertInfo, notify bool) (lxd.ContainerServer, error) {
args := &lxd.ConnectionArgs{
TLSServerCert: string(cert.PublicKey()),
TLSClientCert: string(cert.PublicKey()),
TLSClientKey: string(cert.PrivateKey()),
SkipGetServer: true,
}
if notify {
args.UserAgent = "lxd-c... | go | func Connect(address string, cert *shared.CertInfo, notify bool) (lxd.ContainerServer, error) {
args := &lxd.ConnectionArgs{
TLSServerCert: string(cert.PublicKey()),
TLSClientCert: string(cert.PublicKey()),
TLSClientKey: string(cert.PrivateKey()),
SkipGetServer: true,
}
if notify {
args.UserAgent = "lxd-c... | [
"func",
"Connect",
"(",
"address",
"string",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
",",
"notify",
"bool",
")",
"(",
"lxd",
".",
"ContainerServer",
",",
"error",
")",
"{",
"args",
":=",
"&",
"lxd",
".",
"ConnectionArgs",
"{",
"TLSServerCert",
":",
... | // Connect is a convenience around lxd.ConnectLXD that configures the client
// with the correct parameters for node-to-node communication.
//
// If 'notify' switch is true, then the user agent will be set to the special
// value 'lxd-cluster-notifier', which can be used in some cases to distinguish
// between a regula... | [
"Connect",
"is",
"a",
"convenience",
"around",
"lxd",
".",
"ConnectLXD",
"that",
"configures",
"the",
"client",
"with",
"the",
"correct",
"parameters",
"for",
"node",
"-",
"to",
"-",
"node",
"communication",
".",
"If",
"notify",
"switch",
"is",
"true",
"then... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/connect.go#L21-L34 | test |
lxc/lxd | lxd/cluster/connect.go | ConnectIfContainerIsRemote | func ConnectIfContainerIsRemote(cluster *db.Cluster, project, name string, cert *shared.CertInfo) (lxd.ContainerServer, error) {
var address string // Node address
err := cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
address, err = tx.ContainerNodeAddress(project, name)
return err
})
if err... | go | func ConnectIfContainerIsRemote(cluster *db.Cluster, project, name string, cert *shared.CertInfo) (lxd.ContainerServer, error) {
var address string // Node address
err := cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
address, err = tx.ContainerNodeAddress(project, name)
return err
})
if err... | [
"func",
"ConnectIfContainerIsRemote",
"(",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"project",
",",
"name",
"string",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
")",
"(",
"lxd",
".",
"ContainerServer",
",",
"error",
")",
"{",
"var",
"address",
"string"... | // ConnectIfContainerIsRemote figures out the address of the node which is
// running the container with the given name. If it's not the local node will
// connect to it and return the connected client, otherwise it will just return
// nil. | [
"ConnectIfContainerIsRemote",
"figures",
"out",
"the",
"address",
"of",
"the",
"node",
"which",
"is",
"running",
"the",
"container",
"with",
"the",
"given",
"name",
".",
"If",
"it",
"s",
"not",
"the",
"local",
"node",
"will",
"connect",
"to",
"it",
"and",
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/connect.go#L40-L55 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.