_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q4300 | DestroyMachine | train | func DestroyMachine(c *kvmContainer) error {
if c.runCmd == nil {
c.runCmd = run
}
if c.pathfinder == nil {
c.pathfinder = paths.DataDir
}
// We don't return errors for virsh commands because it is possible that we
// didn't succeed in creating the domain. Additionally, we want all the
// commands to run. I... | go | {
"resource": ""
} |
q4301 | AutostartMachine | train | func AutostartMachine(c *kvmContainer) error {
if c.runCmd == nil {
c.runCmd = run
}
_, err := c.runCmd("", virsh, "autostart", c.Name())
return errors.Annotatef(err, "failed to autostart domain %q", c.Name())
} | go | {
"resource": ""
} |
q4302 | guestPath | train | func guestPath(pathfinder func(string) (string, error)) (string, error) {
baseDir, err := pathfinder(series.MustHostSeries())
if err != nil {
return "", errors.Trace(err)
}
return filepath.Join(baseDir, kvm, guestDir), nil
} | go | {
"resource": ""
} |
q4303 | writeDataSourceVolume | train | func writeDataSourceVolume(params CreateMachineParams) (string, error) {
templateDir := filepath.Dir(params.UserDataFile)
if err := writeMetadata(templateDir); err != nil {
return "", errors.Trace(err)
}
if err := writeNetworkConfig(params, templateDir); err != nil {
return "", errors.Trace(err)
}
// Creat... | go | {
"resource": ""
} |
q4304 | writeDomainXML | train | func writeDomainXML(templateDir string, p CreateMachineParams) (string, error) {
domainPath := filepath.Join(templateDir, fmt.Sprintf("%s.xml", p.Host()))
dom, err := libvirt.NewDomain(p)
if err != nil {
return "", errors.Trace(err)
}
ml, err := xml.MarshalIndent(&dom, "", " ")
if err != nil {
return "", ... | go | {
"resource": ""
} |
q4305 | NewAPI | train | func NewAPI(st *state.State, res facade.Resources, auth facade.Authorizer) (SubnetsAPI, error) {
stateshim, err := networkingcommon.NewStateShim(st)
if err != nil {
return nil, errors.Trace(err)
}
return newAPIWithBacking(stateshim, state.CallContext(st), res, auth)
} | go | {
"resource": ""
} |
q4306 | AllSpaces | train | func (api *subnetsAPI) AllSpaces() (params.SpaceResults, error) {
if err := api.checkCanRead(); err != nil {
return params.SpaceResults{}, err
}
var results params.SpaceResults
spaces, err := api.backing.AllSpaces()
if err != nil {
return results, errors.Trace(err)
}
results.Results = make([]params.SpaceR... | go | {
"resource": ""
} |
q4307 | AddSubnets | train | func (api *subnetsAPI) AddSubnets(args params.AddSubnetsParams) (params.ErrorResults, error) {
if err := api.checkCanWrite(); err != nil {
return params.ErrorResults{}, err
}
return networkingcommon.AddSubnets(api.context, api.backing, args)
} | go | {
"resource": ""
} |
q4308 | NewLeaderGetCommand | train | func NewLeaderGetCommand(ctx Context) (cmd.Command, error) {
return &leaderGetCommand{ctx: ctx}, nil
} | go | {
"resource": ""
} |
q4309 | PersonalCloudMetadata | train | func PersonalCloudMetadata() (map[string]Cloud, error) {
clouds, err := ParseCloudMetadataFile(JujuPersonalCloudsPath())
if err != nil && os.IsNotExist(err) {
return nil, nil
}
return clouds, err
} | go | {
"resource": ""
} |
q4310 | ParseCloudMetadataFile | train | func ParseCloudMetadataFile(file string) (map[string]Cloud, error) {
data, err := ioutil.ReadFile(file)
if err != nil {
return nil, err
}
clouds, err := ParseCloudMetadata(data)
if err != nil {
return nil, err
}
return clouds, err
} | go | {
"resource": ""
} |
q4311 | WritePersonalCloudMetadata | train | func WritePersonalCloudMetadata(cloudsMap map[string]Cloud) error {
data, err := marshalCloudMetadata(cloudsMap)
if err != nil {
return errors.Trace(err)
}
return ioutil.WriteFile(JujuPersonalCloudsPath(), data, os.FileMode(0600))
} | go | {
"resource": ""
} |
q4312 | inferContainerSpaces | train | func (p *BridgePolicy) inferContainerSpaces(m Machine, containerId, defaultSpaceName string) (set.Strings, error) {
if p.ContainerNetworkingMethod == "local" {
return set.NewStrings(""), nil
}
hostSpaces, err := m.AllSpaces()
if err != nil {
return nil, errors.Trace(err)
}
logger.Debugf("container %q not qual... | go | {
"resource": ""
} |
q4313 | determineContainerSpaces | train | func (p *BridgePolicy) determineContainerSpaces(m Machine, containerMachine Container, defaultSpaceName string) (set.Strings, error) {
containerSpaces, err := containerMachine.DesiredSpaces()
if err != nil {
return nil, errors.Trace(err)
}
logger.Debugf("for container %q, found desired spaces: %s",
containerMac... | go | {
"resource": ""
} |
q4314 | findSpacesAndDevicesForContainer | train | func (p *BridgePolicy) findSpacesAndDevicesForContainer(m Machine, containerMachine Container) (set.Strings, map[string][]LinkLayerDevice, error) {
containerSpaces, err := p.determineContainerSpaces(m, containerMachine, "")
if err != nil {
return nil, nil, errors.Trace(err)
}
devicesPerSpace, err := m.LinkLayerDe... | go | {
"resource": ""
} |
q4315 | Manifold | train | func Manifold(config ManifoldConfig) dependency.Manifold {
return dependency.Manifold{
Inputs: []string{
config.AgentName,
config.APICallerName,
config.CentralHubName,
},
Start: func(context dependency.Context) (worker.Worker, error) {
// Get the agent.
var agent coreagent.Agent
if err := conte... | go | {
"resource": ""
} |
q4316 | formatPoolListTabular | train | func formatPoolListTabular(writer io.Writer, value interface{}) error {
pools, ok := value.(map[string]PoolInfo)
if !ok {
return errors.Errorf("expected value of type %T, got %T", pools, value)
}
formatPoolsTabular(writer, pools)
return nil
} | go | {
"resource": ""
} |
q4317 | formatPoolsTabular | train | func formatPoolsTabular(writer io.Writer, pools map[string]PoolInfo) {
tw := output.TabWriter(writer)
print := func(values ...string) {
fmt.Fprintln(tw, strings.Join(values, "\t"))
}
print("Name", "Provider", "Attrs")
poolNames := make([]string, 0, len(pools))
for name := range pools {
poolNames = append(po... | go | {
"resource": ""
} |
q4318 | IsAuthorisationFailure | train | func IsAuthorisationFailure(err error) bool {
baseErr := errors.Cause(err)
if !soap.IsSoapFault(baseErr) {
return false
}
fault := soap.ToSoapFault(baseErr)
if fault.Code != serverFaultCode {
return false
}
_, isPermissionError := fault.Detail.Fault.(types.NoPermission)
if isPermissionError {
return true
... | go | {
"resource": ""
} |
q4319 | ProcessDyingModel | train | func (st *State) ProcessDyingModel() (err error) {
model, err := st.Model()
if err != nil {
return errors.Trace(err)
}
if model.Life() != Dying {
return errors.Trace(ErrModelNotDying)
}
if st.IsController() {
// We should not mark the controller model as Dead until
// all hosted models have been remove... | go | {
"resource": ""
} |
q4320 | NewMetricsDebugAPI | train | func NewMetricsDebugAPI(
st *state.State,
resources facade.Resources,
authorizer facade.Authorizer,
) (*MetricsDebugAPI, error) {
if !authorizer.AuthClient() {
return nil, common.ErrPerm
}
return &MetricsDebugAPI{
state: st,
}, nil
} | go | {
"resource": ""
} |
q4321 | GetMetrics | train | func (api *MetricsDebugAPI) GetMetrics(args params.Entities) (params.MetricResults, error) {
results := params.MetricResults{
Results: make([]params.EntityMetrics, len(args.Entities)),
}
if len(args.Entities) == 0 {
batches, err := api.state.MetricBatchesForModel()
if err != nil {
return results, errors.Ann... | go | {
"resource": ""
} |
q4322 | SetMeterStatus | train | func (api *MetricsDebugAPI) SetMeterStatus(args params.MeterStatusParams) (params.ErrorResults, error) {
results := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Statuses)),
}
for i, arg := range args.Statuses {
tag, err := names.ParseTag(arg.Tag)
if err != nil {
results.Results[i].Error... | go | {
"resource": ""
} |
q4323 | NewPasswordChanger | train | func NewPasswordChanger(st state.EntityFinder, getCanChange GetAuthFunc) *PasswordChanger {
return &PasswordChanger{
st: st,
getCanChange: getCanChange,
}
} | go | {
"resource": ""
} |
q4324 | SetPasswords | train | func (pc *PasswordChanger) SetPasswords(args params.EntityPasswords) (params.ErrorResults, error) {
result := params.ErrorResults{
Results: make([]params.ErrorResult, len(args.Changes)),
}
if len(args.Changes) == 0 {
return result, nil
}
canChange, err := pc.getCanChange()
if err != nil {
return params.Erro... | go | {
"resource": ""
} |
q4325 | NewAddCAASCommand | train | func NewAddCAASCommand(cloudMetadataStore CloudMetadataStore) cmd.Command {
store := jujuclient.NewFileClientStore()
cmd := &AddCAASCommand{
OptionalControllerCommand: modelcmd.OptionalControllerCommand{Store: store},
cloudMetadataStore: cloudMetadataStore,
store: store,
newClientCo... | go | {
"resource": ""
} |
q4326 | getStdinPipe | train | func getStdinPipe(ctx *cmd.Context) (io.Reader, error) {
if stdIn, ok := ctx.Stdin.(*os.File); ok && !terminal.IsTerminal(int(stdIn.Fd())) {
// stdIn from pipe but not terminal
stat, err := stdIn.Stat()
if err != nil {
return nil, err
}
content, err := ioutil.ReadAll(stdIn)
if err != nil {
return nil... | go | {
"resource": ""
} |
q4327 | NewUnitsWatcher | train | func NewUnitsWatcher(st state.EntityFinder, resources facade.Resources, getCanWatch GetAuthFunc) *UnitsWatcher {
return &UnitsWatcher{
st: st,
resources: resources,
getCanWatch: getCanWatch,
}
} | go | {
"resource": ""
} |
q4328 | PreUpgradeSteps | train | func PreUpgradeSteps(_ *state.StatePool, agentConf agent.Config, isController, isMaster, isCaas bool) error {
if isCaas {
logger.Debugf("skipping disk space checks for k8s controllers")
return nil
}
if err := CheckFreeDiskSpace(agentConf.DataDir(), MinDiskSpaceMib); err != nil {
return errors.Trace(err)
}
if... | go | {
"resource": ""
} |
q4329 | CheckFreeDiskSpace | train | func CheckFreeDiskSpace(dir string, thresholdMib uint64) error {
usage := du.NewDiskUsage(dir)
available := usage.Available()
if available < thresholdMib*humanize.MiByte {
return errors.Errorf("not enough free disk space on %q for upgrade: %s available, require %dMiB",
dir, humanize.IBytes(available), threshold... | go | {
"resource": ""
} |
q4330 | ValidateState | train | func ValidateState(state string) error {
if !okayStates.Contains(state) {
supported := okayStates.Values()
sort.Strings(supported)
states := strings.Join(supported, `", "`)
msg := fmt.Sprintf(`status %q not supported; expected one of ["%s"]`, state, states)
return errors.NewNotValid(nil, msg)
}
return nil
... | go | {
"resource": ""
} |
q4331 | NewAPI | train | func NewAPI(backend Backend, resources facade.Resources, authorizer facade.Authorizer) (*API, error) {
isControllerAdmin, err := authorizer.HasPermission(permission.SuperuserAccess, backend.ControllerTag())
if err != nil && !errors.IsNotFound(err) {
return nil, errors.Trace(err)
}
if !authorizer.AuthClient() || ... | go | {
"resource": ""
} |
q4332 | CreateResult | train | func CreateResult(meta *backups.Metadata, filename string) params.BackupsMetadataResult {
var result params.BackupsMetadataResult
result.ID = meta.ID()
result.Checksum = meta.Checksum()
result.ChecksumFormat = meta.ChecksumFormat()
result.Size = meta.Size()
if meta.Stored() != nil {
result.Stored = *(meta.Sto... | go | {
"resource": ""
} |
q4333 | NewInstanceMutaterAPI | train | func NewInstanceMutaterAPI(st InstanceMutaterState,
model ModelCache,
resources facade.Resources,
authorizer facade.Authorizer,
) (*InstanceMutaterAPI, error) {
if !authorizer.AuthMachineAgent() && !authorizer.AuthController() {
return nil, common.ErrPerm
}
getAuthFunc := common.AuthFuncForMachineAgent(authori... | go | {
"resource": ""
} |
q4334 | CharmProfilingInfo | train | func (api *InstanceMutaterAPI) CharmProfilingInfo(arg params.Entity) (params.CharmProfilingInfoResult, error) {
result := params.CharmProfilingInfoResult{
ProfileChanges: make([]params.ProfileInfoResult, 0),
}
canAccess, err := api.getAuthFunc()
if err != nil {
return params.CharmProfilingInfoResult{}, errors.T... | go | {
"resource": ""
} |
q4335 | SetCharmProfiles | train | func (api *InstanceMutaterAPI) SetCharmProfiles(args params.SetProfileArgs) (params.ErrorResults, error) {
results := make([]params.ErrorResult, len(args.Args))
canAccess, err := api.getAuthFunc()
if err != nil {
return params.ErrorResults{}, errors.Trace(err)
}
for i, a := range args.Args {
err := api.setOneM... | go | {
"resource": ""
} |
q4336 | WatchMachines | train | func (api *InstanceMutaterAPI) WatchMachines() (params.StringsWatchResult, error) {
result := params.StringsWatchResult{}
if !api.authorizer.AuthController() {
return result, common.ErrPerm
}
watch, err := api.model.WatchMachines()
if err != nil {
return result, err
}
if changes, ok := <-watch.Changes(); ok... | go | {
"resource": ""
} |
q4337 | WatchContainers | train | func (api *InstanceMutaterAPI) WatchContainers(arg params.Entity) (params.StringsWatchResult, error) {
result := params.StringsWatchResult{}
canAccess, err := api.getAuthFunc()
if err != nil {
return result, errors.Trace(err)
}
tag, err := names.ParseMachineTag(arg.Tag)
if err != nil {
return result, errors.T... | go | {
"resource": ""
} |
q4338 | WatchLXDProfileVerificationNeeded | train | func (api *InstanceMutaterAPI) WatchLXDProfileVerificationNeeded(args params.Entities) (params.NotifyWatchResults, error) {
result := params.NotifyWatchResults{
Results: make([]params.NotifyWatchResult, len(args.Entities)),
}
if len(args.Entities) == 0 {
return result, nil
}
canAccess, err := api.getAuthFunc()... | go | {
"resource": ""
} |
q4339 | newTimedStatusUpdater | train | func newTimedStatusUpdater(ctx *cmd.Context, api destroyControllerAPI, controllerModelUUID string, clock clock.Clock) func(time.Duration) environmentStatus {
return func(wait time.Duration) environmentStatus {
if wait > 0 {
<-clock.After(wait)
}
// If we hit an error, status.HostedModelCount will be 0, the p... | go | {
"resource": ""
} |
q4340 | MakeCloudSpecGetter | train | func MakeCloudSpecGetter(pool Pool) func(names.ModelTag) (environs.CloudSpec, error) {
return func(tag names.ModelTag) (environs.CloudSpec, error) {
st, err := pool.Get(tag.Id())
if err != nil {
return environs.CloudSpec{}, errors.Trace(err)
}
defer st.Release()
m, err := st.Model()
if err != nil {
... | go | {
"resource": ""
} |
q4341 | MakeCloudSpecGetterForModel | train | func MakeCloudSpecGetterForModel(st *state.State) func(names.ModelTag) (environs.CloudSpec, error) {
return func(tag names.ModelTag) (environs.CloudSpec, error) {
m, err := st.Model()
if err != nil {
return environs.CloudSpec{}, errors.Trace(err)
}
configGetter := stateenvirons.EnvironConfigGetter{State: st... | go | {
"resource": ""
} |
q4342 | MakeCloudSpecWatcherForModel | train | func MakeCloudSpecWatcherForModel(st *state.State) func(names.ModelTag) (state.NotifyWatcher, error) {
return func(tag names.ModelTag) (state.NotifyWatcher, error) {
m, err := st.Model()
if err != nil {
return nil, errors.Trace(err)
}
if tag.Id() != st.ModelUUID() {
return nil, errors.New("cannot get clo... | go | {
"resource": ""
} |
q4343 | ValidateUpgradeSeriesStatus | train | func ValidateUpgradeSeriesStatus(status UpgradeSeriesStatus) (UpgradeSeriesStatus, error) {
if _, ok := UpgradeSeriesStatusOrder[status]; !ok {
return UpgradeSeriesNotStarted, errors.NotValidf("upgrade series status of %q is", status)
}
return status, nil
} | go | {
"resource": ""
} |
q4344 | CompareUpgradeSeriesStatus | train | func CompareUpgradeSeriesStatus(status1 UpgradeSeriesStatus, status2 UpgradeSeriesStatus) (int, error) {
var err error
st1, err := ValidateUpgradeSeriesStatus(status1)
st2, err := ValidateUpgradeSeriesStatus(status2)
if err != nil {
return 0, err
}
if UpgradeSeriesStatusOrder[st1] == UpgradeSeriesStatusOrder[s... | go | {
"resource": ""
} |
q4345 | NewAuthenticator | train | func NewAuthenticator(statePool *state.StatePool, clock clock.Clock) (*Authenticator, error) {
authContext, err := newAuthContext(statePool.SystemState(), clock)
if err != nil {
return nil, errors.Trace(err)
}
return &Authenticator{
statePool: statePool,
authContext: authContext,
}, nil
} | go | {
"resource": ""
} |
q4346 | Maintain | train | func (a *Authenticator) Maintain(done <-chan struct{}) {
for {
select {
case <-done:
return
case <-a.authContext.clock.After(authentication.LocalLoginInteractionTimeout):
now := a.authContext.clock.Now()
a.authContext.localUserInteractions.Expire(now)
}
}
} | go | {
"resource": ""
} |
q4347 | CreateLocalLoginMacaroon | train | func (a *Authenticator) CreateLocalLoginMacaroon(tag names.UserTag) (*macaroon.Macaroon, error) {
return a.authContext.CreateLocalLoginMacaroon(tag)
} | go | {
"resource": ""
} |
q4348 | AddHandlers | train | func (a *Authenticator) AddHandlers(mux *apiserverhttp.Mux) {
h := &localLoginHandlers{
authCtxt: a.authContext,
finder: a.statePool.SystemState(),
}
h.AddHandlers(mux)
} | go | {
"resource": ""
} |
q4349 | Authenticate | train | func (a *Authenticator) Authenticate(req *http.Request) (httpcontext.AuthInfo, error) {
modelUUID := httpcontext.RequestModelUUID(req)
if modelUUID == "" {
return httpcontext.AuthInfo{}, errors.New("model UUID not found")
}
loginRequest, err := LoginRequest(req)
if err != nil {
return httpcontext.AuthInfo{}, e... | go | {
"resource": ""
} |
q4350 | mibToGb | train | func mibToGb(m uint64) uint64 {
return common.MiBToGiB(m) * (humanize.GiByte / humanize.GByte)
} | go | {
"resource": ""
} |
q4351 | buildMAASVolumeParameters | train | func buildMAASVolumeParameters(args []storage.VolumeParams, cons constraints.Value) ([]volumeInfo, error) {
if len(args) == 0 && cons.RootDisk == nil {
return nil, nil
}
volumes := make([]volumeInfo, len(args)+1)
rootVolume := volumeInfo{name: rootDiskLabel}
if cons.RootDisk != nil {
rootVolume.sizeInGB = mibT... | go | {
"resource": ""
} |
q4352 | One | train | func (sp statePersistence) One(collName, id string, doc interface{}) error {
coll, closeColl := sp.st.db().GetCollection(collName)
defer closeColl()
err := coll.FindId(id).One(doc)
if err == mgo.ErrNotFound {
return errors.NotFoundf(id)
}
if err != nil {
return errors.Trace(err)
}
return nil
} | go | {
"resource": ""
} |
q4353 | All | train | func (sp statePersistence) All(collName string, query, docs interface{}) error {
coll, closeColl := sp.st.db().GetCollection(collName)
defer closeColl()
if err := coll.Find(query).All(docs); err != nil {
return errors.Trace(err)
}
return nil
} | go | {
"resource": ""
} |
q4354 | Run | train | func (sp statePersistence) Run(transactions jujutxn.TransactionSource) error {
if err := sp.st.db().Run(transactions); err != nil {
return errors.Trace(err)
}
return nil
} | go | {
"resource": ""
} |
q4355 | NewStorage | train | func (sp *statePersistence) NewStorage() storage.Storage {
modelUUID := sp.st.ModelUUID()
// TODO(ericsnow) Copy the session?
session := sp.st.session
store := storage.NewStorage(modelUUID, session)
return store
} | go | {
"resource": ""
} |
q4356 | ApplicationExistsOps | train | func (sp *statePersistence) ApplicationExistsOps(applicationID string) []txn.Op {
return []txn.Op{{
C: applicationsC,
Id: applicationID,
Assert: isAliveDoc,
}}
} | go | {
"resource": ""
} |
q4357 | ClientStore | train | func (c *ModelCommandBase) ClientStore() jujuclient.ClientStore {
// c.store is set in maybeInitModel() below.
if c.store == nil && !c.runStarted {
panic("inappropriate method called before init finished")
}
return c.store
} | go | {
"resource": ""
} |
q4358 | SetModelName | train | func (c *ModelCommandBase) SetModelName(modelName string, allowDefault bool) error {
c._modelName = modelName
c.allowDefaultModel = allowDefault
// After setting the model name, we may need to ensure we have access to the
// other model details if not already done.
if err := c.maybeInitModel(); err != nil {
ret... | go | {
"resource": ""
} |
q4359 | ModelName | train | func (c *ModelCommandBase) ModelName() (string, error) {
c.assertRunStarted()
if err := c.maybeInitModel(); err != nil {
return "", errors.Trace(err)
}
return c._modelName, nil
} | go | {
"resource": ""
} |
q4360 | ModelType | train | func (c *ModelCommandBase) ModelType() (model.ModelType, error) {
if c._modelType != "" {
return c._modelType, nil
}
// If we need to look up the model type, we need to ensure we
// have access to the model details.
if err := c.maybeInitModel(); err != nil {
return "", errors.Trace(err)
}
details, err := c.s... | go | {
"resource": ""
} |
q4361 | SetActiveBranch | train | func (c *ModelCommandBase) SetActiveBranch(branchName string) error {
_, modelDetails, err := c.ModelDetails()
if err != nil {
return errors.Annotate(err, "getting model details")
}
modelDetails.ActiveBranch = branchName
if err = c.store.UpdateModel(c._controllerName, c._modelName, *modelDetails); err != nil {
... | go | {
"resource": ""
} |
q4362 | ActiveBranch | train | func (c *ModelCommandBase) ActiveBranch() (string, error) {
if c._activeBranch != "" {
return c._activeBranch, nil
}
// If we need to look up the model generation, we need to ensure we
// have access to the model details.
if err := c.maybeInitModel(); err != nil {
return "", errors.Trace(err)
}
details, err ... | go | {
"resource": ""
} |
q4363 | ControllerName | train | func (c *ModelCommandBase) ControllerName() (string, error) {
c.assertRunStarted()
if err := c.maybeInitModel(); err != nil {
return "", errors.Trace(err)
}
return c._controllerName, nil
} | go | {
"resource": ""
} |
q4364 | NewAPIRoot | train | func (c *ModelCommandBase) NewAPIRoot() (api.Connection, error) {
// We need to call ModelDetails() here and not just ModelName() to force
// a refresh of the internal model details if those are not yet stored locally.
modelName, _, err := c.ModelDetails()
if err != nil {
return nil, errors.Trace(err)
}
return ... | go | {
"resource": ""
} |
q4365 | newAPIRoot | train | func (c *ModelCommandBase) newAPIRoot(modelName string) (api.Connection, error) {
controllerName, err := c.ControllerName()
if err != nil {
return nil, errors.Trace(err)
}
return c.CommandBase.NewAPIRoot(c.store, controllerName, modelName)
} | go | {
"resource": ""
} |
q4366 | Wrap | train | func Wrap(c ModelCommand, options ...WrapOption) ModelCommand {
wrapper := &modelCommandWrapper{
ModelCommand: c,
skipModelFlags: false,
useDefaultModel: true,
}
for _, option := range options {
option(wrapper)
}
// Define a new type so that we can embed the ModelCommand
// interface one level deeper ... | go | {
"resource": ""
} |
q4367 | validateCommandForModelType | train | func (w *modelCommandWrapper) validateCommandForModelType(runStarted bool) error {
_, iaasOnly := w.inner().(IAASOnlyCommand)
_, caasOnly := w.inner().(CAASOnlyCommand)
if !caasOnly && !iaasOnly {
return nil
}
modelType, err := w.ModelCommand.ModelType()
if err != nil {
err = errors.Cause(err)
// We need t... | go | {
"resource": ""
} |
q4368 | BootstrapContext | train | func BootstrapContext(cmdContext *cmd.Context) environs.BootstrapContext {
return &bootstrapContext{
Context: cmdContext,
verifyCredentials: true,
}
} | go | {
"resource": ""
} |
q4369 | BootstrapContextNoVerify | train | func BootstrapContextNoVerify(cmdContext *cmd.Context) environs.BootstrapContext {
return &bootstrapContext{
Context: cmdContext,
verifyCredentials: false,
}
} | go | {
"resource": ""
} |
q4370 | SplitModelName | train | func SplitModelName(name string) (controller, model string) {
if i := strings.IndexRune(name, ':'); i >= 0 {
return name[:i], name[i+1:]
}
return "", name
} | go | {
"resource": ""
} |
q4371 | vmExtensionProperties | train | func vmExtensionProperties(os jujuos.OSType) (*compute.VirtualMachineExtensionProperties, error) {
var commandToExecute, extensionPublisher, extensionType, extensionVersion string
switch os {
case jujuos.Windows:
commandToExecute = windowsExecuteCustomScriptCommand
extensionPublisher = windowsCustomScriptPublis... | go | {
"resource": ""
} |
q4372 | NewUpgradeCharmCommand | train | func NewUpgradeCharmCommand() cmd.Command {
cmd := &upgradeCharmCommand{
DeployResources: resourceadapters.DeployResources,
ResolveCharm: resolveCharm,
NewCharmAdder: newCharmAdder,
NewCharmClient: func(conn base.APICallCloser) CharmClient {
return charms.NewClient(conn)
},
NewCharmUpgradeClient: f... | go | {
"resource": ""
} |
q4373 | addCharm | train | func (c *upgradeCharmCommand) addCharm(
charmAdder CharmAdder,
charmRepo *charmrepo.CharmStore,
config *config.Config,
oldURL *charm.URL,
charmRef string,
deployedSeries string,
force bool,
) (charmstore.CharmID, *macaroon.Macaroon, error) {
var id charmstore.CharmID
// Charm may have been supplied via a path ... | go | {
"resource": ""
} |
q4374 | FormatOneline | train | func FormatOneline(writer io.Writer, value interface{}) error {
return formatOneline(writer, value, func(out io.Writer, format, uName string, u unitStatus, level int) {
status := fmt.Sprintf(
"agent:%s, workload:%s",
u.JujuStatusInfo.Current,
u.WorkloadStatusInfo.Current,
)
fmt.Fprintf(out, format,
u... | go | {
"resource": ""
} |
q4375 | EnsureCachedImage | train | func (c *kvmContainer) EnsureCachedImage(params StartParams) error {
var srcFunc func() simplestreams.DataSource
if params.ImageDownloadURL != "" {
srcFunc = func() simplestreams.DataSource {
return imagedownloads.NewDataSource(params.ImageDownloadURL)
}
}
var fType = BIOSFType
if params.Arch == arch.ARM64 ... | go | {
"resource": ""
} |
q4376 | Start | train | func (c *kvmContainer) Start(params StartParams) error {
var bridge string
var interfaces []libvirt.InterfaceInfo
if params.Network != nil {
if params.Network.NetworkType == container.BridgeNetwork {
bridge = params.Network.Device
for _, iface := range params.Network.Interfaces {
interfaces = append(inte... | go | {
"resource": ""
} |
q4377 | InstanceAvailabilityZoneNames | train | func (o *OracleEnviron) InstanceAvailabilityZoneNames(ctx context.ProviderCallContext, ids []instance.Id) ([]string, error) {
instances, err := o.Instances(ctx, ids)
if err != nil && err != environs.ErrPartialInstances {
return nil, err
}
zones := make([]string, len(instances))
for idx := range instances {
zon... | go | {
"resource": ""
} |
q4378 | NewOracleEnviron | train | func NewOracleEnviron(p *EnvironProvider, args environs.OpenParams, client EnvironAPI, c clock.Clock) (env *OracleEnviron, err error) {
if client == nil {
return nil, errors.NotFoundf("oracle client")
}
if p == nil {
return nil, errors.NotFoundf("environ proivder")
}
env = &OracleEnviron{
p: p,
spec: ... | go | {
"resource": ""
} |
q4379 | buildSpacesMap | train | func (e *OracleEnviron) buildSpacesMap(ctx context.ProviderCallContext) (map[string]network.SpaceInfo, map[string]string, error) {
empty := set.Strings{}
providerIdMap := map[string]string{}
// NOTE (gsamfira): This seems brittle to me, and I would much rather get this
// from state, as that information should alre... | go | {
"resource": ""
} |
q4380 | StopInstances | train | func (o *OracleEnviron) StopInstances(ctx context.ProviderCallContext, ids ...instance.Id) error {
oracleInstances, err := o.getOracleInstances(ids...)
if err == environs.ErrNoInstances {
return nil
} else if err != nil {
return err
}
logger.Debugf("terminating instances %v", ids)
if err := o.terminateInstan... | go | {
"resource": ""
} |
q4381 | getOracleInstances | train | func (o *OracleEnviron) getOracleInstances(ids ...instance.Id) ([]*oracleInstance, error) {
ret := make([]*oracleInstance, 0, len(ids))
resp, err := o.client.AllInstances(nil)
if err != nil {
return nil, errors.Trace(err)
}
if len(resp.Result) == 0 {
return nil, environs.ErrNoInstances
}
for _, val := rang... | go | {
"resource": ""
} |
q4382 | AllInstances | train | func (o *OracleEnviron) AllInstances(ctx context.ProviderCallContext) ([]envinstance.Instance, error) {
tagFilter := tagValue{tags.JujuModel, o.Config().UUID()}
all, err := o.allInstances(tagFilter)
if err != nil {
return nil, err
}
ret := make([]envinstance.Instance, len(all))
for i, val := range all {
ret[... | go | {
"resource": ""
} |
q4383 | MaintainInstance | train | func (o *OracleEnviron) MaintainInstance(ctx context.ProviderCallContext, args environs.StartInstanceParams) error {
return nil
} | go | {
"resource": ""
} |
q4384 | Config | train | func (o *OracleEnviron) Config() *config.Config {
o.mutex.Lock()
defer o.mutex.Unlock()
return o.cfg
} | go | {
"resource": ""
} |
q4385 | ConstraintsValidator | train | func (o *OracleEnviron) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) {
// list of unsupported oracle provider constraints
unsupportedConstraints := []string{
constraints.Container,
constraints.CpuPower,
constraints.RootDisk,
constraints.VirtType,
}
// we choose to us... | go | {
"resource": ""
} |
q4386 | DestroyController | train | func (o *OracleEnviron) DestroyController(ctx context.ProviderCallContext, controllerUUID string) error {
err := o.Destroy(ctx)
if err != nil {
logger.Errorf("Failed to destroy environment through controller: %s", errors.Trace(err))
}
instances, err := o.allControllerManagedInstances(controllerUUID)
if err != ni... | go | {
"resource": ""
} |
q4387 | InstanceTypes | train | func (o *OracleEnviron) InstanceTypes(context.ProviderCallContext, constraints.Value) (envinstance.InstanceTypesWithCostMetadata, error) {
var i envinstance.InstanceTypesWithCostMetadata
return i, nil
} | go | {
"resource": ""
} |
q4388 | createInstance | train | func (e *OracleEnviron) createInstance(params oci.InstanceParams) (*oracleInstance, error) {
if len(params.Instances) > 1 {
return nil, errors.NotSupportedf("launching multiple instances")
}
logger.Debugf("running createInstance")
resp, err := e.client.CreateInstance(params)
if err != nil {
return nil, errors... | go | {
"resource": ""
} |
q4389 | IsAvailabilityZoneIndependent | train | func IsAvailabilityZoneIndependent(err error) bool {
if err, ok := errors.Cause(err).(AvailabilityZoneError); ok {
return err.AvailabilityZoneIndependent()
}
return false
} | go | {
"resource": ""
} |
q4390 | OSDependentEnvVars | train | func OSDependentEnvVars(paths Paths) []string {
switch jujuos.HostOS() {
case jujuos.Windows:
return windowsEnv(paths)
case jujuos.Ubuntu:
return ubuntuEnv(paths)
case jujuos.CentOS:
return centosEnv(paths)
case jujuos.OpenSUSE:
return opensuseEnv(paths)
}
return nil
} | go | {
"resource": ""
} |
q4391 | windowsEnv | train | func windowsEnv(paths Paths) []string {
charmDir := paths.GetCharmDir()
charmModules := filepath.Join(charmDir, "lib", "Modules")
return []string{
"Path=" + paths.GetToolsDir() + ";" + os.Getenv("Path"),
"PSModulePath=" + os.Getenv("PSModulePath") + ";" + charmModules,
}
} | go | {
"resource": ""
} |
q4392 | stateStepsFor223 | train | func stateStepsFor223() []Step {
return []Step{
&upgradeStep{
description: "add max-action-age and max-action-size config settings",
targets: []Target{DatabaseMaster},
run: func(context Context) error {
return context.State().AddActionPruneSettings()
},
},
}
} | go | {
"resource": ""
} |
q4393 | DestroyController | train | func (c *ControllerAPIv3) DestroyController(args params.DestroyControllerArgs) error {
if args.DestroyStorage != nil {
return errors.New("destroy-storage unexpected on the v3 API")
}
destroyStorage := true
args.DestroyStorage = &destroyStorage
return destroyController(c.state, c.statePool, c.authorizer, args)
} | go | {
"resource": ""
} |
q4394 | DestroyController | train | func (c *ControllerAPI) DestroyController(args params.DestroyControllerArgs) error {
return destroyController(c.state, c.statePool, c.authorizer, args)
} | go | {
"resource": ""
} |
q4395 | Resource2API | train | func Resource2API(res resource.Resource) params.Resource {
return params.Resource{
CharmResource: CharmResource2API(res.Resource),
ID: res.ID,
PendingID: res.PendingID,
ApplicationID: res.ApplicationID,
Username: res.Username,
Timestamp: res.Timestamp,
}
} | go | {
"resource": ""
} |
q4396 | APIResult2ApplicationResources | train | func APIResult2ApplicationResources(apiResult params.ResourcesResult) (resource.ApplicationResources, error) {
var result resource.ApplicationResources
if apiResult.Error != nil {
// TODO(ericsnow) Return the resources too?
err := common.RestoreError(apiResult.Error)
return resource.ApplicationResources{}, err... | go | {
"resource": ""
} |
q4397 | API2Resource | train | func API2Resource(apiRes params.Resource) (resource.Resource, error) {
var res resource.Resource
charmRes, err := API2CharmResource(apiRes.CharmResource)
if err != nil {
return res, errors.Trace(err)
}
res = resource.Resource{
Resource: charmRes,
ID: apiRes.ID,
PendingID: apiRes.Pendi... | go | {
"resource": ""
} |
q4398 | CharmResource2API | train | func CharmResource2API(res charmresource.Resource) params.CharmResource {
return params.CharmResource{
Name: res.Name,
Type: res.Type.String(),
Path: res.Path,
Description: res.Description,
Origin: res.Origin.String(),
Revision: res.Revision,
Fingerprint: res.Fingerprint.Byte... | go | {
"resource": ""
} |
q4399 | API2CharmResource | train | func API2CharmResource(apiInfo params.CharmResource) (charmresource.Resource, error) {
var res charmresource.Resource
rtype, err := charmresource.ParseType(apiInfo.Type)
if err != nil {
return res, errors.Trace(err)
}
origin, err := charmresource.ParseOrigin(apiInfo.Origin)
if err != nil {
return res, error... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.