Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: common/api/dm/service/v1/activate_execution_normalize.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: common/api/dm/service/v1/activate_execution_normalize.go
diff --git a/common/api/dm/service/v1/activate_execution_normalize.go b/common/api/dm/service/v1/activate_execution_normalize.go
new file mode 100644
index 0000000000000000000000000000000000000000..9764f3fcb5f1e8be9219e772767d17d1e563afb3
--- /dev/null
+++ b/common/api/dm/service/v1/activate_execution_normalize.go
@@ -0,0 +1,24 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package dm
+
+import "fmt"
+
+// MinimumActivationTokenLength is the minimum number of bytes in an appropriate
+// ExecutionToken.
+const MinimumActivationTokenLength = 32
+
+// Normalize returns an error iff the ActivateExecutionReq has bad form (nils,
+// insufficient activation token length, etc.
+func (a *ActivateExecutionReq) Normalize() error {
+ if err := a.Auth.Normalize(); err != nil {
+ return err
+ }
+ if len(a.ExecutionToken) < MinimumActivationTokenLength {
+ return fmt.Errorf("insufficiently long ExecutionToken: %d",
+ len(a.ExecutionToken))
+ }
+ return nil
+}

Powered by Google App Engine
This is Rietveld 408576698