// init processes the storage state directory and creates storagers
// for the state files found.
773639
func (a *Attachments) init() error {
	if err := os.MkdirAll(a.storageStateDir, 0755); err != nil {
		return errors.Annotate(err, "creating storage state dir")
	}
	// Query all remote, known storage attachments for the unit,
	// so we can cull state files, and store current context.
	attachmentIds, err := a.st.UnitStorageAttachments(a.unitTag)
	if err != nil {
		return errors.Annotate(err, "getting unit attachments")
	}
	attachmentsByTag := make(map[names.StorageTag]struct{})
	for _, attachmentId := range attachmentIds {
		storageTag, err := names.ParseStorageTag(attachmentId.StorageTag)
		if err != nil {
			return errors.Trace(err)
		}
		attachmentsByTag[storageTag] = struct{}{}
	}
	stateFiles, err := readAllStateFiles(a.storageStateDir)
	if err != nil {
		return errors.Annotate(err, "reading storage state dirs")
	}
	for storageTag, stateFile := range stateFiles {
		if _, ok := attachmentsByTag[storageTag]; !ok {
			// We have previously removed the storage from state,
			// but did not remove the state file. Remove the file.
			if err := stateFile.Remove(); err != nil {
				return errors.Trace(err)
			}
			continue
		}
		// Since there's a state file, we must previously have handled
		// at least "storage-attached", so there is no possibility of
		// short-circuiting the storage's removal.
		attachment, err := a.st.StorageAttachment(storageTag, a.unitTag)
		if err != nil {
			return errors.Annotatef(
				err, "querying storage attachment %q",
				storageTag.Id(),
			)
		}
		a.storageAttachments[storageTag] = storageAttachment{
			stateFile,
			&contextStorage{
				tag:      storageTag,
				kind:     storage.StorageKind(attachment.Kind),
				location: attachment.Location,
			},
		}
	}
	for storageTag := range attachmentsByTag {
		if _, ok := stateFiles[storageTag]; !ok {
			// There is no state file for the attachment, so no
			// hooks have been committed for it.
			a.pending.Add(storageTag)
		}
		// Non-locally recorded attachments will be further handled
		// by the resolver.
	}
	return nil
}
843319
func (d *driver) Init(ctx types.Context, config gofig.Config) error {
	d.config = config

	fields := log.Fields{
		"endpoint":   d.endpoint(),
		"userName":   d.userName(),
		"group":      d.group(),
		"insecure":   d.insecure(),
		"volumePath": d.volumePath(),
		"dataSubnet": d.dataSubnet(),
	}

	if d.password() == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}

	var err error

	if d.client, err = isi.NewClientWithArgs(ctx,
		d.endpoint(),
		d.insecure(),
		d.userName(),
		d.group(),
		d.password(),
		d.volumePath()); err != nil {
		return goof.WithFieldsE(fields,
			"error creating isilon client", err)
	}

	log.WithFields(fields).Info("storage driver initialized")
	return nil
}
1197198
func Init(l ...Logger) {
	for _, logger := range l {
		gl.loggers = append(gl.loggers, logger)
	}
}
1229351
func (w *BatchedFileWriter) init() {
	w.totalSize = 0
	w.currentMultiPart = 0
	w.completedParts = []*s3.CompletedPart{}
	w.activeBuffer = newS3ByteBuffer()

	w.createMultipartUpload()
}
956397
func (c *ConnWriter) Init(config map[string]interface{}) error {
	conf, err := json.Marshal(config)
	if err != nil {
		return err
	}
	return json.Unmarshal(conf, c)
}
1308010
func (is *InfoSyncer) Init(ctx context.Context) error {
	return is.newSessionAndStoreServerInfo(ctx, owner.NewSessionDefaultRetryCnt)
}
677326
func Init(root string, _ []string) (volume.Driver, error) {
	driver := &RsyncDriver{
		root: root,
	}
	if err := os.MkdirAll(driver.MetadataDir(), 0755); err != nil && !os.IsExist(err) {
		return nil, err
	}
	if err := volume.TouchFlagFile(driver.poolDir()); err != nil {
		return nil, err
	}
	return driver, nil
}
374412
func (self *StructTypeDef) Init() *StructTypeDef {
	if self.Fields == nil {
		self.Fields = make([]*StructFieldDef, 0)
	}
	return self
}
266128
func (c *restoreCommand) Init(args []string) error {
	if c.Filename == "" && c.BackupId == "" {
		return errors.Errorf("you must specify either a file or a backup id.")
	}
	if c.Filename != "" && c.BackupId != "" {
		return errors.Errorf("you must specify either a file or a backup id but not both.")
	}

	if c.Filename != "" {
		var err error
		c.Filename, err = filepath.Abs(c.Filename)
		if err != nil {
			return errors.Trace(err)
		}
	}

	return nil
}
644309
func (k *KubeBoot) Init(volumesProvider Volumes) {
	k.volumeMounter = newVolumeMountController(volumesProvider)
	k.etcdControllers = make(map[string]*EtcdController)
}
251042
func init() {
	for out, _ := range collector.DataOutput {
		collector.DataOutputLib = append(collector.DataOutputLib, out)
	}
	sort.Strings(collector.DataOutputLib)
}
244295
func (c *kregistry) Init(opts ...registry.Option) error {
	return configure(c, opts...)
}
899497
func Init() bool {
	initializer, exists := registeredInitializers[os.Args[0]]
	if exists {
		initializer()

		return true
	}
	return false
}
95546
func Init() {
	// Root path is automatically determined from the calling function's source file location.
	// Catch the calling function's source file path.
	_, file, _, _ := runtime.Caller(1)
	// Save the directory alone.
	rootPath = filepath.Dir(file)

	appInfo = make(map[string]string)
}
1018406
func (s *Store) Init(btlPolicy pvtdatapolicy.BTLPolicy) {
	s.pvtdataStore.Init(btlPolicy)
}
1351161
func (c *attachStorageCommand) Init(args []string) error {
	if len(args) < 2 {
		return errors.New("attach-storage requires a unit ID and at least one storage ID")
	}
	c.unitId = args[0]
	c.storageIds = args[1:]
	return nil
}
621521
func (w *FileLogWriter) Init(config map[string]interface{}) error {
	if config == nil {
		return errors.New("config can not be empty")
	}
	if filename, ok := config["filename"]; !ok || len(filename.(string)) == 0 {
		return errors.New("config must have filename")
	}
	conf, err := json.Marshal(config)
	if err != nil {
		return err
	}
	err = json.Unmarshal(conf, w)
	if err != nil {
		return err
	}
	return w.startLogger()
}