// NewAppSource returns an AppSource based on a given AppSourceConfig and path to
// mh configuration(for "configPath" kind of AppSources).
//
// Todo: Get rid of "configFile" argument in favor of defined kinds of
// AppSources - see AppSourceConfig.
NewAppSource returns an AppSource based on a given AppSourceConfig and path to
mh configuration(for "configPath" kind of AppSources).

Get rid of "configFile" argument in favor of defined kinds of
AppSources - see AppSourceConfig.
// NewAppSource returns an AppSource based on a given AppSourceConfig and path to // mh configuration ( for " configPath " kind of AppSources ) . // // Todo : Get rid of " configFile " argument in favor of defined kinds of // AppSources - see AppSourceConfig .
func NewAppSource(config AppSourceConfig, configFile string) (*AppSource, error) {
	var pattern string
	if config.Kind == "path" {
		pattern = config.Source + "/*.y*ml"
	} else if config.Kind == "configPath" {
		pattern = path.Dir(configFile) + "/" + config.Source + "/*.y*ml"
	}
	filePaths, err := filepath.Glob(pattern)
	if err != nil {
		return nil, fmt.Errorf("Failed to determine file from AppSource: %s", err.Error())
	}
	files := AppFiles{}
	for _, path := range filePaths {
		base := filepath.Base(path)
		name := strings.TrimSuffix(base, filepath.Ext(base))
		localpath := path
		file := AppFile{
			Path: &localpath,
		}
		files[name] = file
	}
	return &AppSource{
		config,
		files,
	}, nil
}
func NewAppSource ( config AppSourceConfig , configFile string ) ( * AppSource , error ) { var pattern string if config . Kind == " " { pattern = config . Source + " " } else if config . Kind == " " { pattern = path . Dir ( configFile ) + " " + config . Source + " " } filePaths , err := filepath . Glob ( pattern ) if err != nil { return nil , fmt . Errorf ( " " , err . Error ( ) ) } files := AppFiles { } for _ , path := range filePaths { base := filepath . Base ( path ) name := strings . TrimSuffix ( base , filepath . Ext ( base ) ) localpath := path file := AppFile { Path : & localpath , } files [ name ] = file } return & AppSource { config , files , } , nil }
NewAppSource returns an AppSource based on a given AppSourceConfig and path to
mh configuration(for "configPath" kind of AppSources).
NewAppSource returns an AppSource based on a given AppSourceConfig and path to mh configuration ( for " configPath " kind of AppSources ) .
// Build glob pattern depending on kind of AppSource // Get all files the glob pattern matches // Create an AppFile for each matched file