github.com/abayer/test-infra@v0.0.5/prow/plugins/trigger/push.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package trigger 18 19 import ( 20 "k8s.io/test-infra/prow/github" 21 "k8s.io/test-infra/prow/kube" 22 "k8s.io/test-infra/prow/pjutil" 23 ) 24 25 func handlePE(c client, pe github.PushEvent) error { 26 for _, j := range c.Config.Postsubmits[pe.Repo.FullName] { 27 if !j.RunsAgainstBranch(pe.Branch()) { 28 continue 29 } 30 kr := kube.Refs{ 31 Org: pe.Repo.Owner.Name, 32 Repo: pe.Repo.Name, 33 BaseRef: pe.Branch(), 34 BaseSHA: pe.After, 35 } 36 labels := make(map[string]string) 37 for k, v := range j.Labels { 38 labels[k] = v 39 } 40 labels[github.EventGUID] = pe.GUID 41 pj := pjutil.NewProwJob(pjutil.PostsubmitSpec(j, kr), labels) 42 c.Logger.WithFields(pjutil.ProwJobFields(&pj)).Info("Creating a new prowjob.") 43 if _, err := c.KubeClient.CreateProwJob(pj); err != nil { 44 return err 45 } 46 } 47 return nil 48 }