// InitOnboarding will invoke the onboarding / setup wizard
1250
func (s *Action) InitOnboarding(ctx context.Context, c *cli.Context) error {
	remote := c.String("remote")
	team := c.String("alias")
	create := c.Bool("create")
	name := c.String("name")
	email := c.String("email")
	ctx = backend.WithCryptoBackendString(ctx, c.String("crypto"))

	// default to git
	if rcs := c.String("rcs"); rcs != "" {
		ctx = backend.WithRCSBackendString(ctx, c.String("rcs"))
	} else {
		out.Debug(ctx, "Using default RCS backend (GitCLI)")
		ctx = backend.WithRCSBackend(ctx, backend.GitCLI)
	}

	ctx = out.AddPrefix(ctx, "[init] ")
	out.Debug(ctx, "Starting Onboarding Wizard - remote: %s - team: %s - create: %t - name: %s - email: %s", remote, team, create, name, email)

	crypto := s.getCryptoFor(ctx, name)

	out.Debug(ctx, "Crypto Backend initialized as: %s", crypto.Name())

	// check for existing GPG keypairs (private/secret keys). We need at least
	// one useable key pair. If none exists try to create one
	if !s.initHasUseablePrivateKeys(ctx, crypto, team) {
		out.Yellow(ctx, "No useable crypto keys. Generating new key pair")
		ctx := out.AddPrefix(ctx, "[crypto] ")
		out.Print(ctx, "Key generation may take up to a few minutes")
		if err := s.initCreatePrivateKey(ctx, crypto, team, name, email); err != nil {
			return errors.Wrapf(err, "failed to create new private key")
		}
	}

	out.Debug(ctx, "Has useable private keys")

	// if a git remote and a team name are given attempt unattended team setup
	if remote != "" && team != "" {
		if create {
			return s.initCreateTeam(ctx, c, team, remote)
		}
		return s.initJoinTeam(ctx, c, team, remote)
	}

	// no flags given, run interactively
	choices := []string{
		"Local store",
		"Create a Team",
		"Join an existing Team",
	}
	act, sel := cui.GetSelection(ctx, "Select action", "<↑/↓> to change the selection, <→> to select, <ESC> to quit", choices)
	switch act {
	case "default":
		fallthrough
	case "show":
		switch sel {
		case 0:
			return s.initLocal(ctx, c)
		case 1:
			return s.initCreateTeam(ctx, c, "", "")
		case 2:
			return s.initJoinTeam(ctx, c, "", "")
		}
	default:
		return fmt.Errorf("user aborted")
	}
	return nil
}
644309
func (k *KubeBoot) Init(volumesProvider Volumes) {
	k.volumeMounter = newVolumeMountController(volumesProvider)
	k.etcdControllers = make(map[string]*EtcdController)
}
928136
func Init() {
	// Register to libkv
	zookeeper.Register()
	consul.Register()
	etcd.Register()

	// Register to internal discovery service
	discovery.Register("zk", &Discovery{backend: store.ZK})
	discovery.Register("consul", &Discovery{backend: store.CONSUL})
	discovery.Register("etcd", &Discovery{backend: store.ETCD})
}
1095944
func (lc *logConfig) initIfNeeded() {
	if getLogLevelContext(rootLoggerName, lc.logContexts) != nil {
		return
	}
	lc.setConfigParams(defaultConfigParams)
}
1283251
func CreateNewLoadBalancerSingle(values *CreateLoadBalancerValue, settings []*LoadBalancerSetting) (*LoadBalancer, error) {

	lb := &LoadBalancer{
		Appliance: &Appliance{
			Class:           "loadbalancer",
			propName:        propName{Name: values.Name},
			propDescription: propDescription{Description: values.Description},
			propTags:        propTags{Tags: values.Tags},
			propPlanID:      propPlanID{Plan: &Resource{ID: int64(values.Plan)}},
			propIcon: propIcon{
				&Icon{
					Resource: values.Icon,
				},
			},
		},
		Remark: &LoadBalancerRemark{
			ApplianceRemarkBase: &ApplianceRemarkBase{
				Switch: &ApplianceRemarkSwitch{
					ID: values.SwitchID,
				},
				VRRP: &ApplianceRemarkVRRP{
					VRID: values.VRID,
				},
				Network: &ApplianceRemarkNetwork{
					NetworkMaskLen: values.MaskLen,
					DefaultRoute:   values.DefaultRoute,
				},
				Servers: []interface{}{
					map[string]string{"IPAddress": values.IPAddress1},
				},
			},
		},
	}

	for _, s := range settings {
		lb.AddLoadBalancerSetting(s)
	}

	return lb, nil
}
700380
func (p *Plugin) Init() (err error) {
	if p.Config == nil {
		p.Config, err = p.getConfig()
		if err != nil || p.disabled {
			return err
		}
	}

	p.boltClient, err = NewClient(p.Config)
	if err != nil {
		p.Log.Errorf("Err: %v", err)
		return err
	}

	p.protoWrapper = kvproto.NewProtoWrapper(p.boltClient, &keyval.SerializerJSON{})

	p.Log.Infof("BoltDB started with: %v", p.Config.DbPath)

	return nil
}
676634
func (d *driver) Init(context types.Context, config gofig.Config) error {
	d.config = config

	d.tenantID = d.getTenantID()
	if d.tenantID == "" {
		return goof.New("tenantID is a required config item")
	}

	d.clientID = d.getClientID()
	if d.clientID == "" {
		return goof.New("clientID is a required config item")
	}

	d.clientSecret = d.getClientSecret()
	d.certPath = d.getCertPath()
	if d.clientSecret == "" && d.certPath == "" {
		return goof.New(
			"clientSecret or certPath must be set for login.")
	}
	if d.clientSecret != "" && d.certPath != "" {
		context.Warn("certPath will be ignored since clientSecret is set")
	}

	d.storageAccount = d.getStorageAccount()
	if d.storageAccount == "" {
		return goof.New("storageAccount is a required config item")
	}

	d.storageAccessKey = d.getStorageAccessKey()
	if d.storageAccessKey == "" {
		return goof.New("storageAccessKey is a required config item")
	}

	d.container = d.getContainer()

	d.subscriptionID = d.getSubscriptionID()
	if d.subscriptionID == "" {
		return goof.New("subscriptionID is a required config item")
	}

	d.resourceGroup = d.getResourceGroup()
	if d.resourceGroup == "" {
		return goof.New("resourceGroup is a required config item")
	}

	d.useHTTPS = d.getUseHTTPS()

	context.Info("storage driver initialized")

	return nil
}
1326608
func (c *config) SetHandlerInit(handler cfg.Handler) error {
	c.handler = handler
	return c.Init()
}
670599
func (tl *TestLauncher) OnBoardOrFail(tb testing.TB, req *platform.OnboardingRequest) *platform.OnboardingResults {
	tb.Helper()
	res, err := tl.KeyValueService().Generate(context.Background(), req)
	if err != nil {
		tb.Fatal(err)
	}

	err = tl.KeyValueService().PutOnboardingStatus(context.Background(), false)
	if err != nil {
		tb.Fatal(err)
	}

	return res
}
852143
func NewOnboardingService() *OnboardingService {
	return &OnboardingService{
		IsOnboardingFn: func(context.Context) (bool, error) { return false, nil },
		GenerateFn: func(context.Context, *platform.OnboardingRequest) (*platform.OnboardingResults, error) {
			return nil, nil
		},
	}
}
1088196
func (l *LoadBalancer) AddLoadBalancerSetting(setting *LoadBalancerSetting) {
	if l.Settings == nil {
		l.Settings = &LoadBalancerSettings{}
	}
	if l.Settings.LoadBalancer == nil {
		l.Settings.LoadBalancer = []*LoadBalancerSetting{}
	}
	l.Settings.LoadBalancer = append(l.Settings.LoadBalancer, setting)
}
1035412
func (r *Registration) Init(ic *InitContext) *Plugin {
	p, err := r.InitFn(ic)
	return &Plugin{
		Registration: r,
		Config:       ic.Config,
		Meta:         ic.Meta,
		instance:     p,
		err:          err,
	}
}
690057
func (plugin *flexVolumePlugin) Init(host volume.VolumeHost) error {
	plugin.host = host
	// Hardwired 'success' as any errors from calling init() will be caught by NewFlexVolumePlugin()
	return nil
}
450950
func (engine *OrcEngine) initOperationWorker() {
	tick := time.Tick(time.Duration(RefreshInterval) * time.Second)
	portsTick := time.Tick(5 * time.Minute)
	for {
		select {
		case op := <-engine.opsChan:
			op.Do(engine)
		case <-engine.refreshAllChan:
			engine.refreshAllPodGroups()
		case <-tick:
			engine.refreshAllPodGroups()
		case <-portsTick:
			RefreshPorts(engine.pgCtrls)
		case <-engine.stop:
			return
		}
	}
}
205795
func (h *SetupHandler) isOnboarding(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	result, err := h.OnboardingService.IsOnboarding(ctx)
	if err != nil {
		EncodeError(ctx, err, w)
		return
	}
	if err := encodeResponse(ctx, w, http.StatusOK, isOnboardingResponse{result}); err != nil {
		logEncodingError(h.Logger, r, err)
		return
	}
}
1098751
func (dbGorp *DbGorp) dbInit() (err error) {
	if dbGorp.dbInitFn != nil {
		err = dbGorp.dbInitFn(dbGorp)
	}
	return
}
1103191
func (m *Module) Init(c *service.Config) {
	c.Setup = func() error {
		m.Router.HTTPRouter.NotFound = m
		m.staticBasePath = defaultStaticBasePath
		m.staticDirs = defaultStaticDirs
		m.handle404 = m.DefaultHandle404
		m.handle500 = m.DefaultHandle500
		return nil
	}
	c.Start = func() {
		m.Router.Root.Handle(m.staticBasePath, m)
	}
}