func (t TokenInfoImpl) GetOAuthClient(log log.T, tokenInfo string) (client *http.Client, err error) {
	// Validate the format of the secure parameter
	// Make a call to secure string (disable logging) and obtain the token
	// Create StaticTokenSource and create oauth client and return it

	// Validate the format of token information
	if valid, err := validateTokenParameter(tokenInfo); !valid {
		return nil, err
	}

	var tokenVal ssmparameterresolver.SsmParameterInfo
	var tokenMap map[string]ssmparameterresolver.SsmParameterInfo
	var parameterReferences []string

	// Regex to extract the contents of the parameter from within {{ }} to get parameter value
	// for. e.g. {{ ssm-secure:parameter-name }} will extract ssm-secure:parameter-name
	subParam := regexp.MustCompile(`\{\{(.*?)\}\}`).FindStringSubmatch(tokenInfo)
	if len(subParam) > 1 {
		parameterReferences = []string{subParam[1]}
	} else {
		return client, errors.New("Something went wrong when trying to extract ssm-secure parameter")
	}

	resolverOptions := ssmparameterresolver.ResolveOptions{
		IgnoreSecureParameters: false,
	}

	// Get the parameter value from parameter store.
	// NOTE: Do not log the parameter value
	if tokenMap, err = t.SsmParameter(log, &t.paramAccess, parameterReferences, resolverOptions); err != nil {
		return nil, fmt.Errorf("Could not resolve ssm parameter - %v. Error - %v", parameterReferences, err)
	}

	// Parameter output must be of size 1. Any other number of tokens returned can lead to undesired behavior
	if len(tokenMap) != 1 {
		return nil, fmt.Errorf("Invalid number of tokens returned - %v", len(tokenMap))
	}

	//Extracting single value of token contained within tokenMap
	for _, token := range tokenMap {
		tokenVal = token
	}

	// Validating to check if the parameter obtained is a secure string
	if tokenVal.Type != parameterstore.ParamTypeSecureString {
		return nil, fmt.Errorf("token-parameter-name %v must be of secure string type, Current type - %v", tokenVal.Name, tokenVal.Type)
	}
	return t.gitoauthclient.GetGithubOauthClient(tokenVal.Value), nil
}
// GetOAuthClient is the only method from privategithub package that is accessible to gitresource
GetOAuthClient is the only method from privategithub package that is accessible to gitresource
// GetOAuthClient is the only method from privategithub package that is accessible to gitresource
func (t TokenInfoImpl) GetOAuthClient(log log.T, tokenInfo string) (client *http.Client, err error) {
	if valid, err := validateTokenParameter(tokenInfo); !valid {
		return nil, err
	}
	var tokenVal ssmparameterresolver.SsmParameterInfo
	var tokenMap map[string]ssmparameterresolver.SsmParameterInfo
	var parameterReferences []string
	subParam := regexp.MustCompile(`\{\{(.*?)\}\}`).FindStringSubmatch(tokenInfo)
	if len(subParam) > 1 {
		parameterReferences = []string{subParam[1]}
	} else {
		return client, errors.New("Something went wrong when trying to extract ssm-secure parameter")
	}
	resolverOptions := ssmparameterresolver.ResolveOptions{
		IgnoreSecureParameters: false,
	}
	if tokenMap, err = t.SsmParameter(log, &t.paramAccess, parameterReferences, resolverOptions); err != nil {
		return nil, fmt.Errorf("Could not resolve ssm parameter - %v. Error - %v", parameterReferences, err)
	}
	if len(tokenMap) != 1 {
		return nil, fmt.Errorf("Invalid number of tokens returned - %v", len(tokenMap))
	}
	for _, token := range tokenMap {
		tokenVal = token
	}
	if tokenVal.Type != parameterstore.ParamTypeSecureString {
		return nil, fmt.Errorf("token-parameter-name %v must be of secure string type, Current type - %v", tokenVal.Name, tokenVal.Type)
	}
	return t.gitoauthclient.GetGithubOauthClient(tokenVal.Value), nil
}
func ( t TokenInfoImpl ) GetOAuthClient ( log log . T , tokenInfo string ) ( client * http . Client , err error ) { if valid , err := validateTokenParameter ( tokenInfo ) ; ! valid { return nil , err } var tokenVal ssmparameterresolver . SsmParameterInfo var tokenMap map [ string ] ssmparameterresolver . SsmParameterInfo var parameterReferences [ ] string subParam := regexp . MustCompile ( `\{\{(.*?)\}\}` ) . FindStringSubmatch ( tokenInfo ) if len ( subParam ) > 1 { parameterReferences = [ ] string { subParam [ 1 ] } } else { return client , errors . New ( " " ) } resolverOptions := ssmparameterresolver . ResolveOptions { IgnoreSecureParameters : false , } if tokenMap , err = t . SsmParameter ( log , & t . paramAccess , parameterReferences , resolverOptions ) ; err != nil { return nil , fmt . Errorf ( " " , parameterReferences , err ) } if len ( tokenMap ) != 1 { return nil , fmt . Errorf ( " " , len ( tokenMap ) ) } for _ , token := range tokenMap { tokenVal = token } if tokenVal . Type != parameterstore . ParamTypeSecureString { return nil , fmt . Errorf ( " " , tokenVal . Name , tokenVal . Type ) } return t . gitoauthclient . GetGithubOauthClient ( tokenVal . Value ) , nil }
GetOAuthClient is the only method from privategithub package that is accessible to gitresource
GetOAuthClient is the only method from privategithub package that is accessible to gitresource
// Validate the format of the secure parameter // Make a call to secure string (disable logging) and obtain the token // Create StaticTokenSource and create oauth client and return it // Validate the format of token information // Regex to extract the contents of the parameter from within {{ }} to get parameter value // for. e.g. {{ ssm-secure:parameter-name }} will extract ssm-secure:parameter-name // Get the parameter value from parameter store. // NOTE: Do not log the parameter value // Parameter output must be of size 1. Any other number of tokens returned can lead to undesired behavior //Extracting single value of token contained within tokenMap // Validating to check if the parameter obtained is a secure string