Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2019-12-11 18:56:05 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2019-12-11 18:56:05 +0300
commit31ca324da09b003c7a491edd25880e4e560faab7 (patch)
tree7db4bceb754baaca760ef5ddb207d90754554c47
parent938493edda6e4d1b9a8a5122251aea744623cfe8 (diff)
parentb7f5ff41e0904a7cf3ded4fecc031bf2a1e4aafe (diff)
Merge branch 'jc-add-ff-for-go-hooks' into 'master'
Add feature flag to turn on hooks to go through RPCs See merge request gitlab-org/gitaly!1685
-rw-r--r--internal/metadata/featureflag/feature_flags.go7
-rw-r--r--internal/service/smarthttp/receive_pack.go5
-rw-r--r--internal/service/ssh/receive_pack.go4
3 files changed, 16 insertions, 0 deletions
diff --git a/internal/metadata/featureflag/feature_flags.go b/internal/metadata/featureflag/feature_flags.go
index 7620a3e3f..f220bd5ac 100644
--- a/internal/metadata/featureflag/feature_flags.go
+++ b/internal/metadata/featureflag/feature_flags.go
@@ -12,4 +12,11 @@ const (
FilterShasWithSignaturesGo = "filter_shas_with_signatures_go"
// LinguistFileCountStats will invoke an additional git-linguist command to get the number of files per language
LinguistFileCountStats = "linguist_file_count_stats"
+ // HooksRPC will invoke update, pre receive, and post receive hooks by using RPCs
+ HooksRPC = "hooks_rpc"
+)
+
+const (
+ // HooksRPCEnvVar is the name of the environment variable we use to pass the feature flag down into gitaly-hooks
+ HooksRPCEnvVar = "GITALY_HOOK_RPCS_ENABLED"
)
diff --git a/internal/service/smarthttp/receive_pack.go b/internal/service/smarthttp/receive_pack.go
index e4b4e0bd8..ed11ce77f 100644
--- a/internal/service/smarthttp/receive_pack.go
+++ b/internal/service/smarthttp/receive_pack.go
@@ -1,11 +1,15 @@
package smarthttp
import (
+ "fmt"
+ "strconv"
+
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitaly/internal/command"
"gitlab.com/gitlab-org/gitaly/internal/git"
"gitlab.com/gitlab-org/gitaly/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"
"gitlab.com/gitlab-org/gitaly/streamio"
"google.golang.org/grpc/codes"
@@ -47,6 +51,7 @@ func (s *server) PostReceivePack(stream gitalypb.SmartHTTPService_PostReceivePac
env = git.AddGitProtocolEnv(ctx, req, env)
env = append(env, command.GitEnv...)
+ env = append(env, fmt.Sprintf("%s=%s", featureflag.HooksRPCEnvVar, strconv.FormatBool(featureflag.IsEnabled(ctx, featureflag.HooksRPC))))
globalOpts := git.ReceivePackConfig()
for _, o := range req.GitConfigOptions {
diff --git a/internal/service/ssh/receive_pack.go b/internal/service/ssh/receive_pack.go
index 89d743d3e..33b4fa7ae 100644
--- a/internal/service/ssh/receive_pack.go
+++ b/internal/service/ssh/receive_pack.go
@@ -2,6 +2,9 @@ package ssh
import (
"fmt"
+ "strconv"
+
+ "gitlab.com/gitlab-org/gitaly/internal/metadata/featureflag"
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
log "github.com/sirupsen/logrus"
@@ -59,6 +62,7 @@ func sshReceivePack(stream gitalypb.SSHService_SSHReceivePackServer, req *gitaly
env = git.AddGitProtocolEnv(ctx, req, env)
env = append(env, command.GitEnv...)
+ env = append(env, fmt.Sprintf("%s=%s", featureflag.HooksRPCEnvVar, strconv.FormatBool(featureflag.IsEnabled(ctx, featureflag.HooksRPC))))
globalOpts := git.ReceivePackConfig()
for _, o := range req.GitConfigOptions {