github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/builders/builder.go (about)

     1  package builders
     2  
     3  import (
     4  	"path/filepath"
     5  	"strings"
     6  )
     7  
     8  func GetAppIDForBranch(appID, branchID string) string {
     9  	// Stable
    10  	if strings.TrimSpace(branchID) == "" {
    11  		return appID
    12  	}
    13  
    14  	return appID + "." + branchID
    15  }
    16  
    17  func GetAppNameForBranch(appName, branchName string) string {
    18  	// Stable
    19  	if strings.TrimSpace(branchName) == "" {
    20  		return appName
    21  	}
    22  
    23  	return appName + " (" + branchName + ")"
    24  }
    25  
    26  func GetPathForBranch(path, branchID, prefix string) string {
    27  	// Stable
    28  	if strings.TrimSpace(branchID) == "" {
    29  		return prefix + path + "/stable"
    30  	}
    31  
    32  	return prefix + path + "/" + branchID
    33  }
    34  
    35  func GetFilepathForBranch(path, branchID string) string {
    36  	// Stable
    37  	if strings.TrimSpace(branchID) == "" {
    38  		return filepath.Join(path, "stable")
    39  	}
    40  
    41  	return filepath.Join(path, branchID)
    42  }
    43  
    44  type Builder interface {
    45  	Build() error
    46  	Render(workdir string, ejecting bool) error
    47  }