github.com/Azure/aad-pod-identity@v1.8.17/version/version.go (about)

     1  package version
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"os"
     7  )
     8  
     9  var (
    10  	// BuildDate is the date when the binary was built
    11  	BuildDate string
    12  	// GitCommit is the commit hash when the binary was built
    13  	GitCommit string
    14  	// MICVersion is the version of the MIC component
    15  	MICVersion string
    16  	// NMIVersion is the version of the NMI component
    17  	NMIVersion string
    18  
    19  	// custom user agent to append for adal and arm calls
    20  	customUserAgent = flag.String("custom-user-agent", "", "User agent to append in addition to pod identity component and versions.")
    21  )
    22  
    23  // GetUserAgent is used to get the user agent string which is then provided to adal
    24  // to use as the extended user agent header.
    25  // The format is: aad-pod-identity/<component - either NMI or MIC>/<Version of component>/<Git commit>/<Build date>
    26  func GetUserAgent(component, version string) string {
    27  	if *customUserAgent != "" {
    28  		return fmt.Sprintf("aad-pod-identity/%s/%s/%s/%s %s", component, version, GitCommit, BuildDate, *customUserAgent)
    29  	}
    30  	return fmt.Sprintf("aad-pod-identity/%s/%s/%s/%s", component, version, GitCommit, BuildDate)
    31  }
    32  
    33  // PrintVersionAndExit prints the version and exits
    34  func PrintVersionAndExit() {
    35  	fmt.Printf("MIC Version: %s - NMI Version: %s - Commit: %s - Date: %s\n", MICVersion, NMIVersion, GitCommit, BuildDate)
    36  	os.Exit(0)
    37  }