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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
24,100 | apcera/libretto | virtualmachine/vsphere/vm.go | StartProgress | func (r ReadProgress) StartProgress() {
r.wg.Add(1)
go func() {
var bytesReceived int64
var percent int
tick := time.NewTicker(5 * time.Second)
defer tick.Stop()
defer r.wg.Done()
for {
select {
case b := <-r.ch:
bytesReceived += b
percent = int((float32(bytesReceived) / float32(r.TotalBytes... | go | func (r ReadProgress) StartProgress() {
r.wg.Add(1)
go func() {
var bytesReceived int64
var percent int
tick := time.NewTicker(5 * time.Second)
defer tick.Stop()
defer r.wg.Done()
for {
select {
case b := <-r.ch:
bytesReceived += b
percent = int((float32(bytesReceived) / float32(r.TotalBytes... | [
"func",
"(",
"r",
"ReadProgress",
")",
"StartProgress",
"(",
")",
"{",
"r",
".",
"wg",
".",
"Add",
"(",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"var",
"bytesReceived",
"int64",
"\n",
"var",
"percent",
"int",
"\n",
"tick",
":=",
"time",
".",
... | // StartProgress starts a goroutine that updates local progress on the lease as
// well as pass it down to the underlying lease. | [
"StartProgress",
"starts",
"a",
"goroutine",
"that",
"updates",
"local",
"progress",
"on",
"the",
"lease",
"as",
"well",
"as",
"pass",
"it",
"down",
"to",
"the",
"underlying",
"lease",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L107-L129 |
24,101 | apcera/libretto | virtualmachine/vsphere/vm.go | NewErrorParsingURL | func NewErrorParsingURL(u string, e error) ErrorParsingURL {
return ErrorParsingURL{uri: u, err: e}
} | go | func NewErrorParsingURL(u string, e error) ErrorParsingURL {
return ErrorParsingURL{uri: u, err: e}
} | [
"func",
"NewErrorParsingURL",
"(",
"u",
"string",
",",
"e",
"error",
")",
"ErrorParsingURL",
"{",
"return",
"ErrorParsingURL",
"{",
"uri",
":",
"u",
",",
"err",
":",
"e",
"}",
"\n",
"}"
] | // NewErrorParsingURL returns an ErrorParsingURL error. | [
"NewErrorParsingURL",
"returns",
"an",
"ErrorParsingURL",
"error",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L216-L218 |
24,102 | apcera/libretto | virtualmachine/vsphere/vm.go | NewErrorInvalidHost | func NewErrorInvalidHost(h string, d string, n map[string]string) ErrorInvalidHost {
return ErrorInvalidHost{host: h, ds: d, nw: n}
} | go | func NewErrorInvalidHost(h string, d string, n map[string]string) ErrorInvalidHost {
return ErrorInvalidHost{host: h, ds: d, nw: n}
} | [
"func",
"NewErrorInvalidHost",
"(",
"h",
"string",
",",
"d",
"string",
",",
"n",
"map",
"[",
"string",
"]",
"string",
")",
"ErrorInvalidHost",
"{",
"return",
"ErrorInvalidHost",
"{",
"host",
":",
"h",
",",
"ds",
":",
"d",
",",
"nw",
":",
"n",
"}",
"\... | // NewErrorInvalidHost returns an ErrorInvalidHost error. | [
"NewErrorInvalidHost",
"returns",
"an",
"ErrorInvalidHost",
"error",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L221-L223 |
24,103 | apcera/libretto | virtualmachine/vsphere/vm.go | NewErrorObjectNotFound | func NewErrorObjectNotFound(e error, o string) ErrorObjectNotFound {
return ErrorObjectNotFound{err: e, obj: o}
} | go | func NewErrorObjectNotFound(e error, o string) ErrorObjectNotFound {
return ErrorObjectNotFound{err: e, obj: o}
} | [
"func",
"NewErrorObjectNotFound",
"(",
"e",
"error",
",",
"o",
"string",
")",
"ErrorObjectNotFound",
"{",
"return",
"ErrorObjectNotFound",
"{",
"err",
":",
"e",
",",
"obj",
":",
"o",
"}",
"\n",
"}"
] | // NewErrorObjectNotFound returns an ErrorObjectNotFound error. | [
"NewErrorObjectNotFound",
"returns",
"an",
"ErrorObjectNotFound",
"error",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L231-L233 |
24,104 | apcera/libretto | virtualmachine/vsphere/vm.go | NewErrorPropertyRetrieval | func NewErrorPropertyRetrieval(m types.ManagedObjectReference, p []string, e error) ErrorPropertyRetrieval {
return ErrorPropertyRetrieval{err: e, mor: m, ps: p}
} | go | func NewErrorPropertyRetrieval(m types.ManagedObjectReference, p []string, e error) ErrorPropertyRetrieval {
return ErrorPropertyRetrieval{err: e, mor: m, ps: p}
} | [
"func",
"NewErrorPropertyRetrieval",
"(",
"m",
"types",
".",
"ManagedObjectReference",
",",
"p",
"[",
"]",
"string",
",",
"e",
"error",
")",
"ErrorPropertyRetrieval",
"{",
"return",
"ErrorPropertyRetrieval",
"{",
"err",
":",
"e",
",",
"mor",
":",
"m",
",",
"... | // NewErrorPropertyRetrieval returns an ErrorPropertyRetrieval error. | [
"NewErrorPropertyRetrieval",
"returns",
"an",
"ErrorPropertyRetrieval",
"error",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L236-L238 |
24,105 | apcera/libretto | virtualmachine/vsphere/vm.go | Provision | func (vm *VM) Provision() (err error) {
if err := SetupSession(vm); err != nil {
return fmt.Errorf("Error setting up vSphere session: %s", err)
}
// Cancel the sdk context
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo,... | go | func (vm *VM) Provision() (err error) {
if err := SetupSession(vm); err != nil {
return fmt.Errorf("Error setting up vSphere session: %s", err)
}
// Cancel the sdk context
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo,... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Provision",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
... | // Provision provisions this VM. | [
"Provision",
"provisions",
"this",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L355-L419 |
24,106 | apcera/libretto | virtualmachine/vsphere/vm.go | GetIPs | func (vm *VM) GetIPs() ([]net.IP, error) {
if err := SetupSession(vm); err != nil {
return nil, err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo, err := GetDatacenter(vm)
if err != nil {
return nil, err
}
vmMo, e... | go | func (vm *VM) GetIPs() ([]net.IP, error) {
if err := SetupSession(vm); err != nil {
return nil, err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo, err := GetDatacenter(vm)
if err != nil {
return nil, err
}
vmMo, e... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetIPs",
"(",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"... | // GetIPs returns the IPs of this VM. Returns all the IPs known to the API for
// the different network cards for this VM. Includes IPV4 and IPV6 addresses. | [
"GetIPs",
"returns",
"the",
"IPs",
"of",
"this",
"VM",
".",
"Returns",
"all",
"the",
"IPs",
"known",
"to",
"the",
"API",
"for",
"the",
"different",
"network",
"cards",
"for",
"this",
"VM",
".",
"Includes",
"IPV4",
"and",
"IPV6",
"addresses",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L428-L467 |
24,107 | apcera/libretto | virtualmachine/vsphere/vm.go | Destroy | func (vm *VM) Destroy() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
state, err := getState(vm)
if err != nil {
return err
}
// Can't destroy a suspended VM, power it on and update the state
if state == "standby" {
err =... | go | func (vm *VM) Destroy() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
state, err := getState(vm)
if err != nil {
return err
}
// Can't destroy a suspended VM, power it on and update the state
if state == "standby" {
err =... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Destroy",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"vm",
".... | // Destroy deletes this VM from vSphere. | [
"Destroy",
"deletes",
"this",
"VM",
"from",
"vSphere",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L470-L558 |
24,108 | apcera/libretto | virtualmachine/vsphere/vm.go | GetState | func (vm *VM) GetState() (state string, err error) {
if err := SetupSession(vm); err != nil {
return "", lvm.ErrVMInfoFailed
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
state, err = getState(vm)
if err != nil {
return "", err
}
if state == "running" {
return lvm.VMRunning, nil
} else i... | go | func (vm *VM) GetState() (state string, err error) {
if err := SetupSession(vm); err != nil {
return "", lvm.ErrVMInfoFailed
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
state, err = getState(vm)
if err != nil {
return "", err
}
if state == "running" {
return lvm.VMRunning, nil
} else i... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetState",
"(",
")",
"(",
"state",
"string",
",",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"lvm",
".",
"ErrVMInfoFail... | // GetState returns the power state of this VM. | [
"GetState",
"returns",
"the",
"power",
"state",
"of",
"this",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L561-L583 |
24,109 | apcera/libretto | virtualmachine/vsphere/vm.go | Suspend | func (vm *VM) Suspend() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo, err := GetDatacenter(vm)
if err != nil {
return err
}
vmMo, err := findVM(v... | go | func (vm *VM) Suspend() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
// Get a reference to the datacenter with host and vm folders populated
dcMo, err := GetDatacenter(vm)
if err != nil {
return err
}
vmMo, err := findVM(v... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Suspend",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"defer",
"func",
"(",
")",
"{",
"vm",
... | // Suspend suspends this VM. | [
"Suspend",
"suspends",
"this",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L586-L618 |
24,110 | apcera/libretto | virtualmachine/vsphere/vm.go | Halt | func (vm *VM) Halt() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
return halt(vm)
} | go | func (vm *VM) Halt() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
return halt(vm)
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Halt",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"vm",
".",
... | // Halt halts this VM. | [
"Halt",
"halts",
"this",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L621-L631 |
24,111 | apcera/libretto | virtualmachine/vsphere/vm.go | Start | func (vm *VM) Start() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
return start(vm)
} | go | func (vm *VM) Start() (err error) {
if err := SetupSession(vm); err != nil {
return err
}
defer func() {
vm.client.Logout(vm.ctx)
vm.cancel()
}()
return start(vm)
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Start",
"(",
")",
"(",
"err",
"error",
")",
"{",
"if",
"err",
":=",
"SetupSession",
"(",
"vm",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"func",
"(",
")",
"{",
"vm",
".",... | // Start powers on this VM. | [
"Start",
"powers",
"on",
"this",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vsphere/vm.go#L634-L644 |
24,112 | apcera/libretto | virtualmachine/mockprovider/vm.go | GetSSH | func (vm *VM) GetSSH(options libssh.Options) (libssh.Client, error) {
if vm.MockGetSSH != nil {
return vm.MockGetSSH(options)
}
return nil, lvm.ErrNotImplemented
} | go | func (vm *VM) GetSSH(options libssh.Options) (libssh.Client, error) {
if vm.MockGetSSH != nil {
return vm.MockGetSSH(options)
}
return nil, lvm.ErrNotImplemented
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetSSH",
"(",
"options",
"libssh",
".",
"Options",
")",
"(",
"libssh",
".",
"Client",
",",
"error",
")",
"{",
"if",
"vm",
".",
"MockGetSSH",
"!=",
"nil",
"{",
"return",
"vm",
".",
"MockGetSSH",
"(",
"options",
")... | // GetSSH returns an ssh client for the the vm. | [
"GetSSH",
"returns",
"an",
"ssh",
"client",
"for",
"the",
"the",
"vm",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/mockprovider/vm.go#L37-L42 |
24,113 | apcera/libretto | virtualmachine/mockprovider/vm.go | Resume | func (vm *VM) Resume() error {
if vm.MockResume != nil {
return vm.MockResume()
}
return lvm.ErrNotImplemented
} | go | func (vm *VM) Resume() error {
if vm.MockResume != nil {
return vm.MockResume()
}
return lvm.ErrNotImplemented
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Resume",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"MockResume",
"!=",
"nil",
"{",
"return",
"vm",
".",
"MockResume",
"(",
")",
"\n",
"}",
"\n",
"return",
"lvm",
".",
"ErrNotImplemented",
"\n",
"}"
] | // Resume suspends the active state of the VM. | [
"Resume",
"suspends",
"the",
"active",
"state",
"of",
"the",
"VM",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/mockprovider/vm.go#L69-L74 |
24,114 | apcera/libretto | virtualmachine/mockprovider/vm.go | GetIPs | func (vm *VM) GetIPs() ([]net.IP, error) {
if vm.MockGetIPs != nil {
return vm.MockGetIPs()
}
return []net.IP{}, nil
} | go | func (vm *VM) GetIPs() ([]net.IP, error) {
if vm.MockGetIPs != nil {
return vm.MockGetIPs()
}
return []net.IP{}, nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetIPs",
"(",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"vm",
".",
"MockGetIPs",
"!=",
"nil",
"{",
"return",
"vm",
".",
"MockGetIPs",
"(",
")",
"\n",
"}",
"\n",
"return",
"[",
"]",... | // GetIPs returns a list of ip addresses associated with the vm through VMware tools | [
"GetIPs",
"returns",
"a",
"list",
"of",
"ip",
"addresses",
"associated",
"with",
"the",
"vm",
"through",
"VMware",
"tools"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/mockprovider/vm.go#L85-L90 |
24,115 | apcera/libretto | virtualmachine/mockprovider/vm.go | Provision | func (vm *VM) Provision() error {
if vm.MockProvision != nil {
return vm.MockProvision()
}
return lvm.ErrNotImplemented
} | go | func (vm *VM) Provision() error {
if vm.MockProvision != nil {
return vm.MockProvision()
}
return lvm.ErrNotImplemented
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Provision",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"MockProvision",
"!=",
"nil",
"{",
"return",
"vm",
".",
"MockProvision",
"(",
")",
"\n",
"}",
"\n",
"return",
"lvm",
".",
"ErrNotImplemented",
"\n",
"}"
] | // Provision clones this VM and powers it on, while waiting for it to get an IP address. | [
"Provision",
"clones",
"this",
"VM",
"and",
"powers",
"it",
"on",
"while",
"waiting",
"for",
"it",
"to",
"get",
"an",
"IP",
"address",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/mockprovider/vm.go#L101-L106 |
24,116 | apcera/libretto | ssh/ssh.go | Connect | func (client *SSHClient) Connect() error {
var (
auth cssh.AuthMethod
err error
)
if err = client.Validate(); err != nil {
return err
}
if client.Creds.SSHPrivateKey != "" {
auth, err = getAuth(client.Creds, KeyAuth)
if err != nil {
return err
}
} else {
auth, err = getAuth(client.Creds, Passw... | go | func (client *SSHClient) Connect() error {
var (
auth cssh.AuthMethod
err error
)
if err = client.Validate(); err != nil {
return err
}
if client.Creds.SSHPrivateKey != "" {
auth, err = getAuth(client.Creds, KeyAuth)
if err != nil {
return err
}
} else {
auth, err = getAuth(client.Creds, Passw... | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"Connect",
"(",
")",
"error",
"{",
"var",
"(",
"auth",
"cssh",
".",
"AuthMethod",
"\n",
"err",
"error",
"\n",
")",
"\n\n",
"if",
"err",
"=",
"client",
".",
"Validate",
"(",
")",
";",
"err",
"!=",
"nil",... | // Connect connects to a machine using SSH. | [
"Connect",
"connects",
"to",
"a",
"machine",
"using",
"SSH",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L98-L146 |
24,117 | apcera/libretto | ssh/ssh.go | Run | func (client *SSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error {
session, err := client.cryptoClient.NewSession()
if err != nil {
return err
}
defer session.Close()
session.Stdout = stdout
session.Stderr = stderr
if client.Options.Pty {
modes := cssh.TerminalModes{
cssh.ECHO: ... | go | func (client *SSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error {
session, err := client.cryptoClient.NewSession()
if err != nil {
return err
}
defer session.Close()
session.Stdout = stdout
session.Stderr = stderr
if client.Options.Pty {
modes := cssh.TerminalModes{
cssh.ECHO: ... | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"Run",
"(",
"command",
"string",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
".",
"Writer",
")",
"error",
"{",
"session",
",",
"err",
":=",
"client",
".",
"cryptoClient",
".",
"NewSession",
"("... | // Run runs a command via SSH. | [
"Run",
"runs",
"a",
"command",
"via",
"SSH",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L265-L289 |
24,118 | apcera/libretto | ssh/ssh.go | Validate | func (client *SSHClient) Validate() error {
if client.Creds.SSHUser == "" {
return ErrInvalidUsername
}
if client.Creds.SSHPrivateKey == "" && client.Creds.SSHPassword == "" {
return ErrInvalidAuth
}
return nil
} | go | func (client *SSHClient) Validate() error {
if client.Creds.SSHUser == "" {
return ErrInvalidUsername
}
if client.Creds.SSHPrivateKey == "" && client.Creds.SSHPassword == "" {
return ErrInvalidAuth
}
return nil
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"client",
".",
"Creds",
".",
"SSHUser",
"==",
"\"",
"\"",
"{",
"return",
"ErrInvalidUsername",
"\n",
"}",
"\n\n",
"if",
"client",
".",
"Creds",
".",
"SSHPrivateKey",
... | // Validate verifies that SSH connection credentials were properly configured. | [
"Validate",
"verifies",
"that",
"SSH",
"connection",
"credentials",
"were",
"properly",
"configured",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L350-L360 |
24,119 | apcera/libretto | ssh/ssh.go | WaitForSSH | func (client *SSHClient) WaitForSSH(maxWait time.Duration) error {
start := time.Now()
for {
if err := client.Connect(); err == nil {
defer client.Disconnect()
return nil
}
timePassed := time.Since(start)
if timePassed >= maxWait {
break
}
time.Sleep(5 * time.Second)
}
return ErrTimeout
} | go | func (client *SSHClient) WaitForSSH(maxWait time.Duration) error {
start := time.Now()
for {
if err := client.Connect(); err == nil {
defer client.Disconnect()
return nil
}
timePassed := time.Since(start)
if timePassed >= maxWait {
break
}
time.Sleep(5 * time.Second)
}
return ErrTimeout
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"WaitForSSH",
"(",
"maxWait",
"time",
".",
"Duration",
")",
"error",
"{",
"start",
":=",
"time",
".",
"Now",
"(",
")",
"\n\n",
"for",
"{",
"if",
"err",
":=",
"client",
".",
"Connect",
"(",
")",
";",
"er... | // WaitForSSH will try to connect to an SSH server. If it fails, then it'll
// sleep for 5 seconds. | [
"WaitForSSH",
"will",
"try",
"to",
"connect",
"to",
"an",
"SSH",
"server",
".",
"If",
"it",
"fails",
"then",
"it",
"ll",
"sleep",
"for",
"5",
"seconds",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L364-L382 |
24,120 | apcera/libretto | ssh/ssh.go | SetSSHPrivateKey | func (client *SSHClient) SetSSHPrivateKey(s string) {
client.Creds.mu.Lock()
client.Creds.SSHPrivateKey = s
client.Creds.mu.Unlock()
} | go | func (client *SSHClient) SetSSHPrivateKey(s string) {
client.Creds.mu.Lock()
client.Creds.SSHPrivateKey = s
client.Creds.mu.Unlock()
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"SetSSHPrivateKey",
"(",
"s",
"string",
")",
"{",
"client",
".",
"Creds",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"client",
".",
"Creds",
".",
"SSHPrivateKey",
"=",
"s",
"\n",
"client",
".",
"Creds",
".",... | // SetSSHPrivateKey sets the private key on the clients credentials. | [
"SetSSHPrivateKey",
"sets",
"the",
"private",
"key",
"on",
"the",
"clients",
"credentials",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L385-L389 |
24,121 | apcera/libretto | ssh/ssh.go | GetSSHPrivateKey | func (client *SSHClient) GetSSHPrivateKey() string {
client.Creds.mu.Lock()
defer client.Creds.mu.Unlock()
return client.Creds.SSHPrivateKey
} | go | func (client *SSHClient) GetSSHPrivateKey() string {
client.Creds.mu.Lock()
defer client.Creds.mu.Unlock()
return client.Creds.SSHPrivateKey
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"GetSSHPrivateKey",
"(",
")",
"string",
"{",
"client",
".",
"Creds",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"client",
".",
"Creds",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"client",
... | // GetSSHPrivateKey gets the private key on the clients credentials. | [
"GetSSHPrivateKey",
"gets",
"the",
"private",
"key",
"on",
"the",
"clients",
"credentials",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L392-L396 |
24,122 | apcera/libretto | ssh/ssh.go | SetSSHPassword | func (client *SSHClient) SetSSHPassword(s string) {
client.Creds.mu.Lock()
client.Creds.SSHPassword = s
client.Creds.mu.Unlock()
} | go | func (client *SSHClient) SetSSHPassword(s string) {
client.Creds.mu.Lock()
client.Creds.SSHPassword = s
client.Creds.mu.Unlock()
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"SetSSHPassword",
"(",
"s",
"string",
")",
"{",
"client",
".",
"Creds",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"client",
".",
"Creds",
".",
"SSHPassword",
"=",
"s",
"\n",
"client",
".",
"Creds",
".",
"... | // SetSSHPassword sets the SSH password on the clients credentials. | [
"SetSSHPassword",
"sets",
"the",
"SSH",
"password",
"on",
"the",
"clients",
"credentials",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L399-L403 |
24,123 | apcera/libretto | ssh/ssh.go | GetSSHPassword | func (client *SSHClient) GetSSHPassword() string {
client.Creds.mu.Lock()
defer client.Creds.mu.Unlock()
return client.Creds.SSHPassword
} | go | func (client *SSHClient) GetSSHPassword() string {
client.Creds.mu.Lock()
defer client.Creds.mu.Unlock()
return client.Creds.SSHPassword
} | [
"func",
"(",
"client",
"*",
"SSHClient",
")",
"GetSSHPassword",
"(",
")",
"string",
"{",
"client",
".",
"Creds",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"client",
".",
"Creds",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"return",
"client",
... | // GetSSHPassword gets the SSH password on the clients credentials. | [
"GetSSHPassword",
"gets",
"the",
"SSH",
"password",
"on",
"the",
"clients",
"credentials",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/ssh.go#L406-L410 |
24,124 | apcera/libretto | virtualmachine/azure/management/util.go | getClient | func (vm *VM) getClient() (management.Client, error) {
mu.Lock()
defer mu.Unlock()
if client != nil {
return client, nil
}
var err error
client, err = management.ClientFromPublishSettingsFile(vm.PublishSettings, "")
if err != nil {
return nil, err
}
return client, nil
} | go | func (vm *VM) getClient() (management.Client, error) {
mu.Lock()
defer mu.Unlock()
if client != nil {
return client, nil
}
var err error
client, err = management.ClientFromPublishSettingsFile(vm.PublishSettings, "")
if err != nil {
return nil, err
}
return client, nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"getClient",
"(",
")",
"(",
"management",
".",
"Client",
",",
"error",
")",
"{",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"client",
"!=",
"nil",
"{",
"return",
"cl... | // getClient instantiates an Azure client if necessary and returns a copy of the
// client. It returns an error if there is a problem reading or unmarshaling the
// .publishSettings file. | [
"getClient",
"instantiates",
"an",
"Azure",
"client",
"if",
"necessary",
"and",
"returns",
"a",
"copy",
"of",
"the",
"client",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"is",
"a",
"problem",
"reading",
"or",
"unmarshaling",
"the",
".",
"publishSett... | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L27-L41 |
24,125 | apcera/libretto | virtualmachine/azure/management/util.go | getVMClient | func (vm *VM) getVMClient() (virtualmachine.VirtualMachineClient, error) {
c, err := vm.getClient()
if err != nil {
return virtualmachine.VirtualMachineClient{}, err
}
return virtualmachine.NewClient(c), nil
} | go | func (vm *VM) getVMClient() (virtualmachine.VirtualMachineClient, error) {
c, err := vm.getClient()
if err != nil {
return virtualmachine.VirtualMachineClient{}, err
}
return virtualmachine.NewClient(c), nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"getVMClient",
"(",
")",
"(",
"virtualmachine",
".",
"VirtualMachineClient",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"vm",
".",
"getClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"virtualma... | // getVMClient returns a new Azure virtual machine client. | [
"getVMClient",
"returns",
"a",
"new",
"Azure",
"virtual",
"machine",
"client",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L44-L51 |
24,126 | apcera/libretto | virtualmachine/azure/management/util.go | getServiceClient | func (vm *VM) getServiceClient() (hostedservice.HostedServiceClient, error) {
c, err := vm.getClient()
if err != nil {
return hostedservice.HostedServiceClient{}, err
}
return hostedservice.NewClient(c), nil
} | go | func (vm *VM) getServiceClient() (hostedservice.HostedServiceClient, error) {
c, err := vm.getClient()
if err != nil {
return hostedservice.HostedServiceClient{}, err
}
return hostedservice.NewClient(c), nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"getServiceClient",
"(",
")",
"(",
"hostedservice",
".",
"HostedServiceClient",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"vm",
".",
"getClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"hosted... | // getServiceClient returns a new Azure hosted service client. | [
"getServiceClient",
"returns",
"a",
"new",
"Azure",
"hosted",
"service",
"client",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L54-L61 |
24,127 | apcera/libretto | virtualmachine/azure/management/util.go | getVirtualNetworkClient | func (vm *VM) getVirtualNetworkClient() (virtualnetwork.VirtualNetworkClient, error) {
c, err := vm.getClient()
if err != nil {
return virtualnetwork.VirtualNetworkClient{}, err
}
return virtualnetwork.NewClient(c), nil
} | go | func (vm *VM) getVirtualNetworkClient() (virtualnetwork.VirtualNetworkClient, error) {
c, err := vm.getClient()
if err != nil {
return virtualnetwork.VirtualNetworkClient{}, err
}
return virtualnetwork.NewClient(c), nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"getVirtualNetworkClient",
"(",
")",
"(",
"virtualnetwork",
".",
"VirtualNetworkClient",
",",
"error",
")",
"{",
"c",
",",
"err",
":=",
"vm",
".",
"getClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // getVirtualNetworkClient returns a new virtual network client. | [
"getVirtualNetworkClient",
"returns",
"a",
"new",
"virtual",
"network",
"client",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L64-L71 |
24,128 | apcera/libretto | virtualmachine/azure/management/util.go | createHostedService | func (vm *VM) createHostedService() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
// create hosted service
if err := sc.CreateHostedService(hostedservice.CreateHostedServiceParameters{
ServiceName: vm.ServiceName,
Location: vm.Location,
Label: bas... | go | func (vm *VM) createHostedService() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
// create hosted service
if err := sc.CreateHostedService(hostedservice.CreateHostedServiceParameters{
ServiceName: vm.ServiceName,
Location: vm.Location,
Label: bas... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"createHostedService",
"(",
")",
"error",
"{",
"sc",
",",
"err",
":=",
"vm",
".",
"getServiceClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"errGetClient",
",",
"err",
... | // createHostedService creates a hosted service on Azure. | [
"createHostedService",
"creates",
"a",
"hosted",
"service",
"on",
"Azure",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L74-L97 |
24,129 | apcera/libretto | virtualmachine/azure/management/util.go | deleteHostedService | func (vm *VM) deleteHostedService() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
// Delete hosted service
_, err = sc.DeleteHostedService(vm.ServiceName, true)
return err
} | go | func (vm *VM) deleteHostedService() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
// Delete hosted service
_, err = sc.DeleteHostedService(vm.ServiceName, true)
return err
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"deleteHostedService",
"(",
")",
"error",
"{",
"sc",
",",
"err",
":=",
"vm",
".",
"getServiceClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"errGetClient",
",",
"err",
... | // deleteHostedService deletes a hosted service on Azure. | [
"deleteHostedService",
"deletes",
"a",
"hosted",
"service",
"on",
"Azure",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L100-L109 |
24,130 | apcera/libretto | virtualmachine/azure/management/util.go | listHostedServices | func (vm *VM) listHostedServices() ([]hostedservice.HostedService, error) {
sc, err := vm.getServiceClient()
if err != nil {
return nil, fmt.Errorf(errGetClient, err)
}
resp, err := sc.ListHostedServices()
if err != nil {
return nil, err
}
return resp.HostedServices, nil
} | go | func (vm *VM) listHostedServices() ([]hostedservice.HostedService, error) {
sc, err := vm.getServiceClient()
if err != nil {
return nil, fmt.Errorf(errGetClient, err)
}
resp, err := sc.ListHostedServices()
if err != nil {
return nil, err
}
return resp.HostedServices, nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"listHostedServices",
"(",
")",
"(",
"[",
"]",
"hostedservice",
".",
"HostedService",
",",
"error",
")",
"{",
"sc",
",",
"err",
":=",
"vm",
".",
"getServiceClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // listHostedServices lists all the hosted services under the current account. | [
"listHostedServices",
"lists",
"all",
"the",
"hosted",
"services",
"under",
"the",
"current",
"account",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L112-L124 |
24,131 | apcera/libretto | virtualmachine/azure/management/util.go | addAddCertificate | func (vm *VM) addAddCertificate() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
_, err = sc.AddCertificate(vm.Name, vm.Cert.Data, hostedservice.CertificateFormat(vm.Cert.Format), vm.SSHCreds.SSHPassword)
return err
} | go | func (vm *VM) addAddCertificate() error {
sc, err := vm.getServiceClient()
if err != nil {
return fmt.Errorf(errGetClient, err)
}
_, err = sc.AddCertificate(vm.Name, vm.Cert.Data, hostedservice.CertificateFormat(vm.Cert.Format), vm.SSHCreds.SSHPassword)
return err
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"addAddCertificate",
"(",
")",
"error",
"{",
"sc",
",",
"err",
":=",
"vm",
".",
"getServiceClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"errGetClient",
",",
"err",
"... | // addAddCertificate adds certs to a hosted service. | [
"addAddCertificate",
"adds",
"certs",
"to",
"a",
"hosted",
"service",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L127-L135 |
24,132 | apcera/libretto | virtualmachine/azure/management/util.go | serviceExist | func (vm *VM) serviceExist(services []hostedservice.HostedService) bool {
for _, srv := range services {
if srv.ServiceName == vm.ServiceName {
return true
}
}
return false
} | go | func (vm *VM) serviceExist(services []hostedservice.HostedService) bool {
for _, srv := range services {
if srv.ServiceName == vm.ServiceName {
return true
}
}
return false
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"serviceExist",
"(",
"services",
"[",
"]",
"hostedservice",
".",
"HostedService",
")",
"bool",
"{",
"for",
"_",
",",
"srv",
":=",
"range",
"services",
"{",
"if",
"srv",
".",
"ServiceName",
"==",
"vm",
".",
"ServiceNam... | // serviceExist checks if the desired service name already exists. | [
"serviceExist",
"checks",
"if",
"the",
"desired",
"service",
"name",
"already",
"exists",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L138-L146 |
24,133 | apcera/libretto | virtualmachine/azure/management/util.go | getFirstSubnet | func (vm *VM) getFirstSubnet() (string, error) {
vc, err := vm.getVirtualNetworkClient()
if err != nil {
return "", fmt.Errorf(errGetClient, err)
}
nc, err := vc.GetVirtualNetworkConfiguration()
if err != nil {
return "", fmt.Errorf("Error to get VirtualNetwork Configuration : %s", err)
}
for _, vns := ran... | go | func (vm *VM) getFirstSubnet() (string, error) {
vc, err := vm.getVirtualNetworkClient()
if err != nil {
return "", fmt.Errorf(errGetClient, err)
}
nc, err := vc.GetVirtualNetworkConfiguration()
if err != nil {
return "", fmt.Errorf("Error to get VirtualNetwork Configuration : %s", err)
}
for _, vns := ran... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"getFirstSubnet",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"vc",
",",
"err",
":=",
"vm",
".",
"getVirtualNetworkClient",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
"... | // getFirstSubnet gets the name of the first subnet within the VM's virtual
// network. | [
"getFirstSubnet",
"gets",
"the",
"name",
"of",
"the",
"first",
"subnet",
"within",
"the",
"VM",
"s",
"virtual",
"network",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/azure/management/util.go#L158-L180 |
24,134 | apcera/libretto | virtualmachine/digitalocean/util.go | BuildRequest | func BuildRequest(token, method, url string, body io.Reader) (*http.Request, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
return req, nil
} | go | func BuildRequest(token, method, url string, body io.Reader) (*http.Request, error) {
req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+token)
return req, nil
} | [
"func",
"BuildRequest",
"(",
"token",
",",
"method",
",",
"url",
"string",
",",
"body",
"io",
".",
"Reader",
")",
"(",
"*",
"http",
".",
"Request",
",",
"error",
")",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"method",
",",
"url... | // BuildRequest builds an http request for this provider. | [
"BuildRequest",
"builds",
"an",
"http",
"request",
"for",
"this",
"provider",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/digitalocean/util.go#L14-L23 |
24,135 | apcera/libretto | virtualmachine/digitalocean/util.go | GetDroplets | func GetDroplets(token string) (*DropletsResponse, error) {
client := &http.Client{}
req, err := BuildRequest(token, "GET", apiBaseURL+apiDropletURL, nil)
if err != nil {
return nil, err
}
rsp, err := client.Do(req)
if err != nil {
return nil, err
}
defer rsp.Body.Close()
b, err := ioutil.ReadAll(rsp.Body)... | go | func GetDroplets(token string) (*DropletsResponse, error) {
client := &http.Client{}
req, err := BuildRequest(token, "GET", apiBaseURL+apiDropletURL, nil)
if err != nil {
return nil, err
}
rsp, err := client.Do(req)
if err != nil {
return nil, err
}
defer rsp.Body.Close()
b, err := ioutil.ReadAll(rsp.Body)... | [
"func",
"GetDroplets",
"(",
"token",
"string",
")",
"(",
"*",
"DropletsResponse",
",",
"error",
")",
"{",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"}",
"\n",
"req",
",",
"err",
":=",
"BuildRequest",
"(",
"token",
",",
"\"",
"\"",
",",
"apiBas... | // GetDroplets returns and array of droplets | [
"GetDroplets",
"returns",
"and",
"array",
"of",
"droplets"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/digitalocean/util.go#L61-L86 |
24,136 | apcera/libretto | virtualmachine/digitalocean/util.go | PrintDroplet | func PrintDroplet(droplet *Droplet) {
fmt.Println("ID:", droplet.ID)
fmt.Println("Name:", droplet.Name)
fmt.Println("Status:", droplet.Status)
fmt.Println("Locked:", fmt.Sprintf("%t", droplet.Locked))
fmt.Println("CreatedAt:", droplet.CreatedAt.Format("2006-01-02 15:04:05"))
fmt.Println("SizeSlug:", droplet.Size.... | go | func PrintDroplet(droplet *Droplet) {
fmt.Println("ID:", droplet.ID)
fmt.Println("Name:", droplet.Name)
fmt.Println("Status:", droplet.Status)
fmt.Println("Locked:", fmt.Sprintf("%t", droplet.Locked))
fmt.Println("CreatedAt:", droplet.CreatedAt.Format("2006-01-02 15:04:05"))
fmt.Println("SizeSlug:", droplet.Size.... | [
"func",
"PrintDroplet",
"(",
"droplet",
"*",
"Droplet",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"droplet",
".",
"ID",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"droplet",
".",
"Name",
")",
"\n",
"fmt",
".",
"Println",
... | // PrintDroplet prints the basic droplet values | [
"PrintDroplet",
"prints",
"the",
"basic",
"droplet",
"values"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/digitalocean/util.go#L89-L104 |
24,137 | apcera/libretto | virtualmachine/aws/vm.go | SetTag | func (vm *VM) SetTag(key, value string) error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
return ErrNoInstanceID
}
volIDs, err := getInstanceVolumeIDs(svc, vm.InstanceID)
if err != nil {
return fmt.Errorf("Failed t... | go | func (vm *VM) SetTag(key, value string) error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
return ErrNoInstanceID
}
volIDs, err := getInstanceVolumeIDs(svc, vm.InstanceID)
if err != nil {
return fmt.Errorf("Failed t... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"SetTag",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"svc",
",",
"err",
":=",
"getService",
"(",
"vm",
".",
"Region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
... | // SetTag adds a tag to the VM and its attached volumes. | [
"SetTag",
"adds",
"a",
"tag",
"to",
"the",
"VM",
"and",
"its",
"attached",
"volumes",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L109-L142 |
24,138 | apcera/libretto | virtualmachine/aws/vm.go | SetTags | func (vm *VM) SetTags(tags map[string]string) error {
for k, v := range tags {
if err := vm.SetTag(k, v); err != nil {
return err
}
}
return nil
} | go | func (vm *VM) SetTags(tags map[string]string) error {
for k, v := range tags {
if err := vm.SetTag(k, v); err != nil {
return err
}
}
return nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"SetTags",
"(",
"tags",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"for",
"k",
",",
"v",
":=",
"range",
"tags",
"{",
"if",
"err",
":=",
"vm",
".",
"SetTag",
"(",
"k",
",",
"v",
")",
";",
"err",
... | // SetTags takes in a map of tags to set to the provisioned instance. This is
// essentially a shorter way than calling SetTag many times. | [
"SetTags",
"takes",
"in",
"a",
"map",
"of",
"tags",
"to",
"set",
"to",
"the",
"provisioned",
"instance",
".",
"This",
"is",
"essentially",
"a",
"shorter",
"way",
"than",
"calling",
"SetTag",
"many",
"times",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L146-L153 |
24,139 | apcera/libretto | virtualmachine/aws/vm.go | Provision | func (vm *VM) Provision() error {
wait() // Avoid the AWS rate limit.
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
resp, err := svc.RunInstances(instanceInfo(vm))
if err != nil {
return fmt.Errorf("Failed to create instance: %v", err)
}
if ha... | go | func (vm *VM) Provision() error {
wait() // Avoid the AWS rate limit.
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
resp, err := svc.RunInstances(instanceInfo(vm))
if err != nil {
return fmt.Errorf("Failed to create instance: %v", err)
}
if ha... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Provision",
"(",
")",
"error",
"{",
"wait",
"(",
")",
"// Avoid the AWS rate limit.",
"\n\n",
"svc",
",",
"err",
":=",
"getService",
"(",
"vm",
".",
"Region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fm... | // Provision creates a virtual machine on AWS. It returns an error if
// there was a problem during creation, if there was a problem adding a tag, or
// if the VM takes too long to enter "running" state. | [
"Provision",
"creates",
"a",
"virtual",
"machine",
"on",
"AWS",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"was",
"a",
"problem",
"during",
"creation",
"if",
"there",
"was",
"a",
"problem",
"adding",
"a",
"tag",
"or",
"if",
"the",
"VM",
"takes",... | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L158-L192 |
24,140 | apcera/libretto | virtualmachine/aws/vm.go | wait | func wait() {
const maxWait = 1 * time.Minute
now := time.Now().UTC()
mu.Lock()
wait := getWaitTime(now, maxWait)
mu.Unlock()
time.Sleep(wait)
interval := 500 * time.Millisecond
if wait == maxWait {
interval = maxWait
}
mu.Lock()
defer mu.Unlock()
if now.Before(nextProvision) {
nextProvision = nextP... | go | func wait() {
const maxWait = 1 * time.Minute
now := time.Now().UTC()
mu.Lock()
wait := getWaitTime(now, maxWait)
mu.Unlock()
time.Sleep(wait)
interval := 500 * time.Millisecond
if wait == maxWait {
interval = maxWait
}
mu.Lock()
defer mu.Unlock()
if now.Before(nextProvision) {
nextProvision = nextP... | [
"func",
"wait",
"(",
")",
"{",
"const",
"maxWait",
"=",
"1",
"*",
"time",
".",
"Minute",
"\n\n",
"now",
":=",
"time",
".",
"Now",
"(",
")",
".",
"UTC",
"(",
")",
"\n",
"mu",
".",
"Lock",
"(",
")",
"\n",
"wait",
":=",
"getWaitTime",
"(",
"now",
... | // wait implements a rate limiter that prevents more than one call every
// 0.5s. The maximum time that the caller can be delayed is 1m. | [
"wait",
"implements",
"a",
"rate",
"limiter",
"that",
"prevents",
"more",
"than",
"one",
"call",
"every",
"0",
".",
"5s",
".",
"The",
"maximum",
"time",
"that",
"the",
"caller",
"can",
"be",
"delayed",
"is",
"1m",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L196-L219 |
24,141 | apcera/libretto | virtualmachine/aws/vm.go | Destroy | func (vm *VM) Destroy() error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
_, err = svc.TerminateInstances(&ec2.TerminateInstancesInput{
InstanceIds... | go | func (vm *VM) Destroy() error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
_, err = svc.TerminateInstances(&ec2.TerminateInstancesInput{
InstanceIds... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Destroy",
"(",
")",
"error",
"{",
"svc",
",",
"err",
":=",
"getService",
"(",
"vm",
".",
"Region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
... | // Destroy terminates the VM on AWS. It returns an error if AWS credentials are
// missing or if there is no instance ID. | [
"Destroy",
"terminates",
"the",
"VM",
"on",
"AWS",
".",
"It",
"returns",
"an",
"error",
"if",
"AWS",
"credentials",
"are",
"missing",
"or",
"if",
"there",
"is",
"no",
"instance",
"ID",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L281-L306 |
24,142 | apcera/libretto | virtualmachine/aws/vm.go | GetState | func (vm *VM) GetState() (string, error) {
svc, err := getService(vm.Region)
if err != nil {
return "", fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return "", ErrNoInstanceID
}
stat, err := svc.DescribeInstances(&ec2.DescribeInstanc... | go | func (vm *VM) GetState() (string, error) {
svc, err := getService(vm.Region)
if err != nil {
return "", fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return "", ErrNoInstanceID
}
stat, err := svc.DescribeInstances(&ec2.DescribeInstanc... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetState",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"svc",
",",
"err",
":=",
"getService",
"(",
"vm",
".",
"Region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
... | // GetState returns the state of the VM, such as "running". An error is
// returned if the instance ID is missing, if there was a problem querying AWS,
// or if there are no instances. | [
"GetState",
"returns",
"the",
"state",
"of",
"the",
"VM",
"such",
"as",
"running",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"instance",
"ID",
"is",
"missing",
"if",
"there",
"was",
"a",
"problem",
"querying",
"AWS",
"or",
"if",
"there",
"are",
... | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L331-L359 |
24,143 | apcera/libretto | virtualmachine/aws/vm.go | Halt | func (vm *VM) Halt() error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
_, err = svc.StopInstances(&ec2.StopInstancesInput{
InstanceIds: []*string{... | go | func (vm *VM) Halt() error {
svc, err := getService(vm.Region)
if err != nil {
return fmt.Errorf("failed to get AWS service: %v", err)
}
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
_, err = svc.StopInstances(&ec2.StopInstancesInput{
InstanceIds: []*string{... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Halt",
"(",
")",
"error",
"{",
"svc",
",",
"err",
":=",
"getService",
"(",
"vm",
".",
"Region",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"err",
")",
"\... | // Halt shuts down the VM on AWS. | [
"Halt",
"shuts",
"down",
"the",
"VM",
"on",
"AWS",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L362-L385 |
24,144 | apcera/libretto | virtualmachine/aws/vm.go | SetKeyPair | func (vm *VM) SetKeyPair(privateKey string, name string) {
vm.SSHCreds.SSHPrivateKey = privateKey
vm.KeyPair = name
} | go | func (vm *VM) SetKeyPair(privateKey string, name string) {
vm.SSHCreds.SSHPrivateKey = privateKey
vm.KeyPair = name
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"SetKeyPair",
"(",
"privateKey",
"string",
",",
"name",
"string",
")",
"{",
"vm",
".",
"SSHCreds",
".",
"SSHPrivateKey",
"=",
"privateKey",
"\n",
"vm",
".",
"KeyPair",
"=",
"name",
"\n",
"}"
] | // SetKeyPair sets the given private key and AWS key name for this vm | [
"SetKeyPair",
"sets",
"the",
"given",
"private",
"key",
"and",
"AWS",
"key",
"name",
"for",
"this",
"vm"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/aws/vm.go#L423-L426 |
24,145 | apcera/libretto | virtualmachine/openstack/vm.go | Destroy | func (vm *VM) Destroy() error {
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
client, err := getComputeClient(vm)
if err != nil {
return fmt.Errorf("compute client is not set for the VM, %s", err)
}
// Delete the floating IP first before destroying the VM
va... | go | func (vm *VM) Destroy() error {
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
client, err := getComputeClient(vm)
if err != nil {
return fmt.Errorf("compute client is not set for the VM, %s", err)
}
// Delete the floating IP first before destroying the VM
va... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Destroy",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"InstanceID",
"==",
"\"",
"\"",
"{",
"// Probably need to call Provision first.",
"return",
"ErrNoInstanceID",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"getComputeCl... | // Destroy terminates the VM on Openstack. It returns an error if there is no instance ID. | [
"Destroy",
"terminates",
"the",
"VM",
"on",
"Openstack",
".",
"It",
"returns",
"an",
"error",
"if",
"there",
"is",
"no",
"instance",
"ID",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/openstack/vm.go#L425-L480 |
24,146 | apcera/libretto | virtualmachine/openstack/vm.go | GetState | func (vm *VM) GetState() (string, error) {
server, err := getServer(vm)
if err != nil {
return "", err
}
if server == nil {
// VM state "unknown"
return "", lvm.ErrVMInfoFailed
}
if server.Status == StateActive {
return lvm.VMRunning, nil
} else if server.Status == StateShutOff {
return lvm.VMHalted,... | go | func (vm *VM) GetState() (string, error) {
server, err := getServer(vm)
if err != nil {
return "", err
}
if server == nil {
// VM state "unknown"
return "", lvm.ErrVMInfoFailed
}
if server.Status == StateActive {
return lvm.VMRunning, nil
} else if server.Status == StateShutOff {
return lvm.VMHalted,... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetState",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"server",
",",
"err",
":=",
"getServer",
"(",
"vm",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n\n",
... | // GetState returns the state of the VM, such as "ACTIVE". An error is returned
// if the instance ID is missing, if there was a problem querying Openstack, or if
// there are no instances. | [
"GetState",
"returns",
"the",
"state",
"of",
"the",
"VM",
"such",
"as",
"ACTIVE",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"instance",
"ID",
"is",
"missing",
"if",
"there",
"was",
"a",
"problem",
"querying",
"Openstack",
"or",
"if",
"there",
"a... | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/openstack/vm.go#L497-L516 |
24,147 | apcera/libretto | virtualmachine/openstack/vm.go | Halt | func (vm *VM) Halt() error {
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
client, err := getComputeClient(vm)
if err != nil {
return fmt.Errorf("compute client is not set for the VM, %s", err)
}
// Take a look at the initial state of the VM. Make sure it is i... | go | func (vm *VM) Halt() error {
if vm.InstanceID == "" {
// Probably need to call Provision first.
return ErrNoInstanceID
}
client, err := getComputeClient(vm)
if err != nil {
return fmt.Errorf("compute client is not set for the VM, %s", err)
}
// Take a look at the initial state of the VM. Make sure it is i... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Halt",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"InstanceID",
"==",
"\"",
"\"",
"{",
"// Probably need to call Provision first.",
"return",
"ErrNoInstanceID",
"\n",
"}",
"\n\n",
"client",
",",
"err",
":=",
"getComputeClien... | // Halt shuts down the insance on Openstack. | [
"Halt",
"shuts",
"down",
"the",
"insance",
"on",
"Openstack",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/openstack/vm.go#L519-L548 |
24,148 | apcera/libretto | virtualmachine/gcp/util.go | getInstance | func (svc *googleService) getInstance() (*googlecloud.Instance, error) {
return svc.service.Instances.Get(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
} | go | func (svc *googleService) getInstance() (*googlecloud.Instance, error) {
return svc.service.Instances.Get(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"getInstance",
"(",
")",
"(",
"*",
"googlecloud",
".",
"Instance",
",",
"error",
")",
"{",
"return",
"svc",
".",
"service",
".",
"Instances",
".",
"Get",
"(",
"svc",
".",
"vm",
".",
"Project",
",",
"svc"... | // get instance from current VM definition. | [
"get",
"instance",
"from",
"current",
"VM",
"definition",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L76-L78 |
24,149 | apcera/libretto | virtualmachine/gcp/util.go | waitForOperation | func waitForOperation(timeout int, funcOperation func() (*googlecloud.Operation, error)) error {
var op *googlecloud.Operation
var err error
for i := 0; i < timeout; i++ {
op, err = funcOperation()
if err != nil {
return err
}
if op.Status == "DONE" {
if op.Error != nil {
return fmt.Errorf("opera... | go | func waitForOperation(timeout int, funcOperation func() (*googlecloud.Operation, error)) error {
var op *googlecloud.Operation
var err error
for i := 0; i < timeout; i++ {
op, err = funcOperation()
if err != nil {
return err
}
if op.Status == "DONE" {
if op.Error != nil {
return fmt.Errorf("opera... | [
"func",
"waitForOperation",
"(",
"timeout",
"int",
",",
"funcOperation",
"func",
"(",
")",
"(",
"*",
"googlecloud",
".",
"Operation",
",",
"error",
")",
")",
"error",
"{",
"var",
"op",
"*",
"googlecloud",
".",
"Operation",
"\n",
"var",
"err",
"error",
"\... | // waitForOperation pulls to wait for the operation to finish. | [
"waitForOperation",
"pulls",
"to",
"wait",
"for",
"the",
"operation",
"to",
"finish",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L81-L101 |
24,150 | apcera/libretto | virtualmachine/gcp/util.go | waitForOperationReady | func (svc *googleService) waitForOperationReady(operation string) error {
return waitForOperation(OperationTimeout, func() (*googlecloud.Operation, error) {
return svc.service.ZoneOperations.Get(svc.vm.Project, svc.vm.Zone, operation).Do()
})
} | go | func (svc *googleService) waitForOperationReady(operation string) error {
return waitForOperation(OperationTimeout, func() (*googlecloud.Operation, error) {
return svc.service.ZoneOperations.Get(svc.vm.Project, svc.vm.Zone, operation).Do()
})
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"waitForOperationReady",
"(",
"operation",
"string",
")",
"error",
"{",
"return",
"waitForOperation",
"(",
"OperationTimeout",
",",
"func",
"(",
")",
"(",
"*",
"googlecloud",
".",
"Operation",
",",
"error",
")",
... | // waitForOperationReady waits for the regional operation to finish. | [
"waitForOperationReady",
"waits",
"for",
"the",
"regional",
"operation",
"to",
"finish",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L104-L108 |
24,151 | apcera/libretto | virtualmachine/gcp/util.go | createDisks | func (svc *googleService) createDisks() (disks []*googlecloud.AttachedDisk, err error) {
if len(svc.vm.Disks) == 0 {
return nil, errors.New("no disks were found")
}
image, err := svc.getImage()
if err != nil {
return nil, err
}
for i, disk := range svc.vm.Disks {
if i == 0 {
// First one is booted devi... | go | func (svc *googleService) createDisks() (disks []*googlecloud.AttachedDisk, err error) {
if len(svc.vm.Disks) == 0 {
return nil, errors.New("no disks were found")
}
image, err := svc.getImage()
if err != nil {
return nil, err
}
for i, disk := range svc.vm.Disks {
if i == 0 {
// First one is booted devi... | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"createDisks",
"(",
")",
"(",
"disks",
"[",
"]",
"*",
"googlecloud",
".",
"AttachedDisk",
",",
"err",
"error",
")",
"{",
"if",
"len",
"(",
"svc",
".",
"vm",
".",
"Disks",
")",
"==",
"0",
"{",
"return",... | // createDisks creates non-booted disk. | [
"createDisks",
"creates",
"non",
"-",
"booted",
"disk",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L124-L183 |
24,152 | apcera/libretto | virtualmachine/gcp/util.go | getDisk | func (svc *googleService) getDisk(name string) (*googlecloud.Disk, error) {
return svc.service.Disks.Get(svc.vm.Project, svc.vm.Zone, name).Do()
} | go | func (svc *googleService) getDisk(name string) (*googlecloud.Disk, error) {
return svc.service.Disks.Get(svc.vm.Project, svc.vm.Zone, name).Do()
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"getDisk",
"(",
"name",
"string",
")",
"(",
"*",
"googlecloud",
".",
"Disk",
",",
"error",
")",
"{",
"return",
"svc",
".",
"service",
".",
"Disks",
".",
"Get",
"(",
"svc",
".",
"vm",
".",
"Project",
",... | // getDisk retrieves the Disk object. | [
"getDisk",
"retrieves",
"the",
"Disk",
"object",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L186-L188 |
24,153 | apcera/libretto | virtualmachine/gcp/util.go | deleteDisk | func (svc *googleService) deleteDisk(name string) error {
op, err := svc.service.Disks.Delete(svc.vm.Project, svc.vm.Zone, name).Do()
if err != nil {
return err
}
return svc.waitForOperationReady(op.Name)
} | go | func (svc *googleService) deleteDisk(name string) error {
op, err := svc.service.Disks.Delete(svc.vm.Project, svc.vm.Zone, name).Do()
if err != nil {
return err
}
return svc.waitForOperationReady(op.Name)
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"deleteDisk",
"(",
"name",
"string",
")",
"error",
"{",
"op",
",",
"err",
":=",
"svc",
".",
"service",
".",
"Disks",
".",
"Delete",
"(",
"svc",
".",
"vm",
".",
"Project",
",",
"svc",
".",
"vm",
".",
... | // deleteDisk deletes the persistent disk. | [
"deleteDisk",
"deletes",
"the",
"persistent",
"disk",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L191-L198 |
24,154 | apcera/libretto | virtualmachine/gcp/util.go | deleteDisks | func (svc *googleService) deleteDisks() (errs []error) {
for _, disk := range svc.vm.Disks {
err := svc.deleteDisk(disk.Name)
if err != nil {
errs = append(errs, err)
}
}
return errs
} | go | func (svc *googleService) deleteDisks() (errs []error) {
for _, disk := range svc.vm.Disks {
err := svc.deleteDisk(disk.Name)
if err != nil {
errs = append(errs, err)
}
}
return errs
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"deleteDisks",
"(",
")",
"(",
"errs",
"[",
"]",
"error",
")",
"{",
"for",
"_",
",",
"disk",
":=",
"range",
"svc",
".",
"vm",
".",
"Disks",
"{",
"err",
":=",
"svc",
".",
"deleteDisk",
"(",
"disk",
"."... | // deleteDisks deletes all the persistent disk. | [
"deleteDisks",
"deletes",
"all",
"the",
"persistent",
"disk",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L201-L209 |
24,155 | apcera/libretto | virtualmachine/gcp/util.go | getIPs | func (svc *googleService) getIPs() ([]net.IP, error) {
instance, err := svc.service.Instances.Get(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {
return nil, err
}
ips := make([]net.IP, 2)
nic := instance.NetworkInterfaces[0]
publicIP := nic.AccessConfigs[0].NatIP
if publicIP == "" {
return ... | go | func (svc *googleService) getIPs() ([]net.IP, error) {
instance, err := svc.service.Instances.Get(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {
return nil, err
}
ips := make([]net.IP, 2)
nic := instance.NetworkInterfaces[0]
publicIP := nic.AccessConfigs[0].NatIP
if publicIP == "" {
return ... | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"getIPs",
"(",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"instance",
",",
"err",
":=",
"svc",
".",
"service",
".",
"Instances",
".",
"Get",
"(",
"svc",
".",
"vm",
".",
"Project",
... | // getIPs returns the IP addresses of the GCE instance. | [
"getIPs",
"returns",
"the",
"IP",
"addresses",
"of",
"the",
"GCE",
"instance",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L212-L235 |
24,156 | apcera/libretto | virtualmachine/gcp/util.go | start | func (svc *googleService) start() error {
instance, err := svc.getInstance()
if err != nil {
if !strings.Contains(err.Error(), "no instance found") {
return err
}
}
if instance == nil {
return errors.New("no instance found")
}
op, err := svc.service.Instances.Start(svc.vm.Project, svc.vm.Zone, svc.vm.N... | go | func (svc *googleService) start() error {
instance, err := svc.getInstance()
if err != nil {
if !strings.Contains(err.Error(), "no instance found") {
return err
}
}
if instance == nil {
return errors.New("no instance found")
}
op, err := svc.service.Instances.Start(svc.vm.Project, svc.vm.Zone, svc.vm.N... | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"start",
"(",
")",
"error",
"{",
"instance",
",",
"err",
":=",
"svc",
".",
"getInstance",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",... | // start starts a stopped GCE instance. | [
"start",
"starts",
"a",
"stopped",
"GCE",
"instance",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L335-L353 |
24,157 | apcera/libretto | virtualmachine/gcp/util.go | stop | func (svc *googleService) stop() error {
_, err := svc.getInstance()
if err != nil {
if !strings.Contains(err.Error(), "no instance found") {
return err
}
return fmt.Errorf("no instance found, %v", err)
}
op, err := svc.service.Instances.Stop(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {... | go | func (svc *googleService) stop() error {
_, err := svc.getInstance()
if err != nil {
if !strings.Contains(err.Error(), "no instance found") {
return err
}
return fmt.Errorf("no instance found, %v", err)
}
op, err := svc.service.Instances.Stop(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {... | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"stop",
"(",
")",
"error",
"{",
"_",
",",
"err",
":=",
"svc",
".",
"getInstance",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"!",
"strings",
".",
"Contains",
"(",
"err",
".",
"Error",
"(",
... | // stop halts a GCE instance. | [
"stop",
"halts",
"a",
"GCE",
"instance",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L356-L371 |
24,158 | apcera/libretto | virtualmachine/gcp/util.go | delete | func (svc *googleService) delete() error {
op, err := svc.service.Instances.Delete(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {
return err
}
return svc.waitForOperationReady(op.Name)
} | go | func (svc *googleService) delete() error {
op, err := svc.service.Instances.Delete(svc.vm.Project, svc.vm.Zone, svc.vm.Name).Do()
if err != nil {
return err
}
return svc.waitForOperationReady(op.Name)
} | [
"func",
"(",
"svc",
"*",
"googleService",
")",
"delete",
"(",
")",
"error",
"{",
"op",
",",
"err",
":=",
"svc",
".",
"service",
".",
"Instances",
".",
"Delete",
"(",
"svc",
".",
"vm",
".",
"Project",
",",
"svc",
".",
"vm",
".",
"Zone",
",",
"svc"... | // deletes the GCE instance. | [
"deletes",
"the",
"GCE",
"instance",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/gcp/util.go#L374-L381 |
24,159 | apcera/libretto | virtualmachine/vmrun/vm.go | Run | func (f vmrunRunner) Run(args ...string) (string, string, error) {
var vmrunPath string
// If vmrun is not found in the system path, fall back to the
// hard coded path (VMRunPath).
path, err := exec.LookPath("vmrun")
if err == nil {
vmrunPath = path
} else {
vmrunPath = VMRunPath
}
if vmrunPath == "" {
... | go | func (f vmrunRunner) Run(args ...string) (string, string, error) {
var vmrunPath string
// If vmrun is not found in the system path, fall back to the
// hard coded path (VMRunPath).
path, err := exec.LookPath("vmrun")
if err == nil {
vmrunPath = path
} else {
vmrunPath = VMRunPath
}
if vmrunPath == "" {
... | [
"func",
"(",
"f",
"vmrunRunner",
")",
"Run",
"(",
"args",
"...",
"string",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"var",
"vmrunPath",
"string",
"\n\n",
"// If vmrun is not found in the system path, fall back to the",
"// hard coded path (VMRunPath)... | // Run runs a vmrun command. | [
"Run",
"runs",
"a",
"vmrun",
"command",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/vmrun/vm.go#L80-L117 |
24,160 | apcera/libretto | virtualmachine/exoscale/vm.go | GetName | func (vm *VM) GetName() string {
if err := vm.updateInfo(); err != nil {
return ""
}
return vm.Name
} | go | func (vm *VM) GetName() string {
if err := vm.updateInfo(); err != nil {
return ""
}
return vm.Name
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetName",
"(",
")",
"string",
"{",
"if",
"err",
":=",
"vm",
".",
"updateInfo",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n\n",
"return",
"vm",
".",
"Name",
"\n",
"}"
] | // GetName returns the name of the virtual machine
// If an error occurs, an empty string is returned | [
"GetName",
"returns",
"the",
"name",
"of",
"the",
"virtual",
"machine",
"If",
"an",
"error",
"occurs",
"an",
"empty",
"string",
"is",
"returned"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L95-L102 |
24,161 | apcera/libretto | virtualmachine/exoscale/vm.go | GetIPs | func (vm *VM) GetIPs() ([]net.IP, error) {
if err := vm.updateInfo(); err != nil {
return nil, err
}
return vm.ips, nil
} | go | func (vm *VM) GetIPs() ([]net.IP, error) {
if err := vm.updateInfo(); err != nil {
return nil, err
}
return vm.ips, nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetIPs",
"(",
")",
"(",
"[",
"]",
"net",
".",
"IP",
",",
"error",
")",
"{",
"if",
"err",
":=",
"vm",
".",
"updateInfo",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\... | // GetIPs returns the list of ip addresses associated with the VM | [
"GetIPs",
"returns",
"the",
"list",
"of",
"ip",
"addresses",
"associated",
"with",
"the",
"VM"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L160-L167 |
24,162 | apcera/libretto | virtualmachine/exoscale/vm.go | Destroy | func (vm *VM) Destroy() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to destroy the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("destroyVirtualMachine", params)
if err != nil {
return fmt.Errorf("Destroying virtual ma... | go | func (vm *VM) Destroy() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to destroy the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("destroyVirtualMachine", params)
if err != nil {
return fmt.Errorf("Destroying virtual ma... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Destroy",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",... | // Destroy removes virtual machine and all storage associated | [
"Destroy",
"removes",
"virtual",
"machine",
"and",
"all",
"storage",
"associated"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L170-L193 |
24,163 | apcera/libretto | virtualmachine/exoscale/vm.go | GetState | func (vm *VM) GetState() (string, error) {
if vm.ID == "" {
return "", fmt.Errorf("Need an ID to get virtual machine state")
}
if err := vm.updateInfo(); err != nil {
return "", err
}
return vm.state, nil
} | go | func (vm *VM) GetState() (string, error) {
if vm.ID == "" {
return "", fmt.Errorf("Need an ID to get virtual machine state")
}
if err := vm.updateInfo(); err != nil {
return "", err
}
return vm.state, nil
} | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetState",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"vm",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"e... | // GetState returns virtual machine state | [
"GetState",
"returns",
"virtual",
"machine",
"state"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L196-L207 |
24,164 | apcera/libretto | virtualmachine/exoscale/vm.go | Halt | func (vm *VM) Halt() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to stop the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("stopVirtualMachine", params)
if err != nil {
return fmt.Errorf("Stopping virtual machine %q: %... | go | func (vm *VM) Halt() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to stop the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("stopVirtualMachine", params)
if err != nil {
return fmt.Errorf("Stopping virtual machine %q: %... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Halt",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
... | // Halt stop a virtual machine | [
"Halt",
"stop",
"a",
"virtual",
"machine"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L220-L244 |
24,165 | apcera/libretto | virtualmachine/exoscale/vm.go | Start | func (vm *VM) Start() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to start the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("startVirtualMachine", params)
if err != nil {
return fmt.Errorf("Starting virtual machine %q... | go | func (vm *VM) Start() error {
if vm.ID == "" {
return fmt.Errorf("Need an ID to start the virtual machine")
}
params := url.Values{}
params.Set("id", vm.ID)
client := vm.getExoClient()
resp, err := client.Request("startVirtualMachine", params)
if err != nil {
return fmt.Errorf("Starting virtual machine %q... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"vm",
".",
"ID",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"params",
":=",
"url",
".",
"Values",
"{",
"}",
"\n",
... | // Start starts virtual machine | [
"Start",
"starts",
"virtual",
"machine"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L247-L270 |
24,166 | apcera/libretto | virtualmachine/exoscale/vm.go | GetSSH | func (vm *VM) GetSSH(options ssh.Options) (ssh.Client, error) {
ips, err := util.GetVMIPs(vm, options)
if err != nil {
return nil, err
}
client := &ssh.SSHClient{
Creds: &vm.SSHCreds,
IP: ips[0], // public IP
Options: options,
Port: 22,
}
if err := client.WaitForSSH(SSHTimeout); err != nil {... | go | func (vm *VM) GetSSH(options ssh.Options) (ssh.Client, error) {
ips, err := util.GetVMIPs(vm, options)
if err != nil {
return nil, err
}
client := &ssh.SSHClient{
Creds: &vm.SSHCreds,
IP: ips[0], // public IP
Options: options,
Port: 22,
}
if err := client.WaitForSSH(SSHTimeout); err != nil {... | [
"func",
"(",
"vm",
"*",
"VM",
")",
"GetSSH",
"(",
"options",
"ssh",
".",
"Options",
")",
"(",
"ssh",
".",
"Client",
",",
"error",
")",
"{",
"ips",
",",
"err",
":=",
"util",
".",
"GetVMIPs",
"(",
"vm",
",",
"options",
")",
"\n",
"if",
"err",
"!=... | // GetSSH returns SSH keys to access the virtual machine | [
"GetSSH",
"returns",
"SSH",
"keys",
"to",
"access",
"the",
"virtual",
"machine"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/virtualmachine/exoscale/vm.go#L273-L292 |
24,167 | apcera/libretto | ssh/mock_ssh.go | Connect | func (c *MockSSHClient) Connect() error {
if c.MockConnect != nil {
return c.MockConnect()
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) Connect() error {
if c.MockConnect != nil {
return c.MockConnect()
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"Connect",
"(",
")",
"error",
"{",
"if",
"c",
".",
"MockConnect",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockConnect",
"(",
")",
"\n",
"}",
"\n",
"return",
"ErrNotImplemented",
"\n",
"}"
] | // Connect calls the mocked connect. | [
"Connect",
"calls",
"the",
"mocked",
"connect",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L27-L32 |
24,168 | apcera/libretto | ssh/mock_ssh.go | Download | func (c *MockSSHClient) Download(src io.WriteCloser, dst string) error {
if c.MockDownload != nil {
return c.MockDownload(src, dst)
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) Download(src io.WriteCloser, dst string) error {
if c.MockDownload != nil {
return c.MockDownload(src, dst)
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"Download",
"(",
"src",
"io",
".",
"WriteCloser",
",",
"dst",
"string",
")",
"error",
"{",
"if",
"c",
".",
"MockDownload",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockDownload",
"(",
"src",
",",
"dst",
")",... | // Download calls the mocked download. | [
"Download",
"calls",
"the",
"mocked",
"download",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L42-L47 |
24,169 | apcera/libretto | ssh/mock_ssh.go | Run | func (c *MockSSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error {
if c.MockRun != nil {
return c.MockRun(command, stdout, stderr)
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) Run(command string, stdout io.Writer, stderr io.Writer) error {
if c.MockRun != nil {
return c.MockRun(command, stdout, stderr)
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"Run",
"(",
"command",
"string",
",",
"stdout",
"io",
".",
"Writer",
",",
"stderr",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"c",
".",
"MockRun",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockRun",
"("... | // Run calls the mocked run | [
"Run",
"calls",
"the",
"mocked",
"run"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L50-L55 |
24,170 | apcera/libretto | ssh/mock_ssh.go | Upload | func (c *MockSSHClient) Upload(src io.Reader, dst string, size int, mode uint32) error {
if c.MockUpload != nil {
return c.MockUpload(src, dst, size, mode)
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) Upload(src io.Reader, dst string, size int, mode uint32) error {
if c.MockUpload != nil {
return c.MockUpload(src, dst, size, mode)
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"Upload",
"(",
"src",
"io",
".",
"Reader",
",",
"dst",
"string",
",",
"size",
"int",
",",
"mode",
"uint32",
")",
"error",
"{",
"if",
"c",
".",
"MockUpload",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockUpl... | // Upload calls the mocked upload | [
"Upload",
"calls",
"the",
"mocked",
"upload"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L58-L63 |
24,171 | apcera/libretto | ssh/mock_ssh.go | Validate | func (c *MockSSHClient) Validate() error {
if c.MockValidate != nil {
return c.MockValidate()
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) Validate() error {
if c.MockValidate != nil {
return c.MockValidate()
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"Validate",
"(",
")",
"error",
"{",
"if",
"c",
".",
"MockValidate",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockValidate",
"(",
")",
"\n",
"}",
"\n",
"return",
"ErrNotImplemented",
"\n",
"}"
] | // Validate calls the mocked validate. | [
"Validate",
"calls",
"the",
"mocked",
"validate",
"."
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L66-L71 |
24,172 | apcera/libretto | ssh/mock_ssh.go | WaitForSSH | func (c *MockSSHClient) WaitForSSH(maxWait time.Duration) error {
if c.MockWaitForSSH != nil {
return c.MockWaitForSSH(maxWait)
}
return ErrNotImplemented
} | go | func (c *MockSSHClient) WaitForSSH(maxWait time.Duration) error {
if c.MockWaitForSSH != nil {
return c.MockWaitForSSH(maxWait)
}
return ErrNotImplemented
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"WaitForSSH",
"(",
"maxWait",
"time",
".",
"Duration",
")",
"error",
"{",
"if",
"c",
".",
"MockWaitForSSH",
"!=",
"nil",
"{",
"return",
"c",
".",
"MockWaitForSSH",
"(",
"maxWait",
")",
"\n",
"}",
"\n",
"retu... | // WaitForSSH calls the mocked WaitForSSH | [
"WaitForSSH",
"calls",
"the",
"mocked",
"WaitForSSH"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L74-L79 |
24,173 | apcera/libretto | ssh/mock_ssh.go | SetSSHPrivateKey | func (c *MockSSHClient) SetSSHPrivateKey(s string) {
if c.MockSetSSHPrivateKey != nil {
c.MockSetSSHPrivateKey(s)
}
} | go | func (c *MockSSHClient) SetSSHPrivateKey(s string) {
if c.MockSetSSHPrivateKey != nil {
c.MockSetSSHPrivateKey(s)
}
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"SetSSHPrivateKey",
"(",
"s",
"string",
")",
"{",
"if",
"c",
".",
"MockSetSSHPrivateKey",
"!=",
"nil",
"{",
"c",
".",
"MockSetSSHPrivateKey",
"(",
"s",
")",
"\n",
"}",
"\n",
"}"
] | // SetSSHPrivateKey calls the mocked SetSSHPrivateKey | [
"SetSSHPrivateKey",
"calls",
"the",
"mocked",
"SetSSHPrivateKey"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L82-L86 |
24,174 | apcera/libretto | ssh/mock_ssh.go | SetSSHPassword | func (c *MockSSHClient) SetSSHPassword(s string) {
if c.MockSetSSHPassword != nil {
c.MockSetSSHPassword(s)
}
} | go | func (c *MockSSHClient) SetSSHPassword(s string) {
if c.MockSetSSHPassword != nil {
c.MockSetSSHPassword(s)
}
} | [
"func",
"(",
"c",
"*",
"MockSSHClient",
")",
"SetSSHPassword",
"(",
"s",
"string",
")",
"{",
"if",
"c",
".",
"MockSetSSHPassword",
"!=",
"nil",
"{",
"c",
".",
"MockSetSSHPassword",
"(",
"s",
")",
"\n",
"}",
"\n",
"}"
] | // SetSSHPassword calls the mocked SetSSHPassword | [
"SetSSHPassword",
"calls",
"the",
"mocked",
"SetSSHPassword"
] | 3178799fbb1e39c74b02e3ecf46330b3ef0ed486 | https://github.com/apcera/libretto/blob/3178799fbb1e39c74b02e3ecf46330b3ef0ed486/ssh/mock_ssh.go#L97-L101 |
24,175 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/definition.go | InitializeFields | func (s *Definitions) InitializeFields(d *Definition) {
for fieldName, property := range d.schema.Properties {
des := strings.Replace(property.Description, "\n", " ", -1)
f := &Field{
Name: fieldName,
Type: GetTypeName(property),
Description: EscapeAsterisks(des),
}
if len(property.Exten... | go | func (s *Definitions) InitializeFields(d *Definition) {
for fieldName, property := range d.schema.Properties {
des := strings.Replace(property.Description, "\n", " ", -1)
f := &Field{
Name: fieldName,
Type: GetTypeName(property),
Description: EscapeAsterisks(des),
}
if len(property.Exten... | [
"func",
"(",
"s",
"*",
"Definitions",
")",
"InitializeFields",
"(",
"d",
"*",
"Definition",
")",
"{",
"for",
"fieldName",
",",
"property",
":=",
"range",
"d",
".",
"schema",
".",
"Properties",
"{",
"des",
":=",
"strings",
".",
"Replace",
"(",
"property",... | // Initializes the fields for a definition | [
"Initializes",
"the",
"fields",
"for",
"a",
"definition"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/definition.go#L163-L185 |
24,176 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/util.go | GetDefinitionVersionKind | func GetDefinitionVersionKind(s spec.Schema) (string, string, string) {
// Get the reference for complex types
if IsDefinition(s) {
s := fmt.Sprintf("%s", s.SchemaProps.Ref.GetPointer())
s = strings.Replace(s, "/definitions/", "", -1)
name := strings.Split(s, ".")
var group, version, kind string
if name[le... | go | func GetDefinitionVersionKind(s spec.Schema) (string, string, string) {
// Get the reference for complex types
if IsDefinition(s) {
s := fmt.Sprintf("%s", s.SchemaProps.Ref.GetPointer())
s = strings.Replace(s, "/definitions/", "", -1)
name := strings.Split(s, ".")
var group, version, kind string
if name[le... | [
"func",
"GetDefinitionVersionKind",
"(",
"s",
"spec",
".",
"Schema",
")",
"(",
"string",
",",
"string",
",",
"string",
")",
"{",
"// Get the reference for complex types",
"if",
"IsDefinition",
"(",
"s",
")",
"{",
"s",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
... | // GetDefinitionVersionKind returns the api version and kind for the spec. This is the primary key of a Definition. | [
"GetDefinitionVersionKind",
"returns",
"the",
"api",
"version",
"and",
"kind",
"for",
"the",
"spec",
".",
"This",
"is",
"the",
"primary",
"key",
"of",
"a",
"Definition",
"."
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/util.go#L39-L76 |
24,177 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/util.go | GetTypeName | func GetTypeName(s spec.Schema) string {
// Get the reference for complex types
if IsDefinition(s) {
_, _, name := GetDefinitionVersionKind(s)
return name
}
// Recurse if type is array
if IsArray(s) {
return fmt.Sprintf("%s array", GetTypeName(*s.Items.Schema))
}
// Get the value for primitive types
if le... | go | func GetTypeName(s spec.Schema) string {
// Get the reference for complex types
if IsDefinition(s) {
_, _, name := GetDefinitionVersionKind(s)
return name
}
// Recurse if type is array
if IsArray(s) {
return fmt.Sprintf("%s array", GetTypeName(*s.Items.Schema))
}
// Get the value for primitive types
if le... | [
"func",
"GetTypeName",
"(",
"s",
"spec",
".",
"Schema",
")",
"string",
"{",
"// Get the reference for complex types",
"if",
"IsDefinition",
"(",
"s",
")",
"{",
"_",
",",
"_",
",",
"name",
":=",
"GetDefinitionVersionKind",
"(",
"s",
")",
"\n",
"return",
"name... | // GetTypeName returns the display name of a Schema. This is the api kind for definitions and the type for
// primitive types. Arrays of objects have "array" appended. | [
"GetTypeName",
"returns",
"the",
"display",
"name",
"of",
"a",
"Schema",
".",
"This",
"is",
"the",
"api",
"kind",
"for",
"definitions",
"and",
"the",
"type",
"for",
"primitive",
"types",
".",
"Arrays",
"of",
"objects",
"have",
"array",
"appended",
"."
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/util.go#L80-L95 |
24,178 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/util.go | IsArray | func IsArray(s spec.Schema) bool {
return len(s.Type) > 0 && s.Type[0] == "array"
} | go | func IsArray(s spec.Schema) bool {
return len(s.Type) > 0 && s.Type[0] == "array"
} | [
"func",
"IsArray",
"(",
"s",
"spec",
".",
"Schema",
")",
"bool",
"{",
"return",
"len",
"(",
"s",
".",
"Type",
")",
">",
"0",
"&&",
"s",
".",
"Type",
"[",
"0",
"]",
"==",
"\"",
"\"",
"\n",
"}"
] | // IsArray returns true if the type is an array type. | [
"IsArray",
"returns",
"true",
"if",
"the",
"type",
"is",
"an",
"array",
"type",
"."
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/util.go#L98-L100 |
24,179 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/util.go | IsDefinition | func IsDefinition(s spec.Schema) bool {
return len(s.SchemaProps.Ref.GetPointer().String()) > 0
} | go | func IsDefinition(s spec.Schema) bool {
return len(s.SchemaProps.Ref.GetPointer().String()) > 0
} | [
"func",
"IsDefinition",
"(",
"s",
"spec",
".",
"Schema",
")",
"bool",
"{",
"return",
"len",
"(",
"s",
".",
"SchemaProps",
".",
"Ref",
".",
"GetPointer",
"(",
")",
".",
"String",
"(",
")",
")",
">",
"0",
"\n",
"}"
] | // IsDefinition returns true if Schema is a complex type that should have a Definition. | [
"IsDefinition",
"returns",
"true",
"if",
"Schema",
"is",
"a",
"complex",
"type",
"that",
"should",
"have",
"a",
"Definition",
"."
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/util.go#L103-L105 |
24,180 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/config.go | initOperations | func (c *Config) initOperations(specs []*loads.Document) {
ops := Operations{}
c.GroupMap = map[string]string{}
VisitOperations(specs, func(op Operation) {
ops[op.ID] = &op
// Build a map of the group names to the group name appearing in operation ids
// This is necessary because the group will appear withou... | go | func (c *Config) initOperations(specs []*loads.Document) {
ops := Operations{}
c.GroupMap = map[string]string{}
VisitOperations(specs, func(op Operation) {
ops[op.ID] = &op
// Build a map of the group names to the group name appearing in operation ids
// This is necessary because the group will appear withou... | [
"func",
"(",
"c",
"*",
"Config",
")",
"initOperations",
"(",
"specs",
"[",
"]",
"*",
"loads",
".",
"Document",
")",
"{",
"ops",
":=",
"Operations",
"{",
"}",
"\n\n",
"c",
".",
"GroupMap",
"=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
... | // initOperations returns all Operations found in the Documents | [
"initOperations",
"returns",
"all",
"Operations",
"found",
"in",
"the",
"Documents"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/config.go#L195-L244 |
24,181 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/config.go | CleanUp | func (c *Config) CleanUp() {
for _, d := range c.Definitions.All {
sort.Sort(d.AppearsIn)
sort.Sort(d.Fields)
dedup := SortDefinitionsByName{}
var last *Definition
for _, i := range d.AppearsIn {
if last != nil &&
i.Name == last.Name &&
i.Group.String() == last.Group.String() &&
i.Version.Stri... | go | func (c *Config) CleanUp() {
for _, d := range c.Definitions.All {
sort.Sort(d.AppearsIn)
sort.Sort(d.Fields)
dedup := SortDefinitionsByName{}
var last *Definition
for _, i := range d.AppearsIn {
if last != nil &&
i.Name == last.Name &&
i.Group.String() == last.Group.String() &&
i.Version.Stri... | [
"func",
"(",
"c",
"*",
"Config",
")",
"CleanUp",
"(",
")",
"{",
"for",
"_",
",",
"d",
":=",
"range",
"c",
".",
"Definitions",
".",
"All",
"{",
"sort",
".",
"Sort",
"(",
"d",
".",
"AppearsIn",
")",
"\n",
"sort",
".",
"Sort",
"(",
"d",
".",
"Fi... | // CleanUp sorts and dedups fields | [
"CleanUp",
"sorts",
"and",
"dedups",
"fields"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/config.go#L247-L265 |
24,182 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/config.go | LoadConfigFromYAML | func LoadConfigFromYAML() *Config {
f := filepath.Join(*ConfigDir, "config.yaml")
config := &Config{}
contents, err := ioutil.ReadFile(f)
if err != nil {
if !*UseTags {
fmt.Printf("Failed to read yaml file %s: %v", f, err)
os.Exit(2)
}
} else {
err = yaml.Unmarshal(contents, config)
if err != nil {
... | go | func LoadConfigFromYAML() *Config {
f := filepath.Join(*ConfigDir, "config.yaml")
config := &Config{}
contents, err := ioutil.ReadFile(f)
if err != nil {
if !*UseTags {
fmt.Printf("Failed to read yaml file %s: %v", f, err)
os.Exit(2)
}
} else {
err = yaml.Unmarshal(contents, config)
if err != nil {
... | [
"func",
"LoadConfigFromYAML",
"(",
")",
"*",
"Config",
"{",
"f",
":=",
"filepath",
".",
"Join",
"(",
"*",
"ConfigDir",
",",
"\"",
"\"",
")",
"\n\n",
"config",
":=",
"&",
"Config",
"{",
"}",
"\n",
"contents",
",",
"err",
":=",
"ioutil",
".",
"ReadFile... | // LoadConfigFromYAML reads the config yaml file into a struct | [
"LoadConfigFromYAML",
"reads",
"the",
"config",
"yaml",
"file",
"into",
"a",
"struct"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/config.go#L268-L367 |
24,183 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/config.go | mapOperationsToDefinitions | func (c *Config) mapOperationsToDefinitions() {
for _, d := range c.Definitions.All {
if d.IsInlined {
continue
}
for i := range c.OperationCategories {
oc := c.OperationCategories[i]
for j := range oc.OperationTypes {
ot := oc.OperationTypes[j]
operationId := c.getOperationId(ot.Match, d.GetOp... | go | func (c *Config) mapOperationsToDefinitions() {
for _, d := range c.Definitions.All {
if d.IsInlined {
continue
}
for i := range c.OperationCategories {
oc := c.OperationCategories[i]
for j := range oc.OperationTypes {
ot := oc.OperationTypes[j]
operationId := c.getOperationId(ot.Match, d.GetOp... | [
"func",
"(",
"c",
"*",
"Config",
")",
"mapOperationsToDefinitions",
"(",
")",
"{",
"for",
"_",
",",
"d",
":=",
"range",
"c",
".",
"Definitions",
".",
"All",
"{",
"if",
"d",
".",
"IsInlined",
"{",
"continue",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"ra... | // mapOperationsToDefinitions adds operations to the definitions they operate | [
"mapOperationsToDefinitions",
"adds",
"operations",
"to",
"the",
"definitions",
"they",
"operate"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/config.go#L471-L491 |
24,184 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/config.go | visitResourcesInToc | func (c *Config) visitResourcesInToc() {
missing := false
for _, cat := range c.ResourceCategories {
for _, r := range cat.Resources {
if d, ok := c.Definitions.GetByVersionKind(r.Group, r.Version, r.Name); ok {
d.InToc = true // Mark as in Toc
d.initExample(c)
r.Definition = d
} else {
fmt.Pr... | go | func (c *Config) visitResourcesInToc() {
missing := false
for _, cat := range c.ResourceCategories {
for _, r := range cat.Resources {
if d, ok := c.Definitions.GetByVersionKind(r.Group, r.Version, r.Name); ok {
d.InToc = true // Mark as in Toc
d.initExample(c)
r.Definition = d
} else {
fmt.Pr... | [
"func",
"(",
"c",
"*",
"Config",
")",
"visitResourcesInToc",
"(",
")",
"{",
"missing",
":=",
"false",
"\n",
"for",
"_",
",",
"cat",
":=",
"range",
"c",
".",
"ResourceCategories",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"cat",
".",
"Resources",
"{",... | // For each resource in the ToC, look up its definition and visit it. | [
"For",
"each",
"resource",
"in",
"the",
"ToC",
"look",
"up",
"its",
"definition",
"and",
"visit",
"it",
"."
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/config.go#L524-L541 |
24,185 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/operation.go | GetOperationId | func (ot OperationType) GetOperationId(d string) string {
return strings.Replace(ot.Match, "${resource}", d, -1)
} | go | func (ot OperationType) GetOperationId(d string) string {
return strings.Replace(ot.Match, "${resource}", d, -1)
} | [
"func",
"(",
"ot",
"OperationType",
")",
"GetOperationId",
"(",
"d",
"string",
")",
"string",
"{",
"return",
"strings",
".",
"Replace",
"(",
"ot",
".",
"Match",
",",
"\"",
"\"",
",",
"d",
",",
"-",
"1",
")",
"\n",
"}"
] | // GetOperationId returns the ID of the operation for the given definition | [
"GetOperationId",
"returns",
"the",
"ID",
"of",
"the",
"operation",
"for",
"the",
"given",
"definition"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/operation.go#L35-L37 |
24,186 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/operation.go | VisitOperations | func VisitOperations(specs []*loads.Document, fn func(operation Operation)) {
for _, d := range specs {
for path, item := range d.Spec().Paths.Paths {
for method, operation := range getOperationsForItem(item) {
if operation != nil && !IsBlacklistedOperation(operation) {
fn(Operation{
item: it... | go | func VisitOperations(specs []*loads.Document, fn func(operation Operation)) {
for _, d := range specs {
for path, item := range d.Spec().Paths.Paths {
for method, operation := range getOperationsForItem(item) {
if operation != nil && !IsBlacklistedOperation(operation) {
fn(Operation{
item: it... | [
"func",
"VisitOperations",
"(",
"specs",
"[",
"]",
"*",
"loads",
".",
"Document",
",",
"fn",
"func",
"(",
"operation",
"Operation",
")",
")",
"{",
"for",
"_",
",",
"d",
":=",
"range",
"specs",
"{",
"for",
"path",
",",
"item",
":=",
"range",
"d",
".... | // VisitOperations calls fn once for each operation found in the collection of Documents
// VisitOperations calls fn once for each operation found in the collection of Documents | [
"VisitOperations",
"calls",
"fn",
"once",
"for",
"each",
"operation",
"found",
"in",
"the",
"collection",
"of",
"Documents",
"VisitOperations",
"calls",
"fn",
"once",
"for",
"each",
"operation",
"found",
"in",
"the",
"collection",
"of",
"Documents"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/operation.go#L81-L97 |
24,187 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/operation.go | getOperationsForItem | func getOperationsForItem(pathItem spec.PathItem) map[string]*spec.Operation {
return map[string]*spec.Operation{
"GET": pathItem.Get,
"DELETE": pathItem.Delete,
"PATCH": pathItem.Patch,
"PUT": pathItem.Put,
"POST": pathItem.Post,
"HEAD": pathItem.Head,
}
} | go | func getOperationsForItem(pathItem spec.PathItem) map[string]*spec.Operation {
return map[string]*spec.Operation{
"GET": pathItem.Get,
"DELETE": pathItem.Delete,
"PATCH": pathItem.Patch,
"PUT": pathItem.Put,
"POST": pathItem.Post,
"HEAD": pathItem.Head,
}
} | [
"func",
"getOperationsForItem",
"(",
"pathItem",
"spec",
".",
"PathItem",
")",
"map",
"[",
"string",
"]",
"*",
"spec",
".",
"Operation",
"{",
"return",
"map",
"[",
"string",
"]",
"*",
"spec",
".",
"Operation",
"{",
"\"",
"\"",
":",
"pathItem",
".",
"Ge... | // Get all operations from the pathitem so we cacn iterate over them | [
"Get",
"all",
"operations",
"from",
"the",
"pathitem",
"so",
"we",
"cacn",
"iterate",
"over",
"them"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/operation.go#L108-L117 |
24,188 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/operation.go | initExample | func (o *Operation) initExample(config *Config) {
path := o.Type.Name + ".yaml"
path = filepath.Join(*ConfigDir, config.ExampleLocation, o.Definition.Name, path)
path = strings.Replace(path, " ", "_", -1)
path = strings.ToLower(path)
content, err := ioutil.ReadFile(path)
if err != nil {
return
}
err = yaml.Un... | go | func (o *Operation) initExample(config *Config) {
path := o.Type.Name + ".yaml"
path = filepath.Join(*ConfigDir, config.ExampleLocation, o.Definition.Name, path)
path = strings.Replace(path, " ", "_", -1)
path = strings.ToLower(path)
content, err := ioutil.ReadFile(path)
if err != nil {
return
}
err = yaml.Un... | [
"func",
"(",
"o",
"*",
"Operation",
")",
"initExample",
"(",
"config",
"*",
"Config",
")",
"{",
"path",
":=",
"o",
".",
"Type",
".",
"Name",
"+",
"\"",
"\"",
"\n",
"path",
"=",
"filepath",
".",
"Join",
"(",
"*",
"ConfigDir",
",",
"config",
".",
"... | // initExample reads the example config for an operation | [
"initExample",
"reads",
"the",
"example",
"config",
"for",
"an",
"operation"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/operation.go#L174-L187 |
24,189 | kubernetes-incubator/reference-docs | gen-kubectldocs/generators/read_cmd.go | NewOptions | func NewOptions(flags *pflag.FlagSet) Options {
result := Options{}
flags.VisitAll(func(flag *pflag.Flag) {
opt := &Option{
Name: flag.Name,
Shorthand: flag.Shorthand,
DefaultValue: flag.DefValue,
Usage: flag.Usage,
}
result = append(result, opt)
})
return result
} | go | func NewOptions(flags *pflag.FlagSet) Options {
result := Options{}
flags.VisitAll(func(flag *pflag.Flag) {
opt := &Option{
Name: flag.Name,
Shorthand: flag.Shorthand,
DefaultValue: flag.DefValue,
Usage: flag.Usage,
}
result = append(result, opt)
})
return result
} | [
"func",
"NewOptions",
"(",
"flags",
"*",
"pflag",
".",
"FlagSet",
")",
"Options",
"{",
"result",
":=",
"Options",
"{",
"}",
"\n",
"flags",
".",
"VisitAll",
"(",
"func",
"(",
"flag",
"*",
"pflag",
".",
"Flag",
")",
"{",
"opt",
":=",
"&",
"Option",
"... | // Parse the Options | [
"Parse",
"the",
"Options"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-kubectldocs/generators/read_cmd.go#L66-L78 |
24,190 | kubernetes-incubator/reference-docs | gen-kubectldocs/generators/read_cmd.go | NewSubCommands | func NewSubCommands(c *cobra.Command, path string) Commands {
subCommands := Commands{NewCommand(c, path+c.Name())}
for _, subCommand := range c.Commands() {
subCommands = append(subCommands, NewSubCommands(subCommand, path+c.Name()+" ")...)
}
return subCommands
} | go | func NewSubCommands(c *cobra.Command, path string) Commands {
subCommands := Commands{NewCommand(c, path+c.Name())}
for _, subCommand := range c.Commands() {
subCommands = append(subCommands, NewSubCommands(subCommand, path+c.Name()+" ")...)
}
return subCommands
} | [
"func",
"NewSubCommands",
"(",
"c",
"*",
"cobra",
".",
"Command",
",",
"path",
"string",
")",
"Commands",
"{",
"subCommands",
":=",
"Commands",
"{",
"NewCommand",
"(",
"c",
",",
"path",
"+",
"c",
".",
"Name",
"(",
")",
")",
"}",
"\n",
"for",
"_",
"... | // Parse the Commands | [
"Parse",
"the",
"Commands"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-kubectldocs/generators/read_cmd.go#L81-L87 |
24,191 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/open_api.go | LoadOpenApiSpec | func LoadOpenApiSpec() []*loads.Document {
dir := filepath.Join(*ConfigDir, "openapi-spec/")
docs := []*loads.Document{}
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
ext := filepath.Ext(path)
if ext != ".json" {
return nil
}
var d *loads.Document
d, err = loads.JSONSp... | go | func LoadOpenApiSpec() []*loads.Document {
dir := filepath.Join(*ConfigDir, "openapi-spec/")
docs := []*loads.Document{}
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
ext := filepath.Ext(path)
if ext != ".json" {
return nil
}
var d *loads.Document
d, err = loads.JSONSp... | [
"func",
"LoadOpenApiSpec",
"(",
")",
"[",
"]",
"*",
"loads",
".",
"Document",
"{",
"dir",
":=",
"filepath",
".",
"Join",
"(",
"*",
"ConfigDir",
",",
"\"",
"\"",
")",
"\n",
"docs",
":=",
"[",
"]",
"*",
"loads",
".",
"Document",
"{",
"}",
"\n",
"er... | // Loads all of the open-api documents | [
"Loads",
"all",
"of",
"the",
"open",
"-",
"api",
"documents"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/open_api.go#L37-L58 |
24,192 | kubernetes-incubator/reference-docs | gen-apidocs/generators/api/open_api.go | buildGroupMap | func buildGroupMap(specs []*loads.Document) map[string]string {
mapping := map[string]string{}
mapping["apiregistration"] = "apiregistration.k8s.io"
mapping["apiextensions"] = "apiextensions.k8s.io"
mapping["certificates"] = "certificates.k8s.io"
mapping["meta"] = "meta"
mapping["core"] = "core"
mapping["extensi... | go | func buildGroupMap(specs []*loads.Document) map[string]string {
mapping := map[string]string{}
mapping["apiregistration"] = "apiregistration.k8s.io"
mapping["apiextensions"] = "apiextensions.k8s.io"
mapping["certificates"] = "certificates.k8s.io"
mapping["meta"] = "meta"
mapping["core"] = "core"
mapping["extensi... | [
"func",
"buildGroupMap",
"(",
"specs",
"[",
"]",
"*",
"loads",
".",
"Document",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"mapping",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"mapping",
"[",
"\"",
"\"",
"]",
"=",
"\"",
"\"",
... | // return the map from short group name to full group name | [
"return",
"the",
"map",
"from",
"short",
"group",
"name",
"to",
"full",
"group",
"name"
] | 9642bd3f4de59e831d66fecfeb3b465681ba5711 | https://github.com/kubernetes-incubator/reference-docs/blob/9642bd3f4de59e831d66fecfeb3b465681ba5711/gen-apidocs/generators/api/open_api.go#L61-L102 |
24,193 | docker/go-connections | tlsconfig/certpool_go17.go | SystemCertPool | func SystemCertPool() (*x509.CertPool, error) {
certpool, err := x509.SystemCertPool()
if err != nil && runtime.GOOS == "windows" {
return x509.NewCertPool(), nil
}
return certpool, err
} | go | func SystemCertPool() (*x509.CertPool, error) {
certpool, err := x509.SystemCertPool()
if err != nil && runtime.GOOS == "windows" {
return x509.NewCertPool(), nil
}
return certpool, err
} | [
"func",
"SystemCertPool",
"(",
")",
"(",
"*",
"x509",
".",
"CertPool",
",",
"error",
")",
"{",
"certpool",
",",
"err",
":=",
"x509",
".",
"SystemCertPool",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"&&",
"runtime",
".",
"GOOS",
"==",
"\"",
"\"",
"{... | // SystemCertPool returns a copy of the system cert pool,
// returns an error if failed to load or empty pool on windows. | [
"SystemCertPool",
"returns",
"a",
"copy",
"of",
"the",
"system",
"cert",
"pool",
"returns",
"an",
"error",
"if",
"failed",
"to",
"load",
"or",
"empty",
"pool",
"on",
"windows",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/tlsconfig/certpool_go17.go#L12-L18 |
24,194 | docker/go-connections | sockets/sockets_unix.go | DialPipe | func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
return nil, syscall.EAFNOSUPPORT
} | go | func DialPipe(_ string, _ time.Duration) (net.Conn, error) {
return nil, syscall.EAFNOSUPPORT
} | [
"func",
"DialPipe",
"(",
"_",
"string",
",",
"_",
"time",
".",
"Duration",
")",
"(",
"net",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"nil",
",",
"syscall",
".",
"EAFNOSUPPORT",
"\n",
"}"
] | // DialPipe connects to a Windows named pipe.
// This is not supported on other OSes. | [
"DialPipe",
"connects",
"to",
"a",
"Windows",
"named",
"pipe",
".",
"This",
"is",
"not",
"supported",
"on",
"other",
"OSes",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/sockets/sockets_unix.go#L36-L38 |
24,195 | docker/go-connections | proxy/udp_proxy.go | Run | func (proxy *UDPProxy) Run() {
readBuf := make([]byte, UDPBufSize)
for {
read, from, err := proxy.listener.ReadFromUDP(readBuf)
if err != nil {
// NOTE: Apparently ReadFrom doesn't return
// ECONNREFUSED like Read do (see comment in
// UDPProxy.replyLoop)
if !isClosedError(err) {
proxy.Logger.Prin... | go | func (proxy *UDPProxy) Run() {
readBuf := make([]byte, UDPBufSize)
for {
read, from, err := proxy.listener.ReadFromUDP(readBuf)
if err != nil {
// NOTE: Apparently ReadFrom doesn't return
// ECONNREFUSED like Read do (see comment in
// UDPProxy.replyLoop)
if !isClosedError(err) {
proxy.Logger.Prin... | [
"func",
"(",
"proxy",
"*",
"UDPProxy",
")",
"Run",
"(",
")",
"{",
"readBuf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"UDPBufSize",
")",
"\n",
"for",
"{",
"read",
",",
"from",
",",
"err",
":=",
"proxy",
".",
"listener",
".",
"ReadFromUDP",
"(",
... | // Run starts forwarding the traffic using UDP. | [
"Run",
"starts",
"forwarding",
"the",
"traffic",
"using",
"UDP",
"."
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/proxy/udp_proxy.go#L113-L150 |
24,196 | docker/go-connections | nat/nat.go | NewPort | func NewPort(proto, port string) (Port, error) {
// Check for parsing issues on "port" now so we can avoid having
// to check it later on.
portStartInt, portEndInt, err := ParsePortRangeToInt(port)
if err != nil {
return "", err
}
if portStartInt == portEndInt {
return Port(fmt.Sprintf("%d/%s", portStartInt... | go | func NewPort(proto, port string) (Port, error) {
// Check for parsing issues on "port" now so we can avoid having
// to check it later on.
portStartInt, portEndInt, err := ParsePortRangeToInt(port)
if err != nil {
return "", err
}
if portStartInt == portEndInt {
return Port(fmt.Sprintf("%d/%s", portStartInt... | [
"func",
"NewPort",
"(",
"proto",
",",
"port",
"string",
")",
"(",
"Port",
",",
"error",
")",
"{",
"// Check for parsing issues on \"port\" now so we can avoid having",
"// to check it later on.",
"portStartInt",
",",
"portEndInt",
",",
"err",
":=",
"ParsePortRangeToInt",
... | // NewPort creates a new instance of a Port given a protocol and port number or port range | [
"NewPort",
"creates",
"a",
"new",
"instance",
"of",
"a",
"Port",
"given",
"a",
"protocol",
"and",
"port",
"number",
"or",
"port",
"range"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L34-L47 |
24,197 | docker/go-connections | nat/nat.go | ParsePort | func ParsePort(rawPort string) (int, error) {
if len(rawPort) == 0 {
return 0, nil
}
port, err := strconv.ParseUint(rawPort, 10, 16)
if err != nil {
return 0, err
}
return int(port), nil
} | go | func ParsePort(rawPort string) (int, error) {
if len(rawPort) == 0 {
return 0, nil
}
port, err := strconv.ParseUint(rawPort, 10, 16)
if err != nil {
return 0, err
}
return int(port), nil
} | [
"func",
"ParsePort",
"(",
"rawPort",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"len",
"(",
"rawPort",
")",
"==",
"0",
"{",
"return",
"0",
",",
"nil",
"\n",
"}",
"\n",
"port",
",",
"err",
":=",
"strconv",
".",
"ParseUint",
"(",
"raw... | // ParsePort parses the port number string and returns an int | [
"ParsePort",
"parses",
"the",
"port",
"number",
"string",
"and",
"returns",
"an",
"int"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L50-L59 |
24,198 | docker/go-connections | nat/nat.go | Proto | func (p Port) Proto() string {
proto, _ := SplitProtoPort(string(p))
return proto
} | go | func (p Port) Proto() string {
proto, _ := SplitProtoPort(string(p))
return proto
} | [
"func",
"(",
"p",
"Port",
")",
"Proto",
"(",
")",
"string",
"{",
"proto",
",",
"_",
":=",
"SplitProtoPort",
"(",
"string",
"(",
"p",
")",
")",
"\n",
"return",
"proto",
"\n",
"}"
] | // Proto returns the protocol of a Port | [
"Proto",
"returns",
"the",
"protocol",
"of",
"a",
"Port"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L74-L77 |
24,199 | docker/go-connections | nat/nat.go | Port | func (p Port) Port() string {
_, port := SplitProtoPort(string(p))
return port
} | go | func (p Port) Port() string {
_, port := SplitProtoPort(string(p))
return port
} | [
"func",
"(",
"p",
"Port",
")",
"Port",
"(",
")",
"string",
"{",
"_",
",",
"port",
":=",
"SplitProtoPort",
"(",
"string",
"(",
"p",
")",
")",
"\n",
"return",
"port",
"\n",
"}"
] | // Port returns the port number of a Port | [
"Port",
"returns",
"the",
"port",
"number",
"of",
"a",
"Port"
] | b44139defdac517e3f71df1e60826f8a262a2482 | https://github.com/docker/go-connections/blob/b44139defdac517e3f71df1e60826f8a262a2482/nat/nat.go#L80-L83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.