func ReadFromResource(r string) (string, error) {
	env := os.Getenv("KUBICORN_ENVIRONMENT")

	// Hack in here for local bootstrap override
	devMode := os.Getenv("KUBICORN_FORCE_LOCAL_BOOTSTRAP")
	if devMode != "" {
		logger.Info("Parsing bootstrap script from filesystem [%s]", r)
		return readFromFS(r)
	}

	switch {

	// -----------------------------------------------------------------------------------------------------------------
	//
	//
	// starts with bootstrap/
	//
	case strings.HasPrefix(strings.ToLower(r), "bootstrap/") && env != "LOCAL":

		// If we start with bootstrap/ we know this is a resource we should pull from github.com
		// So here we build the GitHub URL and send the request
		gitHubUrl := getGitHubUrl(r)
		logger.Info("Parsing bootstrap script from GitHub [%s]", gitHubUrl)
		url, err := url.ParseRequestURI(gitHubUrl)
		if err != nil {
			return "", err
		}
		return readFromHTTP(url)

	// -----------------------------------------------------------------------------------------------------------------
	//
	//
	// starts with http(s)://
	//
	case strings.HasPrefix(strings.ToLower(r), "http://") || strings.HasPrefix(strings.ToLower(r), "https://") && env != "LOCAL":
		url, err := url.ParseRequestURI(r)
		logger.Info("Parsing bootstrap script from url [%s]", url)
		if err != nil {
			return "", err
		}
		return readFromHTTP(url)

	// -----------------------------------------------------------------------------------------------------------------
	//
	//
	// pull from local
	//
	default:
		logger.Info("Parsing bootstrap script from filesystem [%s]", r)
		return readFromFS(r)
	}
}
func ReadFromResource(r string) (string, error) {
	env := os.Getenv("KUBICORN_ENVIRONMENT")

	
	devMode := os.Getenv("KUBICORN_FORCE_LOCAL_BOOTSTRAP")
	if devMode != "" {
		logger.Info("Parsing bootstrap script from filesystem [%s]", r)
		return readFromFS(r)
	}

	switch {

	
	
	
	
	
	case strings.HasPrefix(strings.ToLower(r), "bootstrap/") && env != "LOCAL":

		
		
		gitHubUrl := getGitHubUrl(r)
		logger.Info("Parsing bootstrap script from GitHub [%s]", gitHubUrl)
		url, err := url.ParseRequestURI(gitHubUrl)
		if err != nil {
			return "", err
		}
		return readFromHTTP(url)

	
	
	
	
	
	case strings.HasPrefix(strings.ToLower(r), "http:
		url, err := url.ParseRequestURI(r)
		logger.Info("Parsing bootstrap script from url [%s]", url)
		if err != nil {
			return "", err
		}
		return readFromHTTP(url)

	
	
	
	
	
	default:
		logger.Info("Parsing bootstrap script from filesystem [%s]", r)
		return readFromFS(r)
	}
}
func ReadFromResource ( r string ) ( string , error ) { env := os . Getenv ( " " ) // Hack in here for local bootstrap override devMode := os . Getenv ( " " ) if devMode != " " { logger . Info ( " " , r ) return readFromFS ( r ) } switch { // ----------------------------------------------------------------------------------------------------------------- // // // starts with bootstrap/ // case strings . HasPrefix ( strings . ToLower ( r ) , " " ) && env != " " : // If we start with bootstrap/ we know this is a resource we should pull from github.com // So here we build the GitHub URL and send the request gitHubUrl := getGitHubUrl ( r ) logger . Info ( " " , gitHubUrl ) url , err := url . ParseRequestURI ( gitHubUrl ) if err != nil { return " " , err } return readFromHTTP ( url ) // ----------------------------------------------------------------------------------------------------------------- // // // starts with http(s):// // case strings . HasPrefix ( strings . ToLower ( r ) , " " ) || strings . HasPrefix ( strings . ToLower ( r ) , " " ) && env != " " : url , err := url . ParseRequestURI ( r ) logger . Info ( " " , url ) if err != nil { return " " , err } return readFromHTTP ( url ) // ----------------------------------------------------------------------------------------------------------------- // // // pull from local // default : logger . Info ( " " , r ) return readFromFS ( r ) } }
// ReadFromResource reads a file from different sources
// at the moment suppoted resources are http, http, local file system(POSIX)
ReadFromResource reads a file from different sources at the moment suppoted resources are http http local file system ( POSIX )