// newAppSec finds marker in r and returns the corresponding application data
// section.
961550
func newAppSec(marker byte, r io.Reader) (*appSec, error) {
	br := bufio.NewReader(r)
	app := &appSec{marker: marker}
	var dataLen int

	// seek to marker
	for dataLen == 0 {
		if _, err := br.ReadBytes(0xFF); err != nil {
			return nil, err
		}
		c, err := br.ReadByte()
		if err != nil {
			return nil, err
		} else if c != marker {
			continue
		}

		dataLenBytes := make([]byte, 2)
		for k, _ := range dataLenBytes {
			c, err := br.ReadByte()
			if err != nil {
				return nil, err
			}
			dataLenBytes[k] = c
		}
		dataLen = int(binary.BigEndian.Uint16(dataLenBytes)) - 2
	}

	// read section data
	nread := 0
	for nread < dataLen {
		s := make([]byte, dataLen-nread)
		n, err := br.Read(s)
		nread += n
		if err != nil && nread < dataLen {
			return nil, err
		}
		app.data = append(app.data, s[:n]...)
	}
	return app, nil
}
106743
func NewApp(binPath string, paths *model.RevelContainer) *App {
	return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort}
}
864967
func NewAppProxy(tp tokenaccessor.TokenAccessor, c collector.EventCollector, puFromID cache.DataStore, certificate *tls.Certificate, s secrets.Secrets) (*AppProxy, error) {

	systemPool, err := x509.SystemCertPool()
	if err != nil {
		return nil, err
	}

	if ok := systemPool.AppendCertsFromPEM(s.PublicSecrets().CertAuthority()); !ok {
		return nil, fmt.Errorf("error while adding provided CA")
	}

	return &AppProxy{
		collector:     c,
		tokenaccessor: tp,
		secrets:       s,
		puFromID:      puFromID,
		cert:          certificate,
		clients:       cache.NewCache("clients"),
		systemCAPool:  systemPool,
		registry:      serviceregistry.NewServiceRegistry(),
	}, nil
}
336593
func NewWithAppInsightsConfig(name string, conf *appinsights.TelemetryConfiguration) (*AppInsightsHook, error) {
	if conf == nil {
		return nil, fmt.Errorf("Nil configuration provided")
	}
	if conf.InstrumentationKey == "" {
		return nil, fmt.Errorf("InstrumentationKey is required in configuration")
	}
	telemetryClient := appinsights.NewTelemetryClientFromConfig(conf)
	if name != "" {
		telemetryClient.Context().Cloud().SetRoleName(name)
	}
	return &AppInsightsHook{
		client:       telemetryClient,
		levels:       defaultLevels,
		ignoreFields: make(map[string]struct{}),
		filters:      make(map[string]func(interface{}) interface{}),
	}, nil
}
1064278
func (w *Wallet) doselect() (*applicationInfo, error) {
	response, err := transmit(w.card, &commandAPDU{
		Cla:  claISO7816,
		Ins:  insSelect,
		P1:   4,
		P2:   0,
		Data: appletAID,
	})
	if err != nil {
		return nil, err
	}

	appinfo := new(applicationInfo)
	if _, err := asn1.UnmarshalWithParams(response.Data, appinfo, "tag:4"); err != nil {
		return nil, err
	}
	return appinfo, nil
}
449803
func (s *StackSummary) SetAppsCount(v int64) *StackSummary {
	s.AppsCount = &v
	return s
}
752348
func NewApplication() *Application {

	return &Application{
		ReadOnly:               false,
		PerformanceMonitorType: "FIRST_PACKET",
		CertificateCommonName:  "*",
		NetworkSymmetry:        false,
		EnablePPS:              false,
		PostClassificationPath: "ANY",
		PreClassificationPath:  "DEFAULT",
		Protocol:               "NONE",
		Symmetry:               false,
	}
}
1038951
func Convert_v1_DeploymentConfigRollbackSpec_To_apps_DeploymentConfigRollbackSpec(in *v1.DeploymentConfigRollbackSpec, out *apps.DeploymentConfigRollbackSpec, s conversion.Scope) error {
	return autoConvert_v1_DeploymentConfigRollbackSpec_To_apps_DeploymentConfigRollbackSpec(in, out, s)
}
205765
func AppStatusPath(root, appName string) string {
	return filepath.Join(AppsStatusesPath(root), appName)
}
332641
func (actor Actor) GetApplicationSummaryByNameAndSpace(appName string, spaceGUID string, withObfuscatedValues bool, routeActor RouteActor) (ApplicationSummary, Warnings, error) {
	app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
	if err != nil {
		return ApplicationSummary{}, allWarnings, err
	}

	processSummaries, processWarnings, err := actor.getProcessSummariesForApp(app.GUID, withObfuscatedValues)
	allWarnings = append(allWarnings, processWarnings...)
	if err != nil {
		return ApplicationSummary{}, allWarnings, err
	}

	droplet, warnings, err := actor.GetCurrentDropletByApplication(app.GUID)
	allWarnings = append(allWarnings, warnings...)
	if err != nil {
		if _, ok := err.(actionerror.DropletNotFoundError); !ok {
			return ApplicationSummary{}, allWarnings, err
		}
	}

	var appRoutes v2action.Routes
	if routeActor != nil {
		routes, warnings, err := routeActor.GetApplicationRoutes(app.GUID)
		allWarnings = append(allWarnings, Warnings(warnings)...)
		if err != nil {
			if _, ok := err.(ccerror.ResourceNotFoundError); !ok {
				return ApplicationSummary{}, allWarnings, err
			}
		}
		appRoutes = routes
	}

	summary := ApplicationSummary{
		Application:      app,
		ProcessSummaries: processSummaries,
		CurrentDroplet:   droplet,
		Routes:           appRoutes,
	}
	return summary, allWarnings, nil
}
244187
func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelContainer) AppCmd {
	cmd := exec.Command(binPath,
		fmt.Sprintf("-port=%d", port),
		fmt.Sprintf("-importPath=%s", paths.ImportPath),
		fmt.Sprintf("-runMode=%s", runMode))
	cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
	return AppCmd{cmd}
}
1121984
func NewAppInput(rd io.Reader) app.Input {
	return app.Input(NewInputSize(rd, defaultBufSize))
}
550335
func (c *listCommand) NewApplicationOffersAPI() (*applicationoffers.Client, error) {
	root, err := c.NewControllerAPIRoot()
	if err != nil {
		return nil, err
	}
	return applicationoffers.NewClient(root), nil
}
831432
func NewApplication() *Application {
	return &Application{
		events:            make(chan tcell.Event, queueSize),
		updates:           make(chan func(), queueSize),
		screenReplacement: make(chan tcell.Screen, 1),
	}
}
13465
func NewDataScope(data map[string]interface{}) app.DataScope {
	return app.DataScope(&DataScope{
		Data: make(map[string]interface{}),
	})
}
283530
func NewAppLog(loggerName string, msg []byte) *AppLog {
	now := time.Now().UTC()
	return &AppLog{
		Timestamp:  now.UnixNano(),
		Time:       now.Format(time.RFC3339),
		Type:       "app.log",
		Logger:     loggerName,
		Hostname:   hostname,
		EnvVersion: "2.0",
		Pid:        os.Getpid(),
		Fields: map[string]interface{}{
			"msg": string(bytes.TrimSpace(msg)),
		},
	}
}
399489
func NewAppKill(username, password, loginurl, ccurl string) (a *AppKill) {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	httpClient := &http.Client{Transport: tr}
	client := ccclient.New(loginurl, username, password, httpClient)
	lo.G.Debug("cc client: ", client)
	a = &AppKill{
		CloudController:       client,
		HTTPClient:            httpClient,
		CloudControllerAPIURL: ccurl,
	}
	return
}