// NewAirbrake new airbrake client for env name
199056
func NewAirbrake(ctx context.Context, env string) context.Context {
	projectID, apiKey := os.Getenv("AIRBRAKE_PROJECT_ID"), os.Getenv("AIRBRAKE_API_KEY")
	if projectID == "" || apiKey == "" {
		return ctx
	}

	pid, _ := strconv.ParseInt(projectID, 10, 64)
	airbrake := gobrake.NewNotifier(pid, apiKey)
	airbrake.SetContext("environment", env)
	return context.WithValue(ctx, airbrakeKey("heroku"), airbrake)
}
219037
func NewAuthorizerFromEnvironment() (autorest.Authorizer, error) {
	settings, err := GetSettingsFromEnvironment()
	if err != nil {
		return nil, err
	}
	return settings.GetAuthorizer()
}
158580
func (client *clientImpl) makeRepairChecker(ctx context.Context, paranoia ParanoidMode) repairCB {
	if paranoia == NotParanoid {
		return func(string, common.Pin) *RepairPlan { return nil }
	}

	return func(subdir string, pin common.Pin) *RepairPlan {
		switch state, err := client.deployer.CheckDeployed(ctx, subdir, pin.PackageName, paranoia, WithoutManifest); {
		case err != nil:
			// This error is probably non-recoverable, but we'll try anyway and
			// properly fail later.
			return &RepairPlan{
				NeedsReinstall:  true,
				ReinstallReason: fmt.Sprintf("failed to check the package state - %s", err),
			}
		case !state.Deployed:
			// This should generally not happen. Can probably happen if two clients
			// are messing with same .cipd/* directory concurrently.
			return &RepairPlan{
				NeedsReinstall:  true,
				ReinstallReason: "the package is not deployed at all",
			}
		case state.Pin.InstanceID != pin.InstanceID:
			// Same here.
			return &RepairPlan{
				NeedsReinstall:  true,
				ReinstallReason: fmt.Sprintf("expected to see instance %q, but saw %q", pin.InstanceID, state.Pin.InstanceID),
			}
		case len(state.ToRedeploy) != 0 || len(state.ToRelink) != 0:
			// Have some corrupted files that need to be repaired.
			return &RepairPlan{
				ToRedeploy: state.ToRedeploy,
				ToRelink:   state.ToRelink,
			}
		default:
			return nil // the package needs no repairs
		}
	}
}
804283
func NewEngine(name string, database DatabaseProxy, cache CacheProxy) Engine {
	eng := &engine{
		name:     name,
		database: database,
		cache:    cache,
		indexes:  make(map[string]map[string]Index),
	}
	if eng.cache == nil {
		eng.cache = NullCacheProxy
	}
	return eng
}
714442
func NewPodController(client kubernetes.Interface, dns dns.Context, namespace string) (*PodController, error) {
	scope, err := dns.CreateScope("pod")
	if err != nil {
		return nil, fmt.Errorf("error building dns scope: %v", err)
	}
	c := &PodController{
		client:    client,
		scope:     scope,
		namespace: namespace,
	}

	return c, nil
}
947413
func (s *VirtualMachineService) NewAssignVirtualMachineParams(virtualmachineid string) *AssignVirtualMachineParams {
	p := &AssignVirtualMachineParams{}
	p.p = make(map[string]interface{})
	p.p["virtualmachineid"] = virtualmachineid
	return p
}
939522
func NewEngine(path string, c Config, options ...Option) *Engine {
	e := &Engine{
		config:              c,
		path:                path,
		defaultMetricLabels: prometheus.Labels{},
		logger:              zap.NewNop(),
	}

	// Initialize series file.
	e.sfile = tsdb.NewSeriesFile(c.GetSeriesFilePath(path))

	// Initialise index.
	e.index = tsi1.NewIndex(e.sfile, c.Index,
		tsi1.WithPath(c.GetIndexPath(path)))

	// Initialize WAL
	var wal tsm1.Log = new(tsm1.NopWAL)
	if c.WAL.Enabled {
		e.wal = tsm1.NewWAL(c.GetWALPath(path))
		e.wal.WithFsyncDelay(time.Duration(c.WAL.FsyncDelay))
		e.wal.EnableTraceLogging(c.TraceLoggingEnabled)
		wal = e.wal
	}

	// Initialise Engine
	e.engine = tsm1.NewEngine(c.GetEnginePath(path), e.index, c.Engine,
		tsm1.WithWAL(wal),
		tsm1.WithTraceLogging(c.TraceLoggingEnabled))

	// Apply options.
	for _, option := range options {
		option(e)
	}
	// Set default metrics labels.
	e.engine.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.sfile.SetDefaultMetricLabels(e.defaultMetricLabels)
	e.index.SetDefaultMetricLabels(e.defaultMetricLabels)

	return e
}
40074
func NewEnv() (*Env, error) {
	env := new(Env)
	ret := C.mdb_env_create(&env._env)
	if ret != success {
		return nil, operrno("mdb_env_create", ret)
	}
	env.ckey = (*C.MDB_val)(C.malloc(C.size_t(unsafe.Sizeof(C.MDB_val{}))))
	env.cval = (*C.MDB_val)(C.malloc(C.size_t(unsafe.Sizeof(C.MDB_val{}))))

	runtime.SetFinalizer(env, (*Env).Close)
	return env, nil
}
856963
func New(loader Loader) *Env {
	if loader == nil {
		loader = &StringLoader{}
	}
	return &Env{loader, make(map[string]Func), make(map[string]Filter), make(map[string]Test), make([]parse.NodeVisitor, 0)}
}
917736
func NewEnv() *Env {
	return &Env{
		env:    make(map[string]reflect.Value),
		typ:    make(map[string]reflect.Type),
		parent: nil,
	}
}
994032
func NewClient(options ClientOptions) (client *Client, err error) {
	if !options.Environment.Valid() {
		return nil, errors.New("Invalid environment specified: " + string(options.Environment))
	}

	if options.HTTPClient == nil {
		options.HTTPClient = &http.Client{}
	}

	return &Client{
		clientID:    options.ClientID,
		secret:      options.Secret,
		publicKey:   options.PublicKey,
		environment: options.Environment,
		httpClient:  options.HTTPClient,
	}, nil
}
987305
func Create(fname string, size int) (*Env, error) {
	f, err := os.Create(fname)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	env := &Env{
		fname: fname,
		size:  size,
		data:  make(map[string]string),
	}

	return env, nil
}
623453
func NewPreflightPhase() workflow.Phase {
	return workflow.Phase{
		Name:    "preflight",
		Short:   "Run pre-flight checks",
		Long:    "Run pre-flight checks for kubeadm init.",
		Example: preflightExample,
		Run:     runPreflight,
		InheritFlags: []string{
			options.CfgPath,
			options.IgnorePreflightErrors,
		},
	}
}
748024
func NewRWMutex(name string, log bool) *RWMutex {
	return &RWMutex{
		log:   log,
		mutex: &sync.RWMutex{},
		name:  name,
	}
}
414721
func NewClientNew(accessKeyId, accessKeySecret string) *Client {
	endpoint := os.Getenv("DNS_ENDPOINT")
	if endpoint == "" {
		endpoint = DNSDefaultEndpointNew
	}
	return NewClientWithEndpoint(endpoint, accessKeyId, accessKeySecret)
}
680225
func newEnviron(cloud environs.CloudSpec, cfg *config.Config) (*joyentEnviron, error) {
	env := &joyentEnviron{
		name:  cfg.Name(),
		cloud: cloud,
	}
	if err := env.SetConfig(cfg); err != nil {
		return nil, err
	}
	var err error
	env.compute, err = newCompute(cloud)
	if err != nil {
		return nil, err
	}
	return env, nil
}
1225918
func NewEnvironment(ctx context.Context) *Environment {
	ctx, cancel := context.WithCancel(ctx)
	e := &Environment{
		ctx:       ctx,
		cancel:    cancel,
		generator: NewIDGenerator(),
		stopCh:    make(chan struct{}),
	}
	return e
}