// WriteServiceFiles mocks base method
768406
func (m *MockSystemdServiceManager) WriteServiceFiles() error {
	ret := m.ctrl.Call(m, "WriteServiceFiles")
	ret0, _ := ret[0].(error)
	return ret0
}
421074
func (m *MockGauge) Write(arg0 *go0.Metric) error {
	ret := m.ctrl.Call(m, "Write", arg0)
	ret0, _ := ret[0].(error)
	return ret0
}
836080
func (w *ControllersWriter) WriteInitService(encoders, decoders []*EncoderTemplateData) error {
	ctx := map[string]interface{}{
		"API":      design.Design,
		"Encoders": encoders,
		"Decoders": decoders,
	}
	return w.ExecuteTemplate("service", serviceT, nil, ctx)
}
1324756
func (service *GCSService) WriteObject(ctx context.Context, params GCSObjectParams, r io.Reader) (int64, error) {
	obj := service.Client.Bucket(params.Bucket).Object(params.ID)

	w := obj.NewWriter(ctx)

	n, err := io.Copy(w, r)
	if err != nil {
		return 0, err
	}

	err = w.Close()
	if err != nil {
		if gErr, ok := err.(*googleapi.Error); ok && gErr.Code == 404 {
			return 0, fmt.Errorf("gcsstore: the bucket %s could not be found while trying to write an object", params.Bucket)
		}
		return 0, err
	}

	return n, err
}
208186
func (c *RefCount) DecWrites() {
	tracebackEvent(c, c.NumRef(), decWritesEvent)
	n := atomic.AddInt32(&c.writes, -1)

	if ref := c.NumRef(); ref < 1 {
		err := fmt.Errorf("write finish after free: writes=%d, ref=%d", n, ref)
		panicRef(c, err)
	}
}
868191
func writeConfFile(config servicedefinition.ConfigFile) error {
	// write file with default perms
	if err := os.MkdirAll(filepath.Dir(config.Filename), 0755); err != nil {
		glog.Errorf("could not create directories for config file: %s", config.Filename)
		return err
	}
	if err := ioutil.WriteFile(config.Filename, []byte(config.Content), os.FileMode(0664)); err != nil {
		glog.Errorf("Could not write out config file %s", config.Filename)
		return err
	}
	glog.Infof("Wrote config file %s", config.Filename)

	// change owner and permissions
	if err := chownConfFile(config.Filename, config.Owner, config.Permissions); err != nil {
		return err
	}

	return nil
}
235629
func writeCSRFilesIfNotExist(csrDir string, baseName string, csr *x509.CertificateRequest, key crypto.Signer) error {
	if pkiutil.CSROrKeyExist(csrDir, baseName) {
		_, _, err := pkiutil.TryLoadCSRAndKeyFromDisk(csrDir, baseName)
		if err != nil {
			return errors.Wrapf(err, "%s CSR existed but it could not be loaded properly", baseName)
		}

		fmt.Printf("[certs] Using the existing %q CSR\n", baseName)
	} else {
		// Write .key and .csr files to disk
		fmt.Printf("[certs] Generating %q key and CSR\n", baseName)

		if err := pkiutil.WriteKey(csrDir, baseName, key); err != nil {
			return errors.Wrapf(err, "failure while saving %s key", baseName)
		}

		if err := pkiutil.WriteCSR(csrDir, baseName, csr); err != nil {
			return errors.Wrapf(err, "failure while saving %s CSR", baseName)
		}
	}

	return nil
}
320334
func (mlf *MockLogFile) Write(contents []byte) {
	mlf.mu.Lock()
	defer mlf.mu.Unlock()

	mlf.logBuffer = append(mlf.logBuffer, contents...)
}
374662
func ContainerWrite(ctx Context, containers []types.Container) error {
	render := func(format func(subContext SubContext) error) error {
		for _, container := range containers {
			err := format(&containerContext{trunc: ctx.Trunc, c: container})
			if err != nil {
				return err
			}
		}
		return nil
	}
	return ctx.Write(newContainerContext(), render)
}
244133
func installServiceFile(context Context) error {
	hostSeries, err := series.HostSeries()
	if err == nil {
		initName, err := service.VersionInitSystem(hostSeries)
		if err != nil {
			logger.Errorf("unsuccessful writing the service files in /lib/systemd/system path")
			return err
		} else {
			if initName == service.InitSystemSystemd {
				oldDataDir := context.AgentConfig().DataDir()
				oldInitDataDir := filepath.Join(oldDataDir, "init")

				sysdManager := service.NewServiceManagerWithDefaults()
				err = sysdManager.WriteServiceFiles()
				if err != nil {
					logger.Errorf("unsuccessful writing the service files in /lib/systemd/system path")
					return err
				}
				// Cleanup the old dir - /var/lib/init
				return os.RemoveAll(oldInitDataDir)
			} else {
				logger.Infof("upgrade to systemd possible only for 'xenial' and above")
				return nil
			}
		}
	} else {
		return errors.Trace(err)
	}
}
142706
func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error {
	r.err = err
	return r.WriteHeaderAndEntity(httpStatus, err)
}
1065079
func (s *CfgServiceLBState) Write() error {
	key := fmt.Sprintf(serviceLBConfigPath, s.ID)
	err := s.StateDriver.WriteState(key, s, json.Marshal)
	return err
}
234441
func (s *WriteService) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error {
	return s.WriteF(ctx, org, bucket, r)
}
974865
func StorageServices(ctx types.Context) <-chan types.StorageService {
	c := make(chan types.StorageService)
	go func() {
		for _, v := range getStorageServices(ctx) {
			c <- v
		}
		close(c)
	}()
	return c
}
554249
func (rw *RefWriter) WriteRefs(n ipld.Node, enc cidenc.Encoder) (int, error) {
	return rw.writeRefsRecursive(n, 0, enc)
}
911399
func (b *Batcher) Write(ctx context.Context, org, bucket platform.ID, r io.Reader) error {
	ctx, cancel := context.WithCancel(ctx)
	defer cancel()

	if b.Service == nil {
		return fmt.Errorf("destination write service required")
	}

	lines := make(chan []byte)

	errC := make(chan error, 2)
	go b.write(ctx, org, bucket, lines, errC)
	go b.read(ctx, r, lines, errC)

	// we loop twice to check if both read and write have an error. if read exits
	// cleanly, then we still want to wait for write.
	for i := 0; i < 2; i++ {
		select {
		case <-ctx.Done():
			return ctx.Err()
		case err := <-errC:
			// onky if there is any error, exit immediately.
			if err != nil {
				return err
			}
		}
	}
	return nil
}
1357933
func (m *MockVolumeDriver) Write(arg0 string, arg1 []byte, arg2 uint64, arg3 int64) (int64, error) {
	ret := m.ctrl.Call(m, "Write", arg0, arg1, arg2, arg3)
	ret0, _ := ret[0].(int64)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}