github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/cicontext/github_probe.go (about)

     1  /*
     2   * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved.
     3   * This software is released under GPL3.
     4   * The full license information can be found under:
     5   * https://www.gnu.org/licenses/gpl-3.0.en.html
     6   *
     7   */
     8  
     9  package cicontext
    10  
    11  import (
    12  	"os"
    13  	"strings"
    14  )
    15  
    16  type githubProbe struct {
    17  	name string
    18  }
    19  
    20  func (p *githubProbe) Detect() bool {
    21  	for _, v := range os.Environ() {
    22  		kv := strings.SplitN(v, "=", 2)
    23  		if strings.Contains(kv[0], CI_GITHUB_PREFIX) {
    24  			return true
    25  		}
    26  	}
    27  	return false
    28  }
    29  
    30  func (p *githubProbe) GetName() string {
    31  	return p.name
    32  }
    33  
    34  func NewGithubProbe() *githubProbe {
    35  	return &githubProbe{
    36  		name: CI_GITHUB_DESC,
    37  	}
    38  }