id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
148,500
kisom/goutils
sbuf/sbuf.go
Bytes
func (buf *Buffer) Bytes() []byte { if buf.buf == nil { return nil } p := make([]byte, buf.Len()) buf.Read(p) buf.Close() return p }
go
func (buf *Buffer) Bytes() []byte { if buf.buf == nil { return nil } p := make([]byte, buf.Len()) buf.Read(p) buf.Close() return p }
[ "func", "(", "buf", "*", "Buffer", ")", "Bytes", "(", ")", "[", "]", "byte", "{", "if", "buf", ".", "buf", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "p", ":=", "make", "(", "[", "]", "byte", ",", "buf", ".", "Len", "(", ")", ")"...
// Bytes returns the bytes currently in the buffer, and closes itself.
[ "Bytes", "returns", "the", "bytes", "currently", "in", "the", "buffer", "and", "closes", "itself", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/sbuf/sbuf.go#L135-L144
148,501
obeattie/ohmyglob
glob.go
Compile
func Compile(pattern string, options *Options) (Glob, error) { pattern = strings.TrimSpace(pattern) reader := strings.NewReader(pattern) if options == nil { options = DefaultOptions } else { // Check that the separator is not an expander for _, expander := range expanders { if options.Separator == expande...
go
func Compile(pattern string, options *Options) (Glob, error) { pattern = strings.TrimSpace(pattern) reader := strings.NewReader(pattern) if options == nil { options = DefaultOptions } else { // Check that the separator is not an expander for _, expander := range expanders { if options.Separator == expande...
[ "func", "Compile", "(", "pattern", "string", ",", "options", "*", "Options", ")", "(", "Glob", ",", "error", ")", "{", "pattern", "=", "strings", ".", "TrimSpace", "(", "pattern", ")", "\n", "reader", ":=", "strings", ".", "NewReader", "(", "pattern", ...
// Compile parses the given glob pattern and convertes it to a Glob. If no options are given, the DefaultOptions are // used.
[ "Compile", "parses", "the", "given", "glob", "pattern", "and", "convertes", "it", "to", "a", "Glob", ".", "If", "no", "options", "are", "given", "the", "DefaultOptions", "are", "used", "." ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/glob.go#L113-L217
148,502
obeattie/ohmyglob
globset.go
NewGlobSet
func NewGlobSet(globs []Glob) (GlobSet, error) { set := make(globSetImpl, len(globs)) for i, glob := range globs { set[i] = glob } return set, nil }
go
func NewGlobSet(globs []Glob) (GlobSet, error) { set := make(globSetImpl, len(globs)) for i, glob := range globs { set[i] = glob } return set, nil }
[ "func", "NewGlobSet", "(", "globs", "[", "]", "Glob", ")", "(", "GlobSet", ",", "error", ")", "{", "set", ":=", "make", "(", "globSetImpl", ",", "len", "(", "globs", ")", ")", "\n", "for", "i", ",", "glob", ":=", "range", "globs", "{", "set", "["...
// NewGlobSet constructs a GlobSet from a slice of Globs.
[ "NewGlobSet", "constructs", "a", "GlobSet", "from", "a", "slice", "of", "Globs", "." ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/globset.go#L92-L98
148,503
obeattie/ohmyglob
globset.go
CompileGlobSet
func CompileGlobSet(patterns []string, options *Options) (GlobSet, error) { globs := make(globSetImpl, len(patterns)) for i, pattern := range patterns { glob, err := Compile(pattern, options) if err != nil { return nil, err } globs[i] = glob } return globs, nil }
go
func CompileGlobSet(patterns []string, options *Options) (GlobSet, error) { globs := make(globSetImpl, len(patterns)) for i, pattern := range patterns { glob, err := Compile(pattern, options) if err != nil { return nil, err } globs[i] = glob } return globs, nil }
[ "func", "CompileGlobSet", "(", "patterns", "[", "]", "string", ",", "options", "*", "Options", ")", "(", "GlobSet", ",", "error", ")", "{", "globs", ":=", "make", "(", "globSetImpl", ",", "len", "(", "patterns", ")", ")", "\n", "for", "i", ",", "patt...
// CompileGlobSet constructs a GlobSet from a slice of strings, which will be compiled individually to Globs.
[ "CompileGlobSet", "constructs", "a", "GlobSet", "from", "a", "slice", "of", "strings", "which", "will", "be", "compiled", "individually", "to", "Globs", "." ]
290764208a0d066492b1864e86faf90992407852
https://github.com/obeattie/ohmyglob/blob/290764208a0d066492b1864e86faf90992407852/globset.go#L101-L112
148,504
kisom/goutils
lib/lib.go
Duration
func Duration(d time.Duration) string { var s string if d >= yearDuration { years := d / yearDuration s += fmt.Sprintf("%dy", years) d -= (years * yearDuration) } if d >= dayDuration { days := d / dayDuration s += fmt.Sprintf("%dd", days) } if s != "" { return s } d %= 1 * time.Second hours := d...
go
func Duration(d time.Duration) string { var s string if d >= yearDuration { years := d / yearDuration s += fmt.Sprintf("%dy", years) d -= (years * yearDuration) } if d >= dayDuration { days := d / dayDuration s += fmt.Sprintf("%dd", days) } if s != "" { return s } d %= 1 * time.Second hours := d...
[ "func", "Duration", "(", "d", "time", ".", "Duration", ")", "string", "{", "var", "s", "string", "\n", "if", "d", ">=", "yearDuration", "{", "years", ":=", "d", "/", "yearDuration", "\n", "s", "+=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "yea...
// Duration returns a prettier string for time.Durations.
[ "Duration", "returns", "a", "prettier", "string", "for", "time", ".", "Durations", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/lib/lib.go#L87-L109
148,505
kisom/goutils
lib/lib.go
ReadCertificate
func ReadCertificate(in []byte) (cert *x509.Certificate, rest []byte, err error) { if len(in) == 0 { err = errors.New("lib: empty certificate") return } if in[0] == '-' { p, remaining := pem.Decode(in) if p == nil { err = errors.New("lib: invalid PEM file") return } rest = remaining if p.Type !...
go
func ReadCertificate(in []byte) (cert *x509.Certificate, rest []byte, err error) { if len(in) == 0 { err = errors.New("lib: empty certificate") return } if in[0] == '-' { p, remaining := pem.Decode(in) if p == nil { err = errors.New("lib: invalid PEM file") return } rest = remaining if p.Type !...
[ "func", "ReadCertificate", "(", "in", "[", "]", "byte", ")", "(", "cert", "*", "x509", ".", "Certificate", ",", "rest", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "len", "(", "in", ")", "==", "0", "{", "err", "=", "errors", ".", "Ne...
// ReadCertificate reads a DER or PEM-encoded certificate from the // byte slice.
[ "ReadCertificate", "reads", "a", "DER", "or", "PEM", "-", "encoded", "certificate", "from", "the", "byte", "slice", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/lib/lib.go#L113-L137
148,506
kisom/goutils
lib/lib.go
ReadCertificates
func ReadCertificates(in []byte) (certs []*x509.Certificate, err error) { var cert *x509.Certificate for { cert, in, err = ReadCertificate(in) if err != nil { break } if cert == nil { break } certs = append(certs, cert) if len(in) == 0 { break } } return certs, err }
go
func ReadCertificates(in []byte) (certs []*x509.Certificate, err error) { var cert *x509.Certificate for { cert, in, err = ReadCertificate(in) if err != nil { break } if cert == nil { break } certs = append(certs, cert) if len(in) == 0 { break } } return certs, err }
[ "func", "ReadCertificates", "(", "in", "[", "]", "byte", ")", "(", "certs", "[", "]", "*", "x509", ".", "Certificate", ",", "err", "error", ")", "{", "var", "cert", "*", "x509", ".", "Certificate", "\n", "for", "{", "cert", ",", "in", ",", "err", ...
// ReadCertificates tries to read all the certificates in a // PEM-encoded collection.
[ "ReadCertificates", "tries", "to", "read", "all", "the", "certificates", "in", "a", "PEM", "-", "encoded", "collection", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/lib/lib.go#L141-L160
148,507
kisom/goutils
lib/lib.go
LoadCertificates
func LoadCertificates(path string) ([]*x509.Certificate, error) { in, err := ioutil.ReadFile(path) if err != nil { return nil, err } return ReadCertificates(in) }
go
func LoadCertificates(path string) ([]*x509.Certificate, error) { in, err := ioutil.ReadFile(path) if err != nil { return nil, err } return ReadCertificates(in) }
[ "func", "LoadCertificates", "(", "path", "string", ")", "(", "[", "]", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "in", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil...
// LoadCertificates tries to read all the certificates in a file, // returning them in the order that it found them in the file.
[ "LoadCertificates", "tries", "to", "read", "all", "the", "certificates", "in", "a", "file", "returning", "them", "in", "the", "order", "that", "it", "found", "them", "in", "the", "file", "." ]
50c226b726761b48b7cdec66ba702395b45ced95
https://github.com/kisom/goutils/blob/50c226b726761b48b7cdec66ba702395b45ced95/lib/lib.go#L177-L184
148,508
martini-contrib/staticbin
martini.go
ClassicWithoutStatic
func ClassicWithoutStatic() *martini.ClassicMartini { r := martini.NewRouter() m := martini.New() m.Use(martini.Logger()) m.Use(martini.Recovery()) m.MapTo(r, (*martini.Routes)(nil)) m.Action(r.Handle) return &martini.ClassicMartini{m, r} }
go
func ClassicWithoutStatic() *martini.ClassicMartini { r := martini.NewRouter() m := martini.New() m.Use(martini.Logger()) m.Use(martini.Recovery()) m.MapTo(r, (*martini.Routes)(nil)) m.Action(r.Handle) return &martini.ClassicMartini{m, r} }
[ "func", "ClassicWithoutStatic", "(", ")", "*", "martini", ".", "ClassicMartini", "{", "r", ":=", "martini", ".", "NewRouter", "(", ")", "\n", "m", ":=", "martini", ".", "New", "(", ")", "\n", "m", ".", "Use", "(", "martini", ".", "Logger", "(", ")", ...
// ClassicWithoutStatic creates a classic Martini without a default Static.
[ "ClassicWithoutStatic", "creates", "a", "classic", "Martini", "without", "a", "default", "Static", "." ]
b9631fb8c188bec7aefed202f05fb3b76abadced
https://github.com/martini-contrib/staticbin/blob/b9631fb8c188bec7aefed202f05fb3b76abadced/martini.go#L6-L14
148,509
martini-contrib/staticbin
martini.go
Classic
func Classic(asset func(string) ([]byte, error)) *martini.ClassicMartini { m := ClassicWithoutStatic() m.Use(Static(defaultDir, asset)) return m }
go
func Classic(asset func(string) ([]byte, error)) *martini.ClassicMartini { m := ClassicWithoutStatic() m.Use(Static(defaultDir, asset)) return m }
[ "func", "Classic", "(", "asset", "func", "(", "string", ")", "(", "[", "]", "byte", ",", "error", ")", ")", "*", "martini", ".", "ClassicMartini", "{", "m", ":=", "ClassicWithoutStatic", "(", ")", "\n", "m", ".", "Use", "(", "Static", "(", "defaultDi...
// Classic creates a classic Martini with a default Static.
[ "Classic", "creates", "a", "classic", "Martini", "with", "a", "default", "Static", "." ]
b9631fb8c188bec7aefed202f05fb3b76abadced
https://github.com/martini-contrib/staticbin/blob/b9631fb8c188bec7aefed202f05fb3b76abadced/martini.go#L17-L21
148,510
rancher/sparse-tools
stats/stats.go
Sample
func Sample(timestamp time.Time, duration time.Duration, targetID string, op SampleOp, size int, status bool) { storeSample(dataPoint{targetIndex(targetID), op, timestamp, duration, size, status}) }
go
func Sample(timestamp time.Time, duration time.Duration, targetID string, op SampleOp, size int, status bool) { storeSample(dataPoint{targetIndex(targetID), op, timestamp, duration, size, status}) }
[ "func", "Sample", "(", "timestamp", "time", ".", "Time", ",", "duration", "time", ".", "Duration", ",", "targetID", "string", ",", "op", "SampleOp", ",", "size", "int", ",", "status", "bool", ")", "{", "storeSample", "(", "dataPoint", "{", "targetIndex", ...
// Sample to the cyclic buffer
[ "Sample", "to", "the", "cyclic", "buffer" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/stats/stats.go#L132-L134
148,511
rancher/sparse-tools
stats/stats.go
ProcessLimited
func ProcessLimited(limit int, processor func(dataPoint)) chan struct{} { // Fetch unreported window done := make(chan struct{}) dropCount := 0 if limit > 0 { count := len(cdata) if count > limit { // drop old samples to satisfy the limit dropCount = count - limit } } go func(dropCount, limit int, pe...
go
func ProcessLimited(limit int, processor func(dataPoint)) chan struct{} { // Fetch unreported window done := make(chan struct{}) dropCount := 0 if limit > 0 { count := len(cdata) if count > limit { // drop old samples to satisfy the limit dropCount = count - limit } } go func(dropCount, limit int, pe...
[ "func", "ProcessLimited", "(", "limit", "int", ",", "processor", "func", "(", "dataPoint", ")", ")", "chan", "struct", "{", "}", "{", "// Fetch unreported window", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "dropCount", ":=", "0", ...
// ProcessLimited number of unreported samples is restricted by specified limit, the rest os droppped
[ "ProcessLimited", "number", "of", "unreported", "samples", "is", "restricted", "by", "specified", "limit", "the", "rest", "os", "droppped" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/stats/stats.go#L142-L179
148,512
rancher/sparse-tools
stats/stats.go
InsertPendingOp
func InsertPendingOp(timestamp time.Time, targetID string, op SampleOp, size int) OpID { mutexPendingOps.Lock() defer mutexPendingOps.Unlock() var id int if len(pendingOpsFreeSlot) > 0 { //reuse recently freed id id = pendingOpsFreeSlot[len(pendingOpsFreeSlot)-1] pendingOpsFreeSlot = pendingOpsFreeSlot[:len(...
go
func InsertPendingOp(timestamp time.Time, targetID string, op SampleOp, size int) OpID { mutexPendingOps.Lock() defer mutexPendingOps.Unlock() var id int if len(pendingOpsFreeSlot) > 0 { //reuse recently freed id id = pendingOpsFreeSlot[len(pendingOpsFreeSlot)-1] pendingOpsFreeSlot = pendingOpsFreeSlot[:len(...
[ "func", "InsertPendingOp", "(", "timestamp", "time", ".", "Time", ",", "targetID", "string", ",", "op", "SampleOp", ",", "size", "int", ")", "OpID", "{", "mutexPendingOps", ".", "Lock", "(", ")", "\n", "defer", "mutexPendingOps", ".", "Unlock", "(", ")", ...
//InsertPendingOp starts tracking of a pending operation
[ "InsertPendingOp", "starts", "tracking", "of", "a", "pending", "operation" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/stats/stats.go#L211-L226
148,513
rancher/sparse-tools
stats/stats.go
RemovePendingOp
func RemovePendingOp(id OpID, status bool) error { log.Debug("RemovePendingOp id=", id) mutexPendingOps.Lock() defer mutexPendingOps.Unlock() i := int(id) if i < 0 || i >= len(pendingOps) { errMsg := "RemovePendingOp: Invalid OpID" log.Error(errMsg, i) return errors.New(errMsg) } if pendingOps[i].op == Op...
go
func RemovePendingOp(id OpID, status bool) error { log.Debug("RemovePendingOp id=", id) mutexPendingOps.Lock() defer mutexPendingOps.Unlock() i := int(id) if i < 0 || i >= len(pendingOps) { errMsg := "RemovePendingOp: Invalid OpID" log.Error(errMsg, i) return errors.New(errMsg) } if pendingOps[i].op == Op...
[ "func", "RemovePendingOp", "(", "id", "OpID", ",", "status", "bool", ")", "error", "{", "log", ".", "Debug", "(", "\"", "\"", ",", "id", ")", "\n", "mutexPendingOps", ".", "Lock", "(", ")", "\n", "defer", "mutexPendingOps", ".", "Unlock", "(", ")", "...
//RemovePendingOp removes tracking of a completed operation
[ "RemovePendingOp", "removes", "tracking", "of", "a", "completed", "operation" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/stats/stats.go#L229-L256
148,514
rancher/sparse-tools
sparse/rest/router.go
NewRouter
func NewRouter(server *SyncServer) *mux.Router { // API framework routes router := mux.NewRouter().StrictSlash(true) // Application router.HandleFunc("/v1-ssync/getChecksum", server.getChecksum).Methods("GET") router.HandleFunc("/v1-ssync/open", server.open).Methods("GET") router.HandleFunc("/v1-ssync/close", s...
go
func NewRouter(server *SyncServer) *mux.Router { // API framework routes router := mux.NewRouter().StrictSlash(true) // Application router.HandleFunc("/v1-ssync/getChecksum", server.getChecksum).Methods("GET") router.HandleFunc("/v1-ssync/open", server.open).Methods("GET") router.HandleFunc("/v1-ssync/close", s...
[ "func", "NewRouter", "(", "server", "*", "SyncServer", ")", "*", "mux", ".", "Router", "{", "// API framework routes", "router", ":=", "mux", ".", "NewRouter", "(", ")", ".", "StrictSlash", "(", "true", ")", "\n\n", "// Application", "router", ".", "HandleFu...
//NewRouter creates and configures a mux router
[ "NewRouter", "creates", "and", "configures", "a", "mux", "router" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/rest/router.go#L6-L19
148,515
rancher/sparse-tools
sparse/sfold.go
FoldFile
func FoldFile(childFileName, parentFileName string) error { childFInfo, err := os.Stat(childFileName) if err != nil { panic("os.Stat(childFileName) failed, error: " + err.Error()) } parentFInfo, err := os.Stat(parentFileName) if err != nil { panic("os.Stat(parentFileName) failed, error: " + err.Error()) } ...
go
func FoldFile(childFileName, parentFileName string) error { childFInfo, err := os.Stat(childFileName) if err != nil { panic("os.Stat(childFileName) failed, error: " + err.Error()) } parentFInfo, err := os.Stat(parentFileName) if err != nil { panic("os.Stat(parentFileName) failed, error: " + err.Error()) } ...
[ "func", "FoldFile", "(", "childFileName", ",", "parentFileName", "string", ")", "error", "{", "childFInfo", ",", "err", ":=", "os", ".", "Stat", "(", "childFileName", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "\"", "\"", "+", "err", ".", ...
// FoldFile folds child snapshot data into its parent
[ "FoldFile", "folds", "child", "snapshot", "data", "into", "its", "parent" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/sfold.go#L15-L50
148,516
rancher/sparse-tools
sparse/sfold.go
getFileSystemBlockSize
func getFileSystemBlockSize(fileIo FileIoProcessor) (int, error) { var stat syscall.Stat_t err := syscall.Stat(fileIo.Name(), &stat) return int(stat.Blksize), err }
go
func getFileSystemBlockSize(fileIo FileIoProcessor) (int, error) { var stat syscall.Stat_t err := syscall.Stat(fileIo.Name(), &stat) return int(stat.Blksize), err }
[ "func", "getFileSystemBlockSize", "(", "fileIo", "FileIoProcessor", ")", "(", "int", ",", "error", ")", "{", "var", "stat", "syscall", ".", "Stat_t", "\n", "err", ":=", "syscall", ".", "Stat", "(", "fileIo", ".", "Name", "(", ")", ",", "&", "stat", ")"...
// get the file system block size
[ "get", "the", "file", "system", "block", "size" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/sfold.go#L102-L106
148,517
martini-contrib/staticbin
options.go
retrieveOptions
func retrieveOptions(options []Options) Options { var opt Options if len(options) > 0 { opt = options[0] } // Set the default value to opt.IndexFile. if opt.IndexFile == "" { opt.IndexFile = defaultIndexFile } return opt }
go
func retrieveOptions(options []Options) Options { var opt Options if len(options) > 0 { opt = options[0] } // Set the default value to opt.IndexFile. if opt.IndexFile == "" { opt.IndexFile = defaultIndexFile } return opt }
[ "func", "retrieveOptions", "(", "options", "[", "]", "Options", ")", "Options", "{", "var", "opt", "Options", "\n\n", "if", "len", "(", "options", ")", ">", "0", "{", "opt", "=", "options", "[", "0", "]", "\n", "}", "\n\n", "// Set the default value to o...
// retrieveOptions retrieves an options from the array of options.
[ "retrieveOptions", "retrieves", "an", "options", "from", "the", "array", "of", "options", "." ]
b9631fb8c188bec7aefed202f05fb3b76abadced
https://github.com/martini-contrib/staticbin/blob/b9631fb8c188bec7aefed202f05fb3b76abadced/options.go#L12-L25
148,518
rancher/sparse-tools
sparse/failpoint.go
FailPointFileHashMatch
func FailPointFileHashMatch() bool { mutex.Lock() val := failFileHashMatch if val { log.Warn("FailPointFileHashMatch!") failFileHashMatch = false } mutex.Unlock() return val }
go
func FailPointFileHashMatch() bool { mutex.Lock() val := failFileHashMatch if val { log.Warn("FailPointFileHashMatch!") failFileHashMatch = false } mutex.Unlock() return val }
[ "func", "FailPointFileHashMatch", "(", ")", "bool", "{", "mutex", ".", "Lock", "(", ")", "\n", "val", ":=", "failFileHashMatch", "\n", "if", "val", "{", "log", ".", "Warn", "(", "\"", "\"", ")", "\n", "failFileHashMatch", "=", "false", "\n", "}", "\n",...
// FailPointFileHashMatch returns true if this failpoint is set, clears the failpoint
[ "FailPointFileHashMatch", "returns", "true", "if", "this", "failpoint", "is", "set", "clears", "the", "failpoint" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/failpoint.go#L20-L29
148,519
rancher/sparse-tools
sparse/file.go
alignmentShift
func alignmentShift(block []byte) int { if len(block) == 0 { return 0 } return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) }
go
func alignmentShift(block []byte) int { if len(block) == 0 { return 0 } return int(uintptr(unsafe.Pointer(&block[0])) & uintptr(alignment-1)) }
[ "func", "alignmentShift", "(", "block", "[", "]", "byte", ")", "int", "{", "if", "len", "(", "block", ")", "==", "0", "{", "return", "0", "\n", "}", "\n", "return", "int", "(", "uintptr", "(", "unsafe", ".", "Pointer", "(", "&", "block", "[", "0"...
// alignmentShift returns alignment of the block in memory
[ "alignmentShift", "returns", "alignment", "of", "the", "block", "in", "memory" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/file.go#L134-L139
148,520
frostschutz/go-fibmap
fibmap.go
Fibmap
func (f FibmapFile) Fibmap(block uint) (uint, syscall.Errno) { _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIBMAP, uintptr(unsafe.Pointer(&block))) return block, err }
go
func (f FibmapFile) Fibmap(block uint) (uint, syscall.Errno) { _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIBMAP, uintptr(unsafe.Pointer(&block))) return block, err }
[ "func", "(", "f", "FibmapFile", ")", "Fibmap", "(", "block", "uint", ")", "(", "uint", ",", "syscall", ".", "Errno", ")", "{", "_", ",", "_", ",", "err", ":=", "syscall", ".", "Syscall", "(", "syscall", ".", "SYS_IOCTL", ",", "f", ".", "Fd", "(",...
// call FIBMAP ioctl
[ "call", "FIBMAP", "ioctl" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L84-L87
148,521
frostschutz/go-fibmap
fibmap.go
FibmapExtents
func (f FibmapFile) FibmapExtents() ([]Extent, syscall.Errno) { result := make([]Extent, 0) bsz, err := f.Figetbsz() if err != 0 { return nil, err } stat, _ := f.Stat() size := stat.Size() if size == 0 { return result, syscall.Errno(0) } blocks := uint((size-1)/int64(bsz)) + 1 var block, physical, leng...
go
func (f FibmapFile) FibmapExtents() ([]Extent, syscall.Errno) { result := make([]Extent, 0) bsz, err := f.Figetbsz() if err != 0 { return nil, err } stat, _ := f.Stat() size := stat.Size() if size == 0 { return result, syscall.Errno(0) } blocks := uint((size-1)/int64(bsz)) + 1 var block, physical, leng...
[ "func", "(", "f", "FibmapFile", ")", "FibmapExtents", "(", ")", "(", "[", "]", "Extent", ",", "syscall", ".", "Errno", ")", "{", "result", ":=", "make", "(", "[", "]", "Extent", ",", "0", ")", "\n\n", "bsz", ",", "err", ":=", "f", ".", "Figetbsz"...
// emulate FIEMAP with FIBMAP
[ "emulate", "FIEMAP", "with", "FIBMAP" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L90-L154
148,522
frostschutz/go-fibmap
fibmap.go
Fiemap
func (f FibmapFile) Fiemap(size uint32) ([]Extent, syscall.Errno) { extents := make([]Extent, size+1) ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[1])) - FiemapSize) t := (*fiemap)(ptr) t.Start = 0 t.Length = FIEMAP_MAX_OFFSET t.Flags = FIEMAP_FLAG_SYNC t.Extent_count = size _, _, err := syscall.Sysc...
go
func (f FibmapFile) Fiemap(size uint32) ([]Extent, syscall.Errno) { extents := make([]Extent, size+1) ptr := unsafe.Pointer(uintptr(unsafe.Pointer(&extents[1])) - FiemapSize) t := (*fiemap)(ptr) t.Start = 0 t.Length = FIEMAP_MAX_OFFSET t.Flags = FIEMAP_FLAG_SYNC t.Extent_count = size _, _, err := syscall.Sysc...
[ "func", "(", "f", "FibmapFile", ")", "Fiemap", "(", "size", "uint32", ")", "(", "[", "]", "Extent", ",", "syscall", ".", "Errno", ")", "{", "extents", ":=", "make", "(", "[", "]", "Extent", ",", "size", "+", "1", ")", "\n", "ptr", ":=", "unsafe",...
// call FIEMAP ioctl
[ "call", "FIEMAP", "ioctl" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L157-L170
148,523
frostschutz/go-fibmap
fibmap.go
Figetbsz
func (f FibmapFile) Figetbsz() (int, syscall.Errno) { bsz := int(0) _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIGETBSZ, uintptr(unsafe.Pointer(&bsz))) return bsz, err }
go
func (f FibmapFile) Figetbsz() (int, syscall.Errno) { bsz := int(0) _, _, err := syscall.Syscall(syscall.SYS_IOCTL, f.Fd(), FIGETBSZ, uintptr(unsafe.Pointer(&bsz))) return bsz, err }
[ "func", "(", "f", "FibmapFile", ")", "Figetbsz", "(", ")", "(", "int", ",", "syscall", ".", "Errno", ")", "{", "bsz", ":=", "int", "(", "0", ")", "\n", "_", ",", "_", ",", "err", ":=", "syscall", ".", "Syscall", "(", "syscall", ".", "SYS_IOCTL", ...
// call FIGETBSZ ioctl
[ "call", "FIGETBSZ", "ioctl" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L173-L177
148,524
frostschutz/go-fibmap
fibmap.go
SeekDataHole
func (f FibmapFile) SeekDataHole() []int64 { old, _ := f.Seek(0, os.SEEK_CUR) var data, hole int64 var datahole []int64 for { data, _ = f.Seek(hole, SEEK_DATA) if data >= hole { hole, _ = f.Seek(data, SEEK_HOLE) if hole > data { datahole = append(datahole, data, hole-data) continue } } ...
go
func (f FibmapFile) SeekDataHole() []int64 { old, _ := f.Seek(0, os.SEEK_CUR) var data, hole int64 var datahole []int64 for { data, _ = f.Seek(hole, SEEK_DATA) if data >= hole { hole, _ = f.Seek(data, SEEK_HOLE) if hole > data { datahole = append(datahole, data, hole-data) continue } } ...
[ "func", "(", "f", "FibmapFile", ")", "SeekDataHole", "(", ")", "[", "]", "int64", "{", "old", ",", "_", ":=", "f", ".", "Seek", "(", "0", ",", "os", ".", "SEEK_CUR", ")", "\n\n", "var", "data", ",", "hole", "int64", "\n", "var", "datahole", "[", ...
// use SEEK_DATA, SEEK_HOLE to find allocated data ranges in a file
[ "use", "SEEK_DATA", "SEEK_HOLE", "to", "find", "allocated", "data", "ranges", "in", "a", "file" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L180-L203
148,525
frostschutz/go-fibmap
fibmap.go
Fallocate
func (f FibmapFile) Fallocate(offset int64, length int64) error { return syscall.Fallocate(int(f.Fd()), 0, offset, length) }
go
func (f FibmapFile) Fallocate(offset int64, length int64) error { return syscall.Fallocate(int(f.Fd()), 0, offset, length) }
[ "func", "(", "f", "FibmapFile", ")", "Fallocate", "(", "offset", "int64", ",", "length", "int64", ")", "error", "{", "return", "syscall", ".", "Fallocate", "(", "int", "(", "f", ".", "Fd", "(", ")", ")", ",", "0", ",", "offset", ",", "length", ")",...
// allocate using fallocate
[ "allocate", "using", "fallocate" ]
b32c231bfe6a911d413c4a240f560d92e31ef976
https://github.com/frostschutz/go-fibmap/blob/b32c231bfe6a911d413c4a240f560d92e31ef976/fibmap.go#L206-L208
148,526
rancher/sparse-tools
sparse/client.go
SyncFile
func SyncFile(localPath string, remote string, timeout int) error { fileInfo, err := os.Stat(localPath) if err != nil { log.Errorf("Failed to get size of source file: %s, err: %s", localPath, err) return err } fileSize := fileInfo.Size() directIO := (fileSize%Blocks == 0) log.Infof("source file size: %d, sett...
go
func SyncFile(localPath string, remote string, timeout int) error { fileInfo, err := os.Stat(localPath) if err != nil { log.Errorf("Failed to get size of source file: %s, err: %s", localPath, err) return err } fileSize := fileInfo.Size() directIO := (fileSize%Blocks == 0) log.Infof("source file size: %d, sett...
[ "func", "SyncFile", "(", "localPath", "string", ",", "remote", "string", ",", "timeout", "int", ")", "error", "{", "fileInfo", ",", "err", ":=", "os", ".", "Stat", "(", "localPath", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorf", "(",...
// SyncFile synchronizes local file to remote host
[ "SyncFile", "synchronizes", "local", "file", "to", "remote", "host" ]
666f9b3bde21fd0fcf2700ec85c929219e910025
https://github.com/rancher/sparse-tools/blob/666f9b3bde21fd0fcf2700ec85c929219e910025/sparse/client.go#L32-L65
148,527
cybozu-go/usocksd
config.go
NewConfig
func NewConfig() *Config { c := new(Config) c.Incoming.Port = defaultPort return c }
go
func NewConfig() *Config { c := new(Config) c.Incoming.Port = defaultPort return c }
[ "func", "NewConfig", "(", ")", "*", "Config", "{", "c", ":=", "new", "(", "Config", ")", "\n", "c", ".", "Incoming", ".", "Port", "=", "defaultPort", "\n", "return", "c", "\n", "}" ]
// NewConfig creates and initializes Config.
[ "NewConfig", "creates", "and", "initializes", "Config", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/config.go#L41-L45
148,528
cybozu-go/usocksd
config.go
Load
func (c *Config) Load(path string) error { md, err := toml.DecodeFile(path, c) if err != nil { return err } if len(md.Undecoded()) > 0 { return errors.New("Unknown config keys in " + path) } if len(c.Incoming.AllowFrom) > 0 { subnets := make([]*net.IPNet, 0, len(c.Incoming.AllowFrom)) for _, s := range c...
go
func (c *Config) Load(path string) error { md, err := toml.DecodeFile(path, c) if err != nil { return err } if len(md.Undecoded()) > 0 { return errors.New("Unknown config keys in " + path) } if len(c.Incoming.AllowFrom) > 0 { subnets := make([]*net.IPNet, 0, len(c.Incoming.AllowFrom)) for _, s := range c...
[ "func", "(", "c", "*", "Config", ")", "Load", "(", "path", "string", ")", "error", "{", "md", ",", "err", ":=", "toml", ".", "DecodeFile", "(", "path", ",", "c", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", ...
// Load loads a TOML file from path.
[ "Load", "loads", "a", "TOML", "file", "from", "path", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/config.go#L48-L76
148,529
cybozu-go/usocksd
config.go
allowIP
func (c *Config) allowIP(ip net.IP) bool { if len(c.Incoming.allowSubnets) == 0 { return true } for _, n := range c.Incoming.allowSubnets { if n.Contains(ip) { return true } } return false }
go
func (c *Config) allowIP(ip net.IP) bool { if len(c.Incoming.allowSubnets) == 0 { return true } for _, n := range c.Incoming.allowSubnets { if n.Contains(ip) { return true } } return false }
[ "func", "(", "c", "*", "Config", ")", "allowIP", "(", "ip", "net", ".", "IP", ")", "bool", "{", "if", "len", "(", "c", ".", "Incoming", ".", "allowSubnets", ")", "==", "0", "{", "return", "true", "\n", "}", "\n", "for", "_", ",", "n", ":=", "...
// allowIP tests if ip is allowed to connect to usocksd.
[ "allowIP", "tests", "if", "ip", "is", "allowed", "to", "connect", "to", "usocksd", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/config.go#L86-L96
148,530
cybozu-go/usocksd
config.go
allowFQDN
func (c *Config) allowFQDN(fqdn string) bool { fqdn = strings.ToLower(fqdn) if len(c.Outgoing.AllowSites) > 0 { for _, match := range c.Outgoing.AllowSites { if siteMatch(fqdn, match) { goto CHECK_DENY } } return false } CHECK_DENY: for _, match := range c.Outgoing.DenySites { if siteMatch(fqdn, ...
go
func (c *Config) allowFQDN(fqdn string) bool { fqdn = strings.ToLower(fqdn) if len(c.Outgoing.AllowSites) > 0 { for _, match := range c.Outgoing.AllowSites { if siteMatch(fqdn, match) { goto CHECK_DENY } } return false } CHECK_DENY: for _, match := range c.Outgoing.DenySites { if siteMatch(fqdn, ...
[ "func", "(", "c", "*", "Config", ")", "allowFQDN", "(", "fqdn", "string", ")", "bool", "{", "fqdn", "=", "strings", ".", "ToLower", "(", "fqdn", ")", "\n", "if", "len", "(", "c", ".", "Outgoing", ".", "AllowSites", ")", ">", "0", "{", "for", "_",...
// allowFQDN tests if FQDN is granted to access or not.
[ "allowFQDN", "tests", "if", "FQDN", "is", "granted", "to", "access", "or", "not", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/config.go#L106-L124
148,531
cybozu-go/usocksd
config.go
allowPort
func (c *Config) allowPort(port int) bool { for _, p := range c.Outgoing.DenyPorts { if p == port { return false } } return true }
go
func (c *Config) allowPort(port int) bool { for _, p := range c.Outgoing.DenyPorts { if p == port { return false } } return true }
[ "func", "(", "c", "*", "Config", ")", "allowPort", "(", "port", "int", ")", "bool", "{", "for", "_", ",", "p", ":=", "range", "c", ".", "Outgoing", ".", "DenyPorts", "{", "if", "p", "==", "port", "{", "return", "false", "\n", "}", "\n", "}", "\...
// allowPort tests if port is legitimate for destination.
[ "allowPort", "tests", "if", "port", "is", "legitimate", "for", "destination", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/config.go#L127-L134
148,532
cybozu-go/usocksd
server.go
Listeners
func Listeners(c *Config) ([]net.Listener, error) { if len(c.Incoming.Addresses) == 0 { ln, err := net.Listen("tcp", ":"+strconv.Itoa(c.Incoming.Port)) if err != nil { return nil, err } return []net.Listener{ln}, nil } lns := make([]net.Listener, len(c.Incoming.Addresses)) for i, a := range c.Incoming.A...
go
func Listeners(c *Config) ([]net.Listener, error) { if len(c.Incoming.Addresses) == 0 { ln, err := net.Listen("tcp", ":"+strconv.Itoa(c.Incoming.Port)) if err != nil { return nil, err } return []net.Listener{ln}, nil } lns := make([]net.Listener, len(c.Incoming.Addresses)) for i, a := range c.Incoming.A...
[ "func", "Listeners", "(", "c", "*", "Config", ")", "(", "[", "]", "net", ".", "Listener", ",", "error", ")", "{", "if", "len", "(", "c", ".", "Incoming", ".", "Addresses", ")", "==", "0", "{", "ln", ",", "err", ":=", "net", ".", "Listen", "(", ...
// Listeners returns a list of net.Listener.
[ "Listeners", "returns", "a", "list", "of", "net", ".", "Listener", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/server.go#L11-L33
148,533
cybozu-go/usocksd
server.go
NewServer
func NewServer(c *Config) *socks.Server { return &socks.Server{ Rules: createRuleSet(c), Dialer: createDialer(c), } }
go
func NewServer(c *Config) *socks.Server { return &socks.Server{ Rules: createRuleSet(c), Dialer: createDialer(c), } }
[ "func", "NewServer", "(", "c", "*", "Config", ")", "*", "socks", ".", "Server", "{", "return", "&", "socks", ".", "Server", "{", "Rules", ":", "createRuleSet", "(", "c", ")", ",", "Dialer", ":", "createDialer", "(", "c", ")", ",", "}", "\n", "}" ]
// NewServer creates a new socks.Server.
[ "NewServer", "creates", "a", "new", "socks", ".", "Server", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/server.go#L36-L41
148,534
cybozu-go/usocksd
address_group.go
isBadIP
func (a *AddressGroup) isBadIP(ip net.IP) bool { d := makeDNSBLDomain(a.dnsblDomain, ip) if len(d) == 0 { return false } _, err := net.LookupIP(d) return err == nil }
go
func (a *AddressGroup) isBadIP(ip net.IP) bool { d := makeDNSBLDomain(a.dnsblDomain, ip) if len(d) == 0 { return false } _, err := net.LookupIP(d) return err == nil }
[ "func", "(", "a", "*", "AddressGroup", ")", "isBadIP", "(", "ip", "net", ".", "IP", ")", "bool", "{", "d", ":=", "makeDNSBLDomain", "(", "a", ".", "dnsblDomain", ",", "ip", ")", "\n", "if", "len", "(", "d", ")", "==", "0", "{", "return", "false",...
// isBadIP returns true if IP is registered on DNSBL.
[ "isBadIP", "returns", "true", "if", "IP", "is", "registered", "on", "DNSBL", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/address_group.go#L42-L49
148,535
cybozu-go/usocksd
address_group.go
detectInvalid
func (a *AddressGroup) detectInvalid() { for { var valids, invalids []net.IP for _, ip := range a.addresses { if a.isBadIP(ip) { invalids = append(invalids, ip) } else { valids = append(valids, ip) } } a.lock.Lock() if len(invalids) > 0 && len(a.invalids) != len(invalids) { log.Warn("dete...
go
func (a *AddressGroup) detectInvalid() { for { var valids, invalids []net.IP for _, ip := range a.addresses { if a.isBadIP(ip) { invalids = append(invalids, ip) } else { valids = append(valids, ip) } } a.lock.Lock() if len(invalids) > 0 && len(a.invalids) != len(invalids) { log.Warn("dete...
[ "func", "(", "a", "*", "AddressGroup", ")", "detectInvalid", "(", ")", "{", "for", "{", "var", "valids", ",", "invalids", "[", "]", "net", ".", "IP", "\n", "for", "_", ",", "ip", ":=", "range", "a", ".", "addresses", "{", "if", "a", ".", "isBadIP...
// detectInvalid is a non-returning method, thus should be // called as a goroutine, to detect black-listed IP addresses.
[ "detectInvalid", "is", "a", "non", "-", "returning", "method", "thus", "should", "be", "called", "as", "a", "goroutine", "to", "detect", "black", "-", "listed", "IP", "addresses", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/address_group.go#L61-L86
148,536
cybozu-go/usocksd
address_group.go
NewAddressGroup
func NewAddressGroup(addresses []net.IP, dnsblDomain string) *AddressGroup { a := &AddressGroup{ addresses: addresses, dnsblDomain: dnsblDomain, lock: new(sync.Mutex), valids: addresses, invalids: nil, } go a.detectInvalid() return a }
go
func NewAddressGroup(addresses []net.IP, dnsblDomain string) *AddressGroup { a := &AddressGroup{ addresses: addresses, dnsblDomain: dnsblDomain, lock: new(sync.Mutex), valids: addresses, invalids: nil, } go a.detectInvalid() return a }
[ "func", "NewAddressGroup", "(", "addresses", "[", "]", "net", ".", "IP", ",", "dnsblDomain", "string", ")", "*", "AddressGroup", "{", "a", ":=", "&", "AddressGroup", "{", "addresses", ":", "addresses", ",", "dnsblDomain", ":", "dnsblDomain", ",", "lock", "...
// NewAddressGroup initializes a new AddressGroup and starts // helper goroutines.
[ "NewAddressGroup", "initializes", "a", "new", "AddressGroup", "and", "starts", "helper", "goroutines", "." ]
ea18de210d6928233f276494131af56da100d3e2
https://github.com/cybozu-go/usocksd/blob/ea18de210d6928233f276494131af56da100d3e2/address_group.go#L99-L109
148,537
joyent/gosdc
localservices/cloudapi/service_machine_tags.go
ListMachineTags
func (c *CloudAPI) ListMachineTags(machineID string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } return machine.Tags, nil }
go
func (c *CloudAPI) ListMachineTags(machineID string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } return machine.Tags, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListMachineTags", "(", "machineID", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "err...
// ListMachineTags returns the complete set of tags associated with the specified machine.
[ "ListMachineTags", "returns", "the", "complete", "set", "of", "tags", "associated", "with", "the", "specified", "machine", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_tags.go#L6-L13
148,538
joyent/gosdc
localservices/cloudapi/service_machine_tags.go
AddMachineTags
func (c *CloudAPI) AddMachineTags(machineID string, tags map[string]string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } for tag, value := range tags { if _, present := machine.Tags[tag]; !present { machine.Tags[tag] = value } } return machine.T...
go
func (c *CloudAPI) AddMachineTags(machineID string, tags map[string]string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } for tag, value := range tags { if _, present := machine.Tags[tag]; !present { machine.Tags[tag] = value } } return machine.T...
[ "func", "(", "c", "*", "CloudAPI", ")", "AddMachineTags", "(", "machineID", "string", ",", "tags", "map", "[", "string", "]", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "machine", ",", "err", ":=", "c", ".", "G...
// AddMachineTags adds additional tags to the specified machine. // This API lets you append new tags, not overwrite existing tags.
[ "AddMachineTags", "adds", "additional", "tags", "to", "the", "specified", "machine", ".", "This", "API", "lets", "you", "append", "new", "tags", "not", "overwrite", "existing", "tags", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_tags.go#L17-L30
148,539
joyent/gosdc
localservices/cloudapi/service_machine_tags.go
DeleteMachineTags
func (c *CloudAPI) DeleteMachineTags(machineID string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } for tag := range machine.Tags { delete(machine.Tags, tag) } return nil }
go
func (c *CloudAPI) DeleteMachineTags(machineID string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } for tag := range machine.Tags { delete(machine.Tags, tag) } return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteMachineTags", "(", "machineID", "string", ")", "error", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "...
// DeleteMachineTags deletes all tags from the specified machine.
[ "DeleteMachineTags", "deletes", "all", "tags", "from", "the", "specified", "machine", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_tags.go#L50-L61
148,540
joyent/gosdc
localservices/cloudapi/service_machine_tags.go
GetMachineTag
func (c *CloudAPI) GetMachineTag(machineID, tagKey string) (string, error) { machine, err := c.GetMachine(machineID) if err != nil { return "", err } val, ok := machine.Tags[tagKey] if !ok { return "", fmt.Errorf(`tag "%s" not found`, tagKey) } return val, nil }
go
func (c *CloudAPI) GetMachineTag(machineID, tagKey string) (string, error) { machine, err := c.GetMachine(machineID) if err != nil { return "", err } val, ok := machine.Tags[tagKey] if !ok { return "", fmt.Errorf(`tag "%s" not found`, tagKey) } return val, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetMachineTag", "(", "machineID", ",", "tagKey", "string", ")", "(", "string", ",", "error", ")", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "err", "!=", "nil"...
// GetMachineTag returns the value for a single tag on the specified machine.
[ "GetMachineTag", "returns", "the", "value", "for", "a", "single", "tag", "on", "the", "specified", "machine", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_tags.go#L79-L91
148,541
joyent/gosdc
localservices/cloudapi/service_firewalls.go
ListFirewallRules
func (c *CloudAPI) ListFirewallRules() ([]*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.firewallRules, nil }
go
func (c *CloudAPI) ListFirewallRules() ([]*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.firewallRules, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListFirewallRules", "(", ")", "(", "[", "]", "*", "cloudapi", ".", "FirewallRule", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ")", ";", "err", "!=", "nil", "{", "re...
// FirewallRule APIs // ListFirewallRules gets a list of firewall rules from the double
[ "FirewallRule", "APIs", "ListFirewallRules", "gets", "a", "list", "of", "firewall", "rules", "from", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L14-L20
148,542
joyent/gosdc
localservices/cloudapi/service_firewalls.go
CreateFirewallRule
func (c *CloudAPI) CreateFirewallRule(rule string, enabled bool) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, rule, enabled); err != nil { return nil, err } fwRuleID, err := localservices.NewUUID() if err != nil { return nil, fmt.Errorf("Error creating firewall rule: %q", err) } fwRu...
go
func (c *CloudAPI) CreateFirewallRule(rule string, enabled bool) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, rule, enabled); err != nil { return nil, err } fwRuleID, err := localservices.NewUUID() if err != nil { return nil, fmt.Errorf("Error creating firewall rule: %q", err) } fwRu...
[ "func", "(", "c", "*", "CloudAPI", ")", "CreateFirewallRule", "(", "rule", "string", ",", "enabled", "bool", ")", "(", "*", "cloudapi", ".", "FirewallRule", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "rul...
// CreateFirewallRule creates a new firewall rule and returns it
[ "CreateFirewallRule", "creates", "a", "new", "firewall", "rule", "and", "returns", "it" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L38-L52
148,543
joyent/gosdc
localservices/cloudapi/service_firewalls.go
UpdateFirewallRule
func (c *CloudAPI) UpdateFirewallRule(fwRuleID, rule string, enabled bool) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, fwRuleID, rule, enabled); err != nil { return nil, err } for _, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { r.Rule = rule r.Enabled = enab...
go
func (c *CloudAPI) UpdateFirewallRule(fwRuleID, rule string, enabled bool) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, fwRuleID, rule, enabled); err != nil { return nil, err } for _, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { r.Rule = rule r.Enabled = enab...
[ "func", "(", "c", "*", "CloudAPI", ")", "UpdateFirewallRule", "(", "fwRuleID", ",", "rule", "string", ",", "enabled", "bool", ")", "(", "*", "cloudapi", ".", "FirewallRule", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(",...
// UpdateFirewallRule makes changes to a given firewall rule
[ "UpdateFirewallRule", "makes", "changes", "to", "a", "given", "firewall", "rule" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L55-L69
148,544
joyent/gosdc
localservices/cloudapi/service_firewalls.go
EnableFirewallRule
func (c *CloudAPI) EnableFirewallRule(fwRuleID string) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return nil, err } for _, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { r.Enabled = true return r, nil } } return nil, fmt.Errorf("F...
go
func (c *CloudAPI) EnableFirewallRule(fwRuleID string) (*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return nil, err } for _, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { r.Enabled = true return r, nil } } return nil, fmt.Errorf("F...
[ "func", "(", "c", "*", "CloudAPI", ")", "EnableFirewallRule", "(", "fwRuleID", "string", ")", "(", "*", "cloudapi", ".", "FirewallRule", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "fwRuleID", ")", ";", "e...
// EnableFirewallRule enables the given firewall rule
[ "EnableFirewallRule", "enables", "the", "given", "firewall", "rule" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L72-L85
148,545
joyent/gosdc
localservices/cloudapi/service_firewalls.go
DeleteFirewallRule
func (c *CloudAPI) DeleteFirewallRule(fwRuleID string) error { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return err } for i, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { c.firewallRules = append(c.firewallRules[:i], c.firewallRules[i+1:]...) return nil } } retu...
go
func (c *CloudAPI) DeleteFirewallRule(fwRuleID string) error { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return err } for i, r := range c.firewallRules { if strings.EqualFold(r.Id, fwRuleID) { c.firewallRules = append(c.firewallRules[:i], c.firewallRules[i+1:]...) return nil } } retu...
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteFirewallRule", "(", "fwRuleID", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "fwRuleID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", ...
// DeleteFirewallRule deletes the given firewall rule
[ "DeleteFirewallRule", "deletes", "the", "given", "firewall", "rule" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L104-L117
148,546
joyent/gosdc
localservices/cloudapi/service_firewalls.go
ListFirewallRuleMachines
func (c *CloudAPI) ListFirewallRuleMachines(fwRuleID string) ([]*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return nil, err } out := make([]*cloudapi.Machine, len(c.machines)) for i, machine := range c.machines { out[i] = &machine.Machine } return out, nil }
go
func (c *CloudAPI) ListFirewallRuleMachines(fwRuleID string) ([]*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, fwRuleID); err != nil { return nil, err } out := make([]*cloudapi.Machine, len(c.machines)) for i, machine := range c.machines { out[i] = &machine.Machine } return out, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListFirewallRuleMachines", "(", "fwRuleID", "string", ")", "(", "[", "]", "*", "cloudapi", ".", "Machine", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "fwRuleID", "...
// ListFirewallRuleMachines should list the machines that are affected by a // given firewall rule. In this double, it just returns all the machines.
[ "ListFirewallRuleMachines", "should", "list", "the", "machines", "that", "are", "affected", "by", "a", "given", "firewall", "rule", ".", "In", "this", "double", "it", "just", "returns", "all", "the", "machines", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_firewalls.go#L121-L132
148,547
joyent/gosdc
cloudapi/cloudapi.go
Set
func (f *Filter) Set(filter, value string) { f.v.Set(filter, value) }
go
func (f *Filter) Set(filter, value string) { f.v.Set(filter, value) }
[ "func", "(", "f", "*", "Filter", ")", "Set", "(", "filter", ",", "value", "string", ")", "{", "f", ".", "v", ".", "Set", "(", "filter", ",", "value", ")", "\n", "}" ]
// Set a value for the specified filter.
[ "Set", "a", "value", "for", "the", "specified", "filter", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/cloudapi.go#L82-L84
148,548
joyent/gosdc
cloudapi/cloudapi.go
Add
func (f *Filter) Add(filter, value string) { f.v.Add(filter, value) }
go
func (f *Filter) Add(filter, value string) { f.v.Add(filter, value) }
[ "func", "(", "f", "*", "Filter", ")", "Add", "(", "filter", ",", "value", "string", ")", "{", "f", ".", "v", ".", "Add", "(", "filter", ",", "value", ")", "\n", "}" ]
// Add a value for the specified filter.
[ "Add", "a", "value", "for", "the", "specified", "filter", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/cloudapi.go#L87-L89
148,549
joyent/gosdc
localservices/cloudapi/service_machine_metadata.go
GetMachineMetadata
func (c *CloudAPI) GetMachineMetadata(machineID string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } return machine.Metadata, nil }
go
func (c *CloudAPI) GetMachineMetadata(machineID string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } return machine.Metadata, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetMachineMetadata", "(", "machineID", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "...
// GetMachineMetadata returns the complete set of metadata associated with the // specified machine.
[ "GetMachineMetadata", "returns", "the", "complete", "set", "of", "metadata", "associated", "with", "the", "specified", "machine", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_metadata.go#L10-L17
148,550
joyent/gosdc
localservices/cloudapi/service_machine_metadata.go
UpdateMachineMetadata
func (c *CloudAPI) UpdateMachineMetadata(machineID string, metadata map[string]string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } for k, v := range metadata { machine.Metadata[k] = v } machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") ...
go
func (c *CloudAPI) UpdateMachineMetadata(machineID string, metadata map[string]string) (map[string]string, error) { machine, err := c.GetMachine(machineID) if err != nil { return nil, err } for k, v := range metadata { machine.Metadata[k] = v } machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") ...
[ "func", "(", "c", "*", "CloudAPI", ")", "UpdateMachineMetadata", "(", "machineID", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "machine", ",", "err", ":=", "c", ...
// UpdateMachineMetadata updates the metadata for a given machine. // Any metadata keys passed in here are created if they do not exist, and // overwritten if they do.
[ "UpdateMachineMetadata", "updates", "the", "metadata", "for", "a", "given", "machine", ".", "Any", "metadata", "keys", "passed", "in", "here", "are", "created", "if", "they", "do", "not", "exist", "and", "overwritten", "if", "they", "do", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_metadata.go#L22-L34
148,551
joyent/gosdc
localservices/cloudapi/service_machine_metadata.go
DeleteMachineMetadata
func (c *CloudAPI) DeleteMachineMetadata(machineID string, key string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } _, ok := machine.Metadata[key] if !ok { return fmt.Errorf(`"%s" is not a metadata key`, key) } delete(machine.Metadata, key) return nil }
go
func (c *CloudAPI) DeleteMachineMetadata(machineID string, key string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } _, ok := machine.Metadata[key] if !ok { return fmt.Errorf(`"%s" is not a metadata key`, key) } delete(machine.Metadata, key) return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteMachineMetadata", "(", "machineID", "string", ",", "key", "string", ")", "error", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// DeleteMachineMetadata deletes a single metadata key from the specified machine
[ "DeleteMachineMetadata", "deletes", "a", "single", "metadata", "key", "from", "the", "specified", "machine" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_metadata.go#L37-L50
148,552
joyent/gosdc
localservices/cloudapi/service_machine_metadata.go
DeleteAllMachineMetadata
func (c *CloudAPI) DeleteAllMachineMetadata(machineID string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } for k := range machine.Metadata { delete(machine.Metadata, k) } return nil }
go
func (c *CloudAPI) DeleteAllMachineMetadata(machineID string) error { machine, err := c.GetMachine(machineID) if err != nil { return err } for k := range machine.Metadata { delete(machine.Metadata, k) } return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteAllMachineMetadata", "(", "machineID", "string", ")", "error", "{", "machine", ",", "err", ":=", "c", ".", "GetMachine", "(", "machineID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "...
// DeleteAllMachineMetadata deletes all metadata keys from the specified machine.
[ "DeleteAllMachineMetadata", "deletes", "all", "metadata", "keys", "from", "the", "specified", "machine", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machine_metadata.go#L53-L63
148,553
joyent/gosdc
localservices/cloudapi/service_keys.go
ListKeys
func (c *CloudAPI) ListKeys() ([]cloudapi.Key, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.keys, nil }
go
func (c *CloudAPI) ListKeys() ([]cloudapi.Key, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.keys, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListKeys", "(", ")", "(", "[", "]", "cloudapi", ".", "Key", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", ...
// ListKeys lists keys in the double
[ "ListKeys", "lists", "keys", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_keys.go#L10-L16
148,554
joyent/gosdc
localservices/cloudapi/service_keys.go
GetKey
func (c *CloudAPI) GetKey(keyName string) (*cloudapi.Key, error) { if err := c.ProcessFunctionHook(c, keyName); err != nil { return nil, err } for _, key := range c.keys { if key.Name == keyName { return &key, nil } } return nil, fmt.Errorf("Key %s not found", keyName) }
go
func (c *CloudAPI) GetKey(keyName string) (*cloudapi.Key, error) { if err := c.ProcessFunctionHook(c, keyName); err != nil { return nil, err } for _, key := range c.keys { if key.Name == keyName { return &key, nil } } return nil, fmt.Errorf("Key %s not found", keyName) }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetKey", "(", "keyName", "string", ")", "(", "*", "cloudapi", ".", "Key", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "keyName", ")", ";", "err", "!=", "nil", ...
// GetKey gets a single key from the double by name
[ "GetKey", "gets", "a", "single", "key", "from", "the", "double", "by", "name" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_keys.go#L19-L31
148,555
joyent/gosdc
localservices/cloudapi/service_keys.go
CreateKey
func (c *CloudAPI) CreateKey(keyName, key string) (*cloudapi.Key, error) { if err := c.ProcessFunctionHook(c, keyName, key); err != nil { return nil, err } // check if key already exists or keyName already in use for _, k := range c.keys { if k.Name == keyName { return nil, fmt.Errorf("Key name %s already i...
go
func (c *CloudAPI) CreateKey(keyName, key string) (*cloudapi.Key, error) { if err := c.ProcessFunctionHook(c, keyName, key); err != nil { return nil, err } // check if key already exists or keyName already in use for _, k := range c.keys { if k.Name == keyName { return nil, fmt.Errorf("Key name %s already i...
[ "func", "(", "c", "*", "CloudAPI", ")", "CreateKey", "(", "keyName", ",", "key", "string", ")", "(", "*", "cloudapi", ".", "Key", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "keyName", ",", "key", ")",...
// CreateKey creates a new key in the double
[ "CreateKey", "creates", "a", "new", "key", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_keys.go#L34-L53
148,556
joyent/gosdc
localservices/cloudapi/service_keys.go
DeleteKey
func (c *CloudAPI) DeleteKey(keyName string) error { if err := c.ProcessFunctionHook(c, keyName); err != nil { return err } for i, key := range c.keys { if key.Name == keyName { c.keys = append(c.keys[:i], c.keys[i+1:]...) return nil } } return fmt.Errorf("Key %s not found", keyName) }
go
func (c *CloudAPI) DeleteKey(keyName string) error { if err := c.ProcessFunctionHook(c, keyName); err != nil { return err } for i, key := range c.keys { if key.Name == keyName { c.keys = append(c.keys[:i], c.keys[i+1:]...) return nil } } return fmt.Errorf("Key %s not found", keyName) }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteKey", "(", "keyName", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "keyName", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "...
// DeleteKey deletes an existing key from the double
[ "DeleteKey", "deletes", "an", "existing", "key", "from", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_keys.go#L56-L69
148,557
jen20/riviera
azure/token.go
addAuthorizationToRequest
func (tr *tokenRequester) addAuthorizationToRequest(request *retryablehttp.Request) error { token, err := tr.getUsableToken() if err != nil { return fmt.Errorf("Error obtaining authorization token: %s", err) } request.Header.Add("Authorization", fmt.Sprintf("%s %s", token.TokenType, token.AccessToken)) return n...
go
func (tr *tokenRequester) addAuthorizationToRequest(request *retryablehttp.Request) error { token, err := tr.getUsableToken() if err != nil { return fmt.Errorf("Error obtaining authorization token: %s", err) } request.Header.Add("Authorization", fmt.Sprintf("%s %s", token.TokenType, token.AccessToken)) return n...
[ "func", "(", "tr", "*", "tokenRequester", ")", "addAuthorizationToRequest", "(", "request", "*", "retryablehttp", ".", "Request", ")", "error", "{", "token", ",", "err", ":=", "tr", ".", "getUsableToken", "(", ")", "\n", "if", "err", "!=", "nil", "{", "r...
// addAuthorizationToRequest adds an Authorization header to an http.Request, having ensured // that the token is sufficiently fresh. This may invoke network calls, so should not be // relied on to return quickly.
[ "addAuthorizationToRequest", "adds", "an", "Authorization", "header", "to", "an", "http", ".", "Request", "having", "ensured", "that", "the", "token", "is", "sufficiently", "fresh", ".", "This", "may", "invoke", "network", "calls", "so", "should", "not", "be", ...
a7eb91c136c94760d51883cea61a822df66c828d
https://github.com/jen20/riviera/blob/a7eb91c136c94760d51883cea61a822df66c828d/azure/token.go#L52-L60
148,558
jen20/riviera
azure/token.go
willExpireIn
func (t token) willExpireIn(d time.Duration) bool { s, err := strconv.Atoi(t.ExpiresOn) if err != nil { s = -3600 } expiryTime := expirationBase.Add(time.Duration(s) * time.Second).UTC() return !expiryTime.After(time.Now().Add(d)) }
go
func (t token) willExpireIn(d time.Duration) bool { s, err := strconv.Atoi(t.ExpiresOn) if err != nil { s = -3600 } expiryTime := expirationBase.Add(time.Duration(s) * time.Second).UTC() return !expiryTime.After(time.Now().Add(d)) }
[ "func", "(", "t", "token", ")", "willExpireIn", "(", "d", "time", ".", "Duration", ")", "bool", "{", "s", ",", "err", ":=", "strconv", ".", "Atoi", "(", "t", ".", "ExpiresOn", ")", "\n", "if", "err", "!=", "nil", "{", "s", "=", "-", "3600", "\n...
// willExpireIn returns true if the Token will expire after the passed time.Duration interval // from now, false otherwise.
[ "willExpireIn", "returns", "true", "if", "the", "Token", "will", "expire", "after", "the", "passed", "time", ".", "Duration", "interval", "from", "now", "false", "otherwise", "." ]
a7eb91c136c94760d51883cea61a822df66c828d
https://github.com/jen20/riviera/blob/a7eb91c136c94760d51883cea61a822df66c828d/azure/token.go#L117-L125
148,559
jen20/riviera
azure/utils.go
isSuccessCode
func isSuccessCode(statusCode int) bool { if statusCode >= http.StatusOK && statusCode < http.StatusMultipleChoices { return true } return false }
go
func isSuccessCode(statusCode int) bool { if statusCode >= http.StatusOK && statusCode < http.StatusMultipleChoices { return true } return false }
[ "func", "isSuccessCode", "(", "statusCode", "int", ")", "bool", "{", "if", "statusCode", ">=", "http", ".", "StatusOK", "&&", "statusCode", "<", "http", ".", "StatusMultipleChoices", "{", "return", "true", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// isSuccessCode returns true for 200-range numbers which usually denote // that an HTTP request was successful
[ "isSuccessCode", "returns", "true", "for", "200", "-", "range", "numbers", "which", "usually", "denote", "that", "an", "HTTP", "request", "was", "successful" ]
a7eb91c136c94760d51883cea61a822df66c828d
https://github.com/jen20/riviera/blob/a7eb91c136c94760d51883cea61a822df66c828d/azure/utils.go#L34-L40
148,560
joyent/gosdc
localservices/cloudapi/service_machines.go
ListMachines
func (c *CloudAPI) ListMachines(filters map[string]string) ([]*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availableMachines := c.machines if filters != nil { for k, f := range filters { // check if valid filter if contains(machinesFilters, k) {...
go
func (c *CloudAPI) ListMachines(filters map[string]string) ([]*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availableMachines := c.machines if filters != nil { for k, f := range filters { // check if valid filter if contains(machinesFilters, k) {...
[ "func", "(", "c", "*", "CloudAPI", ")", "ListMachines", "(", "filters", "map", "[", "string", "]", "string", ")", "(", "[", "]", "*", "cloudapi", ".", "Machine", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ...
// ListMachines returns a list of machines in the double
[ "ListMachines", "returns", "a", "list", "of", "machines", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L14-L60
148,561
joyent/gosdc
localservices/cloudapi/service_machines.go
CountMachines
func (c *CloudAPI) CountMachines() (int, error) { if err := c.ProcessFunctionHook(c); err != nil { return 0, err } return len(c.machines), nil }
go
func (c *CloudAPI) CountMachines() (int, error) { if err := c.ProcessFunctionHook(c); err != nil { return 0, err } return len(c.machines), nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "CountMachines", "(", ")", "(", "int", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", ...
// CountMachines returns a count of machines the double knows about
[ "CountMachines", "returns", "a", "count", "of", "machines", "the", "double", "knows", "about" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L63-L69
148,562
joyent/gosdc
localservices/cloudapi/service_machines.go
GetMachine
func (c *CloudAPI) GetMachine(machineID string) (*cloudapi.Machine, error) { wrapper, err := c.getMachineWrapper(machineID) if err != nil { return nil, err } return &wrapper.Machine, nil }
go
func (c *CloudAPI) GetMachine(machineID string) (*cloudapi.Machine, error) { wrapper, err := c.getMachineWrapper(machineID) if err != nil { return nil, err } return &wrapper.Machine, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetMachine", "(", "machineID", "string", ")", "(", "*", "cloudapi", ".", "Machine", ",", "error", ")", "{", "wrapper", ",", "err", ":=", "c", ".", "getMachineWrapper", "(", "machineID", ")", "\n", "if", "err", ...
// GetMachine gets a single machine by ID from the double
[ "GetMachine", "gets", "a", "single", "machine", "by", "ID", "from", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L86-L93
148,563
joyent/gosdc
localservices/cloudapi/service_machines.go
CreateMachine
func (c *CloudAPI) CreateMachine(name, pkg, image string, networks []string, metadata, tags map[string]string) (*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, name, pkg, image); err != nil { return nil, err } machineID, err := localservices.NewUUID() if err != nil { return nil, err } mPkg, e...
go
func (c *CloudAPI) CreateMachine(name, pkg, image string, networks []string, metadata, tags map[string]string) (*cloudapi.Machine, error) { if err := c.ProcessFunctionHook(c, name, pkg, image); err != nil { return nil, err } machineID, err := localservices.NewUUID() if err != nil { return nil, err } mPkg, e...
[ "func", "(", "c", "*", "CloudAPI", ")", "CreateMachine", "(", "name", ",", "pkg", ",", "image", "string", ",", "networks", "[", "]", "string", ",", "metadata", ",", "tags", "map", "[", "string", "]", "string", ")", "(", "*", "cloudapi", ".", "Machine...
// CreateMachine creates a new machine in the double. It will be running immediately.
[ "CreateMachine", "creates", "a", "new", "machine", "in", "the", "double", ".", "It", "will", "be", "running", "immediately", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L96-L168
148,564
joyent/gosdc
localservices/cloudapi/service_machines.go
StopMachine
func (c *CloudAPI) StopMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.State = "stopped" machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") return nil } }...
go
func (c *CloudAPI) StopMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.State = "stopped" machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") return nil } }...
[ "func", "(", "c", "*", "CloudAPI", ")", "StopMachine", "(", "machineID", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n...
// StopMachine changes a machine's status to "stopped"
[ "StopMachine", "changes", "a", "machine", "s", "status", "to", "stopped" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L171-L185
148,565
joyent/gosdc
localservices/cloudapi/service_machines.go
ResizeMachine
func (c *CloudAPI) ResizeMachine(machineID, packageName string) error { if err := c.ProcessFunctionHook(c, machineID, packageName); err != nil { return err } mPkg, err := c.GetPackage(packageName) if err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.Pac...
go
func (c *CloudAPI) ResizeMachine(machineID, packageName string) error { if err := c.ProcessFunctionHook(c, machineID, packageName); err != nil { return err } mPkg, err := c.GetPackage(packageName) if err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.Pac...
[ "func", "(", "c", "*", "CloudAPI", ")", "ResizeMachine", "(", "machineID", ",", "packageName", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ",", "packageName", ")", ";", "err", "!=", "nil", ...
// ResizeMachine changes a machine's package to a new size. Unlike the real API, // this method lets you downsize machines.
[ "ResizeMachine", "changes", "a", "machine", "s", "package", "to", "a", "new", "size", ".", "Unlike", "the", "real", "API", "this", "method", "lets", "you", "downsize", "machines", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L223-L244
148,566
joyent/gosdc
localservices/cloudapi/service_machines.go
RenameMachine
func (c *CloudAPI) RenameMachine(machineID, newName string) error { if err := c.ProcessFunctionHook(c, machineID, newName); err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.Name = newName machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") ...
go
func (c *CloudAPI) RenameMachine(machineID, newName string) error { if err := c.ProcessFunctionHook(c, machineID, newName); err != nil { return err } for _, machine := range c.machines { if machine.Id == machineID { machine.Name = newName machine.Updated = time.Now().Format("2013-11-26T19:47:13.448Z") ...
[ "func", "(", "c", "*", "CloudAPI", ")", "RenameMachine", "(", "machineID", ",", "newName", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ",", "newName", ")", ";", "err", "!=", "nil", "{", ...
// RenameMachine changes a machine's name
[ "RenameMachine", "changes", "a", "machine", "s", "name" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L247-L261
148,567
joyent/gosdc
localservices/cloudapi/service_machines.go
ListMachineFirewallRules
func (c *CloudAPI) ListMachineFirewallRules(machineID string) ([]*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, machineID); err != nil { return nil, err } fwRules := []*cloudapi.FirewallRule{} for _, r := range c.firewallRules { vm := "vm " + machineID if strings.Contains(r.Rule, vm) { ...
go
func (c *CloudAPI) ListMachineFirewallRules(machineID string) ([]*cloudapi.FirewallRule, error) { if err := c.ProcessFunctionHook(c, machineID); err != nil { return nil, err } fwRules := []*cloudapi.FirewallRule{} for _, r := range c.firewallRules { vm := "vm " + machineID if strings.Contains(r.Rule, vm) { ...
[ "func", "(", "c", "*", "CloudAPI", ")", "ListMachineFirewallRules", "(", "machineID", "string", ")", "(", "[", "]", "*", "cloudapi", ".", "FirewallRule", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineI...
// ListMachineFirewallRules returns a list of firewall rules that apply to the // given machine
[ "ListMachineFirewallRules", "returns", "a", "list", "of", "firewall", "rules", "that", "apply", "to", "the", "given", "machine" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L265-L279
148,568
joyent/gosdc
localservices/cloudapi/service_machines.go
EnableFirewallMachine
func (c *CloudAPI) EnableFirewallMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } machine, err := c.GetMachine(machineID) if err != nil { return err } machine.FirewallEnabled = true return nil }
go
func (c *CloudAPI) EnableFirewallMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } machine, err := c.GetMachine(machineID) if err != nil { return err } machine.FirewallEnabled = true return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "EnableFirewallMachine", "(", "machineID", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}...
// EnableFirewallMachine enables the firewall for the given machine
[ "EnableFirewallMachine", "enables", "the", "firewall", "for", "the", "given", "machine" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L282-L295
148,569
joyent/gosdc
localservices/cloudapi/service_machines.go
DisableFirewallMachine
func (c *CloudAPI) DisableFirewallMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } machine, err := c.GetMachine(machineID) if err != nil { return err } machine.FirewallEnabled = false return nil }
go
func (c *CloudAPI) DisableFirewallMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } machine, err := c.GetMachine(machineID) if err != nil { return err } machine.FirewallEnabled = false return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DisableFirewallMachine", "(", "machineID", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "...
// DisableFirewallMachine disables the firewall for the given machine
[ "DisableFirewallMachine", "disables", "the", "firewall", "for", "the", "given", "machine" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L298-L311
148,570
joyent/gosdc
localservices/cloudapi/service_machines.go
DeleteMachine
func (c *CloudAPI) DeleteMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } for i, machine := range c.machines { if machine.Id == machineID { if machine.State == "stopped" { c.machines = append(c.machines[:i], c.machines[i+1:]...) return nil ...
go
func (c *CloudAPI) DeleteMachine(machineID string) error { if err := c.ProcessFunctionHook(c, machineID); err != nil { return err } for i, machine := range c.machines { if machine.Id == machineID { if machine.State == "stopped" { c.machines = append(c.machines[:i], c.machines[i+1:]...) return nil ...
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteMachine", "(", "machineID", "string", ")", "error", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "machineID", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n...
// DeleteMachine deletes the given machine from the double
[ "DeleteMachine", "deletes", "the", "given", "machine", "from", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_machines.go#L314-L331
148,571
joyent/gosdc
localservices/cloudapi/service_images.go
ListImages
func (c *CloudAPI) ListImages(filters map[string]string) ([]cloudapi.Image, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availableImages := c.images if filters != nil { for k, f := range filters { // check if valid filter if contains(imagesFilters, k) { imgs :...
go
func (c *CloudAPI) ListImages(filters map[string]string) ([]cloudapi.Image, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availableImages := c.images if filters != nil { for k, f := range filters { // check if valid filter if contains(imagesFilters, k) { imgs :...
[ "func", "(", "c", "*", "CloudAPI", ")", "ListImages", "(", "filters", "map", "[", "string", "]", "string", ")", "(", "[", "]", "cloudapi", ".", "Image", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "fil...
// ListImages returns a list of images in the double
[ "ListImages", "returns", "a", "list", "of", "images", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_images.go#L10-L46
148,572
joyent/gosdc
localservices/cloudapi/service_images.go
GetImage
func (c *CloudAPI) GetImage(imageID string) (*cloudapi.Image, error) { if err := c.ProcessFunctionHook(c, imageID); err != nil { return nil, err } for _, image := range c.images { if image.Id == imageID { return &image, nil } } return nil, fmt.Errorf("Image %s not found", imageID) }
go
func (c *CloudAPI) GetImage(imageID string) (*cloudapi.Image, error) { if err := c.ProcessFunctionHook(c, imageID); err != nil { return nil, err } for _, image := range c.images { if image.Id == imageID { return &image, nil } } return nil, fmt.Errorf("Image %s not found", imageID) }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetImage", "(", "imageID", "string", ")", "(", "*", "cloudapi", ".", "Image", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "imageID", ")", ";", "err", "!=", "nil...
// GetImage gets a single image by name from the double
[ "GetImage", "gets", "a", "single", "image", "by", "name", "from", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_images.go#L49-L61
148,573
joyent/gosdc
localservices/cloudapi/service_fabrics.go
ListFabricVLANs
func (c *CloudAPI) ListFabricVLANs() ([]cloudapi.FabricVLAN, error) { out := []cloudapi.FabricVLAN{} for _, vlan := range c.fabricVLANs { out = append(out, vlan.FabricVLAN) } return out, nil }
go
func (c *CloudAPI) ListFabricVLANs() ([]cloudapi.FabricVLAN, error) { out := []cloudapi.FabricVLAN{} for _, vlan := range c.fabricVLANs { out = append(out, vlan.FabricVLAN) } return out, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListFabricVLANs", "(", ")", "(", "[", "]", "cloudapi", ".", "FabricVLAN", ",", "error", ")", "{", "out", ":=", "[", "]", "cloudapi", ".", "FabricVLAN", "{", "}", "\n", "for", "_", ",", "vlan", ":=", "range",...
// ListFabricVLANs lists VLANs
[ "ListFabricVLANs", "lists", "VLANs" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L21-L28
148,574
joyent/gosdc
localservices/cloudapi/service_fabrics.go
GetFabricVLAN
func (c *CloudAPI) GetFabricVLAN(vlanID int16) (*cloudapi.FabricVLAN, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } return &vlan.FabricVLAN, nil }
go
func (c *CloudAPI) GetFabricVLAN(vlanID int16) (*cloudapi.FabricVLAN, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } return &vlan.FabricVLAN, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetFabricVLAN", "(", "vlanID", "int16", ")", "(", "*", "cloudapi", ".", "FabricVLAN", ",", "error", ")", "{", "vlan", ",", "err", ":=", "c", ".", "getFabricWrapper", "(", "vlanID", ")", "\n", "if", "err", "!="...
// GetFabricVLAN retrieves a single VLAN by ID
[ "GetFabricVLAN", "retrieves", "a", "single", "VLAN", "by", "ID" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L31-L38
148,575
joyent/gosdc
localservices/cloudapi/service_fabrics.go
CreateFabricVLAN
func (c *CloudAPI) CreateFabricVLAN(vlan cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error) { id := int16(rand.Intn(4095 + 1)) vlan.Id = id c.fabricVLANs[id] = &fabricVLAN{ FabricVLAN: vlan, Networks: make(map[string]*cloudapi.FabricNetwork), } return &vlan, nil }
go
func (c *CloudAPI) CreateFabricVLAN(vlan cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error) { id := int16(rand.Intn(4095 + 1)) vlan.Id = id c.fabricVLANs[id] = &fabricVLAN{ FabricVLAN: vlan, Networks: make(map[string]*cloudapi.FabricNetwork), } return &vlan, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "CreateFabricVLAN", "(", "vlan", "cloudapi", ".", "FabricVLAN", ")", "(", "*", "cloudapi", ".", "FabricVLAN", ",", "error", ")", "{", "id", ":=", "int16", "(", "rand", ".", "Intn", "(", "4095", "+", "1", ")", ...
// CreateFabricVLAN creates a new VLAN with the specified options
[ "CreateFabricVLAN", "creates", "a", "new", "VLAN", "with", "the", "specified", "options" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L41-L51
148,576
joyent/gosdc
localservices/cloudapi/service_fabrics.go
UpdateFabricVLAN
func (c *CloudAPI) UpdateFabricVLAN(new cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error) { current, err := c.GetFabricVLAN(new.Id) if err != nil { return nil, err } current.Name = new.Name current.Description = new.Description return current, nil }
go
func (c *CloudAPI) UpdateFabricVLAN(new cloudapi.FabricVLAN) (*cloudapi.FabricVLAN, error) { current, err := c.GetFabricVLAN(new.Id) if err != nil { return nil, err } current.Name = new.Name current.Description = new.Description return current, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "UpdateFabricVLAN", "(", "new", "cloudapi", ".", "FabricVLAN", ")", "(", "*", "cloudapi", ".", "FabricVLAN", ",", "error", ")", "{", "current", ",", "err", ":=", "c", ".", "GetFabricVLAN", "(", "new", ".", "Id", ...
// UpdateFabricVLAN updates a given VLAN with new fields
[ "UpdateFabricVLAN", "updates", "a", "given", "VLAN", "with", "new", "fields" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L54-L64
148,577
joyent/gosdc
localservices/cloudapi/service_fabrics.go
DeleteFabricVLAN
func (c *CloudAPI) DeleteFabricVLAN(vlanID int16) error { _, present := c.fabricVLANs[vlanID] if !present { return fmt.Errorf("VLAN %d not found", vlanID) } delete(c.fabricVLANs, vlanID) return nil }
go
func (c *CloudAPI) DeleteFabricVLAN(vlanID int16) error { _, present := c.fabricVLANs[vlanID] if !present { return fmt.Errorf("VLAN %d not found", vlanID) } delete(c.fabricVLANs, vlanID) return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteFabricVLAN", "(", "vlanID", "int16", ")", "error", "{", "_", ",", "present", ":=", "c", ".", "fabricVLANs", "[", "vlanID", "]", "\n", "if", "!", "present", "{", "return", "fmt", ".", "Errorf", "(", "\"",...
// DeleteFabricVLAN delets a given VLAN as specified by ID
[ "DeleteFabricVLAN", "delets", "a", "given", "VLAN", "as", "specified", "by", "ID" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L67-L75
148,578
joyent/gosdc
localservices/cloudapi/service_fabrics.go
ListFabricNetworks
func (c *CloudAPI) ListFabricNetworks(vlanID int16) ([]cloudapi.FabricNetwork, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } out := []cloudapi.FabricNetwork{} for _, network := range vlan.Networks { out = append(out, *network) } return out, nil }
go
func (c *CloudAPI) ListFabricNetworks(vlanID int16) ([]cloudapi.FabricNetwork, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } out := []cloudapi.FabricNetwork{} for _, network := range vlan.Networks { out = append(out, *network) } return out, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListFabricNetworks", "(", "vlanID", "int16", ")", "(", "[", "]", "cloudapi", ".", "FabricNetwork", ",", "error", ")", "{", "vlan", ",", "err", ":=", "c", ".", "getFabricWrapper", "(", "vlanID", ")", "\n", "if", ...
// ListFabricNetworks lists the networks inside the given VLAN
[ "ListFabricNetworks", "lists", "the", "networks", "inside", "the", "given", "VLAN" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L78-L90
148,579
joyent/gosdc
localservices/cloudapi/service_fabrics.go
GetFabricNetwork
func (c *CloudAPI) GetFabricNetwork(vlanID int16, networkID string) (*cloudapi.FabricNetwork, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } network, present := vlan.Networks[networkID] if !present { return nil, fmt.Errorf("Network %s not found", networkID) } return netw...
go
func (c *CloudAPI) GetFabricNetwork(vlanID int16, networkID string) (*cloudapi.FabricNetwork, error) { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } network, present := vlan.Networks[networkID] if !present { return nil, fmt.Errorf("Network %s not found", networkID) } return netw...
[ "func", "(", "c", "*", "CloudAPI", ")", "GetFabricNetwork", "(", "vlanID", "int16", ",", "networkID", "string", ")", "(", "*", "cloudapi", ".", "FabricNetwork", ",", "error", ")", "{", "vlan", ",", "err", ":=", "c", ".", "getFabricWrapper", "(", "vlanID"...
// GetFabricNetwork gets a single network by VLAN and Network IDs
[ "GetFabricNetwork", "gets", "a", "single", "network", "by", "VLAN", "and", "Network", "IDs" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L93-L105
148,580
joyent/gosdc
localservices/cloudapi/service_fabrics.go
CreateFabricNetwork
func (c *CloudAPI) CreateFabricNetwork(vlanID int16, opts cloudapi.CreateFabricNetworkOpts) (*cloudapi.FabricNetwork, error) { id, err := localservices.NewUUID() if err != nil { return nil, err } vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } vlan.Networks[id] = &cloudapi.FabricN...
go
func (c *CloudAPI) CreateFabricNetwork(vlanID int16, opts cloudapi.CreateFabricNetworkOpts) (*cloudapi.FabricNetwork, error) { id, err := localservices.NewUUID() if err != nil { return nil, err } vlan, err := c.getFabricWrapper(vlanID) if err != nil { return nil, err } vlan.Networks[id] = &cloudapi.FabricN...
[ "func", "(", "c", "*", "CloudAPI", ")", "CreateFabricNetwork", "(", "vlanID", "int16", ",", "opts", "cloudapi", ".", "CreateFabricNetworkOpts", ")", "(", "*", "cloudapi", ".", "FabricNetwork", ",", "error", ")", "{", "id", ",", "err", ":=", "localservices", ...
// CreateFabricNetwork creates a new fabric network
[ "CreateFabricNetwork", "creates", "a", "new", "fabric", "network" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L108-L135
148,581
joyent/gosdc
localservices/cloudapi/service_fabrics.go
DeleteFabricNetwork
func (c *CloudAPI) DeleteFabricNetwork(vlanID int16, networkID string) error { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return err } _, present := vlan.Networks[networkID] if !present { return fmt.Errorf("Network %s not found", networkID) } delete(vlan.Networks, networkID) return nil }
go
func (c *CloudAPI) DeleteFabricNetwork(vlanID int16, networkID string) error { vlan, err := c.getFabricWrapper(vlanID) if err != nil { return err } _, present := vlan.Networks[networkID] if !present { return fmt.Errorf("Network %s not found", networkID) } delete(vlan.Networks, networkID) return nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "DeleteFabricNetwork", "(", "vlanID", "int16", ",", "networkID", "string", ")", "error", "{", "vlan", ",", "err", ":=", "c", ".", "getFabricWrapper", "(", "vlanID", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// DeleteFabricNetwork deletes an existing fabric network
[ "DeleteFabricNetwork", "deletes", "an", "existing", "fabric", "network" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_fabrics.go#L138-L151
148,582
joyent/gosdc
localservices/cloudapi/service_http.go
handleListFabricVLANs
func (c *CloudAPI) handleListFabricVLANs(w http.ResponseWriter, r *http.Request, params httprouter.Params) error { vlans, err := c.ListFabricVLANs() if err != nil { return err } return sendJSON(http.StatusOK, vlans, w, r) }
go
func (c *CloudAPI) handleListFabricVLANs(w http.ResponseWriter, r *http.Request, params httprouter.Params) error { vlans, err := c.ListFabricVLANs() if err != nil { return err } return sendJSON(http.StatusOK, vlans, w, r) }
[ "func", "(", "c", "*", "CloudAPI", ")", "handleListFabricVLANs", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "params", "httprouter", ".", "Params", ")", "error", "{", "vlans", ",", "err", ":=", "c", ".", "ListFa...
// Fabrics + VLANs and Networks
[ "Fabrics", "+", "VLANs", "and", "Networks" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_http.go#L740-L747
148,583
joyent/gosdc
localservices/cloudapi/service_networks.go
ListNetworks
func (c *CloudAPI) ListNetworks() ([]cloudapi.Network, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.networks, nil }
go
func (c *CloudAPI) ListNetworks() ([]cloudapi.Network, error) { if err := c.ProcessFunctionHook(c); err != nil { return nil, err } return c.networks, nil }
[ "func", "(", "c", "*", "CloudAPI", ")", "ListNetworks", "(", ")", "(", "[", "]", "cloudapi", ".", "Network", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ")", ";", "err", "!=", "nil", "{", "return", "nil", ...
// Networks API // ListNetworks returns a list of networks that the double knows about
[ "Networks", "API", "ListNetworks", "returns", "a", "list", "of", "networks", "that", "the", "double", "knows", "about" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_networks.go#L13-L19
148,584
joyent/gosdc
localservices/cloudapi/service_networks.go
GetNetwork
func (c *CloudAPI) GetNetwork(networkID string) (*cloudapi.Network, error) { if err := c.ProcessFunctionHook(c, networkID); err != nil { return nil, err } for _, n := range c.networks { if strings.EqualFold(n.Id, networkID) { return &n, nil } } return nil, fmt.Errorf("Network %s not found", networkID) }
go
func (c *CloudAPI) GetNetwork(networkID string) (*cloudapi.Network, error) { if err := c.ProcessFunctionHook(c, networkID); err != nil { return nil, err } for _, n := range c.networks { if strings.EqualFold(n.Id, networkID) { return &n, nil } } return nil, fmt.Errorf("Network %s not found", networkID) }
[ "func", "(", "c", "*", "CloudAPI", ")", "GetNetwork", "(", "networkID", "string", ")", "(", "*", "cloudapi", ".", "Network", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "networkID", ")", ";", "err", "!="...
// GetNetwork gets a network by ID
[ "GetNetwork", "gets", "a", "network", "by", "ID" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_networks.go#L22-L34
148,585
cmars/basen
basen.go
NewEncoding
func NewEncoding(alphabet string) *Encoding { return &Encoding{ alphabet: alphabet, index: newAlphabetMap(alphabet), base: big.NewInt(int64(len(alphabet))), } }
go
func NewEncoding(alphabet string) *Encoding { return &Encoding{ alphabet: alphabet, index: newAlphabetMap(alphabet), base: big.NewInt(int64(len(alphabet))), } }
[ "func", "NewEncoding", "(", "alphabet", "string", ")", "*", "Encoding", "{", "return", "&", "Encoding", "{", "alphabet", ":", "alphabet", ",", "index", ":", "newAlphabetMap", "(", "alphabet", ")", ",", "base", ":", "big", ".", "NewInt", "(", "int64", "("...
// NewEncoding creates a new base-N representation from the given alphabet. // Panics if the alphabet is not unique. Only ASCII characters are supported.
[ "NewEncoding", "creates", "a", "new", "base", "-", "N", "representation", "from", "the", "given", "alphabet", ".", "Panics", "if", "the", "alphabet", "is", "not", "unique", ".", "Only", "ASCII", "characters", "are", "supported", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L33-L39
148,586
cmars/basen
basen.go
Random
func (enc *Encoding) Random(n int) (string, error) { buf := make([]byte, n) _, err := rand.Reader.Read(buf) if err != nil { return "", err } return enc.EncodeToString(buf), nil }
go
func (enc *Encoding) Random(n int) (string, error) { buf := make([]byte, n) _, err := rand.Reader.Read(buf) if err != nil { return "", err } return enc.EncodeToString(buf), nil }
[ "func", "(", "enc", "*", "Encoding", ")", "Random", "(", "n", "int", ")", "(", "string", ",", "error", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "n", ")", "\n", "_", ",", "err", ":=", "rand", ".", "Reader", ".", "Read", "(", ...
// Random returns the base-encoded representation of n random bytes.
[ "Random", "returns", "the", "base", "-", "encoded", "representation", "of", "n", "random", "bytes", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L56-L63
148,587
cmars/basen
basen.go
MustRandom
func (enc *Encoding) MustRandom(n int) string { s, err := enc.Random(n) if err != nil { panic(err) } return s }
go
func (enc *Encoding) MustRandom(n int) string { s, err := enc.Random(n) if err != nil { panic(err) } return s }
[ "func", "(", "enc", "*", "Encoding", ")", "MustRandom", "(", "n", "int", ")", "string", "{", "s", ",", "err", ":=", "enc", ".", "Random", "(", "n", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", ...
// MustRandom returns the base-encoded representation of n random bytes, // panicking in the unlikely event of a read error from the random source.
[ "MustRandom", "returns", "the", "base", "-", "encoded", "representation", "of", "n", "random", "bytes", "panicking", "in", "the", "unlikely", "event", "of", "a", "read", "error", "from", "the", "random", "source", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L67-L73
148,588
cmars/basen
basen.go
EncodeToString
func (enc *Encoding) EncodeToString(b []byte) string { n := new(big.Int) r := new(big.Int) n.SetBytes(b) var result []byte for n.Cmp(zero) > 0 { n, r = n.DivMod(n, enc.base, r) result = append([]byte{enc.alphabet[r.Int64()]}, result...) } return string(result) }
go
func (enc *Encoding) EncodeToString(b []byte) string { n := new(big.Int) r := new(big.Int) n.SetBytes(b) var result []byte for n.Cmp(zero) > 0 { n, r = n.DivMod(n, enc.base, r) result = append([]byte{enc.alphabet[r.Int64()]}, result...) } return string(result) }
[ "func", "(", "enc", "*", "Encoding", ")", "EncodeToString", "(", "b", "[", "]", "byte", ")", "string", "{", "n", ":=", "new", "(", "big", ".", "Int", ")", "\n", "r", ":=", "new", "(", "big", ".", "Int", ")", "\n", "n", ".", "SetBytes", "(", "...
// EncodeToString returns the base-encoded string representation // of the given bytes.
[ "EncodeToString", "returns", "the", "base", "-", "encoded", "string", "representation", "of", "the", "given", "bytes", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L82-L92
148,589
cmars/basen
basen.go
DecodeString
func (enc *Encoding) DecodeString(s string) ([]byte, error) { result := new(big.Int) for i := range s { n, ok := enc.index[s[i]] if !ok { return nil, fmt.Errorf("invalid character %q at index %d", s[i], i) } result = result.Add(result.Mul(result, enc.base), n) } return result.Bytes(), nil }
go
func (enc *Encoding) DecodeString(s string) ([]byte, error) { result := new(big.Int) for i := range s { n, ok := enc.index[s[i]] if !ok { return nil, fmt.Errorf("invalid character %q at index %d", s[i], i) } result = result.Add(result.Mul(result, enc.base), n) } return result.Bytes(), nil }
[ "func", "(", "enc", "*", "Encoding", ")", "DecodeString", "(", "s", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "result", ":=", "new", "(", "big", ".", "Int", ")", "\n", "for", "i", ":=", "range", "s", "{", "n", ",", "ok", "...
// DecodeString returns the bytes for the given base-encoded string.
[ "DecodeString", "returns", "the", "bytes", "for", "the", "given", "base", "-", "encoded", "string", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L95-L105
148,590
cmars/basen
basen.go
DecodeStringN
func (enc *Encoding) DecodeStringN(s string, n int) ([]byte, error) { value, err := enc.DecodeString(s) if err != nil { return nil, err } if len(value) > n { return nil, fmt.Errorf("value is too large") } pad := make([]byte, n-len(value)) return append(pad, value...), nil }
go
func (enc *Encoding) DecodeStringN(s string, n int) ([]byte, error) { value, err := enc.DecodeString(s) if err != nil { return nil, err } if len(value) > n { return nil, fmt.Errorf("value is too large") } pad := make([]byte, n-len(value)) return append(pad, value...), nil }
[ "func", "(", "enc", "*", "Encoding", ")", "DecodeStringN", "(", "s", "string", ",", "n", "int", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "value", ",", "err", ":=", "enc", ".", "DecodeString", "(", "s", ")", "\n", "if", "err", "!=", "...
// DecodeStringN returns N bytes for the given base-encoded string. // Use this method to ensure the value is left-padded with zeroes.
[ "DecodeStringN", "returns", "N", "bytes", "for", "the", "given", "base", "-", "encoded", "string", ".", "Use", "this", "method", "to", "ensure", "the", "value", "is", "left", "-", "padded", "with", "zeroes", "." ]
fe3947df716ebfda9847eb1b9a48f9592e06478c
https://github.com/cmars/basen/blob/fe3947df716ebfda9847eb1b9a48f9592e06478c/basen.go#L109-L119
148,591
joyent/gosdc
localservices/hook/service.go
currentServiceMethodName
func (s *TestService) currentServiceMethodName() string { pc, _, _, ok := runtime.Caller(2) if !ok { panic("current method name cannot be found") } return unqualifiedMethodName(pc) }
go
func (s *TestService) currentServiceMethodName() string { pc, _, _, ok := runtime.Caller(2) if !ok { panic("current method name cannot be found") } return unqualifiedMethodName(pc) }
[ "func", "(", "s", "*", "TestService", ")", "currentServiceMethodName", "(", ")", "string", "{", "pc", ",", "_", ",", "_", ",", "ok", ":=", "runtime", ".", "Caller", "(", "2", ")", "\n", "if", "!", "ok", "{", "panic", "(", "\"", "\"", ")", "\n", ...
// currentServiceMethodName returns the method executing on the service when ProcessControlHook was invoked.
[ "currentServiceMethodName", "returns", "the", "method", "executing", "on", "the", "service", "when", "ProcessControlHook", "was", "invoked", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/hook/service.go#L32-L38
148,592
joyent/gosdc
localservices/hook/service.go
RegisterControlPoint
func (s *TestService) RegisterControlPoint(hookName string, controller ControlProcessor) ControlHookCleanup { if s.ControlHooks == nil { s.ControlHooks = make(map[string]ControlProcessor) } if controller == nil { delete(s.ControlHooks, hookName) } else { s.ControlHooks[hookName] = controller } return func()...
go
func (s *TestService) RegisterControlPoint(hookName string, controller ControlProcessor) ControlHookCleanup { if s.ControlHooks == nil { s.ControlHooks = make(map[string]ControlProcessor) } if controller == nil { delete(s.ControlHooks, hookName) } else { s.ControlHooks[hookName] = controller } return func()...
[ "func", "(", "s", "*", "TestService", ")", "RegisterControlPoint", "(", "hookName", "string", ",", "controller", "ControlProcessor", ")", "ControlHookCleanup", "{", "if", "s", ".", "ControlHooks", "==", "nil", "{", "s", ".", "ControlHooks", "=", "make", "(", ...
// RegisterControlPoint assigns the specified controller to the named hook. If nil, any existing controller for the // hook is removed. // hookName is the name of a function on the service or some arbitrarily named control point.
[ "RegisterControlPoint", "assigns", "the", "specified", "controller", "to", "the", "named", "hook", ".", "If", "nil", "any", "existing", "controller", "for", "the", "hook", "is", "removed", ".", "hookName", "is", "the", "name", "of", "a", "function", "on", "t...
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/hook/service.go#L75-L87
148,593
joyent/gosdc
localservices/localservice.go
NewMAC
func NewMAC() (string, error) { mac := make([]byte, 6) n, err := io.ReadFull(rand.Reader, mac) if n != len(mac) || err != nil { return "", err } e := hex.EncodeToString(mac) return fmt.Sprintf("%s:%s:%s:%s:%s:%s", e[0:2], e[2:4], e[4:6], e[6:8], e[8:10], e[10:12]), nil }
go
func NewMAC() (string, error) { mac := make([]byte, 6) n, err := io.ReadFull(rand.Reader, mac) if n != len(mac) || err != nil { return "", err } e := hex.EncodeToString(mac) return fmt.Sprintf("%s:%s:%s:%s:%s:%s", e[0:2], e[2:4], e[4:6], e[6:8], e[8:10], e[10:12]), nil }
[ "func", "NewMAC", "(", ")", "(", "string", ",", "error", ")", "{", "mac", ":=", "make", "(", "[", "]", "byte", ",", "6", ")", "\n", "n", ",", "err", ":=", "io", ".", "ReadFull", "(", "rand", ".", "Reader", ",", "mac", ")", "\n", "if", "n", ...
// NewMAC generates a new fake MAC address
[ "NewMAC", "generates", "a", "new", "fake", "MAC", "address" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/localservice.go#L47-L56
148,594
joyent/gosdc
localservices/cloudapi/service_packages.go
ListPackages
func (c *CloudAPI) ListPackages(filters map[string]string) ([]cloudapi.Package, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availablePackages := c.packages if filters != nil { for k, f := range filters { // check if valid filter if contains(packagesFilters, k) { ...
go
func (c *CloudAPI) ListPackages(filters map[string]string) ([]cloudapi.Package, error) { if err := c.ProcessFunctionHook(c, filters); err != nil { return nil, err } availablePackages := c.packages if filters != nil { for k, f := range filters { // check if valid filter if contains(packagesFilters, k) { ...
[ "func", "(", "c", "*", "CloudAPI", ")", "ListPackages", "(", "filters", "map", "[", "string", "]", "string", ")", "(", "[", "]", "cloudapi", ".", "Package", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", ...
// ListPackages lists packages in the double
[ "ListPackages", "lists", "packages", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_packages.go#L11-L59
148,595
joyent/gosdc
localservices/cloudapi/service_packages.go
GetPackage
func (c *CloudAPI) GetPackage(packageName string) (*cloudapi.Package, error) { if err := c.ProcessFunctionHook(c, packageName); err != nil { return nil, err } for _, pkg := range c.packages { if pkg.Name == packageName { return &pkg, nil } if pkg.Id == packageName { return &pkg, nil } } return ni...
go
func (c *CloudAPI) GetPackage(packageName string) (*cloudapi.Package, error) { if err := c.ProcessFunctionHook(c, packageName); err != nil { return nil, err } for _, pkg := range c.packages { if pkg.Name == packageName { return &pkg, nil } if pkg.Id == packageName { return &pkg, nil } } return ni...
[ "func", "(", "c", "*", "CloudAPI", ")", "GetPackage", "(", "packageName", "string", ")", "(", "*", "cloudapi", ".", "Package", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "ProcessFunctionHook", "(", "c", ",", "packageName", ")", ";", "err", ...
// GetPackage gets a single package in the double
[ "GetPackage", "gets", "a", "single", "package", "in", "the", "double" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/localservices/cloudapi/service_packages.go#L62-L77
148,596
joyent/gosdc
cloudapi/machines.go
Equals
func (m Machine) Equals(other Machine) bool { if m.Id == other.Id && m.Name == other.Name && m.Type == other.Type && m.Dataset == other.Dataset && m.Memory == other.Memory && m.Disk == other.Disk && m.Package == other.Package && m.Image == other.Image && m.compareIPs(other) && m.compareMetadata(other) { return t...
go
func (m Machine) Equals(other Machine) bool { if m.Id == other.Id && m.Name == other.Name && m.Type == other.Type && m.Dataset == other.Dataset && m.Memory == other.Memory && m.Disk == other.Disk && m.Package == other.Package && m.Image == other.Image && m.compareIPs(other) && m.compareMetadata(other) { return t...
[ "func", "(", "m", "Machine", ")", "Equals", "(", "other", "Machine", ")", "bool", "{", "if", "m", ".", "Id", "==", "other", ".", "Id", "&&", "m", ".", "Name", "==", "other", ".", "Name", "&&", "m", ".", "Type", "==", "other", ".", "Type", "&&",...
// Equals compares two machines. Ignores state and timestamps.
[ "Equals", "compares", "two", "machines", ".", "Ignores", "state", "and", "timestamps", "." ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/machines.go#L37-L44
148,597
joyent/gosdc
cloudapi/machines.go
compareIPs
func (m Machine) compareIPs(other Machine) bool { if len(m.IPs) != len(other.IPs) { return false } for i, v := range m.IPs { if v != other.IPs[i] { return false } } return true }
go
func (m Machine) compareIPs(other Machine) bool { if len(m.IPs) != len(other.IPs) { return false } for i, v := range m.IPs { if v != other.IPs[i] { return false } } return true }
[ "func", "(", "m", "Machine", ")", "compareIPs", "(", "other", "Machine", ")", "bool", "{", "if", "len", "(", "m", ".", "IPs", ")", "!=", "len", "(", "other", ".", "IPs", ")", "{", "return", "false", "\n", "}", "\n", "for", "i", ",", "v", ":=", ...
// Helper method to compare two machines IPs
[ "Helper", "method", "to", "compare", "two", "machines", "IPs" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/machines.go#L47-L57
148,598
joyent/gosdc
cloudapi/machines.go
compareMetadata
func (m Machine) compareMetadata(other Machine) bool { if len(m.Metadata) != len(other.Metadata) { return false } for k, v := range m.Metadata { if v != other.Metadata[k] { return false } } return true }
go
func (m Machine) compareMetadata(other Machine) bool { if len(m.Metadata) != len(other.Metadata) { return false } for k, v := range m.Metadata { if v != other.Metadata[k] { return false } } return true }
[ "func", "(", "m", "Machine", ")", "compareMetadata", "(", "other", "Machine", ")", "bool", "{", "if", "len", "(", "m", ".", "Metadata", ")", "!=", "len", "(", "other", ".", "Metadata", ")", "{", "return", "false", "\n", "}", "\n", "for", "k", ",", ...
// Helper method to compare two machines metadata
[ "Helper", "method", "to", "compare", "two", "machines", "metadata" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/machines.go#L60-L70
148,599
joyent/gosdc
cloudapi/machines.go
MarshalJSON
func (opts CreateMachineOpts) MarshalJSON() ([]byte, error) { jo := jsonOpts(opts) data, err := json.Marshal(&jo) if err != nil { return nil, err } for k, v := range opts.Tags { if !strings.HasPrefix(k, "tag.") { k = "tag." + k } data, err = appendJSON(data, k, v) if err != nil { return nil, err ...
go
func (opts CreateMachineOpts) MarshalJSON() ([]byte, error) { jo := jsonOpts(opts) data, err := json.Marshal(&jo) if err != nil { return nil, err } for k, v := range opts.Tags { if !strings.HasPrefix(k, "tag.") { k = "tag." + k } data, err = appendJSON(data, k, v) if err != nil { return nil, err ...
[ "func", "(", "opts", "CreateMachineOpts", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "jo", ":=", "jsonOpts", "(", "opts", ")", "\n", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "&", "jo", ")", "\n", "i...
// MarshalJSON turns the given CreateMachineOpts into JSON
[ "MarshalJSON", "turns", "the", "given", "CreateMachineOpts", "into", "JSON" ]
ec8b3503a75edca0df26581b83807677b0240716
https://github.com/joyent/gosdc/blob/ec8b3503a75edca0df26581b83807677b0240716/cloudapi/machines.go#L116-L141