// Init sets up the fake execution environment
779319
func Init(opts *Options) error {
	// verify opts is defined
	if opts == nil {
		return fmt.Errorf("vtaclcheck.Init: opts is NULL")
	}
	// Verify options
	if opts.ACLFile == "" && opts.StaticAuthFile == "" {
		return fmt.Errorf("no options specified")
	}

	options = opts

	return nil
}
55988
func (p *Provider) Init() error {
	defaultRuleTpl, err := provider.MakeDefaultRuleTemplate(p.DefaultRule, nil)
	if err != nil {
		return fmt.Errorf("error while parsing default rule: %v", err)
	}

	p.defaultRuleTpl = defaultRuleTpl
	return nil
}
425447
func (h *Handler) init(cfg config.Configuration) error {
	if cfg.Sampler != nil && cfg.Sampler.SamplingServerURL == "" {
		cfg.Sampler.SamplingServerURL = h.samplingServerURL
	}
	if cfg.Reporter != nil && cfg.Reporter.LocalAgentHostPort == "" {
		cfg.Reporter.LocalAgentHostPort = h.agentHostPort
	}
	tracer, _, err := cfg.New(common.DefaultTracerServiceName)
	if err != nil {
		return err
	}
	h.tracers[cfg.Sampler.Type] = tracer
	return nil
}
1173980
func (s *Server) Init(ctx context.Context) (*Server, error) {

	s.initRouter()

	// Add authorization handler. This must come BEFORE authentication handler
	// so that the latter can run first.
	switch s.authorization {
	case AuthorizationBasic:
		s.Handler = authorizer.NewBasic(
			s.Handler,
			s.getCompiler,
			s.store,
			authorizer.Runtime(s.runtime),
			authorizer.Decision(s.manager.Config.DefaultAuthorizationDecisionRef))
	}

	switch s.authentication {
	case AuthenticationToken:
		s.Handler = identifier.NewTokenBased(s.Handler)
	case AuthenticationTLS:
		s.Handler = identifier.NewTLSBased(s.Handler)
	}

	txn, err := s.store.NewTransaction(ctx, storage.WriteParams)
	if err != nil {
		return nil, err
	}

	// Register triggers so that if runtime reloads the policies, the
	// server sees the change.
	config := storage.TriggerConfig{
		OnCommit: s.reload,
	}
	if _, err := s.store.Register(ctx, txn, config); err != nil {
		s.store.Abort(ctx, txn)
		return nil, err
	}

	s.manager.RegisterCompilerTrigger(s.migrateWatcher)

	s.watcher, err = watch.New(ctx, s.store, s.getCompiler(), txn)
	if err != nil {
		return nil, err
	}

	s.partials = map[string]rego.PartialResult{}

	bp := bundle.Lookup(s.manager)
	if bp != nil {
		s.bundleStatusMtx = new(sync.RWMutex)
		s.hasBundle = true
		bp.Register("REST API Server", func(status bundle.Status) {
			s.updateBundleStatus(status)
		})
	}

	return s, s.store.Commit(ctx, txn)
}
402864
func (h *multiHandler) Init() error {
	for _, handler := range h.handlers {
		if err := handler.Init(); err != nil {
			return err
		}
	}
	return nil
}
1258910
func (r *Rx) Init(b []byte) {
	r.p.init(b)
	r.tail = 0xfffffffe * jump
	r.head = r.tail
}
1161532
func init() {
	if os.Getenv("DEBUG") != "" {
		logger = glog.New(os.Stderr, "", logFlags)
	} else {
		logger = noopLogger{}
	}
}
713794
func (c *removeCommand) Init(args []string) (err error) {
	if c.Kind == "" {
		return errors.New("image kind must be specified")
	}
	if c.Series == "" {
		return errors.New("image series must be specified")
	}
	if c.Arch == "" {
		return errors.New("image architecture must be specified")
	}
	return cmd.CheckEmpty(args)
}
1077523
func (ga *GeneticAlgorithm) Init(populationSize, parallelSimulations int) {
	ga.populationSize = populationSize
	ga.population = ga.createPopulation()
	ga.parallelSimulations = parallelSimulations

	ga.waitGroup = new(sync.WaitGroup)

}
609414
func (c *Cmd) Init() {
	c.Lock()
	defer c.Unlock()

	c.exitCh = make(chan struct{})
}
999238
func (d *VppDriver) Init(info *core.InstanceInfo) error {
	log.Infof("Initializing vppdriver")

	return nil
}
657437
func (s *BaseGenerator) Init() {
	s.Position = vm.Position{State: vm.NewState()}
}
525775
func (c *Client) Init() error {
	stdin, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		return errors.Annotate(err, "failed to read stdin").Err()
	}

	c.InitBuild = &pb.Build{}
	if err := proto.Unmarshal(stdin, c.InitBuild); err != nil {
		return errors.Annotate(err, "failed to parse buildbucket.v2.Build from stdin").Err()
	}

	if c.Logdog, err = bootstrap.Get(); err != nil {
		return err
	}

	buildTimestamp := c.BuildTimestamp
	if buildTimestamp.IsZero() {
		buildTimestamp = time.Now()
	}

	c.buildStream, err = c.Logdog.Client.NewStream(streamproto.Flags{
		Name:        streamproto.StreamNameFlag(BuildStreamName),
		Type:        streamproto.StreamType(logpb.StreamType_DATAGRAM),
		ContentType: protoutil.BuildMediaType,
		Timestamp:   clockflag.Time(buildTimestamp),
	})
	return err
}
800873
func (o *lazyObject) init() error {
	o.lock.Lock()
	defer o.lock.Unlock()
	if o.loaded {
		return o.err
	}
	o.mapper, o.err = o.loader()
	o.loaded = true
	return o.err
}
48156
func (t *ObjectTree) Init(flags byte) *ObjectTree {
	t.Tree.Init(objectCompare, flags)
	return t
}
278491
func (c *BootstrapCommand) Init(args []string) error {
	if len(args) == 0 {
		return errors.New("bootstrap-params file must be specified")
	}
	if err := cmd.CheckEmpty(args[1:]); err != nil {
		return err
	}
	c.BootstrapParamsFile = args[0]
	return c.AgentConf.CheckArgs(args[1:])
}
1196088
func (c *Client) init() error {
	// Ensure the state dir exists if we have one
	if c.config.StateDir != "" {
		if err := os.MkdirAll(c.config.StateDir, 0700); err != nil {
			return fmt.Errorf("failed creating state dir: %s", err)
		}

	} else {
		// Otherwise make a temp directory to use.
		p, err := ioutil.TempDir("", "NomadClient")
		if err != nil {
			return fmt.Errorf("failed creating temporary directory for the StateDir: %v", err)
		}

		p, err = filepath.EvalSymlinks(p)
		if err != nil {
			return fmt.Errorf("failed to find temporary directory for the StateDir: %v", err)
		}

		c.config.StateDir = p
	}
	c.logger.Info("using state directory", "state_dir", c.config.StateDir)

	// Open the state database
	db, err := c.config.StateDBFactory(c.logger, c.config.StateDir)
	if err != nil {
		return fmt.Errorf("failed to open state database: %v", err)
	}

	// Upgrade the state database
	if err := db.Upgrade(); err != nil {
		// Upgrade only returns an error on critical persistence
		// failures in which an operator should intervene before the
		// node is accessible. Upgrade drops and logs corrupt state it
		// encounters, so failing to start the agent should be extremely
		// rare.
		return fmt.Errorf("failed to upgrade state database: %v", err)
	}

	c.stateDB = db

	// Ensure the alloc dir exists if we have one
	if c.config.AllocDir != "" {
		if err := os.MkdirAll(c.config.AllocDir, 0711); err != nil {
			return fmt.Errorf("failed creating alloc dir: %s", err)
		}
	} else {
		// Otherwise make a temp directory to use.
		p, err := ioutil.TempDir("", "NomadClient")
		if err != nil {
			return fmt.Errorf("failed creating temporary directory for the AllocDir: %v", err)
		}

		p, err = filepath.EvalSymlinks(p)
		if err != nil {
			return fmt.Errorf("failed to find temporary directory for the AllocDir: %v", err)
		}

		// Change the permissions to have the execute bit
		if err := os.Chmod(p, 0711); err != nil {
			return fmt.Errorf("failed to change directory permissions for the AllocDir: %v", err)
		}

		c.config.AllocDir = p
	}

	c.logger.Info("using alloc directory", "alloc_dir", c.config.AllocDir)
	return nil
}