// validateGitLabSecret validates that the given secret matches one of the
// webhooks in the external service.
validateGitLabSecret validates that the given secret matches one of the
webhooks in the external service.
// validateGitLabSecret validates that the given secret matches one of the // webhooks in the external service .
func validateGitLabSecret(extSvc *types.ExternalService, secret string) (bool, error) {
	if secret == "" {
		return false, nil
	}
	c, err := extSvc.Configuration()
	if err != nil {
		return false, errors.Wrap(err, "getting external service configuration")
	}
	config, ok := c.(*schema.GitLabConnection)
	if !ok {
		return false, errExternalServiceWrongKind
	}
	for _, webhook := range config.Webhooks {
		if webhook.Secret == secret {
			return true, nil
		}
	}
	return false, nil
}
func validateGitLabSecret ( extSvc * types . ExternalService , secret string ) ( bool , error ) { if secret == " " { return false , nil } c , err := extSvc . Configuration ( ) if err != nil { return false , errors . Wrap ( err , " " ) } config , ok := c . ( * schema . GitLabConnection ) if ! ok { return false , errExternalServiceWrongKind } for _ , webhook := range config . Webhooks { if webhook . Secret == secret { return true , nil } } return false , nil }
validateGitLabSecret validates that the given secret matches one of the
webhooks in the external service.
validateGitLabSecret validates that the given secret matches one of the webhooks in the external service .
// An empty secret never succeeds. // Get the typed configuration. // Iterate over the webhooks and look for one with the right secret. The // number of webhooks in an external service should be small enough that a // linear search like this is sufficient.