| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 package annotation | 15 package annotation |
| 16 | 16 |
| 17 import ( | 17 import ( |
| 18 "encoding/hex" |
| 18 "fmt" | 19 "fmt" |
| 19 "strconv" | 20 "strconv" |
| 20 "strings" | 21 "strings" |
| 21 "time" | 22 "time" |
| 22 | 23 |
| 23 "github.com/golang/protobuf/ptypes/timestamp" | 24 "github.com/golang/protobuf/ptypes/timestamp" |
| 24 | 25 |
| 25 "github.com/luci/luci-go/common/clock" | 26 "github.com/luci/luci-go/common/clock" |
| 26 "github.com/luci/luci-go/common/proto/google" | 27 "github.com/luci/luci-go/common/proto/google" |
| 27 "github.com/luci/luci-go/common/proto/milo" | 28 "github.com/luci/luci-go/common/proto/milo" |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 366 |
| 366 // @@@SET_BUILD_PROPERTY@<name>@<json>@@@ | 367 // @@@SET_BUILD_PROPERTY@<name>@<json>@@@ |
| 367 case "SET_BUILD_PROPERTY": | 368 case "SET_BUILD_PROPERTY": |
| 368 step := s.CurrentStep() | 369 step := s.CurrentStep() |
| 369 parts := strings.SplitN(params, "@", 2) | 370 parts := strings.SplitN(params, "@", 2) |
| 370 if len(parts) == 1 { | 371 if len(parts) == 1 { |
| 371 parts = append(parts, "") | 372 parts = append(parts, "") |
| 372 } | 373 } |
| 373 updatedIf(step, UpdateIterative, step.SetProperty(parts[0], part
s[1])) | 374 updatedIf(step, UpdateIterative, step.SetProperty(parts[0], part
s[1])) |
| 374 | 375 |
| 375 » » // @@@STEP_TRIGGER@<spec>@@@ | 376 » // @@@STEP_TRIGGER@<spec>@@@ |
| 376 case "STEP_TRIGGER": | 377 case "STEP_TRIGGER": |
| 377 // Annotee will stop short of sending an actual request to Build
Bucket. | 378 // Annotee will stop short of sending an actual request to Build
Bucket. |
| 378 break | 379 break |
| 380 |
| 381 // This is ONLY supported by annotee, not by buildbot. |
| 382 // @@@DEPLOYMENT_MANIFEST@<name>@<sha256>@<url>@@@ |
| 383 case "DEPLOYMENT_MANIFEST": |
| 384 parts := strings.SplitN(params, "@", 3) |
| 385 if len(parts) != 3 { |
| 386 return fmt.Errorf("DEPLOYMENT_MANIFEST expected 3 params
, got %q", params) |
| 387 } |
| 388 |
| 389 step := s.RootStep() |
| 390 if step.DeploymentManifests == nil { |
| 391 step.DeploymentManifests = map[string]*milo.Step_Manifes
tLink{} |
| 392 } |
| 393 |
| 394 name, hashHex, url := parts[0], parts[1], parts[2] |
| 395 hash, err := hex.DecodeString(hashHex) |
| 396 if err != nil { |
| 397 return fmt.Errorf("DEPLOYMENT_MANIFEST has bad hash: %s"
, err) |
| 398 } |
| 399 if _, ok := step.DeploymentManifests[name]; ok { |
| 400 return fmt.Errorf("repeated DEPLOYMENT_MANIFEST name %q"
, name) |
| 401 } |
| 402 |
| 403 step.DeploymentManifests[name] = &milo.Step_ManifestLink{ |
| 404 Sha256: hash, |
| 405 Url: url, |
| 406 } |
| 407 updated = step |
| 379 } | 408 } |
| 380 | 409 |
| 381 if updated != nil { | 410 if updated != nil { |
| 382 s.Callbacks.Updated(updated, updateType) | 411 s.Callbacks.Updated(updated, updateType) |
| 383 } | 412 } |
| 384 return nil | 413 return nil |
| 385 } | 414 } |
| 386 | 415 |
| 387 // Finish closes the top-level annotation state and any outstanding steps. | 416 // Finish closes the top-level annotation state and any outstanding steps. |
| 388 func (s *State) Finish() { | 417 func (s *State) Finish() { |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 as.StderrStream, updated = as.maybeSetLogDogStream(as.StderrStream, st) | 980 as.StderrStream, updated = as.maybeSetLogDogStream(as.StderrStream, st) |
| 952 return | 981 return |
| 953 } | 982 } |
| 954 | 983 |
| 955 func (as *Step) maybeSetLogDogStream(target *milo.LogdogStream, st *milo.LogdogS
tream) (*milo.LogdogStream, bool) { | 984 func (as *Step) maybeSetLogDogStream(target *milo.LogdogStream, st *milo.LogdogS
tream) (*milo.LogdogStream, bool) { |
| 956 if (target == nil && st == nil) || (target != nil && st != nil && *targe
t == *st) { | 985 if (target == nil && st == nil) || (target != nil && st != nil && *targe
t == *st) { |
| 957 return target, false | 986 return target, false |
| 958 } | 987 } |
| 959 return st, true | 988 return st, true |
| 960 } | 989 } |
| OLD | NEW |