github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/quickstarts/quickstarts.go (about)

     1  package quickstarts
     2  
     3  import (
     4  	"strings"
     5  
     6  	"github.com/olli-ai/jx/v2/pkg/util"
     7  )
     8  
     9  func (q *Quickstart) SurveyName() string {
    10  	if q.Owner == JenkinsXQuickstartsOwner {
    11  		return q.Name
    12  	}
    13  	// TODO maybe make a nicer string?
    14  	return q.ID
    15  }
    16  
    17  func (f *QuickstartFilter) Matches(q *Quickstart) bool {
    18  	if strings.Contains(q.ID, "WIP-") {
    19  		return false
    20  	}
    21  	text := f.Text
    22  	if text != "" && !strings.Contains(q.ID, text) {
    23  		return false
    24  	}
    25  	owner := strings.ToLower(f.Owner)
    26  	if owner != "" && strings.ToLower(q.Owner) != owner {
    27  		return false
    28  	}
    29  	language := strings.ToLower(f.Language)
    30  	if language != "" && strings.ToLower(q.Language) != language {
    31  		return false
    32  	}
    33  	framework := strings.ToLower(f.Framework)
    34  	if framework != "" && strings.ToLower(q.Framework) != framework {
    35  		return false
    36  	}
    37  	if !f.AllowML && util.StartsWith(q.Name, "ML-") {
    38  		return false
    39  	}
    40  	return true
    41  }
    42  
    43  // GetGitServer returns the git server to use
    44  func (q *Quickstart) GetGitServer() string {
    45  	if q.GitServer == "" {
    46  		q.GitServer = "https://github.com"
    47  	}
    48  	return q.GitServer
    49  }
    50  
    51  // GetGitKind returns the kind of git provider to use
    52  func (q *Quickstart) GetGitKind() string {
    53  	if q.GitKind == "" {
    54  		q.GitKind = "github"
    55  	}
    56  	return q.GitKind
    57  }