// AppCreatedPath returns the path of the ${appname}-created file, which is used to record
// the creation timestamp of the app.
170308
func AppCreatedPath(root, appName string) string {
	return filepath.Join(AppsStatusesPath(root), fmt.Sprintf("%s-created", appName))
}
1183372
func (p *ProjectCard) GetCreatedAt() Timestamp {
	if p == nil || p.CreatedAt == nil {
		return Timestamp{}
	}
	return *p.CreatedAt
}
190768
func appendPath(rootPath, childPath string) string {
	return strings.TrimRight(rootPath, "/") + "/" + strings.TrimLeft(childPath, "/")
}
98222
func (p *scanDir) FileCreated(name string) {
	if pkg := record(name); pkg != nil {
		load(pkg)
	}
}
320894
func (c *FakeApplications) Create(application *v1alpha1.Application) (result *v1alpha1.Application, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(applicationsResource, c.ns, application), &v1alpha1.Application{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.Application), err
}
9519
func (s *Server) Create(ctx context.Context, q *ProjectCreateRequest) (*v1alpha1.AppProject, error) {
	if err := s.enf.EnforceErr(ctx.Value("claims"), rbacpolicy.ResourceProjects, rbacpolicy.ActionCreate, q.Project.Name); err != nil {
		return nil, err
	}
	projectutil.NormalizePolicies(q.Project)
	err := projectutil.ValidateProject(q.Project)
	if err != nil {
		return nil, err
	}
	res, err := s.appclientset.ArgoprojV1alpha1().AppProjects(s.ns).Create(q.Project)
	if err == nil {
		s.logEvent(res, ctx, argo.EventReasonResourceCreated, "created project")
	}
	return res, err
}
683989
func newApp(c *model.CommandConfig) (err error) {
	// Check for an existing folder so we don't clobber it
	_, err = build.Import(c.ImportPath, "", build.FindOnly)
	if err == nil || !utils.Empty(c.AppPath) {
		return utils.NewBuildError("Abort: Import path already exists.", "path", c.ImportPath)
	}

	// checking and setting skeleton
	if err=setSkeletonPath(c);err!=nil {
		return
	}

	// Create application path
	if err := os.MkdirAll(c.AppPath, os.ModePerm); err != nil {
		return utils.NewBuildError("Abort: Unable to create app path.", "path", c.AppPath)
	}

	if c.New.Vendored {
		utils.Logger.Info("Creating a new vendor app")

		vendorPath := filepath.Join(c.AppPath, "vendor")
		if !utils.DirExists(vendorPath) {

			if err := os.MkdirAll(vendorPath, os.ModePerm); err != nil {
				return utils.NewBuildError("Failed to create "+vendorPath, "error", err)
			}
		}

		// In order for dep to run there needs to be a source file in the folder
		tempPath := filepath.Join(c.AppPath, "tmp")
		utils.Logger.Info("Checking for temp folder for source code", "path", tempPath)
		if !utils.DirExists(tempPath) {
			if err := os.MkdirAll(tempPath, os.ModePerm); err != nil {
				return utils.NewBuildIfError(err, "Failed to create "+vendorPath)
			}

			if err = utils.GenerateTemplate(filepath.Join(tempPath, "main.go"), NEW_MAIN_FILE, nil); err != nil {
				return utils.NewBuildIfError(err, "Failed to create main file "+vendorPath)
			}
		}

		// Create a package template file if it does not exist
		packageFile := filepath.Join(c.AppPath, "Gopkg.toml")
		utils.Logger.Info("Checking for Gopkg.toml", "path", packageFile)
		if !utils.Exists(packageFile) {
			utils.Logger.Info("Generating Gopkg.toml", "path", packageFile)
			if err := utils.GenerateTemplate(packageFile, VENDOR_GOPKG, nil); err != nil {
				return utils.NewBuildIfError(err, "Failed to generate template")
			}
		} else {
			utils.Logger.Info("Package file exists in skeleto, skipping adding")
		}

		getCmd := exec.Command("dep", "ensure", "-v")
		utils.CmdInit(getCmd, c.AppPath)

		utils.Logger.Info("Exec:", "args", getCmd.Args, "env", getCmd.Env, "workingdir",getCmd.Dir)
		getOutput, err := getCmd.CombinedOutput()
		if err != nil {
			return utils.NewBuildIfError(err, string(getOutput))
		}
	}

	// checking and setting application
	if err = setApplicationPath(c); err != nil {
		return err
	}
	// At this point the versions can be set
	c.SetVersions()

	// copy files to new app directory
	if err = copyNewAppFiles(c);err != nil {
		return
	}

	// Rerun the dep tool if vendored
	if c.New.Vendored {
		getCmd := exec.Command("dep", "ensure", "-v")
		utils.CmdInit(getCmd, c.AppPath)
		utils.Logger.Info("Exec:", "args", getCmd.Args)
		getOutput, err := getCmd.CombinedOutput()
		if err != nil {
			utils.Logger.Fatal(string(getOutput))
		}
	}

	// goodbye world
	fmt.Fprintln(os.Stdout, "Your application has been created in:\n  ", c.AppPath)
	// Check to see if it should be run right off
	if c.New.Run {
		runApp(c)
	} else {
		fmt.Fprintln(os.Stdout, "\nYou can run it with:\n   revel run -a ", c.ImportPath)
	}
	return
}
1172330
func ApplicationWithPath(
	funcs map[string]func([]string),
	scripts []string,
	loader func(string) ([]byte, error),
	copyEnv bool,
	bashPath string) {

	bash, err := NewContext(bashPath, os.Getenv("DEBUG") != "")
	if err != nil {
		log.Fatal(err)
	}
	for name, fn := range funcs {
		bash.ExportFunc(name, fn)
	}
	if bash.HandleFuncs(os.Args) {
		os.Exit(0)
	}

	for _, script := range scripts {
		bash.Source(script, loader)
	}
	if copyEnv {
		bash.CopyEnv()
	}
	status, err := bash.Run("main", os.Args[1:])
	if err != nil {
		log.Fatal(err)
	}
	os.Exit(status)
}
549465
func (r *marathonClient) CreateApplication(application *Application) (*Application, error) {
	result := new(Application)
	if err := r.apiPost(marathonAPIApps, application, result); err != nil {
		return nil, err
	}

	return result, nil
}
743911
func lookupPathInsideApp(bin string, paths string, appRootfs string, workDir string) (string, error) {
	pathsArr := filepath.SplitList(paths)
	var appPathsArr []string
	for _, p := range pathsArr {
		if !filepath.IsAbs(p) {
			p = filepath.Join(workDir, p)
		}
		appPathsArr = append(appPathsArr, filepath.Join(appRootfs, p))
	}
	for _, path := range appPathsArr {
		binPath := filepath.Join(path, bin)
		stage2Path := strings.TrimPrefix(binPath, appRootfs)
		binRealPath, err := EvaluateSymlinksInsideApp(appRootfs, stage2Path)
		if err != nil {
			return "", errwrap.Wrap(fmt.Errorf("could not evaluate path %v", stage2Path), err)
		}
		binRealPath = filepath.Join(appRootfs, binRealPath)
		if fileutil.IsExecutable(binRealPath) {
			// The real path is executable, return the path relative to the app
			return stage2Path, nil
		}
	}
	return "", fmt.Errorf("unable to find %q in %q", bin, paths)
}
714858
func (o *Enterprise) CreateApplication(child *Application) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
81363
func AppStatusPathFromStage1Rootfs(rootfs, appName string) string {
	return filepath.Join(AppsStatusesPathFromStage1Rootfs(rootfs), appName)
}
820683
func (_m *Marathon) CreateApplication(application *marathon.Application) (*marathon.Application, error) {
	ret := _m.Called(application)

	var r0 *marathon.Application
	if rf, ok := ret.Get(0).(func(*marathon.Application) *marathon.Application); ok {
		r0 = rf(application)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*marathon.Application)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(*marathon.Application) error); ok {
		r1 = rf(application)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
208987
func (p *PushEvent) GetCreated() bool {
	if p == nil || p.Created == nil {
		return false
	}
	return *p.Created
}
43156
func getActiveEnv(appPath, appName string) string {
	val := os.Getenv(strmangle.EnvAppName(appName) + "_ENV")
	if val != "" {
		return val
	}

	contents, err := afero.ReadFile(AppFS, filepath.Join(appPath, AppConfigFilename))
	if err != nil {
		return ""
	}

	var config AppConfig

	_, err = toml.Decode(string(contents), &config)
	if err != nil {
		return ""
	}

	return config.DefaultEnv
}
144555
func (i *Installation) GetCreatedAt() Timestamp {
	if i == nil || i.CreatedAt == nil {
		return Timestamp{}
	}
	return *i.CreatedAt
}
792502
func AppBundleForPath() (string, error) {
	path, err := utils.BinPath()
	if err != nil {
		return "", err
	}
	if path == "" {
		return "", errors.New("Could not get executable name")
	}
	paths := strings.SplitN(path, ".app", 2)
	// If no match, return ""
	if len(paths) <= 1 {
		return "", fmt.Errorf("Unable to resolve bundle for valid path: %s", path)
	}

	appPath := paths[0] + ".app"
	if exists, _ := libkb.FileExists(appPath); !exists {
		return "", fmt.Errorf("App not found: %s", appPath)
	}

	return appPath, nil
}