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
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
157,300
juju/juju
state/state.go
SetSLA
func (st *State) SetSLA(level, owner string, credentials []byte) error { model, err := st.Model() if err != nil { return errors.Trace(err) } return model.SetSLA(level, owner, credentials) }
go
func (st *State) SetSLA(level, owner string, credentials []byte) error { model, err := st.Model() if err != nil { return errors.Trace(err) } return model.SetSLA(level, owner, credentials) }
[ "func", "(", "st", "*", "State", ")", "SetSLA", "(", "level", ",", "owner", "string", ",", "credentials", "[", "]", "byte", ")", "error", "{", "model", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "model", ".", "SetSLA", "(", "level", ",", "owner", ",", "credentials", ")", "\n", "}" ]
// SetSLA sets the SLA on the current connected model.
[ "SetSLA", "sets", "the", "SLA", "on", "the", "current", "connected", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/state.go#L2512-L2518
157,301
juju/juju
state/state.go
SetModelMeterStatus
func (st *State) SetModelMeterStatus(status, info string) error { model, err := st.Model() if err != nil { return errors.Trace(err) } return model.SetMeterStatus(status, info) }
go
func (st *State) SetModelMeterStatus(status, info string) error { model, err := st.Model() if err != nil { return errors.Trace(err) } return model.SetMeterStatus(status, info) }
[ "func", "(", "st", "*", "State", ")", "SetModelMeterStatus", "(", "status", ",", "info", "string", ")", "error", "{", "model", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "model", ".", "SetMeterStatus", "(", "status", ",", "info", ")", "\n", "}" ]
// SetModelMeterStatus sets the meter status for the current connected model.
[ "SetModelMeterStatus", "sets", "the", "meter", "status", "for", "the", "current", "connected", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/state.go#L2521-L2527
157,302
juju/juju
state/state.go
ModelMeterStatus
func (st *State) ModelMeterStatus() (MeterStatus, error) { model, err := st.Model() if err != nil { return MeterStatus{MeterNotAvailable, ""}, errors.Trace(err) } return model.MeterStatus(), nil }
go
func (st *State) ModelMeterStatus() (MeterStatus, error) { model, err := st.Model() if err != nil { return MeterStatus{MeterNotAvailable, ""}, errors.Trace(err) } return model.MeterStatus(), nil }
[ "func", "(", "st", "*", "State", ")", "ModelMeterStatus", "(", ")", "(", "MeterStatus", ",", "error", ")", "{", "model", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "MeterStatus", "{", "MeterNotAvailable", ",", "\"", "\"", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "model", ".", "MeterStatus", "(", ")", ",", "nil", "\n", "}" ]
// ModelMeterStatus returns the meter status for the current connected model.
[ "ModelMeterStatus", "returns", "the", "meter", "status", "for", "the", "current", "connected", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/state.go#L2530-L2536
157,303
juju/juju
state/state.go
SLALevel
func (st *State) SLALevel() (string, error) { model, err := st.Model() if err != nil { return "", errors.Trace(err) } return model.SLALevel(), nil }
go
func (st *State) SLALevel() (string, error) { model, err := st.Model() if err != nil { return "", errors.Trace(err) } return model.SLALevel(), nil }
[ "func", "(", "st", "*", "State", ")", "SLALevel", "(", ")", "(", "string", ",", "error", ")", "{", "model", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "model", ".", "SLALevel", "(", ")", ",", "nil", "\n", "}" ]
// SLALevel returns the SLA level of the current connected model.
[ "SLALevel", "returns", "the", "SLA", "level", "of", "the", "current", "connected", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/state.go#L2539-L2545
157,304
juju/juju
state/state.go
SLACredential
func (st *State) SLACredential() ([]byte, error) { model, err := st.Model() if err != nil { return []byte{}, errors.Trace(err) } return model.SLACredential(), nil }
go
func (st *State) SLACredential() ([]byte, error) { model, err := st.Model() if err != nil { return []byte{}, errors.Trace(err) } return model.SLACredential(), nil }
[ "func", "(", "st", "*", "State", ")", "SLACredential", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "model", ",", "err", ":=", "st", ".", "Model", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "byte", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "model", ".", "SLACredential", "(", ")", ",", "nil", "\n", "}" ]
// SLACredential returns the SLA credential of the current connected model.
[ "SLACredential", "returns", "the", "SLA", "credential", "of", "the", "current", "connected", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/state.go#L2548-L2554
157,305
juju/juju
upgrades/steps_254.go
stateStepsFor254
func stateStepsFor254() []Step { return []Step{ &upgradeStep{ description: "ensure default modification status is set for machines", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureDefaultModificationStatus() }, }, &upgradeStep{ description: "ensure device constraints exists for applications", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureApplicationDeviceConstraints() }, }, } }
go
func stateStepsFor254() []Step { return []Step{ &upgradeStep{ description: "ensure default modification status is set for machines", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureDefaultModificationStatus() }, }, &upgradeStep{ description: "ensure device constraints exists for applications", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().EnsureApplicationDeviceConstraints() }, }, } }
[ "func", "stateStepsFor254", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", "context", "Context", ")", "error", "{", "return", "context", ".", "State", "(", ")", ".", "EnsureDefaultModificationStatus", "(", ")", "\n", "}", ",", "}", ",", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", "context", "Context", ")", "error", "{", "return", "context", ".", "State", "(", ")", ".", "EnsureApplicationDeviceConstraints", "(", ")", "\n", "}", ",", "}", ",", "}", "\n", "}" ]
// stateStepsFor254 returns the upgrade steps for Juju 2.5.4 that manipulates // state directly.
[ "stateStepsFor254", "returns", "the", "upgrade", "steps", "for", "Juju", "2", ".", "5", ".", "4", "that", "manipulates", "state", "directly", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_254.go#L8-L25
157,306
juju/juju
network/bridge.go
DefaultNetplanBridger
func DefaultNetplanBridger(timeout time.Duration, directory string) (Bridger, error) { return newNetplanBridger(clock.WallClock, timeout, directory), nil }
go
func DefaultNetplanBridger(timeout time.Duration, directory string) (Bridger, error) { return newNetplanBridger(clock.WallClock, timeout, directory), nil }
[ "func", "DefaultNetplanBridger", "(", "timeout", "time", ".", "Duration", ",", "directory", "string", ")", "(", "Bridger", ",", "error", ")", "{", "return", "newNetplanBridger", "(", "clock", ".", "WallClock", ",", "timeout", ",", "directory", ")", ",", "nil", "\n", "}" ]
// DefaultNetplanBridger returns a Bridger instance that can parse a set // of netplan yaml files to transform existing devices into bridged devices.
[ "DefaultNetplanBridger", "returns", "a", "Bridger", "instance", "that", "can", "parse", "a", "set", "of", "netplan", "yaml", "files", "to", "transform", "existing", "devices", "into", "bridged", "devices", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/network/bridge.go#L134-L136
157,307
juju/juju
environs/instances/instancetype.go
match
func (itype InstanceType) match(cons constraints.Value) (InstanceType, bool) { nothing := InstanceType{} if cons.Arch != nil { itype.Arches = filterArches(itype.Arches, []string{*cons.Arch}) } if itype.Deprecated && !cons.HasInstanceType() { return nothing, false } if cons.HasInstanceType() && itype.Name != *cons.InstanceType { return nothing, false } if len(itype.Arches) == 0 { return nothing, false } if cons.CpuCores != nil && itype.CpuCores < *cons.CpuCores { return nothing, false } if cons.CpuPower != nil && itype.CpuPower != nil && *itype.CpuPower < *cons.CpuPower { return nothing, false } if cons.Mem != nil && itype.Mem < *cons.Mem { return nothing, false } if cons.RootDisk != nil && itype.RootDisk > 0 && itype.RootDisk < *cons.RootDisk { return nothing, false } if cons.Tags != nil && len(*cons.Tags) > 0 && !tagsMatch(*cons.Tags, itype.Tags) { return nothing, false } if cons.HasVirtType() && (itype.VirtType == nil || *itype.VirtType != *cons.VirtType) { return nothing, false } return itype, true }
go
func (itype InstanceType) match(cons constraints.Value) (InstanceType, bool) { nothing := InstanceType{} if cons.Arch != nil { itype.Arches = filterArches(itype.Arches, []string{*cons.Arch}) } if itype.Deprecated && !cons.HasInstanceType() { return nothing, false } if cons.HasInstanceType() && itype.Name != *cons.InstanceType { return nothing, false } if len(itype.Arches) == 0 { return nothing, false } if cons.CpuCores != nil && itype.CpuCores < *cons.CpuCores { return nothing, false } if cons.CpuPower != nil && itype.CpuPower != nil && *itype.CpuPower < *cons.CpuPower { return nothing, false } if cons.Mem != nil && itype.Mem < *cons.Mem { return nothing, false } if cons.RootDisk != nil && itype.RootDisk > 0 && itype.RootDisk < *cons.RootDisk { return nothing, false } if cons.Tags != nil && len(*cons.Tags) > 0 && !tagsMatch(*cons.Tags, itype.Tags) { return nothing, false } if cons.HasVirtType() && (itype.VirtType == nil || *itype.VirtType != *cons.VirtType) { return nothing, false } return itype, true }
[ "func", "(", "itype", "InstanceType", ")", "match", "(", "cons", "constraints", ".", "Value", ")", "(", "InstanceType", ",", "bool", ")", "{", "nothing", ":=", "InstanceType", "{", "}", "\n", "if", "cons", ".", "Arch", "!=", "nil", "{", "itype", ".", "Arches", "=", "filterArches", "(", "itype", ".", "Arches", ",", "[", "]", "string", "{", "*", "cons", ".", "Arch", "}", ")", "\n", "}", "\n", "if", "itype", ".", "Deprecated", "&&", "!", "cons", ".", "HasInstanceType", "(", ")", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "HasInstanceType", "(", ")", "&&", "itype", ".", "Name", "!=", "*", "cons", ".", "InstanceType", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "len", "(", "itype", ".", "Arches", ")", "==", "0", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "CpuCores", "!=", "nil", "&&", "itype", ".", "CpuCores", "<", "*", "cons", ".", "CpuCores", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "CpuPower", "!=", "nil", "&&", "itype", ".", "CpuPower", "!=", "nil", "&&", "*", "itype", ".", "CpuPower", "<", "*", "cons", ".", "CpuPower", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "Mem", "!=", "nil", "&&", "itype", ".", "Mem", "<", "*", "cons", ".", "Mem", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "RootDisk", "!=", "nil", "&&", "itype", ".", "RootDisk", ">", "0", "&&", "itype", ".", "RootDisk", "<", "*", "cons", ".", "RootDisk", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "Tags", "!=", "nil", "&&", "len", "(", "*", "cons", ".", "Tags", ")", ">", "0", "&&", "!", "tagsMatch", "(", "*", "cons", ".", "Tags", ",", "itype", ".", "Tags", ")", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "if", "cons", ".", "HasVirtType", "(", ")", "&&", "(", "itype", ".", "VirtType", "==", "nil", "||", "*", "itype", ".", "VirtType", "!=", "*", "cons", ".", "VirtType", ")", "{", "return", "nothing", ",", "false", "\n", "}", "\n", "return", "itype", ",", "true", "\n", "}" ]
// match returns true if itype can satisfy the supplied constraints. If so, // it also returns a copy of itype with any arches that do not match the // constraints filtered out.
[ "match", "returns", "true", "if", "itype", "can", "satisfy", "the", "supplied", "constraints", ".", "If", "so", "it", "also", "returns", "a", "copy", "of", "itype", "with", "any", "arches", "that", "do", "not", "match", "the", "constraints", "filtered", "out", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/instancetype.go#L51-L84
157,308
juju/juju
environs/instances/instancetype.go
filterArches
func filterArches(src, filter []string) (dst []string) { for _, arch := range src { for _, match := range filter { if arch == match { dst = append(dst, arch) break } } } return dst }
go
func filterArches(src, filter []string) (dst []string) { for _, arch := range src { for _, match := range filter { if arch == match { dst = append(dst, arch) break } } } return dst }
[ "func", "filterArches", "(", "src", ",", "filter", "[", "]", "string", ")", "(", "dst", "[", "]", "string", ")", "{", "for", "_", ",", "arch", ":=", "range", "src", "{", "for", "_", ",", "match", ":=", "range", "filter", "{", "if", "arch", "==", "match", "{", "dst", "=", "append", "(", "dst", ",", "arch", ")", "\n", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "dst", "\n", "}" ]
// filterArches returns every element of src that also exists in filter.
[ "filterArches", "returns", "every", "element", "of", "src", "that", "also", "exists", "in", "filter", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/instancetype.go#L87-L97
157,309
juju/juju
environs/instances/instancetype.go
matchingTypesForConstraint
func matchingTypesForConstraint(allTypes []InstanceType, cons constraints.Value) []InstanceType { var matchingTypes []InstanceType for _, itype := range allTypes { itype, ok := itype.match(cons) if !ok { continue } matchingTypes = append(matchingTypes, itype) } return matchingTypes }
go
func matchingTypesForConstraint(allTypes []InstanceType, cons constraints.Value) []InstanceType { var matchingTypes []InstanceType for _, itype := range allTypes { itype, ok := itype.match(cons) if !ok { continue } matchingTypes = append(matchingTypes, itype) } return matchingTypes }
[ "func", "matchingTypesForConstraint", "(", "allTypes", "[", "]", "InstanceType", ",", "cons", "constraints", ".", "Value", ")", "[", "]", "InstanceType", "{", "var", "matchingTypes", "[", "]", "InstanceType", "\n", "for", "_", ",", "itype", ":=", "range", "allTypes", "{", "itype", ",", "ok", ":=", "itype", ".", "match", "(", "cons", ")", "\n", "if", "!", "ok", "{", "continue", "\n", "}", "\n", "matchingTypes", "=", "append", "(", "matchingTypes", ",", "itype", ")", "\n", "}", "\n", "return", "matchingTypes", "\n", "}" ]
// matchingTypesForConstraint returns instance types from allTypes which match cons.
[ "matchingTypesForConstraint", "returns", "instance", "types", "from", "allTypes", "which", "match", "cons", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/instancetype.go#L103-L113
157,310
juju/juju
environs/instances/instancetype.go
tagsMatch
func tagsMatch(wanted, have []string) bool { machineTags := map[string]struct{}{} for _, tag := range have { machineTags[tag] = struct{}{} } for _, tag := range wanted { if _, ok := machineTags[tag]; !ok { return false } } return true }
go
func tagsMatch(wanted, have []string) bool { machineTags := map[string]struct{}{} for _, tag := range have { machineTags[tag] = struct{}{} } for _, tag := range wanted { if _, ok := machineTags[tag]; !ok { return false } } return true }
[ "func", "tagsMatch", "(", "wanted", ",", "have", "[", "]", "string", ")", "bool", "{", "machineTags", ":=", "map", "[", "string", "]", "struct", "{", "}", "{", "}", "\n", "for", "_", ",", "tag", ":=", "range", "have", "{", "machineTags", "[", "tag", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "for", "_", ",", "tag", ":=", "range", "wanted", "{", "if", "_", ",", "ok", ":=", "machineTags", "[", "tag", "]", ";", "!", "ok", "{", "return", "false", "\n", "}", "\n", "}", "\n", "return", "true", "\n", "}" ]
// tagsMatch returns if the tags in wanted all exist in have. // Note that duplicates of tags are disregarded in both lists
[ "tagsMatch", "returns", "if", "the", "tags", "in", "wanted", "all", "exist", "in", "have", ".", "Note", "that", "duplicates", "of", "tags", "are", "disregarded", "in", "both", "lists" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/instances/instancetype.go#L154-L165
157,311
juju/juju
worker/machiner/machiner.go
Validate
func (cfg *Config) Validate() error { if cfg.MachineAccessor == nil { return errors.NotValidf("unspecified MachineAccessor") } if cfg.Tag == (names.MachineTag{}) { return errors.NotValidf("unspecified Tag") } return nil }
go
func (cfg *Config) Validate() error { if cfg.MachineAccessor == nil { return errors.NotValidf("unspecified MachineAccessor") } if cfg.Tag == (names.MachineTag{}) { return errors.NotValidf("unspecified Tag") } return nil }
[ "func", "(", "cfg", "*", "Config", ")", "Validate", "(", ")", "error", "{", "if", "cfg", ".", "MachineAccessor", "==", "nil", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "cfg", ".", "Tag", "==", "(", "names", ".", "MachineTag", "{", "}", ")", "{", "return", "errors", ".", "NotValidf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate reports whether or not the configuration is valid.
[ "Validate", "reports", "whether", "or", "not", "the", "configuration", "is", "valid", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/machiner/machiner.go#L42-L50
157,312
juju/juju
worker/machiner/machiner.go
setMachineAddresses
func setMachineAddresses(tag names.MachineTag, m Machine) error { addrs, err := interfaceAddrs() if err != nil { return err } var hostAddresses []network.Address for _, addr := range addrs { var ip net.IP switch addr := addr.(type) { case *net.IPAddr: ip = addr.IP case *net.IPNet: ip = addr.IP default: continue } address := network.NewAddress(ip.String()) // Filter out link-local addresses as we cannot reliably use them. if address.Scope == network.ScopeLinkLocal { continue } hostAddresses = append(hostAddresses, address) } if len(hostAddresses) == 0 { return nil } // Filter out any LXC or LXD bridge addresses. hostAddresses = network.FilterBridgeAddresses(hostAddresses) logger.Infof("setting addresses for %q to %v", tag, hostAddresses) return m.SetMachineAddresses(hostAddresses) }
go
func setMachineAddresses(tag names.MachineTag, m Machine) error { addrs, err := interfaceAddrs() if err != nil { return err } var hostAddresses []network.Address for _, addr := range addrs { var ip net.IP switch addr := addr.(type) { case *net.IPAddr: ip = addr.IP case *net.IPNet: ip = addr.IP default: continue } address := network.NewAddress(ip.String()) // Filter out link-local addresses as we cannot reliably use them. if address.Scope == network.ScopeLinkLocal { continue } hostAddresses = append(hostAddresses, address) } if len(hostAddresses) == 0 { return nil } // Filter out any LXC or LXD bridge addresses. hostAddresses = network.FilterBridgeAddresses(hostAddresses) logger.Infof("setting addresses for %q to %v", tag, hostAddresses) return m.SetMachineAddresses(hostAddresses) }
[ "func", "setMachineAddresses", "(", "tag", "names", ".", "MachineTag", ",", "m", "Machine", ")", "error", "{", "addrs", ",", "err", ":=", "interfaceAddrs", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "var", "hostAddresses", "[", "]", "network", ".", "Address", "\n", "for", "_", ",", "addr", ":=", "range", "addrs", "{", "var", "ip", "net", ".", "IP", "\n", "switch", "addr", ":=", "addr", ".", "(", "type", ")", "{", "case", "*", "net", ".", "IPAddr", ":", "ip", "=", "addr", ".", "IP", "\n", "case", "*", "net", ".", "IPNet", ":", "ip", "=", "addr", ".", "IP", "\n", "default", ":", "continue", "\n", "}", "\n", "address", ":=", "network", ".", "NewAddress", "(", "ip", ".", "String", "(", ")", ")", "\n", "// Filter out link-local addresses as we cannot reliably use them.", "if", "address", ".", "Scope", "==", "network", ".", "ScopeLinkLocal", "{", "continue", "\n", "}", "\n", "hostAddresses", "=", "append", "(", "hostAddresses", ",", "address", ")", "\n", "}", "\n", "if", "len", "(", "hostAddresses", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "// Filter out any LXC or LXD bridge addresses.", "hostAddresses", "=", "network", ".", "FilterBridgeAddresses", "(", "hostAddresses", ")", "\n", "logger", ".", "Infof", "(", "\"", "\"", ",", "tag", ",", "hostAddresses", ")", "\n", "return", "m", ".", "SetMachineAddresses", "(", "hostAddresses", ")", "\n", "}" ]
// setMachineAddresses sets the addresses for this machine to all of the // host's non-loopback interface IP addresses.
[ "setMachineAddresses", "sets", "the", "addresses", "for", "this", "machine", "to", "all", "of", "the", "host", "s", "non", "-", "loopback", "interface", "IP", "addresses", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/machiner/machiner.go#L115-L145
157,313
juju/juju
apiserver/facades/controller/machineundertaker/undertaker.go
NewAPI
func NewAPI(backend Backend, resources facade.Resources, authorizer facade.Authorizer) (*API, error) { if !authorizer.AuthController() { return nil, errors.Trace(common.ErrPerm) } api := &API{ backend: backend, resources: resources, canManageModel: func(modelUUID string) bool { return modelUUID == authorizer.ConnectedModel() }, } return api, nil }
go
func NewAPI(backend Backend, resources facade.Resources, authorizer facade.Authorizer) (*API, error) { if !authorizer.AuthController() { return nil, errors.Trace(common.ErrPerm) } api := &API{ backend: backend, resources: resources, canManageModel: func(modelUUID string) bool { return modelUUID == authorizer.ConnectedModel() }, } return api, nil }
[ "func", "NewAPI", "(", "backend", "Backend", ",", "resources", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ")", "(", "*", "API", ",", "error", ")", "{", "if", "!", "authorizer", ".", "AuthController", "(", ")", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "common", ".", "ErrPerm", ")", "\n", "}", "\n\n", "api", ":=", "&", "API", "{", "backend", ":", "backend", ",", "resources", ":", "resources", ",", "canManageModel", ":", "func", "(", "modelUUID", "string", ")", "bool", "{", "return", "modelUUID", "==", "authorizer", ".", "ConnectedModel", "(", ")", "\n", "}", ",", "}", "\n", "return", "api", ",", "nil", "\n", "}" ]
// NewAPI implements the API used by the machine undertaker worker to // find out what provider-level resources need to be cleaned up when a // machine goes away.
[ "NewAPI", "implements", "the", "API", "used", "by", "the", "machine", "undertaker", "worker", "to", "find", "out", "what", "provider", "-", "level", "resources", "need", "to", "be", "cleaned", "up", "when", "a", "machine", "goes", "away", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/machineundertaker/undertaker.go#L31-L44
157,314
juju/juju
apiserver/facades/controller/machineundertaker/undertaker.go
AllMachineRemovals
func (m *API) AllMachineRemovals(models params.Entities) params.EntitiesResults { results := make([]params.EntitiesResult, len(models.Entities)) for i, entity := range models.Entities { entities, err := m.allRemovalsForTag(entity.Tag) results[i].Entities = entities results[i].Error = common.ServerError(err) } return params.EntitiesResults{Results: results} }
go
func (m *API) AllMachineRemovals(models params.Entities) params.EntitiesResults { results := make([]params.EntitiesResult, len(models.Entities)) for i, entity := range models.Entities { entities, err := m.allRemovalsForTag(entity.Tag) results[i].Entities = entities results[i].Error = common.ServerError(err) } return params.EntitiesResults{Results: results} }
[ "func", "(", "m", "*", "API", ")", "AllMachineRemovals", "(", "models", "params", ".", "Entities", ")", "params", ".", "EntitiesResults", "{", "results", ":=", "make", "(", "[", "]", "params", ".", "EntitiesResult", ",", "len", "(", "models", ".", "Entities", ")", ")", "\n", "for", "i", ",", "entity", ":=", "range", "models", ".", "Entities", "{", "entities", ",", "err", ":=", "m", ".", "allRemovalsForTag", "(", "entity", ".", "Tag", ")", "\n", "results", "[", "i", "]", ".", "Entities", "=", "entities", "\n", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "params", ".", "EntitiesResults", "{", "Results", ":", "results", "}", "\n", "}" ]
// AllMachineRemovals returns tags for all of the machines that have // been marked for removal in the requested model.
[ "AllMachineRemovals", "returns", "tags", "for", "all", "of", "the", "machines", "that", "have", "been", "marked", "for", "removal", "in", "the", "requested", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/machineundertaker/undertaker.go#L53-L61
157,315
juju/juju
apiserver/facades/controller/machineundertaker/undertaker.go
GetMachineProviderInterfaceInfo
func (m *API) GetMachineProviderInterfaceInfo(machines params.Entities) params.ProviderInterfaceInfoResults { results := make([]params.ProviderInterfaceInfoResult, len(machines.Entities)) for i, entity := range machines.Entities { results[i].MachineTag = entity.Tag interfaces, err := m.getInterfaceInfoForOneMachine(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } infos := make([]params.ProviderInterfaceInfo, len(interfaces)) for i, info := range interfaces { infos[i].InterfaceName = info.InterfaceName infos[i].MACAddress = info.MACAddress infos[i].ProviderId = string(info.ProviderId) } results[i].Interfaces = infos } return params.ProviderInterfaceInfoResults{results} }
go
func (m *API) GetMachineProviderInterfaceInfo(machines params.Entities) params.ProviderInterfaceInfoResults { results := make([]params.ProviderInterfaceInfoResult, len(machines.Entities)) for i, entity := range machines.Entities { results[i].MachineTag = entity.Tag interfaces, err := m.getInterfaceInfoForOneMachine(entity.Tag) if err != nil { results[i].Error = common.ServerError(err) continue } infos := make([]params.ProviderInterfaceInfo, len(interfaces)) for i, info := range interfaces { infos[i].InterfaceName = info.InterfaceName infos[i].MACAddress = info.MACAddress infos[i].ProviderId = string(info.ProviderId) } results[i].Interfaces = infos } return params.ProviderInterfaceInfoResults{results} }
[ "func", "(", "m", "*", "API", ")", "GetMachineProviderInterfaceInfo", "(", "machines", "params", ".", "Entities", ")", "params", ".", "ProviderInterfaceInfoResults", "{", "results", ":=", "make", "(", "[", "]", "params", ".", "ProviderInterfaceInfoResult", ",", "len", "(", "machines", ".", "Entities", ")", ")", "\n", "for", "i", ",", "entity", ":=", "range", "machines", ".", "Entities", "{", "results", "[", "i", "]", ".", "MachineTag", "=", "entity", ".", "Tag", "\n\n", "interfaces", ",", "err", ":=", "m", ".", "getInterfaceInfoForOneMachine", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "continue", "\n", "}", "\n\n", "infos", ":=", "make", "(", "[", "]", "params", ".", "ProviderInterfaceInfo", ",", "len", "(", "interfaces", ")", ")", "\n", "for", "i", ",", "info", ":=", "range", "interfaces", "{", "infos", "[", "i", "]", ".", "InterfaceName", "=", "info", ".", "InterfaceName", "\n", "infos", "[", "i", "]", ".", "MACAddress", "=", "info", ".", "MACAddress", "\n", "infos", "[", "i", "]", ".", "ProviderId", "=", "string", "(", "info", ".", "ProviderId", ")", "\n", "}", "\n\n", "results", "[", "i", "]", ".", "Interfaces", "=", "infos", "\n", "}", "\n", "return", "params", ".", "ProviderInterfaceInfoResults", "{", "results", "}", "\n", "}" ]
// GetMachineProviderInterfaceInfo returns the provider details for // all network interfaces attached to the machines requested.
[ "GetMachineProviderInterfaceInfo", "returns", "the", "provider", "details", "for", "all", "network", "interfaces", "attached", "to", "the", "machines", "requested", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/machineundertaker/undertaker.go#L83-L104
157,316
juju/juju
apiserver/facades/controller/machineundertaker/undertaker.go
CompleteMachineRemovals
func (m *API) CompleteMachineRemovals(machines params.Entities) error { machineIDs, err := collectMachineIDs(machines) if err != nil { return errors.Trace(err) } return m.backend.CompleteMachineRemovals(machineIDs...) }
go
func (m *API) CompleteMachineRemovals(machines params.Entities) error { machineIDs, err := collectMachineIDs(machines) if err != nil { return errors.Trace(err) } return m.backend.CompleteMachineRemovals(machineIDs...) }
[ "func", "(", "m", "*", "API", ")", "CompleteMachineRemovals", "(", "machines", "params", ".", "Entities", ")", "error", "{", "machineIDs", ",", "err", ":=", "collectMachineIDs", "(", "machines", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "m", ".", "backend", ".", "CompleteMachineRemovals", "(", "machineIDs", "...", ")", "\n", "}" ]
// CompleteMachineRemovals removes the specified machines from the // model database. It should only be called once any provider-level // cleanup has been done for those machines.
[ "CompleteMachineRemovals", "removes", "the", "specified", "machines", "from", "the", "model", "database", ".", "It", "should", "only", "be", "called", "once", "any", "provider", "-", "level", "cleanup", "has", "been", "done", "for", "those", "machines", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/machineundertaker/undertaker.go#L125-L131
157,317
juju/juju
apiserver/facades/controller/machineundertaker/undertaker.go
WatchMachineRemovals
func (m *API) WatchMachineRemovals(models params.Entities) params.NotifyWatchResults { results := make([]params.NotifyWatchResult, len(models.Entities)) for i, entity := range models.Entities { id, err := m.watchRemovalsForTag(entity.Tag) results[i].NotifyWatcherId = id results[i].Error = common.ServerError(err) } return params.NotifyWatchResults{Results: results} }
go
func (m *API) WatchMachineRemovals(models params.Entities) params.NotifyWatchResults { results := make([]params.NotifyWatchResult, len(models.Entities)) for i, entity := range models.Entities { id, err := m.watchRemovalsForTag(entity.Tag) results[i].NotifyWatcherId = id results[i].Error = common.ServerError(err) } return params.NotifyWatchResults{Results: results} }
[ "func", "(", "m", "*", "API", ")", "WatchMachineRemovals", "(", "models", "params", ".", "Entities", ")", "params", ".", "NotifyWatchResults", "{", "results", ":=", "make", "(", "[", "]", "params", ".", "NotifyWatchResult", ",", "len", "(", "models", ".", "Entities", ")", ")", "\n", "for", "i", ",", "entity", ":=", "range", "models", ".", "Entities", "{", "id", ",", "err", ":=", "m", ".", "watchRemovalsForTag", "(", "entity", ".", "Tag", ")", "\n", "results", "[", "i", "]", ".", "NotifyWatcherId", "=", "id", "\n", "results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "params", ".", "NotifyWatchResults", "{", "Results", ":", "results", "}", "\n", "}" ]
// WatchMachineRemovals returns a watcher that will signal each time a // machine is marked for removal.
[ "WatchMachineRemovals", "returns", "a", "watcher", "that", "will", "signal", "each", "time", "a", "machine", "is", "marked", "for", "removal", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/controller/machineundertaker/undertaker.go#L135-L143
157,318
juju/juju
worker/restorewatcher/worker.go
NewWorker
func NewWorker(config Config) (RestoreStatusWorker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } restoreStatus, err := config.RestoreInfoWatcher.RestoreStatus() if err != nil { return nil, errors.Trace(err) } w := &restoreWorker{ config: config, status: restoreStatus, } if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, }); err != nil { return nil, errors.Trace(err) } return w, nil }
go
func NewWorker(config Config) (RestoreStatusWorker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } restoreStatus, err := config.RestoreInfoWatcher.RestoreStatus() if err != nil { return nil, errors.Trace(err) } w := &restoreWorker{ config: config, status: restoreStatus, } if err := catacomb.Invoke(catacomb.Plan{ Site: &w.catacomb, Work: w.loop, }); err != nil { return nil, errors.Trace(err) } return w, nil }
[ "func", "NewWorker", "(", "config", "Config", ")", "(", "RestoreStatusWorker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "restoreStatus", ",", "err", ":=", "config", ".", "RestoreInfoWatcher", ".", "RestoreStatus", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "w", ":=", "&", "restoreWorker", "{", "config", ":", "config", ",", "status", ":", "restoreStatus", ",", "}", "\n", "if", "err", ":=", "catacomb", ".", "Invoke", "(", "catacomb", ".", "Plan", "{", "Site", ":", "&", "w", ".", "catacomb", ",", "Work", ":", "w", ".", "loop", ",", "}", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "w", ",", "nil", "\n", "}" ]
// NewWorker returns a new worker that watches for changes to restore // info, and reports the status to the provided function.
[ "NewWorker", "returns", "a", "new", "worker", "that", "watches", "for", "changes", "to", "restore", "info", "and", "reports", "the", "status", "to", "the", "provided", "function", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/restorewatcher/worker.go#L37-L56
157,319
juju/juju
worker/restorewatcher/worker.go
RestoreStatus
func (w *restoreWorker) RestoreStatus() state.RestoreStatus { w.mu.Lock() defer w.mu.Unlock() return w.status }
go
func (w *restoreWorker) RestoreStatus() state.RestoreStatus { w.mu.Lock() defer w.mu.Unlock() return w.status }
[ "func", "(", "w", "*", "restoreWorker", ")", "RestoreStatus", "(", ")", "state", ".", "RestoreStatus", "{", "w", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "w", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "w", ".", "status", "\n", "}" ]
// RestoreStatus returns the most recently observed restore status.
[ "RestoreStatus", "returns", "the", "most", "recently", "observed", "restore", "status", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/restorewatcher/worker.go#L86-L90
157,320
juju/juju
api/machineactions/machineactions.go
WatchActionNotifications
func (c *Client) WatchActionNotifications(agent names.MachineTag) (watcher.StringsWatcher, error) { var results params.StringsWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: agent.String()}}, } err := c.facade.FacadeCall("WatchActionNotifications", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, errors.Trace(result.Error) } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
go
func (c *Client) WatchActionNotifications(agent names.MachineTag) (watcher.StringsWatcher, error) { var results params.StringsWatchResults args := params.Entities{ Entities: []params.Entity{{Tag: agent.String()}}, } err := c.facade.FacadeCall("WatchActionNotifications", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Results)) } result := results.Results[0] if result.Error != nil { return nil, errors.Trace(result.Error) } w := apiwatcher.NewStringsWatcher(c.facade.RawAPICaller(), result) return w, nil }
[ "func", "(", "c", "*", "Client", ")", "WatchActionNotifications", "(", "agent", "names", ".", "MachineTag", ")", "(", "watcher", ".", "StringsWatcher", ",", "error", ")", "{", "var", "results", "params", ".", "StringsWatchResults", "\n", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "agent", ".", "String", "(", ")", "}", "}", ",", "}", "\n\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "results", ".", "Results", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "results", ".", "Results", ")", ")", "\n", "}", "\n\n", "result", ":=", "results", ".", "Results", "[", "0", "]", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "result", ".", "Error", ")", "\n", "}", "\n", "w", ":=", "apiwatcher", ".", "NewStringsWatcher", "(", "c", ".", "facade", ".", "RawAPICaller", "(", ")", ",", "result", ")", "\n", "return", "w", ",", "nil", "\n", "}" ]
// WatchActionNotifications returns a StringsWatcher for observing the // IDs of Actions added to the Machine. The initial event will contain the // IDs of any Actions pending at the time the Watcher is made.
[ "WatchActionNotifications", "returns", "a", "StringsWatcher", "for", "observing", "the", "IDs", "of", "Actions", "added", "to", "the", "Machine", ".", "The", "initial", "event", "will", "contain", "the", "IDs", "of", "any", "Actions", "pending", "at", "the", "time", "the", "Watcher", "is", "made", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/machineactions/machineactions.go#L30-L51
157,321
juju/juju
api/machineactions/machineactions.go
RunningActions
func (c *Client) RunningActions(agent names.MachineTag) ([]params.ActionResult, error) { var results params.ActionsByReceivers args := params.Entities{ Entities: []params.Entity{{Tag: agent.String()}}, } err := c.facade.FacadeCall("RunningActions", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Actions) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Actions)) } result := results.Actions[0] if result.Error != nil { return nil, result.Error } return result.Actions, nil }
go
func (c *Client) RunningActions(agent names.MachineTag) ([]params.ActionResult, error) { var results params.ActionsByReceivers args := params.Entities{ Entities: []params.Entity{{Tag: agent.String()}}, } err := c.facade.FacadeCall("RunningActions", args, &results) if err != nil { return nil, errors.Trace(err) } if len(results.Actions) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(results.Actions)) } result := results.Actions[0] if result.Error != nil { return nil, result.Error } return result.Actions, nil }
[ "func", "(", "c", "*", "Client", ")", "RunningActions", "(", "agent", "names", ".", "MachineTag", ")", "(", "[", "]", "params", ".", "ActionResult", ",", "error", ")", "{", "var", "results", "params", ".", "ActionsByReceivers", "\n\n", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "agent", ".", "String", "(", ")", "}", "}", ",", "}", "\n\n", "err", ":=", "c", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "results", ".", "Actions", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "results", ".", "Actions", ")", ")", "\n", "}", "\n\n", "result", ":=", "results", ".", "Actions", "[", "0", "]", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n\n", "return", "result", ".", "Actions", ",", "nil", "\n", "}" ]
// RunningActions returns a list of actions running for the given machine tag.
[ "RunningActions", "returns", "a", "list", "of", "actions", "running", "for", "the", "given", "machine", "tag", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/machineactions/machineactions.go#L128-L150
157,322
juju/juju
provider/azure/networking.go
newSecurityRule
func newSecurityRule(p newSecurityRuleParams) network.SecurityRule { return network.SecurityRule{ Name: to.StringPtr(p.name), SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{ Description: to.StringPtr(p.description), Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefix: to.StringPtr("*"), SourcePortRange: to.StringPtr("*"), DestinationAddressPrefix: to.StringPtr(p.destPrefix), DestinationPortRange: to.StringPtr(fmt.Sprint(p.port)), Access: network.SecurityRuleAccessAllow, Priority: to.Int32Ptr(int32(p.priority)), Direction: network.SecurityRuleDirectionInbound, }, } }
go
func newSecurityRule(p newSecurityRuleParams) network.SecurityRule { return network.SecurityRule{ Name: to.StringPtr(p.name), SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{ Description: to.StringPtr(p.description), Protocol: network.SecurityRuleProtocolTCP, SourceAddressPrefix: to.StringPtr("*"), SourcePortRange: to.StringPtr("*"), DestinationAddressPrefix: to.StringPtr(p.destPrefix), DestinationPortRange: to.StringPtr(fmt.Sprint(p.port)), Access: network.SecurityRuleAccessAllow, Priority: to.Int32Ptr(int32(p.priority)), Direction: network.SecurityRuleDirectionInbound, }, } }
[ "func", "newSecurityRule", "(", "p", "newSecurityRuleParams", ")", "network", ".", "SecurityRule", "{", "return", "network", ".", "SecurityRule", "{", "Name", ":", "to", ".", "StringPtr", "(", "p", ".", "name", ")", ",", "SecurityRulePropertiesFormat", ":", "&", "network", ".", "SecurityRulePropertiesFormat", "{", "Description", ":", "to", ".", "StringPtr", "(", "p", ".", "description", ")", ",", "Protocol", ":", "network", ".", "SecurityRuleProtocolTCP", ",", "SourceAddressPrefix", ":", "to", ".", "StringPtr", "(", "\"", "\"", ")", ",", "SourcePortRange", ":", "to", ".", "StringPtr", "(", "\"", "\"", ")", ",", "DestinationAddressPrefix", ":", "to", ".", "StringPtr", "(", "p", ".", "destPrefix", ")", ",", "DestinationPortRange", ":", "to", ".", "StringPtr", "(", "fmt", ".", "Sprint", "(", "p", ".", "port", ")", ")", ",", "Access", ":", "network", ".", "SecurityRuleAccessAllow", ",", "Priority", ":", "to", ".", "Int32Ptr", "(", "int32", "(", "p", ".", "priority", ")", ")", ",", "Direction", ":", "network", ".", "SecurityRuleDirectionInbound", ",", "}", ",", "}", "\n", "}" ]
// newSecurityRule returns a security rule with the given parameters.
[ "newSecurityRule", "returns", "a", "security", "rule", "with", "the", "given", "parameters", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/networking.go#L83-L98
157,323
juju/juju
provider/azure/networking.go
networkTemplateResources
func networkTemplateResources( location string, envTags map[string]string, apiPorts []int, extraRules []network.SecurityRule, ) []armtemplates.Resource { // Create a network security group for the environment. There is only // one NSG per environment (there's a limit of 100 per subscription), // in which we manage rules for each exposed machine. securityRules := []network.SecurityRule{newSecurityRule(newSecurityRuleParams{ name: sshSecurityRuleName, description: "Allow SSH access to all machines", destPrefix: "*", port: 22, priority: securityRuleInternalSSHInbound, })} for i, apiPort := range apiPorts { securityRules = append(securityRules, newSecurityRule(newSecurityRuleParams{ // Two rules cannot have the same name. name: fmt.Sprintf("%s%d", apiSecurityRulePrefix, apiPort), description: "Allow API connections to controller machines", destPrefix: controllerSubnetPrefix, port: apiPort, // Two rules cannot have the same priority and direction. priority: securityRuleInternalAPIInbound + i, })) } securityRules = append(securityRules, extraRules...) nsgID := fmt.Sprintf( `[resourceId('Microsoft.Network/networkSecurityGroups', '%s')]`, internalSecurityGroupName, ) subnets := []network.Subnet{{ Name: to.StringPtr(internalSubnetName), SubnetPropertiesFormat: &network.SubnetPropertiesFormat{ AddressPrefix: to.StringPtr(internalSubnetPrefix), NetworkSecurityGroup: &network.SecurityGroup{ ID: to.StringPtr(nsgID), }, }, }} if len(apiPorts) > 0 { subnets = append(subnets, network.Subnet{ Name: to.StringPtr(controllerSubnetName), SubnetPropertiesFormat: &network.SubnetPropertiesFormat{ AddressPrefix: to.StringPtr(controllerSubnetPrefix), NetworkSecurityGroup: &network.SecurityGroup{ ID: to.StringPtr(nsgID), }, }, }) } addressPrefixes := []string{internalSubnetPrefix, controllerSubnetPrefix} resources := []armtemplates.Resource{{ APIVersion: networkAPIVersion, Type: "Microsoft.Network/networkSecurityGroups", Name: internalSecurityGroupName, Location: location, Tags: envTags, Properties: &network.SecurityGroupPropertiesFormat{ SecurityRules: &securityRules, }, }, { APIVersion: networkAPIVersion, Type: "Microsoft.Network/virtualNetworks", Name: internalNetworkName, Location: location, Tags: envTags, Properties: &network.VirtualNetworkPropertiesFormat{ AddressSpace: &network.AddressSpace{&addressPrefixes}, Subnets: &subnets, }, DependsOn: []string{nsgID}, }} return resources }
go
func networkTemplateResources( location string, envTags map[string]string, apiPorts []int, extraRules []network.SecurityRule, ) []armtemplates.Resource { // Create a network security group for the environment. There is only // one NSG per environment (there's a limit of 100 per subscription), // in which we manage rules for each exposed machine. securityRules := []network.SecurityRule{newSecurityRule(newSecurityRuleParams{ name: sshSecurityRuleName, description: "Allow SSH access to all machines", destPrefix: "*", port: 22, priority: securityRuleInternalSSHInbound, })} for i, apiPort := range apiPorts { securityRules = append(securityRules, newSecurityRule(newSecurityRuleParams{ // Two rules cannot have the same name. name: fmt.Sprintf("%s%d", apiSecurityRulePrefix, apiPort), description: "Allow API connections to controller machines", destPrefix: controllerSubnetPrefix, port: apiPort, // Two rules cannot have the same priority and direction. priority: securityRuleInternalAPIInbound + i, })) } securityRules = append(securityRules, extraRules...) nsgID := fmt.Sprintf( `[resourceId('Microsoft.Network/networkSecurityGroups', '%s')]`, internalSecurityGroupName, ) subnets := []network.Subnet{{ Name: to.StringPtr(internalSubnetName), SubnetPropertiesFormat: &network.SubnetPropertiesFormat{ AddressPrefix: to.StringPtr(internalSubnetPrefix), NetworkSecurityGroup: &network.SecurityGroup{ ID: to.StringPtr(nsgID), }, }, }} if len(apiPorts) > 0 { subnets = append(subnets, network.Subnet{ Name: to.StringPtr(controllerSubnetName), SubnetPropertiesFormat: &network.SubnetPropertiesFormat{ AddressPrefix: to.StringPtr(controllerSubnetPrefix), NetworkSecurityGroup: &network.SecurityGroup{ ID: to.StringPtr(nsgID), }, }, }) } addressPrefixes := []string{internalSubnetPrefix, controllerSubnetPrefix} resources := []armtemplates.Resource{{ APIVersion: networkAPIVersion, Type: "Microsoft.Network/networkSecurityGroups", Name: internalSecurityGroupName, Location: location, Tags: envTags, Properties: &network.SecurityGroupPropertiesFormat{ SecurityRules: &securityRules, }, }, { APIVersion: networkAPIVersion, Type: "Microsoft.Network/virtualNetworks", Name: internalNetworkName, Location: location, Tags: envTags, Properties: &network.VirtualNetworkPropertiesFormat{ AddressSpace: &network.AddressSpace{&addressPrefixes}, Subnets: &subnets, }, DependsOn: []string{nsgID}, }} return resources }
[ "func", "networkTemplateResources", "(", "location", "string", ",", "envTags", "map", "[", "string", "]", "string", ",", "apiPorts", "[", "]", "int", ",", "extraRules", "[", "]", "network", ".", "SecurityRule", ",", ")", "[", "]", "armtemplates", ".", "Resource", "{", "// Create a network security group for the environment. There is only", "// one NSG per environment (there's a limit of 100 per subscription),", "// in which we manage rules for each exposed machine.", "securityRules", ":=", "[", "]", "network", ".", "SecurityRule", "{", "newSecurityRule", "(", "newSecurityRuleParams", "{", "name", ":", "sshSecurityRuleName", ",", "description", ":", "\"", "\"", ",", "destPrefix", ":", "\"", "\"", ",", "port", ":", "22", ",", "priority", ":", "securityRuleInternalSSHInbound", ",", "}", ")", "}", "\n", "for", "i", ",", "apiPort", ":=", "range", "apiPorts", "{", "securityRules", "=", "append", "(", "securityRules", ",", "newSecurityRule", "(", "newSecurityRuleParams", "{", "// Two rules cannot have the same name.", "name", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "apiSecurityRulePrefix", ",", "apiPort", ")", ",", "description", ":", "\"", "\"", ",", "destPrefix", ":", "controllerSubnetPrefix", ",", "port", ":", "apiPort", ",", "// Two rules cannot have the same priority and direction.", "priority", ":", "securityRuleInternalAPIInbound", "+", "i", ",", "}", ")", ")", "\n", "}", "\n", "securityRules", "=", "append", "(", "securityRules", ",", "extraRules", "...", ")", "\n\n", "nsgID", ":=", "fmt", ".", "Sprintf", "(", "`[resourceId('Microsoft.Network/networkSecurityGroups', '%s')]`", ",", "internalSecurityGroupName", ",", ")", "\n", "subnets", ":=", "[", "]", "network", ".", "Subnet", "{", "{", "Name", ":", "to", ".", "StringPtr", "(", "internalSubnetName", ")", ",", "SubnetPropertiesFormat", ":", "&", "network", ".", "SubnetPropertiesFormat", "{", "AddressPrefix", ":", "to", ".", "StringPtr", "(", "internalSubnetPrefix", ")", ",", "NetworkSecurityGroup", ":", "&", "network", ".", "SecurityGroup", "{", "ID", ":", "to", ".", "StringPtr", "(", "nsgID", ")", ",", "}", ",", "}", ",", "}", "}", "\n", "if", "len", "(", "apiPorts", ")", ">", "0", "{", "subnets", "=", "append", "(", "subnets", ",", "network", ".", "Subnet", "{", "Name", ":", "to", ".", "StringPtr", "(", "controllerSubnetName", ")", ",", "SubnetPropertiesFormat", ":", "&", "network", ".", "SubnetPropertiesFormat", "{", "AddressPrefix", ":", "to", ".", "StringPtr", "(", "controllerSubnetPrefix", ")", ",", "NetworkSecurityGroup", ":", "&", "network", ".", "SecurityGroup", "{", "ID", ":", "to", ".", "StringPtr", "(", "nsgID", ")", ",", "}", ",", "}", ",", "}", ")", "\n", "}", "\n\n", "addressPrefixes", ":=", "[", "]", "string", "{", "internalSubnetPrefix", ",", "controllerSubnetPrefix", "}", "\n", "resources", ":=", "[", "]", "armtemplates", ".", "Resource", "{", "{", "APIVersion", ":", "networkAPIVersion", ",", "Type", ":", "\"", "\"", ",", "Name", ":", "internalSecurityGroupName", ",", "Location", ":", "location", ",", "Tags", ":", "envTags", ",", "Properties", ":", "&", "network", ".", "SecurityGroupPropertiesFormat", "{", "SecurityRules", ":", "&", "securityRules", ",", "}", ",", "}", ",", "{", "APIVersion", ":", "networkAPIVersion", ",", "Type", ":", "\"", "\"", ",", "Name", ":", "internalNetworkName", ",", "Location", ":", "location", ",", "Tags", ":", "envTags", ",", "Properties", ":", "&", "network", ".", "VirtualNetworkPropertiesFormat", "{", "AddressSpace", ":", "&", "network", ".", "AddressSpace", "{", "&", "addressPrefixes", "}", ",", "Subnets", ":", "&", "subnets", ",", "}", ",", "DependsOn", ":", "[", "]", "string", "{", "nsgID", "}", ",", "}", "}", "\n\n", "return", "resources", "\n", "}" ]
// networkTemplateResources returns resource definitions for creating network // resources shared by all machines in a model. // // If apiPort is -1, then there should be no controller subnet created, and // no network security rule allowing Juju API traffic.
[ "networkTemplateResources", "returns", "resource", "definitions", "for", "creating", "network", "resources", "shared", "by", "all", "machines", "in", "a", "model", ".", "If", "apiPort", "is", "-", "1", "then", "there", "should", "be", "no", "controller", "subnet", "created", "and", "no", "network", "security", "rule", "allowing", "Juju", "API", "traffic", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/networking.go#L115-L193
157,324
juju/juju
provider/azure/networking.go
nextSecurityRulePriority
func nextSecurityRulePriority(group network.SecurityGroup, min, max int32) (int32, error) { if group.SecurityRules == nil { return min, nil } for p := min; p <= max; p++ { var found bool for _, rule := range *group.SecurityRules { if to.Int32(rule.Priority) == p { found = true break } } if !found { return p, nil } } return -1, errors.Errorf( "no priorities available in the range [%d, %d]", min, max, ) }
go
func nextSecurityRulePriority(group network.SecurityGroup, min, max int32) (int32, error) { if group.SecurityRules == nil { return min, nil } for p := min; p <= max; p++ { var found bool for _, rule := range *group.SecurityRules { if to.Int32(rule.Priority) == p { found = true break } } if !found { return p, nil } } return -1, errors.Errorf( "no priorities available in the range [%d, %d]", min, max, ) }
[ "func", "nextSecurityRulePriority", "(", "group", "network", ".", "SecurityGroup", ",", "min", ",", "max", "int32", ")", "(", "int32", ",", "error", ")", "{", "if", "group", ".", "SecurityRules", "==", "nil", "{", "return", "min", ",", "nil", "\n", "}", "\n", "for", "p", ":=", "min", ";", "p", "<=", "max", ";", "p", "++", "{", "var", "found", "bool", "\n", "for", "_", ",", "rule", ":=", "range", "*", "group", ".", "SecurityRules", "{", "if", "to", ".", "Int32", "(", "rule", ".", "Priority", ")", "==", "p", "{", "found", "=", "true", "\n", "break", "\n", "}", "\n", "}", "\n", "if", "!", "found", "{", "return", "p", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "-", "1", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "min", ",", "max", ",", ")", "\n", "}" ]
// nextSecurityRulePriority returns the next available priority in the given // security group within a specified range.
[ "nextSecurityRulePriority", "returns", "the", "next", "available", "priority", "in", "the", "given", "security", "group", "within", "a", "specified", "range", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/networking.go#L197-L216
157,325
juju/juju
provider/azure/networking.go
machineSubnetIP
func machineSubnetIP(subnetPrefix, machineId string) (net.IP, error) { _, ipnet, err := net.ParseCIDR(subnetPrefix) if err != nil { return nil, errors.Annotate(err, "parsing subnet prefix") } n, err := strconv.Atoi(machineId) if err != nil { return nil, errors.Annotate(err, "parsing machine ID") } ip := iputils.NthSubnetIP(ipnet, n) if ip == nil { // TODO(axw) getting nil means we've cycled through roughly // 2^12 machines. To work around this limitation, we must // maintain an in-memory set of in-use IP addresses for each // subnet. return nil, errors.Errorf( "no available IP addresses in %s", subnetPrefix, ) } return ip, nil }
go
func machineSubnetIP(subnetPrefix, machineId string) (net.IP, error) { _, ipnet, err := net.ParseCIDR(subnetPrefix) if err != nil { return nil, errors.Annotate(err, "parsing subnet prefix") } n, err := strconv.Atoi(machineId) if err != nil { return nil, errors.Annotate(err, "parsing machine ID") } ip := iputils.NthSubnetIP(ipnet, n) if ip == nil { // TODO(axw) getting nil means we've cycled through roughly // 2^12 machines. To work around this limitation, we must // maintain an in-memory set of in-use IP addresses for each // subnet. return nil, errors.Errorf( "no available IP addresses in %s", subnetPrefix, ) } return ip, nil }
[ "func", "machineSubnetIP", "(", "subnetPrefix", ",", "machineId", "string", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "_", ",", "ipnet", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "subnetPrefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "n", ",", "err", ":=", "strconv", ".", "Atoi", "(", "machineId", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "ip", ":=", "iputils", ".", "NthSubnetIP", "(", "ipnet", ",", "n", ")", "\n", "if", "ip", "==", "nil", "{", "// TODO(axw) getting nil means we've cycled through roughly", "// 2^12 machines. To work around this limitation, we must", "// maintain an in-memory set of in-use IP addresses for each", "// subnet.", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "subnetPrefix", ",", ")", "\n", "}", "\n", "return", "ip", ",", "nil", "\n", "}" ]
// machineSubnetIP returns the private IP address to use for the given // subnet prefix.
[ "machineSubnetIP", "returns", "the", "private", "IP", "address", "to", "use", "for", "the", "given", "subnet", "prefix", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/networking.go#L220-L240
157,326
juju/juju
provider/azure/networking.go
networkSecurityRules
func networkSecurityRules( nsgClient network.SecurityGroupsClient, resourceGroup string, ) ([]network.SecurityRule, error) { sdkCtx := context.Background() nsg, err := nsgClient.Get(sdkCtx, resourceGroup, internalSecurityGroupName, "") if err != nil { if isNotFoundResult(nsg.Response) { return nil, errors.NotFoundf("security group") } return nil, errors.Annotate(err, "querying network security group") } var rules []network.SecurityRule if nsg.SecurityRules != nil { rules = *nsg.SecurityRules } return rules, nil }
go
func networkSecurityRules( nsgClient network.SecurityGroupsClient, resourceGroup string, ) ([]network.SecurityRule, error) { sdkCtx := context.Background() nsg, err := nsgClient.Get(sdkCtx, resourceGroup, internalSecurityGroupName, "") if err != nil { if isNotFoundResult(nsg.Response) { return nil, errors.NotFoundf("security group") } return nil, errors.Annotate(err, "querying network security group") } var rules []network.SecurityRule if nsg.SecurityRules != nil { rules = *nsg.SecurityRules } return rules, nil }
[ "func", "networkSecurityRules", "(", "nsgClient", "network", ".", "SecurityGroupsClient", ",", "resourceGroup", "string", ",", ")", "(", "[", "]", "network", ".", "SecurityRule", ",", "error", ")", "{", "sdkCtx", ":=", "context", ".", "Background", "(", ")", "\n", "nsg", ",", "err", ":=", "nsgClient", ".", "Get", "(", "sdkCtx", ",", "resourceGroup", ",", "internalSecurityGroupName", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "if", "isNotFoundResult", "(", "nsg", ".", "Response", ")", "{", "return", "nil", ",", "errors", ".", "NotFoundf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n", "var", "rules", "[", "]", "network", ".", "SecurityRule", "\n", "if", "nsg", ".", "SecurityRules", "!=", "nil", "{", "rules", "=", "*", "nsg", ".", "SecurityRules", "\n", "}", "\n", "return", "rules", ",", "nil", "\n", "}" ]
// networkSecurityRules returns the network security rules for the internal // network security group in the specified resource group. If the network // security group has not been created, this function will return an error // satisfying errors.IsNotFound.
[ "networkSecurityRules", "returns", "the", "network", "security", "rules", "for", "the", "internal", "network", "security", "group", "in", "the", "specified", "resource", "group", ".", "If", "the", "network", "security", "group", "has", "not", "been", "created", "this", "function", "will", "return", "an", "error", "satisfying", "errors", ".", "IsNotFound", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/networking.go#L246-L263
157,327
juju/juju
core/cache/application.go
CharmURL
func (a *Application) CharmURL() string { a.mu.Lock() defer a.mu.Unlock() return a.details.CharmURL }
go
func (a *Application) CharmURL() string { a.mu.Lock() defer a.mu.Unlock() return a.details.CharmURL }
[ "func", "(", "a", "*", "Application", ")", "CharmURL", "(", ")", "string", "{", "a", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "a", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "a", ".", "details", ".", "CharmURL", "\n", "}" ]
// CharmURL returns the charm url string for this application.
[ "CharmURL", "returns", "the", "charm", "url", "string", "for", "this", "application", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/application.go#L45-L49
157,328
juju/juju
core/cache/application.go
Config
func (a *Application) Config() map[string]interface{} { a.mu.Lock() cfg := make(map[string]interface{}, len(a.details.Config)) for k, v := range a.details.Config { cfg[k] = v } a.mu.Unlock() a.metrics.ApplicationConfigReads.Inc() return cfg }
go
func (a *Application) Config() map[string]interface{} { a.mu.Lock() cfg := make(map[string]interface{}, len(a.details.Config)) for k, v := range a.details.Config { cfg[k] = v } a.mu.Unlock() a.metrics.ApplicationConfigReads.Inc() return cfg }
[ "func", "(", "a", "*", "Application", ")", "Config", "(", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "a", ".", "mu", ".", "Lock", "(", ")", "\n", "cfg", ":=", "make", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "len", "(", "a", ".", "details", ".", "Config", ")", ")", "\n", "for", "k", ",", "v", ":=", "range", "a", ".", "details", ".", "Config", "{", "cfg", "[", "k", "]", "=", "v", "\n", "}", "\n", "a", ".", "mu", ".", "Unlock", "(", ")", "\n", "a", ".", "metrics", ".", "ApplicationConfigReads", ".", "Inc", "(", ")", "\n", "return", "cfg", "\n", "}" ]
// Config returns a copy of the current application config.
[ "Config", "returns", "a", "copy", "of", "the", "current", "application", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/application.go#L52-L61
157,329
juju/juju
core/cache/application.go
WatchConfig
func (a *Application) WatchConfig(keys ...string) *ConfigWatcher { w := newConfigWatcher(keys, a.hashCache, a.hub, a.topic(applicationConfigChange), a.Resident) return w }
go
func (a *Application) WatchConfig(keys ...string) *ConfigWatcher { w := newConfigWatcher(keys, a.hashCache, a.hub, a.topic(applicationConfigChange), a.Resident) return w }
[ "func", "(", "a", "*", "Application", ")", "WatchConfig", "(", "keys", "...", "string", ")", "*", "ConfigWatcher", "{", "w", ":=", "newConfigWatcher", "(", "keys", ",", "a", ".", "hashCache", ",", "a", ".", "hub", ",", "a", ".", "topic", "(", "applicationConfigChange", ")", ",", "a", ".", "Resident", ")", "\n", "return", "w", "\n", "}" ]
// WatchConfig creates a watcher for the application config.
[ "WatchConfig", "creates", "a", "watcher", "for", "the", "application", "config", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/core/cache/application.go#L64-L67
157,330
juju/juju
upgrades/steps_23.go
stateStepsFor23
func stateStepsFor23() []Step { return []Step{ &upgradeStep{ description: "add a 'type' field to model documents", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().AddModelType() }, }, &upgradeStep{ description: "migrate old leases", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().MigrateLeasesToGlobalTime() }, }, } }
go
func stateStepsFor23() []Step { return []Step{ &upgradeStep{ description: "add a 'type' field to model documents", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().AddModelType() }, }, &upgradeStep{ description: "migrate old leases", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().MigrateLeasesToGlobalTime() }, }, } }
[ "func", "stateStepsFor23", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", "context", "Context", ")", "error", "{", "return", "context", ".", "State", "(", ")", ".", "AddModelType", "(", ")", "\n", "}", ",", "}", ",", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", "context", "Context", ")", "error", "{", "return", "context", ".", "State", "(", ")", ".", "MigrateLeasesToGlobalTime", "(", ")", "\n", "}", ",", "}", ",", "}", "\n", "}" ]
// stateStepsFor23 returns upgrade steps for Juju 2.3.0 that manipulate state directly.
[ "stateStepsFor23", "returns", "upgrade", "steps", "for", "Juju", "2", ".", "3", ".", "0", "that", "manipulate", "state", "directly", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_23.go#L7-L24
157,331
juju/juju
upgrades/steps_23.go
stateStepsFor231
func stateStepsFor231() []Step { return []Step{ &upgradeStep{ description: "add status to relations", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().AddRelationStatus() }, }, } }
go
func stateStepsFor231() []Step { return []Step{ &upgradeStep{ description: "add status to relations", targets: []Target{DatabaseMaster}, run: func(context Context) error { return context.State().AddRelationStatus() }, }, } }
[ "func", "stateStepsFor231", "(", ")", "[", "]", "Step", "{", "return", "[", "]", "Step", "{", "&", "upgradeStep", "{", "description", ":", "\"", "\"", ",", "targets", ":", "[", "]", "Target", "{", "DatabaseMaster", "}", ",", "run", ":", "func", "(", "context", "Context", ")", "error", "{", "return", "context", ".", "State", "(", ")", ".", "AddRelationStatus", "(", ")", "\n", "}", ",", "}", ",", "}", "\n", "}" ]
// stateStepsFor231 returns upgrade steps for Juju 2.3.1 that manipulate state directly.
[ "stateStepsFor231", "returns", "upgrade", "steps", "for", "Juju", "2", ".", "3", ".", "1", "that", "manipulate", "state", "directly", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/upgrades/steps_23.go#L27-L37
157,332
juju/juju
environs/imagemetadata/marshal.go
MarshalImageMetadataJSON
func MarshalImageMetadataJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (index, products []byte, err error) { if index, err = MarshalImageMetadataIndexJSON(metadata, cloudSpec, updated); err != nil { return nil, nil, err } if products, err = MarshalImageMetadataProductsJSON(metadata, updated); err != nil { return nil, nil, err } return index, products, err }
go
func MarshalImageMetadataJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (index, products []byte, err error) { if index, err = MarshalImageMetadataIndexJSON(metadata, cloudSpec, updated); err != nil { return nil, nil, err } if products, err = MarshalImageMetadataProductsJSON(metadata, updated); err != nil { return nil, nil, err } return index, products, err }
[ "func", "MarshalImageMetadataJSON", "(", "metadata", "[", "]", "*", "ImageMetadata", ",", "cloudSpec", "[", "]", "simplestreams", ".", "CloudSpec", ",", "updated", "time", ".", "Time", ")", "(", "index", ",", "products", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "index", ",", "err", "=", "MarshalImageMetadataIndexJSON", "(", "metadata", ",", "cloudSpec", ",", "updated", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "if", "products", ",", "err", "=", "MarshalImageMetadataProductsJSON", "(", "metadata", ",", "updated", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "return", "index", ",", "products", ",", "err", "\n", "}" ]
// MarshalImageMetadataJSON marshals image metadata to index and products JSON. // // updated is the time at which the JSON file was updated.
[ "MarshalImageMetadataJSON", "marshals", "image", "metadata", "to", "index", "and", "products", "JSON", ".", "updated", "is", "the", "time", "at", "which", "the", "JSON", "file", "was", "updated", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/imagemetadata/marshal.go#L23-L33
157,333
juju/juju
environs/imagemetadata/marshal.go
MarshalImageMetadataIndexJSON
func MarshalImageMetadataIndexJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (out []byte, err error) { productIds := make([]string, len(metadata)) for i, t := range metadata { productIds[i] = t.productId() } var indices simplestreams.Indices indices.Updated = updated.Format(time.RFC1123Z) indices.Format = simplestreams.IndexFormat indices.Indexes = map[string]*simplestreams.IndexMetadata{ ImageContentId: { CloudName: "custom", Updated: indices.Updated, Format: simplestreams.ProductFormat, DataType: "image-ids", ProductsFilePath: ProductMetadataPath, ProductIds: set.NewStrings(productIds...).SortedValues(), Clouds: cloudSpec, }, } return json.MarshalIndent(&indices, "", " ") }
go
func MarshalImageMetadataIndexJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (out []byte, err error) { productIds := make([]string, len(metadata)) for i, t := range metadata { productIds[i] = t.productId() } var indices simplestreams.Indices indices.Updated = updated.Format(time.RFC1123Z) indices.Format = simplestreams.IndexFormat indices.Indexes = map[string]*simplestreams.IndexMetadata{ ImageContentId: { CloudName: "custom", Updated: indices.Updated, Format: simplestreams.ProductFormat, DataType: "image-ids", ProductsFilePath: ProductMetadataPath, ProductIds: set.NewStrings(productIds...).SortedValues(), Clouds: cloudSpec, }, } return json.MarshalIndent(&indices, "", " ") }
[ "func", "MarshalImageMetadataIndexJSON", "(", "metadata", "[", "]", "*", "ImageMetadata", ",", "cloudSpec", "[", "]", "simplestreams", ".", "CloudSpec", ",", "updated", "time", ".", "Time", ")", "(", "out", "[", "]", "byte", ",", "err", "error", ")", "{", "productIds", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "metadata", ")", ")", "\n", "for", "i", ",", "t", ":=", "range", "metadata", "{", "productIds", "[", "i", "]", "=", "t", ".", "productId", "(", ")", "\n", "}", "\n", "var", "indices", "simplestreams", ".", "Indices", "\n", "indices", ".", "Updated", "=", "updated", ".", "Format", "(", "time", ".", "RFC1123Z", ")", "\n", "indices", ".", "Format", "=", "simplestreams", ".", "IndexFormat", "\n", "indices", ".", "Indexes", "=", "map", "[", "string", "]", "*", "simplestreams", ".", "IndexMetadata", "{", "ImageContentId", ":", "{", "CloudName", ":", "\"", "\"", ",", "Updated", ":", "indices", ".", "Updated", ",", "Format", ":", "simplestreams", ".", "ProductFormat", ",", "DataType", ":", "\"", "\"", ",", "ProductsFilePath", ":", "ProductMetadataPath", ",", "ProductIds", ":", "set", ".", "NewStrings", "(", "productIds", "...", ")", ".", "SortedValues", "(", ")", ",", "Clouds", ":", "cloudSpec", ",", "}", ",", "}", "\n", "return", "json", ".", "MarshalIndent", "(", "&", "indices", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}" ]
// MarshalImageMetadataIndexJSON marshals image metadata to index JSON. // // updated is the time at which the JSON file was updated.
[ "MarshalImageMetadataIndexJSON", "marshals", "image", "metadata", "to", "index", "JSON", ".", "updated", "is", "the", "time", "at", "which", "the", "JSON", "file", "was", "updated", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/imagemetadata/marshal.go#L38-L60
157,334
juju/juju
environs/imagemetadata/marshal.go
MarshalImageMetadataProductsJSON
func MarshalImageMetadataProductsJSON(metadata []*ImageMetadata, updated time.Time) (out []byte, err error) { var cloud simplestreams.CloudMetadata cloud.Updated = updated.Format(time.RFC1123Z) cloud.Format = simplestreams.ProductFormat cloud.ContentId = ImageContentId cloud.Products = make(map[string]simplestreams.MetadataCatalog) itemsversion := updated.Format("20060102") // YYYYMMDD for _, t := range metadata { toWrite := *t // These fields are not required in the individual // record values - they are recorded at the top level. toWrite.RegionAlias = "" toWrite.Version = "" toWrite.Arch = "" if catalog, ok := cloud.Products[t.productId()]; ok { catalog.Items[itemsversion].Items[t.Id] = toWrite } else { catalog = simplestreams.MetadataCatalog{ Arch: t.Arch, Version: t.Version, Items: map[string]*simplestreams.ItemCollection{ itemsversion: { Items: map[string]interface{}{t.Id: toWrite}, }, }, } cloud.Products[t.productId()] = catalog } } return json.MarshalIndent(&cloud, "", " ") }
go
func MarshalImageMetadataProductsJSON(metadata []*ImageMetadata, updated time.Time) (out []byte, err error) { var cloud simplestreams.CloudMetadata cloud.Updated = updated.Format(time.RFC1123Z) cloud.Format = simplestreams.ProductFormat cloud.ContentId = ImageContentId cloud.Products = make(map[string]simplestreams.MetadataCatalog) itemsversion := updated.Format("20060102") // YYYYMMDD for _, t := range metadata { toWrite := *t // These fields are not required in the individual // record values - they are recorded at the top level. toWrite.RegionAlias = "" toWrite.Version = "" toWrite.Arch = "" if catalog, ok := cloud.Products[t.productId()]; ok { catalog.Items[itemsversion].Items[t.Id] = toWrite } else { catalog = simplestreams.MetadataCatalog{ Arch: t.Arch, Version: t.Version, Items: map[string]*simplestreams.ItemCollection{ itemsversion: { Items: map[string]interface{}{t.Id: toWrite}, }, }, } cloud.Products[t.productId()] = catalog } } return json.MarshalIndent(&cloud, "", " ") }
[ "func", "MarshalImageMetadataProductsJSON", "(", "metadata", "[", "]", "*", "ImageMetadata", ",", "updated", "time", ".", "Time", ")", "(", "out", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "cloud", "simplestreams", ".", "CloudMetadata", "\n", "cloud", ".", "Updated", "=", "updated", ".", "Format", "(", "time", ".", "RFC1123Z", ")", "\n", "cloud", ".", "Format", "=", "simplestreams", ".", "ProductFormat", "\n", "cloud", ".", "ContentId", "=", "ImageContentId", "\n", "cloud", ".", "Products", "=", "make", "(", "map", "[", "string", "]", "simplestreams", ".", "MetadataCatalog", ")", "\n", "itemsversion", ":=", "updated", ".", "Format", "(", "\"", "\"", ")", "// YYYYMMDD", "\n", "for", "_", ",", "t", ":=", "range", "metadata", "{", "toWrite", ":=", "*", "t", "\n", "// These fields are not required in the individual", "// record values - they are recorded at the top level.", "toWrite", ".", "RegionAlias", "=", "\"", "\"", "\n", "toWrite", ".", "Version", "=", "\"", "\"", "\n", "toWrite", ".", "Arch", "=", "\"", "\"", "\n", "if", "catalog", ",", "ok", ":=", "cloud", ".", "Products", "[", "t", ".", "productId", "(", ")", "]", ";", "ok", "{", "catalog", ".", "Items", "[", "itemsversion", "]", ".", "Items", "[", "t", ".", "Id", "]", "=", "toWrite", "\n", "}", "else", "{", "catalog", "=", "simplestreams", ".", "MetadataCatalog", "{", "Arch", ":", "t", ".", "Arch", ",", "Version", ":", "t", ".", "Version", ",", "Items", ":", "map", "[", "string", "]", "*", "simplestreams", ".", "ItemCollection", "{", "itemsversion", ":", "{", "Items", ":", "map", "[", "string", "]", "interface", "{", "}", "{", "t", ".", "Id", ":", "toWrite", "}", ",", "}", ",", "}", ",", "}", "\n", "cloud", ".", "Products", "[", "t", ".", "productId", "(", ")", "]", "=", "catalog", "\n", "}", "\n", "}", "\n", "return", "json", ".", "MarshalIndent", "(", "&", "cloud", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "}" ]
// MarshalImageMetadataProductsJSON marshals image metadata to products JSON. // // updated is the time at which the JSON file was updated.
[ "MarshalImageMetadataProductsJSON", "marshals", "image", "metadata", "to", "products", "JSON", ".", "updated", "is", "the", "time", "at", "which", "the", "JSON", "file", "was", "updated", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/imagemetadata/marshal.go#L65-L95
157,335
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
NewMockInterface
func NewMockInterface(ctrl *gomock.Controller) *MockInterface { mock := &MockInterface{ctrl: ctrl} mock.recorder = &MockInterfaceMockRecorder{mock} return mock }
go
func NewMockInterface(ctrl *gomock.Controller) *MockInterface { mock := &MockInterface{ctrl: ctrl} mock.recorder = &MockInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockInterface", "{", "mock", ":=", "&", "MockInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockInterfaceMockRecorder", "{", "mock", "}", "\n", "return", "mock", "\n", "}" ]
// NewMockInterface creates a new mock instance
[ "NewMockInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L56-L60
157,336
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Admissionregistration
func (m *MockInterface) Admissionregistration() v1beta1.AdmissionregistrationV1beta1Interface { ret := m.ctrl.Call(m, "Admissionregistration") ret0, _ := ret[0].(v1beta1.AdmissionregistrationV1beta1Interface) return ret0 }
go
func (m *MockInterface) Admissionregistration() v1beta1.AdmissionregistrationV1beta1Interface { ret := m.ctrl.Call(m, "Admissionregistration") ret0, _ := ret[0].(v1beta1.AdmissionregistrationV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Admissionregistration", "(", ")", "v1beta1", ".", "AdmissionregistrationV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta1", ".", "AdmissionregistrationV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Admissionregistration mocks base method
[ "Admissionregistration", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L68-L72
157,337
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Admissionregistration
func (mr *MockInterfaceMockRecorder) Admissionregistration() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Admissionregistration", reflect.TypeOf((*MockInterface)(nil).Admissionregistration)) }
go
func (mr *MockInterfaceMockRecorder) Admissionregistration() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Admissionregistration", reflect.TypeOf((*MockInterface)(nil).Admissionregistration)) }
[ "func", "(", "mr", "*", "MockInterfaceMockRecorder", ")", "Admissionregistration", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflect", ".", "TypeOf", "(", "(", "*", "MockInterface", ")", "(", "nil", ")", ".", "Admissionregistration", ")", ")", "\n", "}" ]
// Admissionregistration indicates an expected call of Admissionregistration
[ "Admissionregistration", "indicates", "an", "expected", "call", "of", "Admissionregistration" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L75-L77
157,338
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AdmissionregistrationV1alpha1
func (m *MockInterface) AdmissionregistrationV1alpha1() v1alpha1.AdmissionregistrationV1alpha1Interface { ret := m.ctrl.Call(m, "AdmissionregistrationV1alpha1") ret0, _ := ret[0].(v1alpha1.AdmissionregistrationV1alpha1Interface) return ret0 }
go
func (m *MockInterface) AdmissionregistrationV1alpha1() v1alpha1.AdmissionregistrationV1alpha1Interface { ret := m.ctrl.Call(m, "AdmissionregistrationV1alpha1") ret0, _ := ret[0].(v1alpha1.AdmissionregistrationV1alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AdmissionregistrationV1alpha1", "(", ")", "v1alpha1", ".", "AdmissionregistrationV1alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1alpha1", ".", "AdmissionregistrationV1alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AdmissionregistrationV1alpha1 mocks base method
[ "AdmissionregistrationV1alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L80-L84
157,339
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Apps
func (m *MockInterface) Apps() v1.AppsV1Interface { ret := m.ctrl.Call(m, "Apps") ret0, _ := ret[0].(v1.AppsV1Interface) return ret0 }
go
func (m *MockInterface) Apps() v1.AppsV1Interface { ret := m.ctrl.Call(m, "Apps") ret0, _ := ret[0].(v1.AppsV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Apps", "(", ")", "v1", ".", "AppsV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1", ".", "AppsV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Apps mocks base method
[ "Apps", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L104-L108
157,340
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AppsV1beta1
func (m *MockInterface) AppsV1beta1() v1beta10.AppsV1beta1Interface { ret := m.ctrl.Call(m, "AppsV1beta1") ret0, _ := ret[0].(v1beta10.AppsV1beta1Interface) return ret0 }
go
func (m *MockInterface) AppsV1beta1() v1beta10.AppsV1beta1Interface { ret := m.ctrl.Call(m, "AppsV1beta1") ret0, _ := ret[0].(v1beta10.AppsV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AppsV1beta1", "(", ")", "v1beta10", ".", "AppsV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta10", ".", "AppsV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AppsV1beta1 mocks base method
[ "AppsV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L128-L132
157,341
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AppsV1beta2
func (m *MockInterface) AppsV1beta2() v1beta2.AppsV1beta2Interface { ret := m.ctrl.Call(m, "AppsV1beta2") ret0, _ := ret[0].(v1beta2.AppsV1beta2Interface) return ret0 }
go
func (m *MockInterface) AppsV1beta2() v1beta2.AppsV1beta2Interface { ret := m.ctrl.Call(m, "AppsV1beta2") ret0, _ := ret[0].(v1beta2.AppsV1beta2Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AppsV1beta2", "(", ")", "v1beta2", ".", "AppsV1beta2Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta2", ".", "AppsV1beta2Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AppsV1beta2 mocks base method
[ "AppsV1beta2", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L140-L144
157,342
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Authentication
func (m *MockInterface) Authentication() v10.AuthenticationV1Interface { ret := m.ctrl.Call(m, "Authentication") ret0, _ := ret[0].(v10.AuthenticationV1Interface) return ret0 }
go
func (m *MockInterface) Authentication() v10.AuthenticationV1Interface { ret := m.ctrl.Call(m, "Authentication") ret0, _ := ret[0].(v10.AuthenticationV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Authentication", "(", ")", "v10", ".", "AuthenticationV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v10", ".", "AuthenticationV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Authentication mocks base method
[ "Authentication", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L152-L156
157,343
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AuthenticationV1beta1
func (m *MockInterface) AuthenticationV1beta1() v1beta11.AuthenticationV1beta1Interface { ret := m.ctrl.Call(m, "AuthenticationV1beta1") ret0, _ := ret[0].(v1beta11.AuthenticationV1beta1Interface) return ret0 }
go
func (m *MockInterface) AuthenticationV1beta1() v1beta11.AuthenticationV1beta1Interface { ret := m.ctrl.Call(m, "AuthenticationV1beta1") ret0, _ := ret[0].(v1beta11.AuthenticationV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AuthenticationV1beta1", "(", ")", "v1beta11", ".", "AuthenticationV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta11", ".", "AuthenticationV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AuthenticationV1beta1 mocks base method
[ "AuthenticationV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L176-L180
157,344
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AuthorizationV1
func (m *MockInterface) AuthorizationV1() v11.AuthorizationV1Interface { ret := m.ctrl.Call(m, "AuthorizationV1") ret0, _ := ret[0].(v11.AuthorizationV1Interface) return ret0 }
go
func (m *MockInterface) AuthorizationV1() v11.AuthorizationV1Interface { ret := m.ctrl.Call(m, "AuthorizationV1") ret0, _ := ret[0].(v11.AuthorizationV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AuthorizationV1", "(", ")", "v11", ".", "AuthorizationV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v11", ".", "AuthorizationV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AuthorizationV1 mocks base method
[ "AuthorizationV1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L200-L204
157,345
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AuthorizationV1beta1
func (m *MockInterface) AuthorizationV1beta1() v1beta12.AuthorizationV1beta1Interface { ret := m.ctrl.Call(m, "AuthorizationV1beta1") ret0, _ := ret[0].(v1beta12.AuthorizationV1beta1Interface) return ret0 }
go
func (m *MockInterface) AuthorizationV1beta1() v1beta12.AuthorizationV1beta1Interface { ret := m.ctrl.Call(m, "AuthorizationV1beta1") ret0, _ := ret[0].(v1beta12.AuthorizationV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AuthorizationV1beta1", "(", ")", "v1beta12", ".", "AuthorizationV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta12", ".", "AuthorizationV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AuthorizationV1beta1 mocks base method
[ "AuthorizationV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L212-L216
157,346
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Autoscaling
func (m *MockInterface) Autoscaling() v12.AutoscalingV1Interface { ret := m.ctrl.Call(m, "Autoscaling") ret0, _ := ret[0].(v12.AutoscalingV1Interface) return ret0 }
go
func (m *MockInterface) Autoscaling() v12.AutoscalingV1Interface { ret := m.ctrl.Call(m, "Autoscaling") ret0, _ := ret[0].(v12.AutoscalingV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Autoscaling", "(", ")", "v12", ".", "AutoscalingV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v12", ".", "AutoscalingV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Autoscaling mocks base method
[ "Autoscaling", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L224-L228
157,347
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
AutoscalingV2beta1
func (m *MockInterface) AutoscalingV2beta1() v2beta1.AutoscalingV2beta1Interface { ret := m.ctrl.Call(m, "AutoscalingV2beta1") ret0, _ := ret[0].(v2beta1.AutoscalingV2beta1Interface) return ret0 }
go
func (m *MockInterface) AutoscalingV2beta1() v2beta1.AutoscalingV2beta1Interface { ret := m.ctrl.Call(m, "AutoscalingV2beta1") ret0, _ := ret[0].(v2beta1.AutoscalingV2beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "AutoscalingV2beta1", "(", ")", "v2beta1", ".", "AutoscalingV2beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v2beta1", ".", "AutoscalingV2beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// AutoscalingV2beta1 mocks base method
[ "AutoscalingV2beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L248-L252
157,348
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
BatchV1beta1
func (m *MockInterface) BatchV1beta1() v1beta13.BatchV1beta1Interface { ret := m.ctrl.Call(m, "BatchV1beta1") ret0, _ := ret[0].(v1beta13.BatchV1beta1Interface) return ret0 }
go
func (m *MockInterface) BatchV1beta1() v1beta13.BatchV1beta1Interface { ret := m.ctrl.Call(m, "BatchV1beta1") ret0, _ := ret[0].(v1beta13.BatchV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "BatchV1beta1", "(", ")", "v1beta13", ".", "BatchV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta13", ".", "BatchV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// BatchV1beta1 mocks base method
[ "BatchV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L284-L288
157,349
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
BatchV2alpha1
func (m *MockInterface) BatchV2alpha1() v2alpha1.BatchV2alpha1Interface { ret := m.ctrl.Call(m, "BatchV2alpha1") ret0, _ := ret[0].(v2alpha1.BatchV2alpha1Interface) return ret0 }
go
func (m *MockInterface) BatchV2alpha1() v2alpha1.BatchV2alpha1Interface { ret := m.ctrl.Call(m, "BatchV2alpha1") ret0, _ := ret[0].(v2alpha1.BatchV2alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "BatchV2alpha1", "(", ")", "v2alpha1", ".", "BatchV2alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v2alpha1", ".", "BatchV2alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// BatchV2alpha1 mocks base method
[ "BatchV2alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L296-L300
157,350
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Certificates
func (m *MockInterface) Certificates() v1beta14.CertificatesV1beta1Interface { ret := m.ctrl.Call(m, "Certificates") ret0, _ := ret[0].(v1beta14.CertificatesV1beta1Interface) return ret0 }
go
func (m *MockInterface) Certificates() v1beta14.CertificatesV1beta1Interface { ret := m.ctrl.Call(m, "Certificates") ret0, _ := ret[0].(v1beta14.CertificatesV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Certificates", "(", ")", "v1beta14", ".", "CertificatesV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta14", ".", "CertificatesV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Certificates mocks base method
[ "Certificates", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L308-L312
157,351
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
CoordinationV1beta1
func (m *MockInterface) CoordinationV1beta1() v1beta15.CoordinationV1beta1Interface { ret := m.ctrl.Call(m, "CoordinationV1beta1") ret0, _ := ret[0].(v1beta15.CoordinationV1beta1Interface) return ret0 }
go
func (m *MockInterface) CoordinationV1beta1() v1beta15.CoordinationV1beta1Interface { ret := m.ctrl.Call(m, "CoordinationV1beta1") ret0, _ := ret[0].(v1beta15.CoordinationV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "CoordinationV1beta1", "(", ")", "v1beta15", ".", "CoordinationV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta15", ".", "CoordinationV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// CoordinationV1beta1 mocks base method
[ "CoordinationV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L344-L348
157,352
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Core
func (m *MockInterface) Core() v14.CoreV1Interface { ret := m.ctrl.Call(m, "Core") ret0, _ := ret[0].(v14.CoreV1Interface) return ret0 }
go
func (m *MockInterface) Core() v14.CoreV1Interface { ret := m.ctrl.Call(m, "Core") ret0, _ := ret[0].(v14.CoreV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Core", "(", ")", "v14", ".", "CoreV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v14", ".", "CoreV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Core mocks base method
[ "Core", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L356-L360
157,353
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Extensions
func (m *MockInterface) Extensions() v1beta17.ExtensionsV1beta1Interface { ret := m.ctrl.Call(m, "Extensions") ret0, _ := ret[0].(v1beta17.ExtensionsV1beta1Interface) return ret0 }
go
func (m *MockInterface) Extensions() v1beta17.ExtensionsV1beta1Interface { ret := m.ctrl.Call(m, "Extensions") ret0, _ := ret[0].(v1beta17.ExtensionsV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Extensions", "(", ")", "v1beta17", ".", "ExtensionsV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta17", ".", "ExtensionsV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Extensions mocks base method
[ "Extensions", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L416-L420
157,354
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Networking
func (m *MockInterface) Networking() v15.NetworkingV1Interface { ret := m.ctrl.Call(m, "Networking") ret0, _ := ret[0].(v15.NetworkingV1Interface) return ret0 }
go
func (m *MockInterface) Networking() v15.NetworkingV1Interface { ret := m.ctrl.Call(m, "Networking") ret0, _ := ret[0].(v15.NetworkingV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Networking", "(", ")", "v15", ".", "NetworkingV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v15", ".", "NetworkingV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Networking mocks base method
[ "Networking", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L440-L444
157,355
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Policy
func (m *MockInterface) Policy() v1beta18.PolicyV1beta1Interface { ret := m.ctrl.Call(m, "Policy") ret0, _ := ret[0].(v1beta18.PolicyV1beta1Interface) return ret0 }
go
func (m *MockInterface) Policy() v1beta18.PolicyV1beta1Interface { ret := m.ctrl.Call(m, "Policy") ret0, _ := ret[0].(v1beta18.PolicyV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Policy", "(", ")", "v1beta18", ".", "PolicyV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta18", ".", "PolicyV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Policy mocks base method
[ "Policy", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L464-L468
157,356
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Rbac
func (m *MockInterface) Rbac() v16.RbacV1Interface { ret := m.ctrl.Call(m, "Rbac") ret0, _ := ret[0].(v16.RbacV1Interface) return ret0 }
go
func (m *MockInterface) Rbac() v16.RbacV1Interface { ret := m.ctrl.Call(m, "Rbac") ret0, _ := ret[0].(v16.RbacV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Rbac", "(", ")", "v16", ".", "RbacV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v16", ".", "RbacV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Rbac mocks base method
[ "Rbac", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L488-L492
157,357
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
RbacV1alpha1
func (m *MockInterface) RbacV1alpha1() v1alpha10.RbacV1alpha1Interface { ret := m.ctrl.Call(m, "RbacV1alpha1") ret0, _ := ret[0].(v1alpha10.RbacV1alpha1Interface) return ret0 }
go
func (m *MockInterface) RbacV1alpha1() v1alpha10.RbacV1alpha1Interface { ret := m.ctrl.Call(m, "RbacV1alpha1") ret0, _ := ret[0].(v1alpha10.RbacV1alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "RbacV1alpha1", "(", ")", "v1alpha10", ".", "RbacV1alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1alpha10", ".", "RbacV1alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// RbacV1alpha1 mocks base method
[ "RbacV1alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L512-L516
157,358
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
RbacV1beta1
func (m *MockInterface) RbacV1beta1() v1beta19.RbacV1beta1Interface { ret := m.ctrl.Call(m, "RbacV1beta1") ret0, _ := ret[0].(v1beta19.RbacV1beta1Interface) return ret0 }
go
func (m *MockInterface) RbacV1beta1() v1beta19.RbacV1beta1Interface { ret := m.ctrl.Call(m, "RbacV1beta1") ret0, _ := ret[0].(v1beta19.RbacV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "RbacV1beta1", "(", ")", "v1beta19", ".", "RbacV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta19", ".", "RbacV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// RbacV1beta1 mocks base method
[ "RbacV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L524-L528
157,359
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Scheduling
func (m *MockInterface) Scheduling() v1beta110.SchedulingV1beta1Interface { ret := m.ctrl.Call(m, "Scheduling") ret0, _ := ret[0].(v1beta110.SchedulingV1beta1Interface) return ret0 }
go
func (m *MockInterface) Scheduling() v1beta110.SchedulingV1beta1Interface { ret := m.ctrl.Call(m, "Scheduling") ret0, _ := ret[0].(v1beta110.SchedulingV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Scheduling", "(", ")", "v1beta110", ".", "SchedulingV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta110", ".", "SchedulingV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Scheduling mocks base method
[ "Scheduling", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L536-L540
157,360
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
SchedulingV1alpha1
func (m *MockInterface) SchedulingV1alpha1() v1alpha11.SchedulingV1alpha1Interface { ret := m.ctrl.Call(m, "SchedulingV1alpha1") ret0, _ := ret[0].(v1alpha11.SchedulingV1alpha1Interface) return ret0 }
go
func (m *MockInterface) SchedulingV1alpha1() v1alpha11.SchedulingV1alpha1Interface { ret := m.ctrl.Call(m, "SchedulingV1alpha1") ret0, _ := ret[0].(v1alpha11.SchedulingV1alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "SchedulingV1alpha1", "(", ")", "v1alpha11", ".", "SchedulingV1alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1alpha11", ".", "SchedulingV1alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// SchedulingV1alpha1 mocks base method
[ "SchedulingV1alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L548-L552
157,361
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
SettingsV1alpha1
func (m *MockInterface) SettingsV1alpha1() v1alpha12.SettingsV1alpha1Interface { ret := m.ctrl.Call(m, "SettingsV1alpha1") ret0, _ := ret[0].(v1alpha12.SettingsV1alpha1Interface) return ret0 }
go
func (m *MockInterface) SettingsV1alpha1() v1alpha12.SettingsV1alpha1Interface { ret := m.ctrl.Call(m, "SettingsV1alpha1") ret0, _ := ret[0].(v1alpha12.SettingsV1alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "SettingsV1alpha1", "(", ")", "v1alpha12", ".", "SettingsV1alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1alpha12", ".", "SettingsV1alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// SettingsV1alpha1 mocks base method
[ "SettingsV1alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L584-L588
157,362
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
Storage
func (m *MockInterface) Storage() v17.StorageV1Interface { ret := m.ctrl.Call(m, "Storage") ret0, _ := ret[0].(v17.StorageV1Interface) return ret0 }
go
func (m *MockInterface) Storage() v17.StorageV1Interface { ret := m.ctrl.Call(m, "Storage") ret0, _ := ret[0].(v17.StorageV1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "Storage", "(", ")", "v17", ".", "StorageV1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v17", ".", "StorageV1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// Storage mocks base method
[ "Storage", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L596-L600
157,363
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
StorageV1alpha1
func (m *MockInterface) StorageV1alpha1() v1alpha13.StorageV1alpha1Interface { ret := m.ctrl.Call(m, "StorageV1alpha1") ret0, _ := ret[0].(v1alpha13.StorageV1alpha1Interface) return ret0 }
go
func (m *MockInterface) StorageV1alpha1() v1alpha13.StorageV1alpha1Interface { ret := m.ctrl.Call(m, "StorageV1alpha1") ret0, _ := ret[0].(v1alpha13.StorageV1alpha1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "StorageV1alpha1", "(", ")", "v1alpha13", ".", "StorageV1alpha1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1alpha13", ".", "StorageV1alpha1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// StorageV1alpha1 mocks base method
[ "StorageV1alpha1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L620-L624
157,364
juju/juju
caas/kubernetes/provider/mocks/k8sclient_mock.go
StorageV1beta1
func (m *MockInterface) StorageV1beta1() v1beta111.StorageV1beta1Interface { ret := m.ctrl.Call(m, "StorageV1beta1") ret0, _ := ret[0].(v1beta111.StorageV1beta1Interface) return ret0 }
go
func (m *MockInterface) StorageV1beta1() v1beta111.StorageV1beta1Interface { ret := m.ctrl.Call(m, "StorageV1beta1") ret0, _ := ret[0].(v1beta111.StorageV1beta1Interface) return ret0 }
[ "func", "(", "m", "*", "MockInterface", ")", "StorageV1beta1", "(", ")", "v1beta111", ".", "StorageV1beta1Interface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", "v1beta111", ".", "StorageV1beta1Interface", ")", "\n", "return", "ret0", "\n", "}" ]
// StorageV1beta1 mocks base method
[ "StorageV1beta1", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/k8sclient_mock.go#L632-L636
157,365
juju/juju
apiserver/resources.go
readResource
func (h *ResourcesHandler) readResource(backend ResourcesBackend, req *http.Request) (*uploadedResource, error) { uReq, err := extractUploadRequest(req) if err != nil { return nil, errors.Trace(err) } var res resource.Resource if uReq.PendingID != "" { res, err = backend.GetPendingResource(uReq.Application, uReq.Name, uReq.PendingID) } else { res, err = backend.GetResource(uReq.Application, uReq.Name) } if err != nil { return nil, errors.Trace(err) } switch res.Type { case charmresource.TypeFile: ext := path.Ext(res.Path) if path.Ext(uReq.Filename) != ext { return nil, errors.Errorf("incorrect extension on resource upload %q, expected %q", uReq.Filename, ext) } case charmresource.TypeContainerImage: // At this stage the docker 'filename' could be a reference to // what the user has on their local filesystem that got parsed and // is in the process of being uploaded so it makes no sense to validate uReq.Filename // The uploaded finger print from the CLI will not match what comes in from the API request, do not store it. uReq.Fingerprint = charmresource.Fingerprint{} } chRes, err := updateResource(res.Resource, uReq.Fingerprint, uReq.Size) if err != nil { return nil, errors.Trace(err) } return &uploadedResource{ Application: uReq.Application, PendingID: uReq.PendingID, Resource: chRes, Data: req.Body, }, nil }
go
func (h *ResourcesHandler) readResource(backend ResourcesBackend, req *http.Request) (*uploadedResource, error) { uReq, err := extractUploadRequest(req) if err != nil { return nil, errors.Trace(err) } var res resource.Resource if uReq.PendingID != "" { res, err = backend.GetPendingResource(uReq.Application, uReq.Name, uReq.PendingID) } else { res, err = backend.GetResource(uReq.Application, uReq.Name) } if err != nil { return nil, errors.Trace(err) } switch res.Type { case charmresource.TypeFile: ext := path.Ext(res.Path) if path.Ext(uReq.Filename) != ext { return nil, errors.Errorf("incorrect extension on resource upload %q, expected %q", uReq.Filename, ext) } case charmresource.TypeContainerImage: // At this stage the docker 'filename' could be a reference to // what the user has on their local filesystem that got parsed and // is in the process of being uploaded so it makes no sense to validate uReq.Filename // The uploaded finger print from the CLI will not match what comes in from the API request, do not store it. uReq.Fingerprint = charmresource.Fingerprint{} } chRes, err := updateResource(res.Resource, uReq.Fingerprint, uReq.Size) if err != nil { return nil, errors.Trace(err) } return &uploadedResource{ Application: uReq.Application, PendingID: uReq.PendingID, Resource: chRes, Data: req.Body, }, nil }
[ "func", "(", "h", "*", "ResourcesHandler", ")", "readResource", "(", "backend", "ResourcesBackend", ",", "req", "*", "http", ".", "Request", ")", "(", "*", "uploadedResource", ",", "error", ")", "{", "uReq", ",", "err", ":=", "extractUploadRequest", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "var", "res", "resource", ".", "Resource", "\n", "if", "uReq", ".", "PendingID", "!=", "\"", "\"", "{", "res", ",", "err", "=", "backend", ".", "GetPendingResource", "(", "uReq", ".", "Application", ",", "uReq", ".", "Name", ",", "uReq", ".", "PendingID", ")", "\n", "}", "else", "{", "res", ",", "err", "=", "backend", ".", "GetResource", "(", "uReq", ".", "Application", ",", "uReq", ".", "Name", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "switch", "res", ".", "Type", "{", "case", "charmresource", ".", "TypeFile", ":", "ext", ":=", "path", ".", "Ext", "(", "res", ".", "Path", ")", "\n", "if", "path", ".", "Ext", "(", "uReq", ".", "Filename", ")", "!=", "ext", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "uReq", ".", "Filename", ",", "ext", ")", "\n", "}", "\n", "case", "charmresource", ".", "TypeContainerImage", ":", "// At this stage the docker 'filename' could be a reference to", "// what the user has on their local filesystem that got parsed and", "// is in the process of being uploaded so it makes no sense to validate uReq.Filename", "// The uploaded finger print from the CLI will not match what comes in from the API request, do not store it.", "uReq", ".", "Fingerprint", "=", "charmresource", ".", "Fingerprint", "{", "}", "\n", "}", "\n\n", "chRes", ",", "err", ":=", "updateResource", "(", "res", ".", "Resource", ",", "uReq", ".", "Fingerprint", ",", "uReq", ".", "Size", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "&", "uploadedResource", "{", "Application", ":", "uReq", ".", "Application", ",", "PendingID", ":", "uReq", ".", "PendingID", ",", "Resource", ":", "chRes", ",", "Data", ":", "req", ".", "Body", ",", "}", ",", "nil", "\n", "}" ]
// readResource extracts the relevant info from the request.
[ "readResource", "extracts", "the", "relevant", "info", "from", "the", "request", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/resources.go#L138-L177
157,366
juju/juju
apiserver/resources.go
updateResource
func updateResource(res charmresource.Resource, fp charmresource.Fingerprint, size int64) (charmresource.Resource, error) { res.Origin = charmresource.OriginUpload res.Revision = 0 res.Fingerprint = fp res.Size = size if err := res.Validate(); err != nil { return res, errors.Trace(err) } return res, nil }
go
func updateResource(res charmresource.Resource, fp charmresource.Fingerprint, size int64) (charmresource.Resource, error) { res.Origin = charmresource.OriginUpload res.Revision = 0 res.Fingerprint = fp res.Size = size if err := res.Validate(); err != nil { return res, errors.Trace(err) } return res, nil }
[ "func", "updateResource", "(", "res", "charmresource", ".", "Resource", ",", "fp", "charmresource", ".", "Fingerprint", ",", "size", "int64", ")", "(", "charmresource", ".", "Resource", ",", "error", ")", "{", "res", ".", "Origin", "=", "charmresource", ".", "OriginUpload", "\n", "res", ".", "Revision", "=", "0", "\n", "res", ".", "Fingerprint", "=", "fp", "\n", "res", ".", "Size", "=", "size", "\n\n", "if", "err", ":=", "res", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "res", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// updateResource returns a copy of the provided resource, updated with // the given information.
[ "updateResource", "returns", "a", "copy", "of", "the", "provided", "resource", "updated", "with", "the", "given", "information", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/resources.go#L181-L191
157,367
juju/juju
apiserver/resources.go
extractUploadRequest
func extractUploadRequest(req *http.Request) (api.UploadRequest, error) { var ur api.UploadRequest if req.Header.Get(api.HeaderContentLength) == "" { size := req.ContentLength // size will be negative if there is no content. if size < 0 { size = 0 } req.Header.Set(api.HeaderContentLength, fmt.Sprint(size)) } ctype := req.Header.Get(api.HeaderContentType) if ctype != api.ContentTypeRaw { return ur, errors.Errorf("unsupported content type %q", ctype) } application, name := api.ExtractEndpointDetails(req.URL) fingerprint := req.Header.Get(api.HeaderContentSha384) // This parallels "Content-MD5". sizeRaw := req.Header.Get(api.HeaderContentLength) pendingID := req.URL.Query().Get(api.QueryParamPendingID) fp, err := charmresource.ParseFingerprint(fingerprint) if err != nil { return ur, errors.Annotate(err, "invalid fingerprint") } filename, err := extractFilename(req) if err != nil { return ur, errors.Trace(err) } size, err := strconv.ParseInt(sizeRaw, 10, 64) if err != nil { return ur, errors.Annotate(err, "invalid size") } ur = api.UploadRequest{ Application: application, Name: name, Filename: filename, Size: size, Fingerprint: fp, PendingID: pendingID, } return ur, nil }
go
func extractUploadRequest(req *http.Request) (api.UploadRequest, error) { var ur api.UploadRequest if req.Header.Get(api.HeaderContentLength) == "" { size := req.ContentLength // size will be negative if there is no content. if size < 0 { size = 0 } req.Header.Set(api.HeaderContentLength, fmt.Sprint(size)) } ctype := req.Header.Get(api.HeaderContentType) if ctype != api.ContentTypeRaw { return ur, errors.Errorf("unsupported content type %q", ctype) } application, name := api.ExtractEndpointDetails(req.URL) fingerprint := req.Header.Get(api.HeaderContentSha384) // This parallels "Content-MD5". sizeRaw := req.Header.Get(api.HeaderContentLength) pendingID := req.URL.Query().Get(api.QueryParamPendingID) fp, err := charmresource.ParseFingerprint(fingerprint) if err != nil { return ur, errors.Annotate(err, "invalid fingerprint") } filename, err := extractFilename(req) if err != nil { return ur, errors.Trace(err) } size, err := strconv.ParseInt(sizeRaw, 10, 64) if err != nil { return ur, errors.Annotate(err, "invalid size") } ur = api.UploadRequest{ Application: application, Name: name, Filename: filename, Size: size, Fingerprint: fp, PendingID: pendingID, } return ur, nil }
[ "func", "extractUploadRequest", "(", "req", "*", "http", ".", "Request", ")", "(", "api", ".", "UploadRequest", ",", "error", ")", "{", "var", "ur", "api", ".", "UploadRequest", "\n\n", "if", "req", ".", "Header", ".", "Get", "(", "api", ".", "HeaderContentLength", ")", "==", "\"", "\"", "{", "size", ":=", "req", ".", "ContentLength", "\n", "// size will be negative if there is no content.", "if", "size", "<", "0", "{", "size", "=", "0", "\n", "}", "\n", "req", ".", "Header", ".", "Set", "(", "api", ".", "HeaderContentLength", ",", "fmt", ".", "Sprint", "(", "size", ")", ")", "\n", "}", "\n\n", "ctype", ":=", "req", ".", "Header", ".", "Get", "(", "api", ".", "HeaderContentType", ")", "\n", "if", "ctype", "!=", "api", ".", "ContentTypeRaw", "{", "return", "ur", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "ctype", ")", "\n", "}", "\n\n", "application", ",", "name", ":=", "api", ".", "ExtractEndpointDetails", "(", "req", ".", "URL", ")", "\n", "fingerprint", ":=", "req", ".", "Header", ".", "Get", "(", "api", ".", "HeaderContentSha384", ")", "// This parallels \"Content-MD5\".", "\n", "sizeRaw", ":=", "req", ".", "Header", ".", "Get", "(", "api", ".", "HeaderContentLength", ")", "\n", "pendingID", ":=", "req", ".", "URL", ".", "Query", "(", ")", ".", "Get", "(", "api", ".", "QueryParamPendingID", ")", "\n\n", "fp", ",", "err", ":=", "charmresource", ".", "ParseFingerprint", "(", "fingerprint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ur", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "filename", ",", "err", ":=", "extractFilename", "(", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ur", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "size", ",", "err", ":=", "strconv", ".", "ParseInt", "(", "sizeRaw", ",", "10", ",", "64", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ur", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "ur", "=", "api", ".", "UploadRequest", "{", "Application", ":", "application", ",", "Name", ":", "name", ",", "Filename", ":", "filename", ",", "Size", ":", "size", ",", "Fingerprint", ":", "fp", ",", "PendingID", ":", "pendingID", ",", "}", "\n", "return", "ur", ",", "nil", "\n", "}" ]
// extractUploadRequest pulls the required info from the HTTP request.
[ "extractUploadRequest", "pulls", "the", "required", "info", "from", "the", "HTTP", "request", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/resources.go#L194-L240
157,368
juju/juju
apiserver/facades/agent/hostkeyreporter/facade.go
New
func New(backend Backend, _ facade.Resources, authorizer facade.Authorizer) (*Facade, error) { return &Facade{ backend: backend, getCanModify: func() (common.AuthFunc, error) { return authorizer.AuthOwner, nil }, }, nil }
go
func New(backend Backend, _ facade.Resources, authorizer facade.Authorizer) (*Facade, error) { return &Facade{ backend: backend, getCanModify: func() (common.AuthFunc, error) { return authorizer.AuthOwner, nil }, }, nil }
[ "func", "New", "(", "backend", "Backend", ",", "_", "facade", ".", "Resources", ",", "authorizer", "facade", ".", "Authorizer", ")", "(", "*", "Facade", ",", "error", ")", "{", "return", "&", "Facade", "{", "backend", ":", "backend", ",", "getCanModify", ":", "func", "(", ")", "(", "common", ".", "AuthFunc", ",", "error", ")", "{", "return", "authorizer", ".", "AuthOwner", ",", "nil", "\n", "}", ",", "}", ",", "nil", "\n", "}" ]
// New returns a new API facade for the hostkeyreporter worker.
[ "New", "returns", "a", "new", "API", "facade", "for", "the", "hostkeyreporter", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/hostkeyreporter/facade.go#L29-L36
157,369
juju/juju
apiserver/facades/agent/hostkeyreporter/facade.go
ReportKeys
func (facade *Facade) ReportKeys(args params.SSHHostKeySet) (params.ErrorResults, error) { results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.EntityKeys)), } canModify, err := facade.getCanModify() if err != nil { return results, err } for i, arg := range args.EntityKeys { tag, err := names.ParseMachineTag(arg.Tag) if err != nil { results.Results[i].Error = common.ServerError(common.ErrPerm) continue } err = common.ErrPerm if canModify(tag) { err = facade.backend.SetSSHHostKeys(tag, state.SSHHostKeys(arg.PublicKeys)) } results.Results[i].Error = common.ServerError(err) } return results, nil }
go
func (facade *Facade) ReportKeys(args params.SSHHostKeySet) (params.ErrorResults, error) { results := params.ErrorResults{ Results: make([]params.ErrorResult, len(args.EntityKeys)), } canModify, err := facade.getCanModify() if err != nil { return results, err } for i, arg := range args.EntityKeys { tag, err := names.ParseMachineTag(arg.Tag) if err != nil { results.Results[i].Error = common.ServerError(common.ErrPerm) continue } err = common.ErrPerm if canModify(tag) { err = facade.backend.SetSSHHostKeys(tag, state.SSHHostKeys(arg.PublicKeys)) } results.Results[i].Error = common.ServerError(err) } return results, nil }
[ "func", "(", "facade", "*", "Facade", ")", "ReportKeys", "(", "args", "params", ".", "SSHHostKeySet", ")", "(", "params", ".", "ErrorResults", ",", "error", ")", "{", "results", ":=", "params", ".", "ErrorResults", "{", "Results", ":", "make", "(", "[", "]", "params", ".", "ErrorResult", ",", "len", "(", "args", ".", "EntityKeys", ")", ")", ",", "}", "\n\n", "canModify", ",", "err", ":=", "facade", ".", "getCanModify", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "results", ",", "err", "\n", "}", "\n\n", "for", "i", ",", "arg", ":=", "range", "args", ".", "EntityKeys", "{", "tag", ",", "err", ":=", "names", ".", "ParseMachineTag", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "common", ".", "ErrPerm", ")", "\n", "continue", "\n", "}", "\n", "err", "=", "common", ".", "ErrPerm", "\n", "if", "canModify", "(", "tag", ")", "{", "err", "=", "facade", ".", "backend", ".", "SetSSHHostKeys", "(", "tag", ",", "state", ".", "SSHHostKeys", "(", "arg", ".", "PublicKeys", ")", ")", "\n", "}", "\n", "results", ".", "Results", "[", "i", "]", ".", "Error", "=", "common", ".", "ServerError", "(", "err", ")", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// ReportKeys sets the SSH host keys for one or more entities.
[ "ReportKeys", "sets", "the", "SSH", "host", "keys", "for", "one", "or", "more", "entities", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/hostkeyreporter/facade.go#L39-L62
157,370
juju/juju
cmd/plugins/juju-metadata/imagemetadata.go
setParams
func (c *imageMetadataCommand) setParams(context *cmd.Context) error { c.privateStorage = "<private storage name>" controllerName, err := c.ControllerName() err = errors.Cause(err) if err != nil && err != modelcmd.ErrNoControllersDefined && err != modelcmd.ErrNoCurrentController { return errors.Trace(err) } var environ environs.Environ if err == nil { if environ, err := prepare(context, controllerName, c.ClientStore()); err == nil { logger.Infof("creating image metadata for model %q", environ.Config().Name()) // If the user has not specified region and endpoint, try and get it from the environment. if c.Region == "" || c.Endpoint == "" { var cloudSpec simplestreams.CloudSpec if inst, ok := environ.(simplestreams.HasRegion); ok { if cloudSpec, err = inst.Region(); err != nil { return err } } else { return errors.Errorf("model %q cannot provide region and endpoint", environ.Config().Name()) } // If only one of region or endpoint is provided, that is a problem. if cloudSpec.Region != cloudSpec.Endpoint && (cloudSpec.Region == "" || cloudSpec.Endpoint == "") { return errors.Errorf("cannot generate metadata without a complete cloud configuration") } if c.Region == "" { c.Region = cloudSpec.Region } if c.Endpoint == "" { c.Endpoint = cloudSpec.Endpoint } } cfg := environ.Config() if c.Series == "" { c.Series = config.PreferredSeries(cfg) } } else { logger.Warningf("bootstrap parameters could not be opened: %v", err) } } if environ == nil { logger.Infof("no model found, creating image metadata using user supplied data") } if c.Series == "" { c.Series = version.SupportedLTS() } if c.ImageId == "" { return errors.Errorf("image id must be specified") } if c.Region == "" { return errors.Errorf("image region must be specified") } if c.Endpoint == "" { return errors.Errorf("cloud endpoint URL must be specified") } if c.Dir == "" { logger.Infof("no destination directory specified, using current directory") var err error if c.Dir, err = os.Getwd(); err != nil { return err } } return nil }
go
func (c *imageMetadataCommand) setParams(context *cmd.Context) error { c.privateStorage = "<private storage name>" controllerName, err := c.ControllerName() err = errors.Cause(err) if err != nil && err != modelcmd.ErrNoControllersDefined && err != modelcmd.ErrNoCurrentController { return errors.Trace(err) } var environ environs.Environ if err == nil { if environ, err := prepare(context, controllerName, c.ClientStore()); err == nil { logger.Infof("creating image metadata for model %q", environ.Config().Name()) // If the user has not specified region and endpoint, try and get it from the environment. if c.Region == "" || c.Endpoint == "" { var cloudSpec simplestreams.CloudSpec if inst, ok := environ.(simplestreams.HasRegion); ok { if cloudSpec, err = inst.Region(); err != nil { return err } } else { return errors.Errorf("model %q cannot provide region and endpoint", environ.Config().Name()) } // If only one of region or endpoint is provided, that is a problem. if cloudSpec.Region != cloudSpec.Endpoint && (cloudSpec.Region == "" || cloudSpec.Endpoint == "") { return errors.Errorf("cannot generate metadata without a complete cloud configuration") } if c.Region == "" { c.Region = cloudSpec.Region } if c.Endpoint == "" { c.Endpoint = cloudSpec.Endpoint } } cfg := environ.Config() if c.Series == "" { c.Series = config.PreferredSeries(cfg) } } else { logger.Warningf("bootstrap parameters could not be opened: %v", err) } } if environ == nil { logger.Infof("no model found, creating image metadata using user supplied data") } if c.Series == "" { c.Series = version.SupportedLTS() } if c.ImageId == "" { return errors.Errorf("image id must be specified") } if c.Region == "" { return errors.Errorf("image region must be specified") } if c.Endpoint == "" { return errors.Errorf("cloud endpoint URL must be specified") } if c.Dir == "" { logger.Infof("no destination directory specified, using current directory") var err error if c.Dir, err = os.Getwd(); err != nil { return err } } return nil }
[ "func", "(", "c", "*", "imageMetadataCommand", ")", "setParams", "(", "context", "*", "cmd", ".", "Context", ")", "error", "{", "c", ".", "privateStorage", "=", "\"", "\"", "\n\n", "controllerName", ",", "err", ":=", "c", ".", "ControllerName", "(", ")", "\n", "err", "=", "errors", ".", "Cause", "(", "err", ")", "\n", "if", "err", "!=", "nil", "&&", "err", "!=", "modelcmd", ".", "ErrNoControllersDefined", "&&", "err", "!=", "modelcmd", ".", "ErrNoCurrentController", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "var", "environ", "environs", ".", "Environ", "\n", "if", "err", "==", "nil", "{", "if", "environ", ",", "err", ":=", "prepare", "(", "context", ",", "controllerName", ",", "c", ".", "ClientStore", "(", ")", ")", ";", "err", "==", "nil", "{", "logger", ".", "Infof", "(", "\"", "\"", ",", "environ", ".", "Config", "(", ")", ".", "Name", "(", ")", ")", "\n", "// If the user has not specified region and endpoint, try and get it from the environment.", "if", "c", ".", "Region", "==", "\"", "\"", "||", "c", ".", "Endpoint", "==", "\"", "\"", "{", "var", "cloudSpec", "simplestreams", ".", "CloudSpec", "\n", "if", "inst", ",", "ok", ":=", "environ", ".", "(", "simplestreams", ".", "HasRegion", ")", ";", "ok", "{", "if", "cloudSpec", ",", "err", "=", "inst", ".", "Region", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "else", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ",", "environ", ".", "Config", "(", ")", ".", "Name", "(", ")", ")", "\n", "}", "\n", "// If only one of region or endpoint is provided, that is a problem.", "if", "cloudSpec", ".", "Region", "!=", "cloudSpec", ".", "Endpoint", "&&", "(", "cloudSpec", ".", "Region", "==", "\"", "\"", "||", "cloudSpec", ".", "Endpoint", "==", "\"", "\"", ")", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Region", "==", "\"", "\"", "{", "c", ".", "Region", "=", "cloudSpec", ".", "Region", "\n", "}", "\n", "if", "c", ".", "Endpoint", "==", "\"", "\"", "{", "c", ".", "Endpoint", "=", "cloudSpec", ".", "Endpoint", "\n", "}", "\n", "}", "\n", "cfg", ":=", "environ", ".", "Config", "(", ")", "\n", "if", "c", ".", "Series", "==", "\"", "\"", "{", "c", ".", "Series", "=", "config", ".", "PreferredSeries", "(", "cfg", ")", "\n", "}", "\n", "}", "else", "{", "logger", ".", "Warningf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "}", "\n", "if", "environ", "==", "nil", "{", "logger", ".", "Infof", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Series", "==", "\"", "\"", "{", "c", ".", "Series", "=", "version", ".", "SupportedLTS", "(", ")", "\n", "}", "\n", "if", "c", ".", "ImageId", "==", "\"", "\"", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Region", "==", "\"", "\"", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Endpoint", "==", "\"", "\"", "{", "return", "errors", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "c", ".", "Dir", "==", "\"", "\"", "{", "logger", ".", "Infof", "(", "\"", "\"", ")", "\n", "var", "err", "error", "\n", "if", "c", ".", "Dir", ",", "err", "=", "os", ".", "Getwd", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// setParams sets parameters based on the environment configuration // for those which have not been explicitly specified.
[ "setParams", "sets", "parameters", "based", "on", "the", "environment", "configuration", "for", "those", "which", "have", "not", "been", "explicitly", "specified", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/plugins/juju-metadata/imagemetadata.go#L111-L176
157,371
juju/juju
provider/joyent/environ_firewall.go
createFirewallRuleAll
func createFirewallRuleAll(envName string, portRange network.IngressRule) string { ports := []string{} for p := portRange.FromPort; p <= portRange.ToPort; p++ { ports = append(ports, fmt.Sprintf("PORT %d", p)) } var portList string if len(ports) > 1 { portList = fmt.Sprintf("( %s )", strings.Join(ports, " AND ")) } else if len(ports) == 1 { portList = ports[0] } return fmt.Sprintf(firewallRuleAll, envName, strings.ToLower(portRange.Protocol), portList) }
go
func createFirewallRuleAll(envName string, portRange network.IngressRule) string { ports := []string{} for p := portRange.FromPort; p <= portRange.ToPort; p++ { ports = append(ports, fmt.Sprintf("PORT %d", p)) } var portList string if len(ports) > 1 { portList = fmt.Sprintf("( %s )", strings.Join(ports, " AND ")) } else if len(ports) == 1 { portList = ports[0] } return fmt.Sprintf(firewallRuleAll, envName, strings.ToLower(portRange.Protocol), portList) }
[ "func", "createFirewallRuleAll", "(", "envName", "string", ",", "portRange", "network", ".", "IngressRule", ")", "string", "{", "ports", ":=", "[", "]", "string", "{", "}", "\n", "for", "p", ":=", "portRange", ".", "FromPort", ";", "p", "<=", "portRange", ".", "ToPort", ";", "p", "++", "{", "ports", "=", "append", "(", "ports", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ")", ")", "\n", "}", "\n", "var", "portList", "string", "\n", "if", "len", "(", "ports", ")", ">", "1", "{", "portList", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "strings", ".", "Join", "(", "ports", ",", "\"", "\"", ")", ")", "\n", "}", "else", "if", "len", "(", "ports", ")", "==", "1", "{", "portList", "=", "ports", "[", "0", "]", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "firewallRuleAll", ",", "envName", ",", "strings", ".", "ToLower", "(", "portRange", ".", "Protocol", ")", ",", "portList", ")", "\n", "}" ]
// Helper method to create a firewall rule string for the given port
[ "Helper", "method", "to", "create", "a", "firewall", "rule", "string", "for", "the", "given", "port" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/joyent/environ_firewall.go#L31-L43
157,372
juju/juju
provider/joyent/environ_firewall.go
ruleExists
func ruleExists(rules []cloudapi.FirewallRule, rule string) (bool, string) { for _, r := range rules { if strings.EqualFold(r.Rule, rule) { return true, r.Id } } return false, "" }
go
func ruleExists(rules []cloudapi.FirewallRule, rule string) (bool, string) { for _, r := range rules { if strings.EqualFold(r.Rule, rule) { return true, r.Id } } return false, "" }
[ "func", "ruleExists", "(", "rules", "[", "]", "cloudapi", ".", "FirewallRule", ",", "rule", "string", ")", "(", "bool", ",", "string", ")", "{", "for", "_", ",", "r", ":=", "range", "rules", "{", "if", "strings", ".", "EqualFold", "(", "r", ".", "Rule", ",", "rule", ")", "{", "return", "true", ",", "r", ".", "Id", "\n", "}", "\n", "}", "\n\n", "return", "false", ",", "\"", "\"", "\n", "}" ]
// Helper method to check if a firewall rule string already exist
[ "Helper", "method", "to", "check", "if", "a", "firewall", "rule", "string", "already", "exist" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/joyent/environ_firewall.go#L46-L54
157,373
juju/juju
provider/joyent/environ_firewall.go
getRules
func getRules(envName string, fwrules []cloudapi.FirewallRule) ([]network.IngressRule, error) { rules := []network.IngressRule{} for _, r := range fwrules { rule := r.Rule if r.Enabled && strings.HasPrefix(rule, "FROM tag "+envName) && strings.Contains(rule, "PORT") { if firewallSinglePortRule.MatchString(rule) { parts := firewallSinglePortRule.FindStringSubmatch(rule) if len(parts) != 3 { continue } protocol := parts[1] n, _ := strconv.Atoi(parts[2]) rule, err := network.NewIngressRule(protocol, n, n, "0.0.0.0/0") if err != nil { return nil, errors.Trace(err) } rules = append(rules, rule) } else if firewallMultiPortRule.MatchString(rule) { parts := firewallMultiPortRule.FindStringSubmatch(rule) if len(parts) != 3 { continue } protocol := parts[1] var ports []corenetwork.Port portStrings := strings.Split(parts[2], " AND ") for _, portString := range portStrings { portString = portString[strings.LastIndex(portString, "PORT")+5:] port, _ := strconv.Atoi(portString) ports = append(ports, corenetwork.Port{Protocol: protocol, Number: port}) } portRange := corenetwork.CollapsePorts(ports) for _, port := range portRange { rule, _ := network.NewIngressRule(port.Protocol, port.FromPort, port.ToPort, "0.0.0.0/0") rules = append(rules, rule) } } } } network.SortIngressRules(rules) return rules, nil }
go
func getRules(envName string, fwrules []cloudapi.FirewallRule) ([]network.IngressRule, error) { rules := []network.IngressRule{} for _, r := range fwrules { rule := r.Rule if r.Enabled && strings.HasPrefix(rule, "FROM tag "+envName) && strings.Contains(rule, "PORT") { if firewallSinglePortRule.MatchString(rule) { parts := firewallSinglePortRule.FindStringSubmatch(rule) if len(parts) != 3 { continue } protocol := parts[1] n, _ := strconv.Atoi(parts[2]) rule, err := network.NewIngressRule(protocol, n, n, "0.0.0.0/0") if err != nil { return nil, errors.Trace(err) } rules = append(rules, rule) } else if firewallMultiPortRule.MatchString(rule) { parts := firewallMultiPortRule.FindStringSubmatch(rule) if len(parts) != 3 { continue } protocol := parts[1] var ports []corenetwork.Port portStrings := strings.Split(parts[2], " AND ") for _, portString := range portStrings { portString = portString[strings.LastIndex(portString, "PORT")+5:] port, _ := strconv.Atoi(portString) ports = append(ports, corenetwork.Port{Protocol: protocol, Number: port}) } portRange := corenetwork.CollapsePorts(ports) for _, port := range portRange { rule, _ := network.NewIngressRule(port.Protocol, port.FromPort, port.ToPort, "0.0.0.0/0") rules = append(rules, rule) } } } } network.SortIngressRules(rules) return rules, nil }
[ "func", "getRules", "(", "envName", "string", ",", "fwrules", "[", "]", "cloudapi", ".", "FirewallRule", ")", "(", "[", "]", "network", ".", "IngressRule", ",", "error", ")", "{", "rules", ":=", "[", "]", "network", ".", "IngressRule", "{", "}", "\n", "for", "_", ",", "r", ":=", "range", "fwrules", "{", "rule", ":=", "r", ".", "Rule", "\n", "if", "r", ".", "Enabled", "&&", "strings", ".", "HasPrefix", "(", "rule", ",", "\"", "\"", "+", "envName", ")", "&&", "strings", ".", "Contains", "(", "rule", ",", "\"", "\"", ")", "{", "if", "firewallSinglePortRule", ".", "MatchString", "(", "rule", ")", "{", "parts", ":=", "firewallSinglePortRule", ".", "FindStringSubmatch", "(", "rule", ")", "\n", "if", "len", "(", "parts", ")", "!=", "3", "{", "continue", "\n", "}", "\n", "protocol", ":=", "parts", "[", "1", "]", "\n", "n", ",", "_", ":=", "strconv", ".", "Atoi", "(", "parts", "[", "2", "]", ")", "\n", "rule", ",", "err", ":=", "network", ".", "NewIngressRule", "(", "protocol", ",", "n", ",", "n", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "rules", "=", "append", "(", "rules", ",", "rule", ")", "\n", "}", "else", "if", "firewallMultiPortRule", ".", "MatchString", "(", "rule", ")", "{", "parts", ":=", "firewallMultiPortRule", ".", "FindStringSubmatch", "(", "rule", ")", "\n", "if", "len", "(", "parts", ")", "!=", "3", "{", "continue", "\n", "}", "\n", "protocol", ":=", "parts", "[", "1", "]", "\n", "var", "ports", "[", "]", "corenetwork", ".", "Port", "\n", "portStrings", ":=", "strings", ".", "Split", "(", "parts", "[", "2", "]", ",", "\"", "\"", ")", "\n", "for", "_", ",", "portString", ":=", "range", "portStrings", "{", "portString", "=", "portString", "[", "strings", ".", "LastIndex", "(", "portString", ",", "\"", "\"", ")", "+", "5", ":", "]", "\n", "port", ",", "_", ":=", "strconv", ".", "Atoi", "(", "portString", ")", "\n", "ports", "=", "append", "(", "ports", ",", "corenetwork", ".", "Port", "{", "Protocol", ":", "protocol", ",", "Number", ":", "port", "}", ")", "\n", "}", "\n", "portRange", ":=", "corenetwork", ".", "CollapsePorts", "(", "ports", ")", "\n", "for", "_", ",", "port", ":=", "range", "portRange", "{", "rule", ",", "_", ":=", "network", ".", "NewIngressRule", "(", "port", ".", "Protocol", ",", "port", ".", "FromPort", ",", "port", ".", "ToPort", ",", "\"", "\"", ")", "\n", "rules", "=", "append", "(", "rules", ",", "rule", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "network", ".", "SortIngressRules", "(", "rules", ")", "\n", "return", "rules", ",", "nil", "\n", "}" ]
// Helper method to get port from the given firewall rules
[ "Helper", "method", "to", "get", "port", "from", "the", "given", "firewall", "rules" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/joyent/environ_firewall.go#L57-L98
157,374
juju/juju
cmd/juju/cloud/addcredential.go
NewAddCredentialCommand
func NewAddCredentialCommand() cmd.Command { return &addCredentialCommand{ store: jujuclient.NewFileCredentialStore(), cloudByNameFunc: jujucloud.CloudByName, } }
go
func NewAddCredentialCommand() cmd.Command { return &addCredentialCommand{ store: jujuclient.NewFileCredentialStore(), cloudByNameFunc: jujucloud.CloudByName, } }
[ "func", "NewAddCredentialCommand", "(", ")", "cmd", ".", "Command", "{", "return", "&", "addCredentialCommand", "{", "store", ":", "jujuclient", ".", "NewFileCredentialStore", "(", ")", ",", "cloudByNameFunc", ":", "jujucloud", ".", "CloudByName", ",", "}", "\n", "}" ]
// NewAddCredentialCommand returns a command to add credential information.
[ "NewAddCredentialCommand", "returns", "a", "command", "to", "add", "credential", "information", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/cloud/addcredential.go#L89-L94
157,375
juju/juju
environs/imagemetadata/validation.go
ValidateImageMetadata
func ValidateImageMetadata(params *simplestreams.MetadataLookupParams) ([]string, *simplestreams.ResolveInfo, error) { if params.Series == "" { return nil, nil, fmt.Errorf("required parameter series not specified") } if params.Region == "" { return nil, nil, fmt.Errorf("required parameter region not specified") } if params.Endpoint == "" { return nil, nil, fmt.Errorf("required parameter endpoint not specified") } if len(params.Sources) == 0 { return nil, nil, fmt.Errorf("required parameter sources not specified") } imageConstraint := NewImageConstraint(simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{ Region: params.Region, Endpoint: params.Endpoint, }, Series: []string{params.Series}, Arches: params.Architectures, Stream: params.Stream, }) matchingImages, resolveInfo, err := Fetch(params.Sources, imageConstraint) if err != nil { return nil, resolveInfo, err } if len(matchingImages) == 0 { return nil, resolveInfo, fmt.Errorf("no matching images found for constraint %+v", imageConstraint) } image_ids := make([]string, len(matchingImages)) for i, im := range matchingImages { image_ids[i] = im.Id } return image_ids, resolveInfo, nil }
go
func ValidateImageMetadata(params *simplestreams.MetadataLookupParams) ([]string, *simplestreams.ResolveInfo, error) { if params.Series == "" { return nil, nil, fmt.Errorf("required parameter series not specified") } if params.Region == "" { return nil, nil, fmt.Errorf("required parameter region not specified") } if params.Endpoint == "" { return nil, nil, fmt.Errorf("required parameter endpoint not specified") } if len(params.Sources) == 0 { return nil, nil, fmt.Errorf("required parameter sources not specified") } imageConstraint := NewImageConstraint(simplestreams.LookupParams{ CloudSpec: simplestreams.CloudSpec{ Region: params.Region, Endpoint: params.Endpoint, }, Series: []string{params.Series}, Arches: params.Architectures, Stream: params.Stream, }) matchingImages, resolveInfo, err := Fetch(params.Sources, imageConstraint) if err != nil { return nil, resolveInfo, err } if len(matchingImages) == 0 { return nil, resolveInfo, fmt.Errorf("no matching images found for constraint %+v", imageConstraint) } image_ids := make([]string, len(matchingImages)) for i, im := range matchingImages { image_ids[i] = im.Id } return image_ids, resolveInfo, nil }
[ "func", "ValidateImageMetadata", "(", "params", "*", "simplestreams", ".", "MetadataLookupParams", ")", "(", "[", "]", "string", ",", "*", "simplestreams", ".", "ResolveInfo", ",", "error", ")", "{", "if", "params", ".", "Series", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "params", ".", "Region", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "params", ".", "Endpoint", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "params", ".", "Sources", ")", "==", "0", "{", "return", "nil", ",", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "imageConstraint", ":=", "NewImageConstraint", "(", "simplestreams", ".", "LookupParams", "{", "CloudSpec", ":", "simplestreams", ".", "CloudSpec", "{", "Region", ":", "params", ".", "Region", ",", "Endpoint", ":", "params", ".", "Endpoint", ",", "}", ",", "Series", ":", "[", "]", "string", "{", "params", ".", "Series", "}", ",", "Arches", ":", "params", ".", "Architectures", ",", "Stream", ":", "params", ".", "Stream", ",", "}", ")", "\n", "matchingImages", ",", "resolveInfo", ",", "err", ":=", "Fetch", "(", "params", ".", "Sources", ",", "imageConstraint", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "resolveInfo", ",", "err", "\n", "}", "\n", "if", "len", "(", "matchingImages", ")", "==", "0", "{", "return", "nil", ",", "resolveInfo", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "imageConstraint", ")", "\n", "}", "\n", "image_ids", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "matchingImages", ")", ")", "\n", "for", "i", ",", "im", ":=", "range", "matchingImages", "{", "image_ids", "[", "i", "]", "=", "im", ".", "Id", "\n", "}", "\n", "return", "image_ids", ",", "resolveInfo", ",", "nil", "\n", "}" ]
// ValidateImageMetadata attempts to load image metadata for the specified cloud attributes and stream // and returns any image ids found, or an error if the metadata could not be loaded.
[ "ValidateImageMetadata", "attempts", "to", "load", "image", "metadata", "for", "the", "specified", "cloud", "attributes", "and", "stream", "and", "returns", "any", "image", "ids", "found", "or", "an", "error", "if", "the", "metadata", "could", "not", "be", "loaded", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/environs/imagemetadata/validation.go#L14-L48
157,376
juju/juju
apiserver/httpattachment/attachment.go
NewBody
func NewBody(attached io.ReadSeeker, meta interface{}, name string) (body io.ReadSeeker, contentType string, err error) { var parts bytes.Buffer // Set up the multi-part portion of the body. writer := multipart.NewWriter(&parts) // Set the metadata part. header := make(textproto.MIMEHeader) header.Set("Content-Disposition", `form-data; name="metadata"`) header.Set("Content-Type", params.ContentTypeJSON) part, err := writer.CreatePart(header) if err != nil { return nil, "", errors.Trace(err) } if err := json.NewEncoder(part).Encode(meta); err != nil { return nil, "", errors.Trace(err) } // Set the attached part. _, err = writer.CreateFormFile("attached", name) if err != nil { return nil, "", errors.Trace(err) } // We don't actually write the reader's data to the part. // Instead We use a chained reader to facilitate streaming // directly from the reader. // // Technically this is boundary-breaking, as the knowledge of // how to make multipart archives should be kept to the // mime/multipart package, but doing it this way means we don't // need to return a Writer which would be harder to turn into // a ReadSeeker. return newMultiReaderSeeker( bytes.NewReader(parts.Bytes()), attached, strings.NewReader("\r\n--"+writer.Boundary()+"--\r\n"), ), writer.FormDataContentType(), nil }
go
func NewBody(attached io.ReadSeeker, meta interface{}, name string) (body io.ReadSeeker, contentType string, err error) { var parts bytes.Buffer // Set up the multi-part portion of the body. writer := multipart.NewWriter(&parts) // Set the metadata part. header := make(textproto.MIMEHeader) header.Set("Content-Disposition", `form-data; name="metadata"`) header.Set("Content-Type", params.ContentTypeJSON) part, err := writer.CreatePart(header) if err != nil { return nil, "", errors.Trace(err) } if err := json.NewEncoder(part).Encode(meta); err != nil { return nil, "", errors.Trace(err) } // Set the attached part. _, err = writer.CreateFormFile("attached", name) if err != nil { return nil, "", errors.Trace(err) } // We don't actually write the reader's data to the part. // Instead We use a chained reader to facilitate streaming // directly from the reader. // // Technically this is boundary-breaking, as the knowledge of // how to make multipart archives should be kept to the // mime/multipart package, but doing it this way means we don't // need to return a Writer which would be harder to turn into // a ReadSeeker. return newMultiReaderSeeker( bytes.NewReader(parts.Bytes()), attached, strings.NewReader("\r\n--"+writer.Boundary()+"--\r\n"), ), writer.FormDataContentType(), nil }
[ "func", "NewBody", "(", "attached", "io", ".", "ReadSeeker", ",", "meta", "interface", "{", "}", ",", "name", "string", ")", "(", "body", "io", ".", "ReadSeeker", ",", "contentType", "string", ",", "err", "error", ")", "{", "var", "parts", "bytes", ".", "Buffer", "\n\n", "// Set up the multi-part portion of the body.", "writer", ":=", "multipart", ".", "NewWriter", "(", "&", "parts", ")", "\n\n", "// Set the metadata part.", "header", ":=", "make", "(", "textproto", ".", "MIMEHeader", ")", "\n", "header", ".", "Set", "(", "\"", "\"", ",", "`form-data; name=\"metadata\"`", ")", "\n", "header", ".", "Set", "(", "\"", "\"", ",", "params", ".", "ContentTypeJSON", ")", "\n", "part", ",", "err", ":=", "writer", ".", "CreatePart", "(", "header", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "json", ".", "NewEncoder", "(", "part", ")", ".", "Encode", "(", "meta", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "// Set the attached part.", "_", ",", "err", "=", "writer", ".", "CreateFormFile", "(", "\"", "\"", ",", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "\"", "\"", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "// We don't actually write the reader's data to the part.", "// Instead We use a chained reader to facilitate streaming", "// directly from the reader.", "//", "// Technically this is boundary-breaking, as the knowledge of", "// how to make multipart archives should be kept to the", "// mime/multipart package, but doing it this way means we don't", "// need to return a Writer which would be harder to turn into", "// a ReadSeeker.", "return", "newMultiReaderSeeker", "(", "bytes", ".", "NewReader", "(", "parts", ".", "Bytes", "(", ")", ")", ",", "attached", ",", "strings", ".", "NewReader", "(", "\"", "\\r", "\\n", "\"", "+", "writer", ".", "Boundary", "(", ")", "+", "\"", "\\r", "\\n", "\"", ")", ",", ")", ",", "writer", ".", "FormDataContentType", "(", ")", ",", "nil", "\n", "}" ]
// NewBody returns an HTTP request body and content type // suitable for using to make an HTTP request containing // the given attached body data and JSON-marshaled metadata. // // The name parameter is used to identify the attached "file", so // a filename is an appropriate value.
[ "NewBody", "returns", "an", "HTTP", "request", "body", "and", "content", "type", "suitable", "for", "using", "to", "make", "an", "HTTP", "request", "containing", "the", "given", "attached", "body", "data", "and", "JSON", "-", "marshaled", "metadata", ".", "The", "name", "parameter", "is", "used", "to", "identify", "the", "attached", "file", "so", "a", "filename", "is", "an", "appropriate", "value", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpattachment/attachment.go#L30-L68
157,377
juju/juju
apiserver/httpattachment/attachment.go
Seek
func (r *multiReaderSeeker) Seek(offset int64, whence int) (int64, error) { if offset != 0 || whence != 0 { return 0, errors.New("cannot only seek to the start of multipart reader") } for _, reader := range r.readers { if _, err := reader.Seek(0, 0); err != nil { return 0, errors.Trace(err) } } r.index = 0 return 0, nil }
go
func (r *multiReaderSeeker) Seek(offset int64, whence int) (int64, error) { if offset != 0 || whence != 0 { return 0, errors.New("cannot only seek to the start of multipart reader") } for _, reader := range r.readers { if _, err := reader.Seek(0, 0); err != nil { return 0, errors.Trace(err) } } r.index = 0 return 0, nil }
[ "func", "(", "r", "*", "multiReaderSeeker", ")", "Seek", "(", "offset", "int64", ",", "whence", "int", ")", "(", "int64", ",", "error", ")", "{", "if", "offset", "!=", "0", "||", "whence", "!=", "0", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "reader", ":=", "range", "r", ".", "readers", "{", "if", "_", ",", "err", ":=", "reader", ".", "Seek", "(", "0", ",", "0", ")", ";", "err", "!=", "nil", "{", "return", "0", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "}", "\n", "r", ".", "index", "=", "0", "\n", "return", "0", ",", "nil", "\n", "}" ]
// Read implements io.Seeker.Seek. It can only be used to seek to the // start.
[ "Read", "implements", "io", ".", "Seeker", ".", "Seek", ".", "It", "can", "only", "be", "used", "to", "seek", "to", "the", "start", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpattachment/attachment.go#L101-L112
157,378
juju/juju
apiserver/httpattachment/attachment.go
Get
func Get(req *http.Request, metaResult interface{}) (io.ReadCloser, error) { ctype := req.Header.Get("Content-Type") mediaType, cParams, err := mime.ParseMediaType(ctype) if err != nil { return nil, errors.Annotate(err, "while parsing content type header") } if !strings.HasPrefix(mediaType, "multipart/") { return nil, errors.Errorf("expected multipart Content-Type, got %q", mediaType) } reader := multipart.NewReader(req.Body, cParams["boundary"]) // Extract the metadata. part, err := reader.NextPart() if err != nil { if err == io.EOF { return nil, errors.New("missing metadata") } return nil, errors.Trace(err) } if err := checkContentType(part.Header, params.ContentTypeJSON); err != nil { return nil, errors.Trace(err) } if err := json.NewDecoder(part).Decode(metaResult); err != nil { return nil, errors.Trace(err) } // Extract the archive. part, err = reader.NextPart() if err != nil { if err == io.EOF { return nil, errors.New("missing archive") } return nil, errors.Trace(err) } if err := checkContentType(part.Header, params.ContentTypeRaw); err != nil { return nil, errors.Trace(err) } // We're not going to worry about verifying that the file matches the // metadata (e.g. size, checksum). archive := part // We are going to trust that there aren't any more attachments after // the file. If there are, we ignore them. return archive, nil }
go
func Get(req *http.Request, metaResult interface{}) (io.ReadCloser, error) { ctype := req.Header.Get("Content-Type") mediaType, cParams, err := mime.ParseMediaType(ctype) if err != nil { return nil, errors.Annotate(err, "while parsing content type header") } if !strings.HasPrefix(mediaType, "multipart/") { return nil, errors.Errorf("expected multipart Content-Type, got %q", mediaType) } reader := multipart.NewReader(req.Body, cParams["boundary"]) // Extract the metadata. part, err := reader.NextPart() if err != nil { if err == io.EOF { return nil, errors.New("missing metadata") } return nil, errors.Trace(err) } if err := checkContentType(part.Header, params.ContentTypeJSON); err != nil { return nil, errors.Trace(err) } if err := json.NewDecoder(part).Decode(metaResult); err != nil { return nil, errors.Trace(err) } // Extract the archive. part, err = reader.NextPart() if err != nil { if err == io.EOF { return nil, errors.New("missing archive") } return nil, errors.Trace(err) } if err := checkContentType(part.Header, params.ContentTypeRaw); err != nil { return nil, errors.Trace(err) } // We're not going to worry about verifying that the file matches the // metadata (e.g. size, checksum). archive := part // We are going to trust that there aren't any more attachments after // the file. If there are, we ignore them. return archive, nil }
[ "func", "Get", "(", "req", "*", "http", ".", "Request", ",", "metaResult", "interface", "{", "}", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "ctype", ":=", "req", ".", "Header", ".", "Get", "(", "\"", "\"", ")", "\n", "mediaType", ",", "cParams", ",", "err", ":=", "mime", ".", "ParseMediaType", "(", "ctype", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", "\n", "}", "\n\n", "if", "!", "strings", ".", "HasPrefix", "(", "mediaType", ",", "\"", "\"", ")", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "mediaType", ")", "\n", "}", "\n", "reader", ":=", "multipart", ".", "NewReader", "(", "req", ".", "Body", ",", "cParams", "[", "\"", "\"", "]", ")", "\n\n", "// Extract the metadata.", "part", ",", "err", ":=", "reader", ".", "NextPart", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "if", "err", ":=", "checkContentType", "(", "part", ".", "Header", ",", "params", ".", "ContentTypeJSON", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "json", ".", "NewDecoder", "(", "part", ")", ".", "Decode", "(", "metaResult", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "// Extract the archive.", "part", ",", "err", "=", "reader", ".", "NextPart", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "if", "err", ":=", "checkContentType", "(", "part", ".", "Header", ",", "params", ".", "ContentTypeRaw", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "// We're not going to worry about verifying that the file matches the", "// metadata (e.g. size, checksum).", "archive", ":=", "part", "\n\n", "// We are going to trust that there aren't any more attachments after", "// the file. If there are, we ignore them.", "return", "archive", ",", "nil", "\n", "}" ]
// Get extracts the attached file and its metadata from the multipart // data in the request. The metadata is JSON-unmarshaled into the value // pointed to by metaResult.
[ "Get", "extracts", "the", "attached", "file", "and", "its", "metadata", "from", "the", "multipart", "data", "in", "the", "request", ".", "The", "metadata", "is", "JSON", "-", "unmarshaled", "into", "the", "value", "pointed", "to", "by", "metaResult", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/httpattachment/attachment.go#L117-L164
157,379
juju/juju
api/provisioner/provisioner.go
NewStateFromFacade
func NewStateFromFacade(facadeCaller base.FacadeCaller) *State { return &State{ ModelWatcher: common.NewModelWatcher(facadeCaller), APIAddresser: common.NewAPIAddresser(facadeCaller), ControllerConfigAPI: common.NewControllerConfig(facadeCaller), facade: facadeCaller, } }
go
func NewStateFromFacade(facadeCaller base.FacadeCaller) *State { return &State{ ModelWatcher: common.NewModelWatcher(facadeCaller), APIAddresser: common.NewAPIAddresser(facadeCaller), ControllerConfigAPI: common.NewControllerConfig(facadeCaller), facade: facadeCaller, } }
[ "func", "NewStateFromFacade", "(", "facadeCaller", "base", ".", "FacadeCaller", ")", "*", "State", "{", "return", "&", "State", "{", "ModelWatcher", ":", "common", ".", "NewModelWatcher", "(", "facadeCaller", ")", ",", "APIAddresser", ":", "common", ".", "NewAPIAddresser", "(", "facadeCaller", ")", ",", "ControllerConfigAPI", ":", "common", ".", "NewControllerConfig", "(", "facadeCaller", ")", ",", "facade", ":", "facadeCaller", ",", "}", "\n", "}" ]
// NewStateFromFacade creates a new provisioner facade using the input // facade caller.
[ "NewStateFromFacade", "creates", "a", "new", "provisioner", "facade", "using", "the", "input", "facade", "caller", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L68-L75
157,380
juju/juju
api/provisioner/provisioner.go
machineLife
func (st *State) machineLife(tag names.MachineTag) (params.Life, error) { return common.OneLife(st.facade, tag) }
go
func (st *State) machineLife(tag names.MachineTag) (params.Life, error) { return common.OneLife(st.facade, tag) }
[ "func", "(", "st", "*", "State", ")", "machineLife", "(", "tag", "names", ".", "MachineTag", ")", "(", "params", ".", "Life", ",", "error", ")", "{", "return", "common", ".", "OneLife", "(", "st", ".", "facade", ",", "tag", ")", "\n", "}" ]
// machineLife requests the lifecycle of the given machine from the server.
[ "machineLife", "requests", "the", "lifecycle", "of", "the", "given", "machine", "from", "the", "server", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L78-L80
157,381
juju/juju
api/provisioner/provisioner.go
Machines
func (st *State) Machines(tags ...names.MachineTag) ([]MachineResult, error) { lenTags := len(tags) genericTags := make([]names.Tag, lenTags) for i, t := range tags { genericTags[i] = t } result, err := common.Life(st.facade, genericTags) if err != nil { return []MachineResult{}, err } machines := make([]MachineResult, lenTags) for i, r := range result { if r.Error == nil { machines[i].Machine = &Machine{ tag: tags[i], life: r.Life, st: st, } } else { machines[i].Err = r.Error } } return machines, nil }
go
func (st *State) Machines(tags ...names.MachineTag) ([]MachineResult, error) { lenTags := len(tags) genericTags := make([]names.Tag, lenTags) for i, t := range tags { genericTags[i] = t } result, err := common.Life(st.facade, genericTags) if err != nil { return []MachineResult{}, err } machines := make([]MachineResult, lenTags) for i, r := range result { if r.Error == nil { machines[i].Machine = &Machine{ tag: tags[i], life: r.Life, st: st, } } else { machines[i].Err = r.Error } } return machines, nil }
[ "func", "(", "st", "*", "State", ")", "Machines", "(", "tags", "...", "names", ".", "MachineTag", ")", "(", "[", "]", "MachineResult", ",", "error", ")", "{", "lenTags", ":=", "len", "(", "tags", ")", "\n", "genericTags", ":=", "make", "(", "[", "]", "names", ".", "Tag", ",", "lenTags", ")", "\n", "for", "i", ",", "t", ":=", "range", "tags", "{", "genericTags", "[", "i", "]", "=", "t", "\n", "}", "\n", "result", ",", "err", ":=", "common", ".", "Life", "(", "st", ".", "facade", ",", "genericTags", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "MachineResult", "{", "}", ",", "err", "\n", "}", "\n", "machines", ":=", "make", "(", "[", "]", "MachineResult", ",", "lenTags", ")", "\n", "for", "i", ",", "r", ":=", "range", "result", "{", "if", "r", ".", "Error", "==", "nil", "{", "machines", "[", "i", "]", ".", "Machine", "=", "&", "Machine", "{", "tag", ":", "tags", "[", "i", "]", ",", "life", ":", "r", ".", "Life", ",", "st", ":", "st", ",", "}", "\n", "}", "else", "{", "machines", "[", "i", "]", ".", "Err", "=", "r", ".", "Error", "\n", "}", "\n", "}", "\n", "return", "machines", ",", "nil", "\n", "}" ]
// Machine provides access to methods of a state.Machine through the facade // for the given tags.
[ "Machine", "provides", "access", "to", "methods", "of", "a", "state", ".", "Machine", "through", "the", "facade", "for", "the", "given", "tags", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L84-L107
157,382
juju/juju
api/provisioner/provisioner.go
MachinesWithTransientErrors
func (st *State) MachinesWithTransientErrors() ([]MachineStatusResult, error) { var results params.StatusResults err := st.facade.FacadeCall("MachinesWithTransientErrors", nil, &results) if err != nil { return []MachineStatusResult{}, err } machines := make([]MachineStatusResult, len(results.Results)) for i, status := range results.Results { if status.Error != nil { continue } machines[i].Machine = &Machine{ tag: names.NewMachineTag(status.Id), life: status.Life, st: st, } machines[i].Status = status } return machines, nil }
go
func (st *State) MachinesWithTransientErrors() ([]MachineStatusResult, error) { var results params.StatusResults err := st.facade.FacadeCall("MachinesWithTransientErrors", nil, &results) if err != nil { return []MachineStatusResult{}, err } machines := make([]MachineStatusResult, len(results.Results)) for i, status := range results.Results { if status.Error != nil { continue } machines[i].Machine = &Machine{ tag: names.NewMachineTag(status.Id), life: status.Life, st: st, } machines[i].Status = status } return machines, nil }
[ "func", "(", "st", "*", "State", ")", "MachinesWithTransientErrors", "(", ")", "(", "[", "]", "MachineStatusResult", ",", "error", ")", "{", "var", "results", "params", ".", "StatusResults", "\n", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "nil", ",", "&", "results", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "MachineStatusResult", "{", "}", ",", "err", "\n", "}", "\n", "machines", ":=", "make", "(", "[", "]", "MachineStatusResult", ",", "len", "(", "results", ".", "Results", ")", ")", "\n", "for", "i", ",", "status", ":=", "range", "results", ".", "Results", "{", "if", "status", ".", "Error", "!=", "nil", "{", "continue", "\n", "}", "\n", "machines", "[", "i", "]", ".", "Machine", "=", "&", "Machine", "{", "tag", ":", "names", ".", "NewMachineTag", "(", "status", ".", "Id", ")", ",", "life", ":", "status", ".", "Life", ",", "st", ":", "st", ",", "}", "\n", "machines", "[", "i", "]", ".", "Status", "=", "status", "\n", "}", "\n", "return", "machines", ",", "nil", "\n", "}" ]
// MachinesWithTransientErrors returns a slice of machines and corresponding status information // for those machines which have transient provisioning errors.
[ "MachinesWithTransientErrors", "returns", "a", "slice", "of", "machines", "and", "corresponding", "status", "information", "for", "those", "machines", "which", "have", "transient", "provisioning", "errors", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L187-L206
157,383
juju/juju
api/provisioner/provisioner.go
FindTools
func (st *State) FindTools(v version.Number, series string, arch string) (tools.List, error) { args := params.FindToolsParams{ Number: v, Series: series, MajorVersion: -1, MinorVersion: -1, } if arch != "" { args.Arch = arch } var result params.FindToolsResult if err := st.facade.FacadeCall("FindTools", args, &result); err != nil { return nil, err } if result.Error != nil { return nil, result.Error } return result.List, nil }
go
func (st *State) FindTools(v version.Number, series string, arch string) (tools.List, error) { args := params.FindToolsParams{ Number: v, Series: series, MajorVersion: -1, MinorVersion: -1, } if arch != "" { args.Arch = arch } var result params.FindToolsResult if err := st.facade.FacadeCall("FindTools", args, &result); err != nil { return nil, err } if result.Error != nil { return nil, result.Error } return result.List, nil }
[ "func", "(", "st", "*", "State", ")", "FindTools", "(", "v", "version", ".", "Number", ",", "series", "string", ",", "arch", "string", ")", "(", "tools", ".", "List", ",", "error", ")", "{", "args", ":=", "params", ".", "FindToolsParams", "{", "Number", ":", "v", ",", "Series", ":", "series", ",", "MajorVersion", ":", "-", "1", ",", "MinorVersion", ":", "-", "1", ",", "}", "\n", "if", "arch", "!=", "\"", "\"", "{", "args", ".", "Arch", "=", "arch", "\n", "}", "\n", "var", "result", "params", ".", "FindToolsResult", "\n", "if", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "result", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "result", ".", "Error", "!=", "nil", "{", "return", "nil", ",", "result", ".", "Error", "\n", "}", "\n", "return", "result", ".", "List", ",", "nil", "\n", "}" ]
// FindTools returns al ist of tools matching the specified version number and // series, and, arch. If arch is blank, a default will be used.
[ "FindTools", "returns", "al", "ist", "of", "tools", "matching", "the", "specified", "version", "number", "and", "series", "and", "arch", ".", "If", "arch", "is", "blank", "a", "default", "will", "be", "used", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L210-L228
157,384
juju/juju
api/provisioner/provisioner.go
ReleaseContainerAddresses
func (st *State) ReleaseContainerAddresses(containerTag names.MachineTag) (err error) { defer errors.DeferredAnnotatef(&err, "cannot release static addresses for %q", containerTag.Id()) var result params.ErrorResults args := params.Entities{ Entities: []params.Entity{{Tag: containerTag.String()}}, } if err := st.facade.FacadeCall("ReleaseContainerAddresses", args, &result); err != nil { return err } return result.OneError() }
go
func (st *State) ReleaseContainerAddresses(containerTag names.MachineTag) (err error) { defer errors.DeferredAnnotatef(&err, "cannot release static addresses for %q", containerTag.Id()) var result params.ErrorResults args := params.Entities{ Entities: []params.Entity{{Tag: containerTag.String()}}, } if err := st.facade.FacadeCall("ReleaseContainerAddresses", args, &result); err != nil { return err } return result.OneError() }
[ "func", "(", "st", "*", "State", ")", "ReleaseContainerAddresses", "(", "containerTag", "names", ".", "MachineTag", ")", "(", "err", "error", ")", "{", "defer", "errors", ".", "DeferredAnnotatef", "(", "&", "err", ",", "\"", "\"", ",", "containerTag", ".", "Id", "(", ")", ")", "\n", "var", "result", "params", ".", "ErrorResults", "\n", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "containerTag", ".", "String", "(", ")", "}", "}", ",", "}", "\n", "if", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "result", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "result", ".", "OneError", "(", ")", "\n", "}" ]
// ReleaseContainerAddresses releases a static IP address allocated to a // container.
[ "ReleaseContainerAddresses", "releases", "a", "static", "IP", "address", "allocated", "to", "a", "container", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L232-L242
157,385
juju/juju
api/provisioner/provisioner.go
SetHostMachineNetworkConfig
func (st *State) SetHostMachineNetworkConfig(hostMachineTag names.MachineTag, netConfig []params.NetworkConfig) error { args := params.SetMachineNetworkConfig{ Tag: hostMachineTag.String(), Config: netConfig, } err := st.facade.FacadeCall("SetHostMachineNetworkConfig", args, nil) if err != nil { return errors.Trace(err) } return nil }
go
func (st *State) SetHostMachineNetworkConfig(hostMachineTag names.MachineTag, netConfig []params.NetworkConfig) error { args := params.SetMachineNetworkConfig{ Tag: hostMachineTag.String(), Config: netConfig, } err := st.facade.FacadeCall("SetHostMachineNetworkConfig", args, nil) if err != nil { return errors.Trace(err) } return nil }
[ "func", "(", "st", "*", "State", ")", "SetHostMachineNetworkConfig", "(", "hostMachineTag", "names", ".", "MachineTag", ",", "netConfig", "[", "]", "params", ".", "NetworkConfig", ")", "error", "{", "args", ":=", "params", ".", "SetMachineNetworkConfig", "{", "Tag", ":", "hostMachineTag", ".", "String", "(", ")", ",", "Config", ":", "netConfig", ",", "}", "\n", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// SetHostMachineNetworkConfig sets the network configuration of the // machine with netConfig
[ "SetHostMachineNetworkConfig", "sets", "the", "network", "configuration", "of", "the", "machine", "with", "netConfig" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L325-L335
157,386
juju/juju
api/provisioner/provisioner.go
DistributionGroupByMachineId
func (st *State) DistributionGroupByMachineId(tags ...names.MachineTag) ([]DistributionGroupResult, error) { var stringResults params.StringsResults entities := make([]params.Entity, len(tags)) for i, t := range tags { entities[i] = params.Entity{Tag: t.String()} } err := st.facade.FacadeCall("DistributionGroupByMachineId", params.Entities{Entities: entities}, &stringResults) if err != nil { return []DistributionGroupResult{}, err } results := make([]DistributionGroupResult, len(tags)) for i, stringResult := range stringResults.Results { results[i] = DistributionGroupResult{MachineIds: stringResult.Result, Err: stringResult.Error} } return results, nil }
go
func (st *State) DistributionGroupByMachineId(tags ...names.MachineTag) ([]DistributionGroupResult, error) { var stringResults params.StringsResults entities := make([]params.Entity, len(tags)) for i, t := range tags { entities[i] = params.Entity{Tag: t.String()} } err := st.facade.FacadeCall("DistributionGroupByMachineId", params.Entities{Entities: entities}, &stringResults) if err != nil { return []DistributionGroupResult{}, err } results := make([]DistributionGroupResult, len(tags)) for i, stringResult := range stringResults.Results { results[i] = DistributionGroupResult{MachineIds: stringResult.Result, Err: stringResult.Error} } return results, nil }
[ "func", "(", "st", "*", "State", ")", "DistributionGroupByMachineId", "(", "tags", "...", "names", ".", "MachineTag", ")", "(", "[", "]", "DistributionGroupResult", ",", "error", ")", "{", "var", "stringResults", "params", ".", "StringsResults", "\n", "entities", ":=", "make", "(", "[", "]", "params", ".", "Entity", ",", "len", "(", "tags", ")", ")", "\n", "for", "i", ",", "t", ":=", "range", "tags", "{", "entities", "[", "i", "]", "=", "params", ".", "Entity", "{", "Tag", ":", "t", ".", "String", "(", ")", "}", "\n", "}", "\n", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "params", ".", "Entities", "{", "Entities", ":", "entities", "}", ",", "&", "stringResults", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "DistributionGroupResult", "{", "}", ",", "err", "\n", "}", "\n", "results", ":=", "make", "(", "[", "]", "DistributionGroupResult", ",", "len", "(", "tags", ")", ")", "\n", "for", "i", ",", "stringResult", ":=", "range", "stringResults", ".", "Results", "{", "results", "[", "i", "]", "=", "DistributionGroupResult", "{", "MachineIds", ":", "stringResult", ".", "Result", ",", "Err", ":", "stringResult", ".", "Error", "}", "\n", "}", "\n", "return", "results", ",", "nil", "\n", "}" ]
// DistributionGroupByMachineId returns a slice of machine.Ids // that belong to the same distribution group as the given // Machine. The provisioner may use this information // to distribute instances for high availability.
[ "DistributionGroupByMachineId", "returns", "a", "slice", "of", "machine", ".", "Ids", "that", "belong", "to", "the", "same", "distribution", "group", "as", "the", "given", "Machine", ".", "The", "provisioner", "may", "use", "this", "information", "to", "distribute", "instances", "for", "high", "availability", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L365-L380
157,387
juju/juju
api/provisioner/provisioner.go
CACert
func (a *State) CACert() (string, error) { var result params.BytesResult err := a.facade.FacadeCall("CACert", nil, &result) if err != nil { return "", err } return string(result.Result), nil }
go
func (a *State) CACert() (string, error) { var result params.BytesResult err := a.facade.FacadeCall("CACert", nil, &result) if err != nil { return "", err } return string(result.Result), nil }
[ "func", "(", "a", "*", "State", ")", "CACert", "(", ")", "(", "string", ",", "error", ")", "{", "var", "result", "params", ".", "BytesResult", "\n", "err", ":=", "a", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "nil", ",", "&", "result", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "string", "(", "result", ".", "Result", ")", ",", "nil", "\n", "}" ]
// CACert returns the certificate used to validate the API and state connections.
[ "CACert", "returns", "the", "certificate", "used", "to", "validate", "the", "API", "and", "state", "connections", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L383-L390
157,388
juju/juju
api/provisioner/provisioner.go
GetContainerProfileInfo
func (st *State) GetContainerProfileInfo(containerTag names.MachineTag) ([]*LXDProfileResult, error) { var result params.ContainerProfileResults args := params.Entities{ Entities: []params.Entity{{Tag: containerTag.String()}}, } if err := st.facade.FacadeCall("GetContainerProfileInfo", args, &result); err != nil { return nil, err } if len(result.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(result.Results)) } if err := result.Results[0].Error; err != nil { return nil, err } profiles := result.Results[0].LXDProfiles var res []*LXDProfileResult for _, p := range profiles { if p == nil { continue } res = append(res, &LXDProfileResult{ Config: p.Profile.Config, Description: p.Profile.Description, Devices: p.Profile.Devices, Name: p.Name, }) } return res, nil }
go
func (st *State) GetContainerProfileInfo(containerTag names.MachineTag) ([]*LXDProfileResult, error) { var result params.ContainerProfileResults args := params.Entities{ Entities: []params.Entity{{Tag: containerTag.String()}}, } if err := st.facade.FacadeCall("GetContainerProfileInfo", args, &result); err != nil { return nil, err } if len(result.Results) != 1 { return nil, errors.Errorf("expected 1 result, got %d", len(result.Results)) } if err := result.Results[0].Error; err != nil { return nil, err } profiles := result.Results[0].LXDProfiles var res []*LXDProfileResult for _, p := range profiles { if p == nil { continue } res = append(res, &LXDProfileResult{ Config: p.Profile.Config, Description: p.Profile.Description, Devices: p.Profile.Devices, Name: p.Name, }) } return res, nil }
[ "func", "(", "st", "*", "State", ")", "GetContainerProfileInfo", "(", "containerTag", "names", ".", "MachineTag", ")", "(", "[", "]", "*", "LXDProfileResult", ",", "error", ")", "{", "var", "result", "params", ".", "ContainerProfileResults", "\n", "args", ":=", "params", ".", "Entities", "{", "Entities", ":", "[", "]", "params", ".", "Entity", "{", "{", "Tag", ":", "containerTag", ".", "String", "(", ")", "}", "}", ",", "}", "\n", "if", "err", ":=", "st", ".", "facade", ".", "FacadeCall", "(", "\"", "\"", ",", "args", ",", "&", "result", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "len", "(", "result", ".", "Results", ")", "!=", "1", "{", "return", "nil", ",", "errors", ".", "Errorf", "(", "\"", "\"", ",", "len", "(", "result", ".", "Results", ")", ")", "\n", "}", "\n", "if", "err", ":=", "result", ".", "Results", "[", "0", "]", ".", "Error", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "profiles", ":=", "result", ".", "Results", "[", "0", "]", ".", "LXDProfiles", "\n", "var", "res", "[", "]", "*", "LXDProfileResult", "\n", "for", "_", ",", "p", ":=", "range", "profiles", "{", "if", "p", "==", "nil", "{", "continue", "\n", "}", "\n", "res", "=", "append", "(", "res", ",", "&", "LXDProfileResult", "{", "Config", ":", "p", ".", "Profile", ".", "Config", ",", "Description", ":", "p", ".", "Profile", ".", "Description", ",", "Devices", ":", "p", ".", "Profile", ".", "Devices", ",", "Name", ":", "p", ".", "Name", ",", "}", ")", "\n", "}", "\n", "return", "res", ",", "nil", "\n", "}" ]
// GetContainerProfileInfo returns a slice of ContainerLXDProfile, 1 for each unit's charm // which contains an lxd-profile.yaml.
[ "GetContainerProfileInfo", "returns", "a", "slice", "of", "ContainerLXDProfile", "1", "for", "each", "unit", "s", "charm", "which", "contains", "an", "lxd", "-", "profile", ".", "yaml", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/api/provisioner/provisioner.go#L394-L422
157,389
juju/juju
container/lxd/instance.go
OpenPorts
func (lxd *lxdInstance) OpenPorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error { return fmt.Errorf("not implemented") }
go
func (lxd *lxdInstance) OpenPorts(ctx context.ProviderCallContext, machineId string, rules []network.IngressRule) error { return fmt.Errorf("not implemented") }
[ "func", "(", "lxd", "*", "lxdInstance", ")", "OpenPorts", "(", "ctx", "context", ".", "ProviderCallContext", ",", "machineId", "string", ",", "rules", "[", "]", "network", ".", "IngressRule", ")", "error", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// OpenPorts implements instances.Instance.OpenPorts.
[ "OpenPorts", "implements", "instances", ".", "Instance", ".", "OpenPorts", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/container/lxd/instance.go#L67-L69
157,390
juju/juju
cmd/juju/commands/upgradecontroller.go
initCAASVersions
func initCAASVersions( controllerCfg controller.Config, desiredVersion, agentVersion version.Number, filterOnPrior bool, ) (*upgradeContext, error) { if desiredVersion == agentVersion { return nil, errUpToDate } filterVersion := jujuversion.Current if desiredVersion != version.Zero { filterVersion = desiredVersion } else if filterOnPrior { filterVersion.Major-- } logger.Debugf("searching for agent images with major: %d", filterVersion.Major) imagePath := podcfg.GetJujuOCIImagePath(controllerCfg, version.Zero) availableTags, err := docker.ListOperatorImages(imagePath) if err != nil { return nil, err } logger.Debugf("found available tags: %v", availableTags) var matchingTags tools.Versions for _, t := range availableTags { vers := t.AgentVersion() if filterVersion.Major != -1 && vers.Major != filterVersion.Major { continue } matchingTags = append(matchingTags, t) } logger.Debugf("found matching tags: %v", matchingTags) if len(matchingTags) == 0 { // No images found, so if we are not asking for a major upgrade, // pretend there is no more recent version available. if desiredVersion == version.Zero && agentVersion.Major == filterVersion.Major { return nil, errUpToDate } return nil, err } return &upgradeContext{ agent: agentVersion, client: jujuversion.Current, chosen: desiredVersion, packagedAgents: matchingTags, }, nil }
go
func initCAASVersions( controllerCfg controller.Config, desiredVersion, agentVersion version.Number, filterOnPrior bool, ) (*upgradeContext, error) { if desiredVersion == agentVersion { return nil, errUpToDate } filterVersion := jujuversion.Current if desiredVersion != version.Zero { filterVersion = desiredVersion } else if filterOnPrior { filterVersion.Major-- } logger.Debugf("searching for agent images with major: %d", filterVersion.Major) imagePath := podcfg.GetJujuOCIImagePath(controllerCfg, version.Zero) availableTags, err := docker.ListOperatorImages(imagePath) if err != nil { return nil, err } logger.Debugf("found available tags: %v", availableTags) var matchingTags tools.Versions for _, t := range availableTags { vers := t.AgentVersion() if filterVersion.Major != -1 && vers.Major != filterVersion.Major { continue } matchingTags = append(matchingTags, t) } logger.Debugf("found matching tags: %v", matchingTags) if len(matchingTags) == 0 { // No images found, so if we are not asking for a major upgrade, // pretend there is no more recent version available. if desiredVersion == version.Zero && agentVersion.Major == filterVersion.Major { return nil, errUpToDate } return nil, err } return &upgradeContext{ agent: agentVersion, client: jujuversion.Current, chosen: desiredVersion, packagedAgents: matchingTags, }, nil }
[ "func", "initCAASVersions", "(", "controllerCfg", "controller", ".", "Config", ",", "desiredVersion", ",", "agentVersion", "version", ".", "Number", ",", "filterOnPrior", "bool", ",", ")", "(", "*", "upgradeContext", ",", "error", ")", "{", "if", "desiredVersion", "==", "agentVersion", "{", "return", "nil", ",", "errUpToDate", "\n", "}", "\n\n", "filterVersion", ":=", "jujuversion", ".", "Current", "\n", "if", "desiredVersion", "!=", "version", ".", "Zero", "{", "filterVersion", "=", "desiredVersion", "\n", "}", "else", "if", "filterOnPrior", "{", "filterVersion", ".", "Major", "--", "\n", "}", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "filterVersion", ".", "Major", ")", "\n", "imagePath", ":=", "podcfg", ".", "GetJujuOCIImagePath", "(", "controllerCfg", ",", "version", ".", "Zero", ")", "\n", "availableTags", ",", "err", ":=", "docker", ".", "ListOperatorImages", "(", "imagePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "availableTags", ")", "\n", "var", "matchingTags", "tools", ".", "Versions", "\n", "for", "_", ",", "t", ":=", "range", "availableTags", "{", "vers", ":=", "t", ".", "AgentVersion", "(", ")", "\n", "if", "filterVersion", ".", "Major", "!=", "-", "1", "&&", "vers", ".", "Major", "!=", "filterVersion", ".", "Major", "{", "continue", "\n", "}", "\n", "matchingTags", "=", "append", "(", "matchingTags", ",", "t", ")", "\n", "}", "\n\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "matchingTags", ")", "\n", "if", "len", "(", "matchingTags", ")", "==", "0", "{", "// No images found, so if we are not asking for a major upgrade,", "// pretend there is no more recent version available.", "if", "desiredVersion", "==", "version", ".", "Zero", "&&", "agentVersion", ".", "Major", "==", "filterVersion", ".", "Major", "{", "return", "nil", ",", "errUpToDate", "\n", "}", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "return", "&", "upgradeContext", "{", "agent", ":", "agentVersion", ",", "client", ":", "jujuversion", ".", "Current", ",", "chosen", ":", "desiredVersion", ",", "packagedAgents", ":", "matchingTags", ",", "}", ",", "nil", "\n", "}" ]
// initCAASVersions collects state relevant to an upgrade decision. The returned // agent and client versions, and the list of currently available operator images, will // always be accurate; the chosen version, and the flag indicating development // mode, may remain blank until uploadTools or validate is called.
[ "initCAASVersions", "collects", "state", "relevant", "to", "an", "upgrade", "decision", ".", "The", "returned", "agent", "and", "client", "versions", "and", "the", "list", "of", "currently", "available", "operator", "images", "will", "always", "be", "accurate", ";", "the", "chosen", "version", "and", "the", "flag", "indicating", "development", "mode", "may", "remain", "blank", "until", "uploadTools", "or", "validate", "is", "called", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/commands/upgradecontroller.go#L219-L263
157,391
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
NewHookContextFacade
func NewHookContextFacade(st *state.State, unit *state.Unit) (interface{}, error) { up, err := st.UnitPayloads(unit) if err != nil { return nil, errors.Trace(err) } return NewUnitFacade(up), nil }
go
func NewHookContextFacade(st *state.State, unit *state.Unit) (interface{}, error) { up, err := st.UnitPayloads(unit) if err != nil { return nil, errors.Trace(err) } return NewUnitFacade(up), nil }
[ "func", "NewHookContextFacade", "(", "st", "*", "state", ".", "State", ",", "unit", "*", "state", ".", "Unit", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "up", ",", "err", ":=", "st", ".", "UnitPayloads", "(", "unit", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "return", "NewUnitFacade", "(", "up", ")", ",", "nil", "\n", "}" ]
// NewHookContextFacade returns a new payloads hook context facade for // the State and Unit given. It is used for facade registration.
[ "NewHookContextFacade", "returns", "a", "new", "payloads", "hook", "context", "facade", "for", "the", "State", "and", "Unit", "given", ".", "It", "is", "used", "for", "facade", "registration", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L22-L28
157,392
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
Track
func (uf UnitFacade) Track(args params.TrackPayloadArgs) (params.PayloadResults, error) { logger.Debugf("tracking %d payloads from API", len(args.Payloads)) var r params.PayloadResults for _, apiPayload := range args.Payloads { pl, err := api.API2Payload(apiPayload) if err != nil { return r, errors.Trace(err) } logger.Debugf("tracking payload from API: %#v", pl) id, err := uf.track(pl.Payload) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
go
func (uf UnitFacade) Track(args params.TrackPayloadArgs) (params.PayloadResults, error) { logger.Debugf("tracking %d payloads from API", len(args.Payloads)) var r params.PayloadResults for _, apiPayload := range args.Payloads { pl, err := api.API2Payload(apiPayload) if err != nil { return r, errors.Trace(err) } logger.Debugf("tracking payload from API: %#v", pl) id, err := uf.track(pl.Payload) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
[ "func", "(", "uf", "UnitFacade", ")", "Track", "(", "args", "params", ".", "TrackPayloadArgs", ")", "(", "params", ".", "PayloadResults", ",", "error", ")", "{", "logger", ".", "Debugf", "(", "\"", "\"", ",", "len", "(", "args", ".", "Payloads", ")", ")", "\n\n", "var", "r", "params", ".", "PayloadResults", "\n", "for", "_", ",", "apiPayload", ":=", "range", "args", ".", "Payloads", "{", "pl", ",", "err", ":=", "api", ".", "API2Payload", "(", "apiPayload", ")", "\n", "if", "err", "!=", "nil", "{", "return", "r", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "logger", ".", "Debugf", "(", "\"", "\"", ",", "pl", ")", "\n\n", "id", ",", "err", ":=", "uf", ".", "track", "(", "pl", ".", "Payload", ")", "\n", "res", ":=", "newPayloadResult", "(", "id", ",", "err", ")", "\n", "r", ".", "Results", "=", "append", "(", "r", ".", "Results", ",", "res", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// Track stores a payload to be tracked in state.
[ "Track", "stores", "a", "payload", "to", "be", "tracked", "in", "state", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L59-L75
157,393
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
List
func (uf UnitFacade) List(args params.Entities) (params.PayloadResults, error) { if len(args.Entities) == 0 { return uf.listAll() } var ids []string for _, entity := range args.Entities { id, err := api.API2ID(entity.Tag) if err != nil { return params.PayloadResults{}, errors.Trace(err) } ids = append(ids, id) } results, err := uf.backend.List(ids...) if err != nil { return params.PayloadResults{}, errors.Trace(err) } var r params.PayloadResults for _, result := range results { res := Result2api(result) r.Results = append(r.Results, res) } return r, nil }
go
func (uf UnitFacade) List(args params.Entities) (params.PayloadResults, error) { if len(args.Entities) == 0 { return uf.listAll() } var ids []string for _, entity := range args.Entities { id, err := api.API2ID(entity.Tag) if err != nil { return params.PayloadResults{}, errors.Trace(err) } ids = append(ids, id) } results, err := uf.backend.List(ids...) if err != nil { return params.PayloadResults{}, errors.Trace(err) } var r params.PayloadResults for _, result := range results { res := Result2api(result) r.Results = append(r.Results, res) } return r, nil }
[ "func", "(", "uf", "UnitFacade", ")", "List", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "PayloadResults", ",", "error", ")", "{", "if", "len", "(", "args", ".", "Entities", ")", "==", "0", "{", "return", "uf", ".", "listAll", "(", ")", "\n", "}", "\n\n", "var", "ids", "[", "]", "string", "\n", "for", "_", ",", "entity", ":=", "range", "args", ".", "Entities", "{", "id", ",", "err", ":=", "api", ".", "API2ID", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "PayloadResults", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n", "ids", "=", "append", "(", "ids", ",", "id", ")", "\n", "}", "\n\n", "results", ",", "err", ":=", "uf", ".", "backend", ".", "List", "(", "ids", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "params", ".", "PayloadResults", "{", "}", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "var", "r", "params", ".", "PayloadResults", "\n", "for", "_", ",", "result", ":=", "range", "results", "{", "res", ":=", "Result2api", "(", "result", ")", "\n", "r", ".", "Results", "=", "append", "(", "r", ".", "Results", ",", "res", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// List builds the list of payload being tracked for // the given unit and IDs. If no IDs are provided then all tracked // payloads for the unit are returned.
[ "List", "builds", "the", "list", "of", "payload", "being", "tracked", "for", "the", "given", "unit", "and", "IDs", ".", "If", "no", "IDs", "are", "provided", "then", "all", "tracked", "payloads", "for", "the", "unit", "are", "returned", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L91-L116
157,394
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
LookUp
func (uf UnitFacade) LookUp(args params.LookUpPayloadArgs) (params.PayloadResults, error) { var r params.PayloadResults for _, arg := range args.Args { id, err := uf.backend.LookUp(arg.Name, arg.ID) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
go
func (uf UnitFacade) LookUp(args params.LookUpPayloadArgs) (params.PayloadResults, error) { var r params.PayloadResults for _, arg := range args.Args { id, err := uf.backend.LookUp(arg.Name, arg.ID) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
[ "func", "(", "uf", "UnitFacade", ")", "LookUp", "(", "args", "params", ".", "LookUpPayloadArgs", ")", "(", "params", ".", "PayloadResults", ",", "error", ")", "{", "var", "r", "params", ".", "PayloadResults", "\n", "for", "_", ",", "arg", ":=", "range", "args", ".", "Args", "{", "id", ",", "err", ":=", "uf", ".", "backend", ".", "LookUp", "(", "arg", ".", "Name", ",", "arg", ".", "ID", ")", "\n", "res", ":=", "newPayloadResult", "(", "id", ",", "err", ")", "\n", "r", ".", "Results", "=", "append", "(", "r", ".", "Results", ",", "res", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// LookUp identifies the payload with the provided name and raw ID.
[ "LookUp", "identifies", "the", "payload", "with", "the", "provided", "name", "and", "raw", "ID", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L143-L151
157,395
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
SetStatus
func (uf UnitFacade) SetStatus(args params.SetPayloadStatusArgs) (params.PayloadResults, error) { var r params.PayloadResults for _, arg := range args.Args { id, err := api.API2ID(arg.Tag) if err != nil { return r, errors.Trace(err) } err = uf.backend.SetStatus(id, arg.Status) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
go
func (uf UnitFacade) SetStatus(args params.SetPayloadStatusArgs) (params.PayloadResults, error) { var r params.PayloadResults for _, arg := range args.Args { id, err := api.API2ID(arg.Tag) if err != nil { return r, errors.Trace(err) } err = uf.backend.SetStatus(id, arg.Status) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
[ "func", "(", "uf", "UnitFacade", ")", "SetStatus", "(", "args", "params", ".", "SetPayloadStatusArgs", ")", "(", "params", ".", "PayloadResults", ",", "error", ")", "{", "var", "r", "params", ".", "PayloadResults", "\n", "for", "_", ",", "arg", ":=", "range", "args", ".", "Args", "{", "id", ",", "err", ":=", "api", ".", "API2ID", "(", "arg", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "r", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "err", "=", "uf", ".", "backend", ".", "SetStatus", "(", "id", ",", "arg", ".", "Status", ")", "\n", "res", ":=", "newPayloadResult", "(", "id", ",", "err", ")", "\n", "r", ".", "Results", "=", "append", "(", "r", ".", "Results", ",", "res", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// SetStatus sets the raw status of a payload.
[ "SetStatus", "sets", "the", "raw", "status", "of", "a", "payload", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L154-L167
157,396
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
Untrack
func (uf UnitFacade) Untrack(args params.Entities) (params.PayloadResults, error) { var r params.PayloadResults for _, entity := range args.Entities { id, err := api.API2ID(entity.Tag) if err != nil { return r, errors.Trace(err) } err = uf.backend.Untrack(id) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
go
func (uf UnitFacade) Untrack(args params.Entities) (params.PayloadResults, error) { var r params.PayloadResults for _, entity := range args.Entities { id, err := api.API2ID(entity.Tag) if err != nil { return r, errors.Trace(err) } err = uf.backend.Untrack(id) res := newPayloadResult(id, err) r.Results = append(r.Results, res) } return r, nil }
[ "func", "(", "uf", "UnitFacade", ")", "Untrack", "(", "args", "params", ".", "Entities", ")", "(", "params", ".", "PayloadResults", ",", "error", ")", "{", "var", "r", "params", ".", "PayloadResults", "\n", "for", "_", ",", "entity", ":=", "range", "args", ".", "Entities", "{", "id", ",", "err", ":=", "api", ".", "API2ID", "(", "entity", ".", "Tag", ")", "\n", "if", "err", "!=", "nil", "{", "return", "r", ",", "errors", ".", "Trace", "(", "err", ")", "\n", "}", "\n\n", "err", "=", "uf", ".", "backend", ".", "Untrack", "(", "id", ")", "\n", "res", ":=", "newPayloadResult", "(", "id", ",", "err", ")", "\n", "r", ".", "Results", "=", "append", "(", "r", ".", "Results", ",", "res", ")", "\n", "}", "\n", "return", "r", ",", "nil", "\n", "}" ]
// Untrack marks the identified payload as no longer being tracked.
[ "Untrack", "marks", "the", "identified", "payload", "as", "no", "longer", "being", "tracked", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L170-L183
157,397
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
newPayloadResult
func newPayloadResult(id string, err error) params.PayloadResult { result := payload.Result{ ID: id, Payload: nil, NotFound: errors.IsNotFound(err), Error: err, } return Result2api(result) }
go
func newPayloadResult(id string, err error) params.PayloadResult { result := payload.Result{ ID: id, Payload: nil, NotFound: errors.IsNotFound(err), Error: err, } return Result2api(result) }
[ "func", "newPayloadResult", "(", "id", "string", ",", "err", "error", ")", "params", ".", "PayloadResult", "{", "result", ":=", "payload", ".", "Result", "{", "ID", ":", "id", ",", "Payload", ":", "nil", ",", "NotFound", ":", "errors", ".", "IsNotFound", "(", "err", ")", ",", "Error", ":", "err", ",", "}", "\n", "return", "Result2api", "(", "result", ")", "\n", "}" ]
// newPayloadResult builds a new PayloadResult from the provided tag // and error. NotFound is also set based on the error.
[ "newPayloadResult", "builds", "a", "new", "PayloadResult", "from", "the", "provided", "tag", "and", "error", ".", "NotFound", "is", "also", "set", "based", "on", "the", "error", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L187-L195
157,398
juju/juju
apiserver/facades/agent/payloadshookcontext/unitfacade.go
Result2api
func Result2api(result payload.Result) params.PayloadResult { res := params.PayloadResult{ NotFound: result.NotFound, } if result.ID != "" { res.Tag = names.NewPayloadTag(result.ID).String() } if result.Payload != nil { pl := api.Payload2api(*result.Payload) res.Payload = &pl } if result.Error != nil { res.Error = common.ServerError(result.Error) } return res }
go
func Result2api(result payload.Result) params.PayloadResult { res := params.PayloadResult{ NotFound: result.NotFound, } if result.ID != "" { res.Tag = names.NewPayloadTag(result.ID).String() } if result.Payload != nil { pl := api.Payload2api(*result.Payload) res.Payload = &pl } if result.Error != nil { res.Error = common.ServerError(result.Error) } return res }
[ "func", "Result2api", "(", "result", "payload", ".", "Result", ")", "params", ".", "PayloadResult", "{", "res", ":=", "params", ".", "PayloadResult", "{", "NotFound", ":", "result", ".", "NotFound", ",", "}", "\n\n", "if", "result", ".", "ID", "!=", "\"", "\"", "{", "res", ".", "Tag", "=", "names", ".", "NewPayloadTag", "(", "result", ".", "ID", ")", ".", "String", "(", ")", "\n", "}", "\n\n", "if", "result", ".", "Payload", "!=", "nil", "{", "pl", ":=", "api", ".", "Payload2api", "(", "*", "result", ".", "Payload", ")", "\n", "res", ".", "Payload", "=", "&", "pl", "\n", "}", "\n\n", "if", "result", ".", "Error", "!=", "nil", "{", "res", ".", "Error", "=", "common", ".", "ServerError", "(", "result", ".", "Error", ")", "\n", "}", "\n\n", "return", "res", "\n", "}" ]
// Result2api converts the payload.Result into a PayloadResult.
[ "Result2api", "converts", "the", "payload", ".", "Result", "into", "a", "PayloadResult", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/apiserver/facades/agent/payloadshookcontext/unitfacade.go#L198-L217
157,399
juju/juju
cmd/juju/resource/list_charm_resources.go
NewListCharmResourcesCommand
func NewListCharmResourcesCommand(resourceLister ResourceLister) modelcmd.ModelCommand { var c ListCharmResourcesCommand c.setResourceLister(resourceLister) return modelcmd.Wrap(&c) }
go
func NewListCharmResourcesCommand(resourceLister ResourceLister) modelcmd.ModelCommand { var c ListCharmResourcesCommand c.setResourceLister(resourceLister) return modelcmd.Wrap(&c) }
[ "func", "NewListCharmResourcesCommand", "(", "resourceLister", "ResourceLister", ")", "modelcmd", ".", "ModelCommand", "{", "var", "c", "ListCharmResourcesCommand", "\n", "c", ".", "setResourceLister", "(", "resourceLister", ")", "\n", "return", "modelcmd", ".", "Wrap", "(", "&", "c", ")", "\n", "}" ]
// NewListCharmResourcesCommand returns a new command that lists resources defined // by a charm.
[ "NewListCharmResourcesCommand", "returns", "a", "new", "command", "that", "lists", "resources", "defined", "by", "a", "charm", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/resource/list_charm_resources.go#L26-L30