Merge "changelog: Added README.md"
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..01bdb0c
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module cos.googlesource.com/cos/tools
+
+go 1.14
diff --git a/src/cmd/changelog/main.go b/src/cmd/changelog/main.go
new file mode 100755
index 0000000..fa29575
--- /dev/null
+++ b/src/cmd/changelog/main.go
@@ -0,0 +1,124 @@
+// Copyright 2020 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This file contains the CLI application for COS Changelog.
+// Project information available at go/cos-changelog
+//
+// This application is responsible for:
+// 1. Accepting user input and creating the authenticator object used for
+// queries
+// 2. Calling function in the Changelog package, converting the output
+// to json, and writing the result into a file
+
+package main
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "time"
+
+ "cos.googlesource.com/cos/tools/pkg/changelog"
+
+ "github.com/google/martian/log"
+ "github.com/urfave/cli/v2"
+ "go.chromium.org/luci/auth"
+ "go.chromium.org/luci/common/api/gerrit"
+ "go.chromium.org/luci/hardcoded/chromeinfra"
+)
+
+// Default Manifest location
+const (
+ cosInstanceURL string = "cos.googlesource.com"
+ defaultManifestRepo string = "cos/manifest-snapshots"
+)
+
+func getAuthenticator() *auth.Authenticator {
+ opts := chromeinfra.DefaultAuthOptions()
+ opts.Scopes = []string{gerrit.OAuthScope, auth.OAuthScopeEmail}
+ return auth.NewAuthenticator(context.Background(), auth.InteractiveLogin, opts)
+}
+
+func writeChangelogAsJSON(source string, target string, changes map[string][]*changelog.Commit) error {
+ jsonData, err := json.MarshalIndent(changes, "", " ")
+ if err != nil {
+ return fmt.Errorf("writeChangelogAsJSON: Error marshalling changelog from: %s to: %s\n%v", source, target, err)
+ }
+ fileName := fmt.Sprintf("%s -> %s.json", source, target)
+ if err = ioutil.WriteFile(fileName, jsonData, 0644); err != nil {
+ return fmt.Errorf("writeChangelogAsJSON: Error writing changelog to file: %s\n%v", fileName, err)
+ }
+ return nil
+}
+
+func generateChangelog(source, target, instance, manifestRepo string) {
+ start := time.Now()
+ authenticator := getAuthenticator()
+ sourceToTargetChanges, targetToSourceChanges, err := changelog.Changelog(authenticator, source, target, instance, manifestRepo)
+ if err != nil {
+ log.Infof("generateChangelog: error retrieving changelog between builds %s and %s on GoB instance: %s with manifest repository: %s\n%v\n",
+ source, target, instance, manifestRepo, err)
+ os.Exit(1)
+ }
+ if err := writeChangelogAsJSON(source, target, sourceToTargetChanges); err != nil {
+ log.Infof("generateChangelog: error writing first changelog with source: %s and target: %s\n%v\n",
+ source, target, err)
+ }
+ if err := writeChangelogAsJSON(target, source, targetToSourceChanges); err != nil {
+ log.Infof("generateChangelog: Error writing second changelog with source: %s and target: %s\n%v\n",
+ target, source, err)
+ }
+ log.Infof("Retrieved changelog in %s\n", time.Since(start))
+}
+
+func main() {
+ var instance, manifestRepo string
+ app := &cli.App{
+ Name: "changelog",
+ Usage: "get commits between builds",
+ Flags: []cli.Flag{
+ &cli.StringFlag{
+ Name: "instance",
+ Value: cosInstanceURL,
+ Aliases: []string{"i"},
+ Usage: "GoB `INSTANCE` to use as client",
+ Destination: &instance,
+ },
+ &cli.StringFlag{
+ Name: "repo",
+ Value: defaultManifestRepo,
+ Aliases: []string{"r"},
+ Usage: "`REPO` containing Manifest file",
+ Destination: &manifestRepo,
+ },
+ },
+ Action: func(c *cli.Context) error {
+ if c.NArg() < 2 {
+ return errors.New("Must specify source and target build number")
+ }
+ source := c.Args().Get(0)
+ target := c.Args().Get(1)
+ generateChangelog(source, target, instance, manifestRepo)
+ return nil
+ },
+ }
+ err := app.Run(os.Args)
+ if err != nil {
+ log.Infof("main: error running app with arguments: %v:\n%v", os.Args, err)
+ os.Exit(1)
+ }
+}
diff --git a/src/cmd/changelog/main_test.py b/src/cmd/changelog/main_test.py
new file mode 100644
index 0000000..251a9ad
--- /dev/null
+++ b/src/cmd/changelog/main_test.py
@@ -0,0 +1,167 @@
+# Copyright 2020 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import subprocess
+import unittest
+import json
+import os
+
+
+def get_filename(source, target):
+ return source + ' -> ' + target + '.json'
+
+
+def check_file_exists(source, target):
+ return os.path.exists(get_filename(source, target))
+
+
+def delete_logs(source, target):
+ try:
+ os.remove(get_filename(source, target))
+ os.remove(get_filename(target, source))
+ except OSError:
+ pass
+
+
+def check_empty_json_file(source, target):
+ with open(get_filename(source, target)) as f:
+ return f.read() == '{}'
+
+
+def check_commit_schema(commit):
+ schema = {
+ "SHA": str,
+ "AuthorName": str,
+ "CommitterName": str,
+ "Subject": str,
+ "Bugs": list,
+ "CommitTime": str,
+ "ReleaseNote": str
+ }
+ for attr, attrType in schema.items():
+ if attr not in commit:
+ return False
+ elif not isinstance(commit[attr], attrType):
+ return False
+ return True
+
+
+def check_changelog_schema(source, target):
+ with open(get_filename(source, target)) as f:
+ data = json.load(f)
+ if len(data) == 0:
+ return False
+ for repo, commit_log in data.items():
+ for commit in commit_log:
+ if not check_commit_schema(commit):
+ return False
+ return True
+
+
+class TestCLIApplication(unittest.TestCase):
+
+ def test_build(self):
+ process = subprocess.run(["go", "build", "-o", "changelog","main.go"])
+ assert process.returncode == 0
+
+ def test_basic_run(self):
+ source = "15050.0.0"
+ target = "15056.0.0"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", source, target])
+ assert process.returncode == 0
+ assert check_file_exists(source, target)
+ assert check_file_exists(target, source)
+ assert check_changelog_schema(source, target)
+ assert check_empty_json_file(target, source)
+
+ def test_with_instance_and_repo(self):
+ source = "15048.0.0"
+ target = "15049.0.0"
+ instance = "cos.googlesource.com"
+ repo = "cos/manifest-snapshots"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", "-i", instance, "-r", repo, source, target])
+ assert process.returncode == 0
+ assert check_file_exists(source, target)
+ assert check_file_exists(target, source)
+ assert check_changelog_schema(source, target)
+ assert check_empty_json_file(target, source)
+
+ def test_large_run(self):
+ source = "15055.0.0"
+ target = "15000.0.0"
+ instance = "cos.googlesource.com"
+ repo = "cos/manifest-snapshots"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", "-i", instance, "-r", repo, source, target])
+ assert process.returncode == 0
+ assert check_file_exists(source, target)
+ assert check_file_exists(target, source)
+ assert check_changelog_schema(source, target)
+ assert check_changelog_schema(target, source)
+
+ def test_with_invalid_source(self):
+ source = "99999.0.0"
+ target = "15040.0.0"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", source, target])
+ assert process.returncode != 0
+ assert not check_file_exists(source, target)
+ assert not check_file_exists(target, source)
+
+ def test_with_invalid_target(self):
+ source = "15038.0.0"
+ target = "89981.0.0"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", source, target])
+ assert process.returncode != 0
+ assert not check_file_exists(source, target)
+ assert not check_file_exists(target, source)
+
+ def test_with_invalid_instance(self):
+ source = "15048.0.0"
+ target = "15049.0.0"
+ instance = "cos.gglesource.com"
+ repo = "cos/manifest-snapshots"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", "-i", instance, "-r", repo, source, target])
+ assert process.returncode != 0
+ assert not check_file_exists(source, target)
+ assert not check_file_exists(target, source)
+
+ def test_with_invalid_repo(self):
+ source = "15048.0.0"
+ target = "15049.0.0"
+ instance = "cos.googlesource.com"
+ repo = "cos/not-manifest-snapshots"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", "-i", instance, "-r", repo, source, target])
+ assert process.returncode != 0
+ assert not check_file_exists(source, target)
+ assert not check_file_exists(target, source)
+
+ def test_with_same_source_and_target(self):
+ source = "15056.0.0"
+ target = "15056.0.0"
+ delete_logs(source, target)
+ process = subprocess.run(["./changelog", source, target])
+ assert process.returncode == 0
+ assert check_file_exists(source, target)
+ assert check_file_exists(target, source)
+ assert check_empty_json_file(source, target)
+ assert check_empty_json_file(target, source)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/src/cmd/cos_image_analyzer/internal/binary/binarydiff.go b/src/cmd/cos_image_analyzer/internal/binary/binarydiff.go
new file mode 100644
index 0000000..7f22f4c
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/binary/binarydiff.go
@@ -0,0 +1,48 @@
+package binary
+
+import (
+ "cos.googlesource.com/cos/tools/src/cmd/cos_image_analyzer/internal/utilities"
+ "fmt"
+)
+
+// Global variables
+var (
+ // Command-line path strings
+ // /etc/os-release is the file describing COS versioning
+ etcOSRelease = "/etc/os-release"
+)
+
+// BinaryDiff is a tool that finds all binary differneces of two COS images
+// (COS version, rootfs, kernel command line, stateful parition, ...)
+//
+// Input: (string) img1Path - The path to the root directory for COS image1
+// (string) img2Path - The path to the root directory for COS image2
+//
+// Output: (stdout) terminal ouput - All differences printed to the terminal
+func BinaryDiff(img1Path, img2Path string) error {
+ fmt.Println("================== Binary Differences ==================")
+
+ // COS Verison Difference
+ fmt.Println("--------- COS Verison Difference ---------")
+ verMap1, err := utilities.ReadFileToMap(img1Path+etcOSRelease, "=")
+ if err != nil {
+ return err
+ }
+ verMap2, err := utilities.ReadFileToMap(img2Path+etcOSRelease, "=")
+ if err != nil {
+ return err
+ }
+
+ // Compare Version (Major)
+ _, err = utilities.CmpMapValues(verMap1, verMap2, "VERSION")
+ if err != nil {
+ return err
+ }
+ // Compare BUILD_ID (Minor)
+ _, err = utilities.CmpMapValues(verMap1, verMap2, "BUILD_ID")
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
diff --git a/src/cmd/cos_image_analyzer/internal/input/cleanup_api.go b/src/cmd/cos_image_analyzer/internal/input/cleanup_api.go
new file mode 100644
index 0000000..1d3bc50
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/input/cleanup_api.go
@@ -0,0 +1,23 @@
+package input
+
+import (
+ "os"
+ "os/exec"
+)
+
+// Cleanup is called to remove a mounted directory and its loop device
+// (string) mountDir - Active mount directory ready to close
+// (string) loopDevice - Active loop device ready to close
+// Output: nil on success, else error
+func Cleanup(mountDir, loopDevice string) error {
+ _, err := exec.Command("sudo", "umount", mountDir).Output()
+ if err != nil {
+ return err
+ }
+ _, err1 := exec.Command("sudo", "losetup", "-d", loopDevice).Output()
+ if err1 != nil {
+ return err1
+ }
+ os.Remove(mountDir)
+ return nil
+}
diff --git a/src/cmd/cos_image_analyzer/internal/input/gce_api.go b/src/cmd/cos_image_analyzer/internal/input/gce_api.go
new file mode 100644
index 0000000..c147b4c
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/input/gce_api.go
@@ -0,0 +1,96 @@
+package input
+
+import (
+ "bytes"
+ "encoding/json"
+ // "fmt"
+ "io/ioutil"
+ "log"
+ "net/http"
+ "path/filepath"
+ "strings"
+)
+
+const timeOut = "7200"
+const imageFormat = "vmdk"
+const name = "gcr.io/compute-image-tools/gce_vm_image_export:release"
+
+type Steps struct {
+ Args [6]string `json:"args"`
+ Name string `json:"name"`
+ Env [1]string `json:"env"`
+}
+
+type GcePayload struct {
+ Timeout string `json:"timeout"`
+ Steps [1]Steps `json:"steps"`
+ Tags [2]string `json:"tags"`
+}
+
+// gceExport calls the cloud build REST api that exports a public compute
+// image to a specfic GCS bucket.
+// Input:
+// (string) projectID - project ID of the cloud project holding the image
+// (string) bucket - name of the GCS bucket holding the COS Image
+// (string) image - name of the source image to be exported
+// Output: None
+func gceExport(projectID, bucket, image string) error {
+ // API Variables
+ gceURL := "https://cloudbuild.googleapis.com/v1/projects/" + projectID + "/builds"
+ destURI := "gs://" + bucket + "/" + image + "." + imageFormat
+ args := [6]string{"-oauth=/usr/local/google/home/acueva/cos-googlesource/tools/src/cmd/cos_image_analyzer/internal/utilities/oauth.json", "-timeout=" + timeOut, "-source_image=" + image, "-client_id=api", "-format=" + imageFormat, "-destination_uri=" + destURI}
+ env := [1]string{"BUILD_ID=$BUILD_ID"}
+ tags := [2]string{"gce-daisy", "gce-daisy-image-export"}
+
+ // Build API bodies
+ steps := [1]Steps{Steps{Args: args, Name: name, Env: env}}
+ payload := &GcePayload{
+ Timeout: timeOut,
+ Steps: steps,
+ Tags: tags}
+
+ requestBody, err := json.Marshal(payload)
+ if err != nil {
+ return err
+ }
+ log.Println(string(requestBody))
+
+ resp, err := http.Post(gceURL, "application/json", bytes.NewBuffer(requestBody))
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return err
+ }
+
+ log.Println(string(body))
+ return nil
+}
+
+// GetCosImage calls the cloud build api to export a public COS image to a
+// a GCS bucket and then calls GetGcsImage() to download that image from GCS.
+// ADC is used for authorization.
+// Input:
+// (string) cosCloudPath - The "projectID/gcs-bucket/image" path of the
+// source image to be exported
+// Output:
+// (string) imageDir - Path to the mounted directory of the COS Image
+func GetCosImage(cosCloudPath string) (string, error) {
+ spiltPath := strings.Split(cosCloudPath, "/")
+ projectID, bucket, image := spiltPath[0], spiltPath[1], spiltPath[2]
+
+ if err := gceExport(projectID, bucket, image); err != nil {
+ return "", err
+ }
+
+ gcsPath := filepath.Join(bucket, image)
+ imageDir, err := GetGcsImage(gcsPath, 1)
+ if err != nil {
+ return "", err
+ }
+
+ return imageDir, nil
+}
diff --git a/src/cmd/cos_image_analyzer/internal/input/gcs_api.go b/src/cmd/cos_image_analyzer/internal/input/gcs_api.go
new file mode 100644
index 0000000..3f657d9
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/input/gcs_api.go
@@ -0,0 +1,155 @@
+package input
+
+import (
+ "bytes"
+ "cloud.google.com/go/storage"
+ "context"
+ "io"
+ "io/ioutil"
+ "log"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "time"
+)
+
+const contextTimeOut = time.Second * 50
+
+// gcsDowndload calls the GCS client api to download a specifed object from
+// a GCS bucket. ADC is used for authorization
+// Input:
+// (io.Writier) w - Output destination for download info
+// (string) bucket - Name of the GCS bucket
+// (string) object - Name of the GCS object
+// (string) destDir - Destination for downloaded GCS object
+// Output:
+// (string) downloadedFile - Path to downloaded GCS object
+func gcsDowndload(w io.Writer, bucket, object, destDir string) (string, error) {
+ // Call API to download GCS object into tempDir
+ ctx := context.Background()
+ client, err := storage.NewClient(ctx)
+ if err != nil {
+ return "", err
+ }
+ defer client.Close()
+
+ ctx, cancel := context.WithTimeout(ctx, contextTimeOut)
+ defer cancel()
+
+ rc, err := client.Bucket(bucket).Object(object).NewReader(ctx)
+ if err != nil {
+ return "", err
+ }
+ defer rc.Close()
+
+ data, err := ioutil.ReadAll(rc)
+ if err != nil {
+ return "", err
+ }
+
+ log.Print(log.New(w, "Blob "+object+" downloaded.\n", log.Ldate|log.Ltime|log.Lshortfile))
+
+ downloadedFile := filepath.Join(destDir, object)
+ if err := ioutil.WriteFile(downloadedFile, data, 0666); err != nil {
+ return "", err
+ }
+ return downloadedFile, nil
+}
+
+// getPartitionStart finds the start partition offset of the disk
+// Input:
+// (string) diskFile - Name of DOS/MBR file (ex: disk.raw)
+// (string) parition - The parition number you are pulling the offset from
+// Output:
+// (int) start - The start of the partition on the disk
+func getPartitionStart(partition, diskRaw string) (int, error) {
+ //create command
+ cmd1 := exec.Command("fdisk", "-l", diskRaw)
+ cmd2 := exec.Command("grep", "disk.raw"+partition)
+
+ reader, writer := io.Pipe()
+ var buf bytes.Buffer
+
+ cmd1.Stdout = writer
+ cmd2.Stdin = reader
+ cmd2.Stdout = &buf
+
+ cmd1.Start()
+ cmd2.Start()
+ cmd1.Wait()
+ writer.Close()
+ cmd2.Wait()
+ reader.Close()
+
+ words := strings.Fields(buf.String())
+ start, err := strconv.Atoi(words[1])
+ if err != nil {
+ return -1, err
+ }
+
+ return start, nil
+}
+
+// mountDisk finds a free loop device and mounts a DOS/MBR disk file
+// Input:
+// (string) diskFile - Name of DOS/MBR file (ex: disk.raw)
+// (string) mountDir - Mount Destiination
+// Output: nil on success, else error
+func mountDisk(diskFile, mountDir string, flag int) error {
+ sectorSize := 512
+ startOfPartition, err := getPartitionStart("3", diskFile)
+ if err != nil {
+ return err
+ }
+ offset := strconv.Itoa(sectorSize * startOfPartition)
+ out, err := exec.Command("sudo", "losetup", "--show", "-fP", diskFile).Output()
+ if err != nil {
+ return err
+ }
+ _, err1 := exec.Command("sudo", "mount", "-o", "ro,loop,offset="+offset, string(out[:len(out)-1]), mountDir).Output()
+ if err1 != nil {
+ return err1
+ }
+
+ return nil
+}
+
+// GetGcsImage calls the GCS client api that downloads a specifed object from
+// a GCS bucket and unzips its contents. ADC is used for authorization
+// Input:
+// (string) gcsPath - GCS "bucket/object" path for COS Image (.tar.gz file)
+// Output:
+// (string) imageDir - Path to the mounted directory of the COS Image
+func GetGcsImage(gcsPath string, flag int) (string, error) {
+ bucket := strings.Split(gcsPath, "/")[0]
+ object := strings.Split(gcsPath, "/")[1]
+
+ tempDir, err := ioutil.TempDir(".", "tempDir-"+object) // Removed at end
+ if err != nil {
+ return "", err
+ }
+
+ tarFile, err := gcsDowndload(os.Stdout, bucket, object, tempDir)
+ if err != nil {
+ return "", err
+ }
+
+ imageDir := filepath.Join(tempDir, "Image-"+object)
+ if err = os.Mkdir(imageDir, 0700); err != nil {
+ return "", err
+ }
+
+ _, err1 := exec.Command("tar", "-xzf", tarFile, "-C", imageDir).Output()
+ if err1 != nil {
+ return "", err1
+ }
+
+ diskRaw := filepath.Join(imageDir, "disk.raw")
+ if err = mountDisk(diskRaw, imageDir, flag); err != nil {
+ return "", err
+ }
+
+ return imageDir, nil
+}
diff --git a/src/cmd/cos_image_analyzer/internal/input/parse_input.go b/src/cmd/cos_image_analyzer/internal/input/parse_input.go
new file mode 100644
index 0000000..9e081d1
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/input/parse_input.go
@@ -0,0 +1,94 @@
+package input
+
+import (
+ "errors"
+ "flag"
+ "fmt"
+ "os"
+)
+
+// Custom usage function. See -h flag
+func printUsage() {
+ usageTemplate := `NAME
+cos_image_analyzer - finds all meaningful differences of two COS Images
+(binary, package, commit, and release notes differences)
+
+SYNOPSIS
+%s [-local] DIRECTORY-1 DIRECTORY-2 (default true)
+ DIRECTORY 1/2 - the local directory path to the root of the COS Image
+
+%s [-gcs] GCS-PATH-1 GCS-PATH-2
+ GCS-PATH 1/2 - GCS "bucket/object" path for the COS Image (.tar.gz file)
+ Ex: %s -gcs my-bucket/cos-77-12371-273-0.tar.gz my-bucket/cos-81-12871-119-0.tar.gz
+
+%s [-cos-cloud] COS-CLOUD-PATH-1 COS-CLOUD-PATH-2
+ COS-CLOUD-PATH 1/2 - The "projectID/gcs-bucket/image" path of the source image to be exported
+ Ex: %s -cos-cloud my-project/my-bucket/my-exported-image1 my-project/my-bucket/my-exported-image2
+
+DESCRIPTION
+`
+ usage := fmt.Sprintf(usageTemplate, os.Args[0], os.Args[0], os.Args[0], os.Args[0], os.Args[0])
+ fmt.Printf("%s", usage)
+ flag.PrintDefaults()
+ fmt.Println("\nOUTPUT\n(stdout) terminal output - All differences printed to the terminal")
+}
+
+// ParseInput handles the input based on its type and returns the root
+// directory path of both images to the start of the CosImageAnalyzer
+//
+// Input: None (reads command-line args)
+//
+// Output: (string) rootImg1 - The local filesystem path for COS image1
+// (string) rootImg2 - The local filesystem path for COS image2
+func ParseInput() (string, string, error) {
+ // Flag Declaration
+ flag.Usage = printUsage
+ localPtr := flag.Bool("local", true, "input is two mounted images on local filesystem")
+ gcsPtr := flag.Bool("gcs", false, "input is two objects stored on Google Cloud Storage")
+ cosCloudPtr := flag.Bool("cos-cloud", false, "input is two public COS-cloud images")
+ flag.Parse()
+
+ if flag.NFlag() > 1 {
+ printUsage()
+ return "", "", errors.New("Error: Only one flag allowed")
+ }
+
+ // Input Selection
+ if *gcsPtr {
+ if len(flag.Args()) != 2 {
+ printUsage()
+ return "", "", errors.New("Error: GCS input requires two agruments")
+ }
+ rootImg1, err := GetGcsImage(flag.Args()[0], 1)
+ if err != nil {
+ return "", "", err
+ }
+ rootImg2, err := GetGcsImage(flag.Args()[1], 2)
+ if err != nil {
+ return "", "", err
+ }
+ return rootImg1, rootImg2, nil
+ } else if *cosCloudPtr {
+ if len(flag.Args()) != 2 {
+ printUsage()
+ return "", "", errors.New("Error: COS-cloud input requires two agruments")
+ }
+ rootImg1, err := GetCosImage(flag.Args()[0])
+ if err != nil {
+ return "", "", err
+ }
+ rootImg2, err := GetCosImage(flag.Args()[1])
+ if err != nil {
+ return "", "", err
+ }
+ return rootImg1, rootImg2, nil
+ } else if *localPtr {
+ if len(flag.Args()) != 2 {
+ printUsage()
+ return "", "", errors.New("Error: Local input requires two arguments")
+ }
+ return flag.Args()[0], flag.Args()[1], nil
+ }
+ printUsage()
+ return "", "", errors.New("Error: At least one flag needs to be true")
+}
diff --git a/src/cmd/cos_image_analyzer/internal/testdata/os-release-77 b/src/cmd/cos_image_analyzer/internal/testdata/os-release-77
new file mode 100644
index 0000000..b21554c
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/testdata/os-release-77
@@ -0,0 +1,2 @@
+BUILD_ID=12371.273.0
+ID=cos
\ No newline at end of file
diff --git a/src/cmd/cos_image_analyzer/internal/testdata/os-release-81 b/src/cmd/cos_image_analyzer/internal/testdata/os-release-81
new file mode 100644
index 0000000..826d8f8
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/testdata/os-release-81
@@ -0,0 +1,3 @@
+BUILD_ID=12871.119.0
+VERSION=81
+ID=cos
diff --git a/src/cmd/cos_image_analyzer/internal/utilities/logic_helper.go b/src/cmd/cos_image_analyzer/internal/utilities/logic_helper.go
new file mode 100644
index 0000000..bfdc0ea
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/utilities/logic_helper.go
@@ -0,0 +1,9 @@
+package utilities
+
+// // Helper Function for error checking
+// func check(e error) error {
+// if e != nil {
+// return e
+// }
+// return nil
+// }
diff --git a/src/cmd/cos_image_analyzer/internal/utilities/map_helpers.go b/src/cmd/cos_image_analyzer/internal/utilities/map_helpers.go
new file mode 100644
index 0000000..06b1d39
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/utilities/map_helpers.go
@@ -0,0 +1,61 @@
+package utilities
+
+import (
+ "bufio"
+ "errors"
+ "fmt"
+ "os"
+ "strings"
+)
+
+// ReadFileToMap reads a text file line by line into a map. For each line
+// key: first word split by separator, value: rest of line after separator.
+// Ex: Inputs: textLine: "NAME=Container-Optimized OS", sep: "="
+// Outputs: map: {"NAME":"Container-Optimized OS"}
+//
+// Input: (string) filePath - The command-line path to the text file
+// (string) sep - The separator string for the key and value pairs
+// Output: (map[string]string) mapOfFile - The map of the read-in text file
+func ReadFileToMap(filePath, sep string) (map[string]string, error) {
+ file, err := os.Open(filePath)
+ if err != nil {
+ return map[string]string{}, err
+ }
+ defer file.Close()
+
+ mapOfFile := make(map[string]string)
+ scanner := bufio.NewScanner(file) // Read file line by line to fill map
+ for scanner.Scan() {
+ key := strings.Split(string(scanner.Text()[:]), sep)[0]
+ mapOfFile[key] = strings.Split(string(scanner.Text()[:]), sep)[1]
+ }
+
+ if scanner.Err() != nil {
+ return map[string]string{}, scanner.Err()
+ }
+ return mapOfFile, nil
+}
+
+// CmpMapValues is a helper function that compares a value shared by two maps
+// Input: (map[string]string) map1 - First map to be compared
+// (map[string]string) map2 - Second map to be compared
+// (string) key - The key of the value be compared in both maps
+//
+// Output: (stdout) terminal - If equal, print nothing. Else print difference
+// (int) result - -1 error, 0 for no difference, 1 for difference
+func CmpMapValues(map1, map2 map[string]string, key string) (int, error) {
+ value1, ok1 := map1[key]
+ value2, ok2 := map2[key]
+
+ if !ok1 || !ok2 { // Error Check: At least one key is not present
+ return -1, errors.New("Error:" + key + "key not found in at least one of the maps")
+ }
+
+ if value1 != value2 {
+ fmt.Println(key, "Difference")
+ fmt.Println("< ", value1)
+ fmt.Println("> ", value2)
+ return 1, nil
+ }
+ return 0, nil
+}
diff --git a/src/cmd/cos_image_analyzer/internal/utilities/map_helpers_test.go b/src/cmd/cos_image_analyzer/internal/utilities/map_helpers_test.go
new file mode 100644
index 0000000..8e43712
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/internal/utilities/map_helpers_test.go
@@ -0,0 +1,36 @@
+package utilities
+
+import (
+ "testing"
+)
+
+// test ReadFileToMap function
+func TestReadFileToMap(t *testing.T) {
+ // test normal file
+ testFile, sep := "../testdata/os-release-77", "="
+ expectedMap := map[string]string{"BUILD_ID": "12371.273.0", "ID": "cos"}
+ resultMap, _ := ReadFileToMap(testFile, sep)
+
+ // Compare result with expected
+ if resultMap["BUILD_ID"] != expectedMap["BUILD_ID"] && resultMap["ID"] != expectedMap["ID"] {
+ t.Errorf("ReadFileToMap failed, expected %v, got %v", expectedMap, resultMap)
+ }
+}
+
+// test ReadFileToMap function
+func TestCmpMapValues(t *testing.T) {
+ // test data
+ testMap1 := map[string]string{"BUILD_ID": "12371.273.0", "VERSION": "77", "ID": "cos"}
+ testMap2 := map[string]string{"BUILD_ID": "12871.119.0", "VERSION": "81", "ID": "cos"}
+ testKey1, testKey2 := "ID", "VERSION"
+
+ // test similar keys
+ if result1, _ := CmpMapValues(testMap1, testMap2, testKey1); result1 != 0 { // Expect 0 for same values
+ t.Errorf("CmpMapValues failed, expected %v, got %v", 0, result1)
+ }
+
+ // test different keys
+ if result2, _ := CmpMapValues(testMap1, testMap2, testKey2); result2 != 1 { // Expect 1 for different values
+ t.Errorf("CmpMapValues failed, expected %v, got %v", 1, result2)
+ }
+}
diff --git a/src/cmd/cos_image_analyzer/main.go b/src/cmd/cos_image_analyzer/main.go
new file mode 100644
index 0000000..017d44a
--- /dev/null
+++ b/src/cmd/cos_image_analyzer/main.go
@@ -0,0 +1,47 @@
+// cos_Image_Analyzer finds all the meaningful differences of two COS Images
+// (binary, package, commit, and release notes differences)
+//
+// Input: (string) rootImg1 - The path for COS image1
+// (string) rootImg2 - The path for COS image2
+// (int) inputFlag - 0-Local filesystem path to root directory,
+// 1-COS cloud names, 2-GCS object names
+//
+// Output: (stdout) terminal ouput - All differences printed to the terminal
+package main
+
+import (
+ "cos.googlesource.com/cos/tools/src/cmd/cos_image_analyzer/internal/binary"
+ "cos.googlesource.com/cos/tools/src/cmd/cos_image_analyzer/internal/input"
+ "fmt"
+ "os"
+ "runtime"
+)
+
+func cosImageAnalyzer(img1Path, img2Path string) error {
+ err := binary.BinaryDiff(img1Path, img2Path)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func main() {
+ if runtime.GOOS != "linux" {
+ fmt.Printf("Error: This is a Linux tool, can not run on %s", runtime.GOOS)
+ os.Exit(1)
+ }
+ rootImg1, rootImg2, err := input.ParseInput()
+ if err != nil {
+ fmt.Println(err)
+ os.Exit(1)
+ }
+
+ err1 := cosImageAnalyzer(rootImg1, rootImg2)
+ if err1 != nil {
+ fmt.Println(err1)
+ os.Exit(1)
+ }
+ // Cleanup(rootImg1, loop1) Debating on a struct that holds this info
+ // Cleanup(rootImg2, loop2)
+
+}
diff --git a/src/go.mod b/src/go.mod
new file mode 100644
index 0000000..613c4c8
--- /dev/null
+++ b/src/go.mod
@@ -0,0 +1,16 @@
+module cos.googlesource.com/cos/tools
+
+go 1.14
+
+require (
+ cloud.google.com/go v0.61.0 // indirect
+ github.com/beevik/etree v1.1.0
+ github.com/google/martian v2.1.0+incompatible
+ github.com/julienschmidt/httprouter v1.3.0 // indirect
+ github.com/mitchellh/go-homedir v1.1.0 // indirect
+ github.com/urfave/cli/v2 v2.2.0
+ go.chromium.org/luci v0.0.0-20200715073306-edba25a92a1f
+ golang.org/x/tools v0.0.0-20200716193322-f2c07d7d8ec1 // indirect
+ google.golang.org/genproto v0.0.0-20200715011427-11fb19a81f2c // indirect
+ google.golang.org/protobuf v1.25.0
+)
diff --git a/src/go.sum b/src/go.sum
new file mode 100644
index 0000000..a0d91c6
--- /dev/null
+++ b/src/go.sum
@@ -0,0 +1,379 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
+cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
+cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
+cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
+cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
+cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
+cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
+cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
+cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
+cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
+cloud.google.com/go v0.61.0 h1:NLQf5e1OMspfNT1RAHOB3ublr1TW3YTXO8OiWwVjK2U=
+cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw=
+cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
+cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
+cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
+cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
+cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
+cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
+cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
+cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
+cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
+cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
+dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
+github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
+github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
+github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
+github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
+github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
+github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
+github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw=
+github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
+github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
+github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
+github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/urfave/cli v1.22.4 h1:u7tSpNPPswAFymm8IehJhy4uJMlUuU/GmqSkvJ1InXA=
+github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
+github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
+github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+go.chromium.org/luci v0.0.0-20200715073306-edba25a92a1f h1:Wje6yC+n0xLfrCE2EI9SC5p18J5L9tuanLNEysc3efM=
+go.chromium.org/luci v0.0.0-20200715073306-edba25a92a1f/go.mod h1:MIQewVTLvOvc0UioV0JNqTNO/RspKFS0XEeoKrOxsdM=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
+golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
+golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
+golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
+golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
+golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
+golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
+golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
+golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k=
+golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
+golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
+golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
+golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
+golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU=
+golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
+golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o=
+golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
+golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
+golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed h1:+qzWo37K31KxduIYaBeMqJ8MUOyTayOQKpH9aDPLMSY=
+golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200716193322-f2c07d7d8ec1 h1:+L0anz7VPZcdhiFmfOYsyvU4q2cvemMri/ayLxr/5JE=
+golang.org/x/tools v0.0.0-20200716193322-f2c07d7d8ec1/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
+google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
+google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
+google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
+google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
+google.golang.org/api v0.29.0 h1:BaiDisFir8O4IJxvAabCGGkQ6yCJegNQqSVoYUNAnbk=
+google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
+google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
+google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
+google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
+google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200715011427-11fb19a81f2c h1:6DWnZZ6EY/59QRRQttZKiktVL23UuQYs7uy75MhhLRM=
+google.golang.org/genproto v0.0.0-20200715011427-11fb19a81f2c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
+google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
+google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
+google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
+google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
+google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
+rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
+rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/src/pkg/changelog/changelog.go b/src/pkg/changelog/changelog.go
new file mode 100755
index 0000000..8d25802
--- /dev/null
+++ b/src/pkg/changelog/changelog.go
@@ -0,0 +1,311 @@
+// Copyright 2020 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// This package generates a changelog based on the commit history between
+// two build numbers. The changelog consists of two outputs - the commits
+// added to the target build that aren't present in the source build, and the
+// commits in the source build that aren't present in the target build. This
+// package uses concurrency to improve performance.
+//
+// This packages uses Gitiles to request information from a Git on Borg instance.
+// To generate a changelog, the package first retrieves the the manifest files for
+// the two requested builds using the provided manifest GoB instance and repository.
+// The package then parses the XML files and retrieves the committish and instance
+// URL. A request is sent on a seperate thread for each repository, asking for a list
+// of commits that occurred between the source committish and the target committish.
+// Finally, the resulting git.Commit objects are converted to Commit objects, and
+// consolidated into a mapping of repositoryName -> []*Commit.
+
+package changelog
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "strings"
+ "time"
+
+ "github.com/beevik/etree"
+ "github.com/google/martian/log"
+ "go.chromium.org/luci/auth"
+ gitilesApi "go.chromium.org/luci/common/api/gitiles"
+ gitilesProto "go.chromium.org/luci/common/proto/gitiles"
+)
+
+const (
+ manifestFileName string = "snapshot.xml"
+
+ // These constants are used for exponential increase in Gitiles request size.
+ defaultPageSize int32 = 1000
+ pageSizeGrowthMultiplier int32 = 5
+ maxPageSize int32 = 10000
+)
+
+type repo struct {
+ // The Git on Borg instance to query from.
+ InstanceURL string
+ // A value that points to the last commit for a build on a given repo.
+ // Acceptable values:
+ // - A commit SHA
+ // - A ref, ex. "refs/heads/branch"
+ // - A ref defined as n-th parent of R in the form "R-n".
+ // ex. "master-2" or "deadbeef-1".
+ // Source: https://pkg.go.dev/go.chromium.org/luci/common/proto/gitiles?tab=doc#LogRequest
+ Committish string
+}
+
+type commitsResult struct {
+ RepoURL string
+ Commits []*Commit
+ Err error
+}
+
+type additionsResult struct {
+ Additions map[string][]*Commit
+ Err error
+}
+
+func client(authenticator *auth.Authenticator, remoteURL string) (gitilesProto.GitilesClient, error) {
+ authedClient, err := authenticator.Client()
+ cl, err := gitilesApi.NewRESTClient(authedClient, remoteURL, true)
+ if err != nil {
+ return nil, errors.New("changelog: Failed to establish client to remote url: " + remoteURL)
+ }
+ return cl, nil
+}
+
+func createClients(clients map[string]gitilesProto.GitilesClient, authenticator *auth.Authenticator, repoMap map[string]*repo) error {
+ for _, repoData := range repoMap {
+ remoteURL := repoData.InstanceURL
+ if _, ok := clients[remoteURL]; ok {
+ continue
+ }
+ client, err := client(authenticator, remoteURL)
+ if err != nil {
+ return fmt.Errorf("createClients: error creating client mapping:\n%v", err)
+ }
+ clients[remoteURL] = client
+ }
+ return nil
+}
+
+// repoMap generates a mapping of repo name to instance URL and committish.
+// This eliminates the need to track remote names and allows lookup
+// of source committish when generating changelog.
+func repoMap(manifest string) (map[string]*repo, error) {
+ doc := etree.NewDocument()
+ if err := doc.ReadFromString(manifest); err != nil {
+ return nil, fmt.Errorf("repoMap: error parsing manifest xml:\n%v", err)
+ }
+ root := doc.SelectElement("manifest")
+
+ // Parse each <remote fetch=X name=Y> tag in the manifest xml file.
+ // Extract the "fetch" and "name" attributes from each remote tag, and map the name to the fetch URL.
+ remoteMap := make(map[string]string)
+ for _, remote := range root.SelectElements("remote") {
+ url := strings.Replace(remote.SelectAttr("fetch").Value, "https://", "", 1)
+ remoteMap[remote.SelectAttr("name").Value] = url
+ }
+
+ // Parse each <project name=X remote=Y revision=Z> tag in the manifest xml file.
+ // Extract the "name", "remote", and "revision" attributes from each project tag.
+ // Some projects do not have a "remote" attribute.
+ // If this is the case, they should use the default remoteURL.
+ remoteMap[""] = remoteMap[root.SelectElement("default").SelectAttr("remote").Value]
+ repos := make(map[string]*repo)
+ for _, project := range root.SelectElements("project") {
+ repos[project.SelectAttr("name").Value] = &repo{
+ InstanceURL: remoteMap[project.SelectAttrValue("remote", "")],
+ Committish: project.SelectAttr("revision").Value,
+ }
+ }
+ return repos, nil
+}
+
+// mappedManifest retrieves a Manifest file from GoB and unmarshals XML.
+func mappedManifest(client gitilesProto.GitilesClient, repo string, buildNum string) (map[string]*repo, error) {
+ request := gitilesProto.DownloadFileRequest{
+ Project: repo,
+ Committish: "refs/tags/" + buildNum,
+ Path: manifestFileName,
+ Format: 1,
+ }
+ response, err := client.DownloadFile(context.Background(), &request)
+ if err != nil {
+ return nil, fmt.Errorf("mappedManifest: error downloading manifest file from repo %s:\n%v",
+ repo, err)
+ }
+ mappedManifest, err := repoMap(response.Contents)
+ if err != nil {
+ return nil, fmt.Errorf("mappedManifest: error parsing manifest contents from repo %s:\n%v",
+ repo, err)
+ }
+ return mappedManifest, nil
+}
+
+// commits get all commits that occur between committish and ancestor for a specific repo.
+func commits(client gitilesProto.GitilesClient, repo string, committish string, ancestor string, outputChan chan commitsResult) {
+ start := time.Now()
+ pageSize := defaultPageSize
+ request := gitilesProto.LogRequest{
+ Project: repo,
+ Committish: committish,
+ ExcludeAncestorsOf: ancestor,
+ PageSize: pageSize,
+ }
+ response, err := client.Log(context.Background(), &request)
+ if err != nil {
+ outputChan <- commitsResult{Err: fmt.Errorf("commits: Error retrieving log for repo: %s with committish: %s and ancestor %s:\n%v",
+ repo, committish, ancestor, err)}
+ return
+ }
+ // No nextPageToken means there were less than <defaultPageSize> commits total.
+ // We can immediately return.
+ if response.NextPageToken == "" {
+ log.Infof("Retrieved %d commits from %s in %s\n", len(response.Log), repo, time.Since(start))
+ parsedCommits, err := ParseGitCommitLog(response.Log)
+ if err != nil {
+ outputChan <- commitsResult{Err: fmt.Errorf("commits: Error parsing log response for repo: %s with committish: %s and ancestor %s:\n%v",
+ repo, committish, ancestor, err)}
+ return
+ }
+ outputChan <- commitsResult{RepoURL: repo, Commits: parsedCommits}
+ return
+ }
+ // Retrieve remaining commits using exponential increase in pageSize.
+ allCommits := response.Log
+ for response.NextPageToken != "" {
+ if pageSize < maxPageSize {
+ pageSize *= pageSizeGrowthMultiplier
+ }
+ request := gitilesProto.LogRequest{
+ Project: repo,
+ Committish: committish,
+ ExcludeAncestorsOf: ancestor,
+ PageToken: response.NextPageToken,
+ PageSize: pageSize,
+ }
+ response, err = client.Log(context.Background(), &request)
+ if err != nil {
+ outputChan <- commitsResult{Err: fmt.Errorf("commits: Error retrieving log for repo: %s with committish: %s and ancestor %s:\n%v",
+ repo, committish, ancestor, err)}
+ return
+ }
+ allCommits = append(allCommits, response.Log...)
+ }
+ log.Infof("Retrieved %d commits from %s in %s\n", len(allCommits), repo, time.Since(start))
+ parsedCommits, err := ParseGitCommitLog(allCommits)
+ if err != nil {
+ outputChan <- commitsResult{Err: fmt.Errorf("commits: Error parsing log response for repo: %s with committish: %s and ancestor %s:\n%v",
+ repo, committish, ancestor, err)}
+ return
+ }
+ outputChan <- commitsResult{RepoURL: repo, Commits: parsedCommits}
+}
+
+// additions retrieves all commits that occured between 2 parsed manifest files for each repo.
+// Returns a map of repo name -> list of commits.
+func additions(clients map[string]gitilesProto.GitilesClient, sourceRepos map[string]*repo, targetRepos map[string]*repo, outputChan chan additionsResult) {
+ repoCommits := make(map[string][]*Commit)
+ commitsChan := make(chan commitsResult, len(targetRepos))
+ for repoURL, targetRepoInfo := range targetRepos {
+ cl := clients[targetRepoInfo.InstanceURL]
+ // If the source Manifest file does not contain a target repo,
+ // count every commit since target repo creation as an addition
+ ancestorCommittish := ""
+ if sourceRepoInfo, ok := sourceRepos[repoURL]; ok {
+ ancestorCommittish = sourceRepoInfo.Committish
+ }
+ go commits(cl, repoURL, targetRepoInfo.Committish, ancestorCommittish, commitsChan)
+ }
+ for i := 0; i < len(targetRepos); i++ {
+ res := <-commitsChan
+ if res.Err != nil {
+ outputChan <- additionsResult{Err: res.Err}
+ return
+ }
+ if len(res.Commits) > 0 {
+ repoCommits[res.RepoURL] = res.Commits
+ }
+ }
+ outputChan <- additionsResult{Additions: repoCommits}
+ return
+}
+
+// Changelog generates a changelog between 2 build numbers
+//
+// authenticator is an auth.Authenticator object that is used to build authenticated
+// Gitiles clients
+//
+// sourceBuildNum and targetBuildNum should be build numbers. It should match
+// a tag that links directly to snapshot.xml
+// Ex. For /refs/tags/15049.0.0, the argument should be 15049.0.0
+//
+// The host should be the GoB instance that Manifest files are hosted in
+// ex. "cos.googlesource.com"
+//
+// The repo should be the repository that build manifest files
+// are located, ex. "cos/manifest-snapshots"
+//
+// Outputs two changelogs
+// The first changelog contains new commits that were added to the target
+// build starting from the source build number
+//
+// The second changelog contains all commits that are present in the source build
+// but not present in the target build
+func Changelog(authenticator *auth.Authenticator, sourceBuildNum string, targetBuildNum string, host string, repo string) (map[string][]*Commit, map[string][]*Commit, error) {
+ clients := make(map[string]gitilesProto.GitilesClient)
+
+ // Since the manifest file is always in the cos instance, add cos client
+ // so that client knows what URL to use
+ manifestClient, err := client(authenticator, host)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Changelog: error creating client for GoB instance: %s:\n%v", host, err)
+ }
+ sourceRepos, err := mappedManifest(manifestClient, repo, sourceBuildNum)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Changelog: error retrieving mapped manifest for source build number: %s using manifest repository: %s:\n%v",
+ sourceBuildNum, repo, err)
+ }
+ targetRepos, err := mappedManifest(manifestClient, repo, targetBuildNum)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Changelog: error retrieving mapped manifest for target build number: %s using manifest repository: %s:\n%v",
+ targetBuildNum, repo, err)
+ }
+
+ clients[host] = manifestClient
+ err = createClients(clients, authenticator, sourceRepos)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Changelog: error creating source clients:\n%v", err)
+ }
+ err = createClients(clients, authenticator, targetRepos)
+ if err != nil {
+ return nil, nil, fmt.Errorf("Changelog: error creating target clients:\n%v", err)
+ }
+
+ addChan := make(chan additionsResult, 1)
+ missChan := make(chan additionsResult, 1)
+ go additions(clients, sourceRepos, targetRepos, addChan)
+ go additions(clients, targetRepos, sourceRepos, missChan)
+ addRes := <-addChan
+ if addRes.Err != nil {
+ return nil, nil, fmt.Errorf("Changelog: failure when retrieving commit additions:\n%v", err)
+ }
+ missRes := <-missChan
+ if missRes.Err != nil {
+ return nil, nil, fmt.Errorf("Changelog: failure when retrieving missed commits:\n%v", err)
+ }
+
+ return addRes.Additions, missRes.Additions, nil
+}
diff --git a/src/pkg/changelog/changelog_test.go b/src/pkg/changelog/changelog_test.go
new file mode 100644
index 0000000..361750e
--- /dev/null
+++ b/src/pkg/changelog/changelog_test.go
@@ -0,0 +1,273 @@
+// Copyright 2020 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package changelog
+
+import (
+ "context"
+ "testing"
+
+ "go.chromium.org/luci/auth"
+ "go.chromium.org/luci/common/api/gerrit"
+ "go.chromium.org/luci/hardcoded/chromeinfra"
+)
+
+const cosInstance = "cos.googlesource.com"
+const defaultManifestRepo = "cos/manifest-snapshots"
+
+func getAuthenticator() *auth.Authenticator {
+ opts := chromeinfra.DefaultAuthOptions()
+ opts.Scopes = []string{gerrit.OAuthScope, auth.OAuthScopeEmail}
+ return auth.NewAuthenticator(context.Background(), auth.InteractiveLogin, opts)
+}
+
+func commitsMatch(commits []*Commit, expectedCommits []string) bool {
+ if len(commits) != len(expectedCommits) {
+ return false
+ }
+ for i, commit := range commits {
+ if commit == nil {
+ return false
+ }
+ if commit.SHA != expectedCommits[i] {
+ return false
+ }
+ }
+ return true
+}
+
+func mappingInLog(log map[string][]*Commit, check []string) bool {
+ for _, check := range check {
+ if log, ok := log[check]; !ok || len(log) == 0 {
+ return false
+ }
+ }
+ return true
+}
+
+func TestChangelog(t *testing.T) {
+ authenticator := getAuthenticator()
+
+ // Test invalid source
+ additions, misses, err := Changelog(authenticator, "15", "15043.0.0", cosInstance, defaultManifestRepo)
+ if additions != nil {
+ t.Errorf("Changelog failed, expected nil additions, got %v", additions)
+ } else if misses != nil {
+ t.Errorf("Changelog failed, expected nil misses, got %v", misses)
+ } else if err == nil {
+ t.Errorf("Changelog failed, expected error, got nil")
+ }
+
+ // Test invalid target
+ additions, misses, err = Changelog(authenticator, "15043.0.0", "abx", cosInstance, defaultManifestRepo)
+ if additions != nil {
+ t.Errorf("Changelog failed, expected nil additions, got %v", additions)
+ } else if misses != nil {
+ t.Errorf("Changelog failed, expected nil misses, got %v", misses)
+ } else if err == nil {
+ t.Errorf("Changelog failed, expected error, got nil")
+ }
+
+ // Test invalid instance
+ additions, misses, err = Changelog(authenticator, "15036.0.0", "15041.0.0", "com", defaultManifestRepo)
+ if additions != nil {
+ t.Errorf("Changelog failed, expected nil additions, got %v", additions)
+ } else if misses != nil {
+ t.Errorf("Changelog failed, expected nil misses, got %v", misses)
+ } else if err == nil {
+ t.Errorf("Changelog failed, expected error, got nil")
+ }
+
+ // Test invalid manifest repo
+ additions, misses, err = Changelog(authenticator, "15036.0.0", "15041.0.0", cosInstance, "cos/not-a-repo")
+ if additions != nil {
+ t.Errorf("Changelog failed, expected nil additions, got %v", additions)
+ } else if misses != nil {
+ t.Errorf("Changelog failed, expected nil misses, got %v", misses)
+ } else if err == nil {
+ t.Errorf("Changelog failed, expected error, got nil")
+ }
+
+ // Test build number higher than latest release
+ additions, misses, err = Changelog(authenticator, "15036.0.0", "99999.0.0", cosInstance, defaultManifestRepo)
+ if additions != nil {
+ t.Errorf("Changelog failed, expected nil additions, got %v", additions)
+ } else if misses != nil {
+ t.Errorf("Changelog failed, expected nil misses, got %v", misses)
+ } else if err == nil {
+ t.Errorf("Changelog failed, expected error, got nil")
+ }
+
+ // Test 1 build number difference with only 1 repo change between them
+ // Ensure that commits are correctly inserted in proper order
+ source := "15050.0.0"
+ target := "15051.0.0"
+ expectedCommits := []string{
+ "6201c49afe667c8fa7796608a4d7162bb3f7f4f4",
+ "a8bcf0feaa0e3c0131a888fcd9d0dcbbe8c3850c",
+ "5e3ef32e062fb227aaa6b47138950557ec91d23e",
+ "654ed08e8a349e7199eb3a80b6d7704a20ff8ec4",
+ "d5c0e74fbb2a50517a1249cbbec4dcee3d049883",
+ "cd226061776dad6c0e35323f407eaa138795f4cc",
+ "4351d0dc5480e941fac96cb0ec898a87171eadda",
+ "cdbcf507749a86acad3e8787ffb3c3356ed76b3a",
+ "4fdd7f397bc09924e91f475d3ed55bb5a302bdaf",
+ "3adae69de78875a8d33061205357388a513ea51d",
+ "5fd85ec937d362984e5108762e8b5e20105a4219",
+ "03b6099c920c1b3cb4cbda2172089e80b4d4be6e",
+ "1febb203aaf99f00e5d9d80d965726458ba8348f",
+ "2de610687308b6ea00d9ac6190d83f0edb2a46b4",
+ "db3083c438442ea6ab34e84404b4602618d2e07b",
+ "13eb9486f2bf43d56ce58695df8461099fd7c314",
+ "12b8a449ef93289674d93f437c19a06530c2c966",
+ "6d9752b0abeeaf7438ab08ea7ff5b0f76c2dacca",
+ "8555ba160a5eee0be464b25a07abc6031dc9159c",
+ "a8c1c3c2971acc03f4246c20b1ddd5bb5376ded3",
+ "762495e014eaa74e3aa4d83caaaa778fcfb968a2",
+ "784782cd8c1d846c17541a3e527ad56857fe2e91",
+ "7c6916858860715db25eaadc2b3ec81865304095",
+ "76cc8bf290a133ee821a8a2b14207150de9a7803",
+ "dc07ec7806f249fdb0b7bda68c687a87b311c952",
+ "f18ad3b35466354d5a0e166008070f54a06759a6",
+ "34f008f664e11b6df2f06735b6db6d6a42804d25",
+ "a24eee7a6b6caed0448365e548e92724069a8448",
+ "64ddf2924656f07bd63269524ed1731a2357b82f",
+ "e40d4ce60313cd28ebf1c376860402f9b3d373cd",
+ "3018e2531a1f0f22c4d053ed0b8a5cc86ad81319",
+ "668cd418350d03e1535c7862ebe93801ace0b1c6",
+ "fabf26e3eab2af24371c48e19062d7c8df34bd9f",
+ "7b38982caecbeb16520b4dd84422ecad0edaf772",
+ "658380877ca2eedc3cd80d3b6daafa24ab96a261",
+ "63dee6c8cd318dfa20cfddf2e72243873e816046",
+ "bc194a3ce16407015da5bc8d46df55231cf4d625",
+ "ff75e90067c7c535116cb5566ebc14451785b36a",
+ "c64b1cc6b930024e77425fd105716ade26d0524c",
+ "d5123111900fd70d85b7acf5809df701da24f1ea",
+ "c617b261c68b52b0abefc0635c1ea03c4cb0cb11",
+ "a2619465e4eca49692d832b593cb205118042bc9",
+ "6f6451dd56a7fad25b2e8b31a053275adb2008a4",
+ "68d5d3901d5c3df44e3be8c3fac0c6b1e90d780c",
+ "308882e4e837f231e3ad0f37fd143cee419d816f",
+ "1cb20f5aa5a82a412d97fad7b9c13c87c9381f14",
+ "f6c0c6f1618676519efd74c8f946e191472b6a4e",
+ "dea6ca48a629e80cc2ffbf203c9cc1855a28a47e",
+ "fa0115b220b3471a1542b3b66463f9ec80c8c7f0",
+ "b815d624f7715ab51379e8a913c280cac1eafde4",
+ "39fe5d201b87e02baedf4da8b02523571c4ccbcc",
+ "58aff81e0829100cc9d3239791573300e2d2398d",
+ "cd570b8e278aca36f166eb84b5003eaee3c03ecc",
+ "50f9936fe8ab106d2716e007a342860c695f7822",
+ "2a1e98d6c3dca9b52bcb7b02c7a242c10c0a0de9",
+ "b9fe6cc174f215d576954e6b2c93bc4de8ba2c34",
+ "f78d275ec9d0c4061f75ae2f97f958657a71ebd1",
+ "315ea4a344e3f8b300e8c3e48fafc21eaee767fe",
+ "1c9392eb35c68ca38a1f0178cd191f07d387f52d",
+ "9cd44834d383b5414bd9bac873e9c620a67eff1d",
+ "e0f3f79316591affedeaf2702a350d3512bd6a69",
+ "148bba54f3762b23a79057825a763c1132bd1d55",
+ "48ce30dd18de40852cea15dccaaa833b4017ae10",
+ "474e61f82f79d9779b0e2c3bc63d920d9f75b5b6",
+ "b93f0e4f3edbe3e64b0128db38ee231a737f06c9",
+ "714065afa108556b6ff43ff312b731c239d6e551",
+ "45a780a84daa27307addd836df94afa2c70dccb6",
+ "0df346778d142f9c6bf221d67bdac96d9d636408",
+ "6ad098080fb6437da98511e56026476fa71cce87",
+ "3f2915159ab1e42b258ee78d2a71f2dc59d51d35",
+ "1d5a9ebc23d1455966963a042bd610fdb38cd705",
+ "e31b072bbc2d83db107d913a3f32d907de119ca2",
+ "6da63745bd4318577ab8937100871e654df04cb3",
+ "d5a54c19f7bf1f8250bc5ac779f80450764e836e",
+ "54c59bdcf9965dbb77a6dd9682f255e21e4821a1",
+ "67b538de711500bfb1ed5d322e916e8cd3f74700",
+ "2814ccbb44a3d19cb4d696705794ced3beb31ef3",
+ "deb92542c03e9096fe37d8833532a50a6bb1df3c",
+ "d2b9b62c2ad5440005b72826bb55a36dfc115ac2",
+ "da9cd84436f716c3c7a6d90e820afb87a9a218b9",
+ "d0937f57cd2904df1af7449f32c75aaadaeac2a2",
+ "65441913baef06967e59158f3848e41dce18b43a",
+ "7cc03e836eba4d13526969b84aaa8dd61d8b6216",
+ "dff08d118cab7f8416b8f171aac91b8ca3f6b44d",
+ "aedb933f853499a0c736deb2d2ab899b607aacee",
+ "aa592bf7b0b7b13eee2b20fa54fd81e11e96cf56",
+ "f495c107eefc879b10fdf2e3a2a0155259210dba",
+ "7e4e0964a1426d46cdbcbccd861cee7a106a9430",
+ "d0ca437a1ed89e2adbd6b2d1bd572b475cd1d8ec",
+ "0dce9e5070718b7ba950f0b6575bb3bbd0e362bc",
+ "ddd73889c36e93c6128a4d791b6d673cd655447e",
+ "04e70ee7abbb702e4939fef98d50b5e6cc018ccd",
+ "86da591dd3d8515ebf4d1eebc68a61092ad13e95",
+ "8676fbad9fa41e0d0f69dafb2b4f8bd4b5a3b3cc",
+ "b8b3a8cc67fcdf58d495489c19e5d3aa23d22563",
+ "7441c2cf859b84f7cedff8946dbd0c3dc7ef956b",
+ "7f3e0778e212c8a22f8262e2819a6aebfca8b879",
+ "a82b808965dbe304e0a95cb9534b09b3b5c0486a",
+ "0388f30783e2454ea9f0c3978f92c797fc0bdf20",
+ "67f6e97cee8a5b33f8e27b4d2426fb009c0ae435",
+ "094bef7b6bd0c034ea19aa3cb9744ca35998ecc8",
+ "ec07a4f7eb15d867e453c8c8991656b361a29882",
+ "0a304d6481d01d774fe97f31c9574c970fdb532f",
+ "3f77b91ad1abb2d2074286635927fa6472eb0a2e",
+ "ca721a37ec8edc8f1b8aeb4c143aa936dc032ac1",
+ "c0b7d2df81ae29869f9d7a1874b741eeec0d5d18",
+ "9bc12bb411f357188d008864f80dfba43210b9d8",
+ "bf0dd3757826b9bc9d7082f5f749ff7615d4bcb3",
+ }
+ additions, misses, err = Changelog(authenticator, source, target, cosInstance, defaultManifestRepo)
+ if err != nil {
+ t.Errorf("Changelog failed, expected no error, got %v", err)
+ } else if len(misses) != 0 {
+ t.Errorf("Changelog failed, expected empty misses list, got %v", misses)
+ } else if len(additions) != 1 {
+ t.Errorf("Changelog failed, expected only 1 repo in additions, got %v", additions)
+ } else if _, ok := additions["cos/overlays/board-overlays"]; !ok {
+ t.Errorf("Changelog failed, expected \"cos/overlays/board-overlays\" in additions, got %v", additions)
+ } else if changes, _ := additions["cos/overlays/board-overlays"]; len(changes) != 108 {
+ t.Errorf("Changelog failed, expected 108 changes for \"cos/overlays/board-overlays\", got %d", len(changes))
+ } else if !commitsMatch(additions["cos/overlays/board-overlays"], expectedCommits) {
+ t.Errorf("Changelog failed, Changelog output does not match expected commits or is not sorted")
+ }
+
+ // Test build numbers further apart from each other with multiple repo differences
+ // Also ensures that misses are correctly populated
+ source = "15020.0.0"
+ target = "15056.0.0"
+ additionRepos := []string{
+ "mirrors/cros/chromiumos/platform/crosutils",
+ "cos/manifest",
+ "mirrors/cros/chromiumos/platform/vboot_reference",
+ "mirrors/cros/chromiumos/platform/dev-util",
+ "mirrors/cros/chromiumos/platform/crostestutils",
+ "mirrors/cros/chromiumos/infra/proto",
+ "mirrors/cros/chromiumos/third_party/toolchain-utils",
+ "mirrors/cros/chromiumos/third_party/coreboot",
+ "cos/overlays/board-overlays",
+ "mirrors/cros/chromiumos/platform2",
+ "mirrors/cros/chromiumos/overlays/eclass-overlay",
+ "mirrors/cros/chromiumos/chromite",
+ "mirrors/cros/chromiumos/third_party/autotest",
+ "mirrors/cros/chromiumos/overlays/chromiumos-overlay",
+ "third_party/kernel",
+ "mirrors/cros/chromium/tools/depot_tools",
+ "mirrors/cros/chromiumos/repohooks",
+ "mirrors/cros/chromiumos/overlays/portage-stable",
+ }
+ additions, misses, err = Changelog(authenticator, source, target, cosInstance, defaultManifestRepo)
+ if err != nil {
+ t.Errorf("Changelog failed, expected no error, got %v", err)
+ } else if _, ok := misses["third_party/kernel"]; len(misses) != 1 && ok {
+ t.Errorf("Changelog failed, expected miss list containing only \"third_party/kernel\", got %v", misses)
+ } else if !mappingInLog(additions, additionRepos) {
+ t.Errorf("Changelog failed, additions repo output does not match expected repos %v", additionRepos)
+ }
+}
diff --git a/src/pkg/changelog/gitcommit.go b/src/pkg/changelog/gitcommit.go
new file mode 100755
index 0000000..e52b2c7
--- /dev/null
+++ b/src/pkg/changelog/gitcommit.go
@@ -0,0 +1,144 @@
+// Copyright 2020 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package changelog
+
+import (
+ "errors"
+ "regexp"
+ "strings"
+ "time"
+
+ "go.chromium.org/luci/common/proto/git"
+)
+
+const bugLinePrefix string = "BUG="
+const releaseNoteLinePrefix string = "RELEASE_NOTE="
+
+// Commit is a simplified struct of git.Commit
+// Useful for interfaces
+type Commit struct {
+ SHA string
+ AuthorName string
+ CommitterName string
+ Subject string
+ Bugs []string
+ ReleaseNote string
+ CommitTime string
+}
+
+// All bug patterns need to be added here to recognize whether a bug entry
+// should be ignored or not
+var bugPatternToReplacement = map[*regexp.Regexp]string{
+ regexp.MustCompile("^b/"): "b/",
+ regexp.MustCompile("^b:"): "b/",
+ regexp.MustCompile("^chromium.*:"): "crbug/",
+ regexp.MustCompile("^chrome.*:"): "crbug/",
+}
+
+func author(commit *git.Commit) string {
+ if commit.Author != nil {
+ return commit.Author.Name
+ }
+ return "None"
+}
+
+func committer(commit *git.Commit) string {
+ if commit.Committer != nil {
+ return commit.Committer.Name
+ }
+ return "None"
+}
+
+func subject(commit *git.Commit) string {
+ return strings.Split(commit.Message, "\n")[0]
+}
+
+func bugs(commit *git.Commit) []string {
+ output := []string{}
+ msgSplit := strings.Split(commit.Message, "\n")
+ bugLine := ""
+ for _, line := range msgSplit {
+ line = strings.TrimSpace(line)
+ if strings.HasPrefix(line, bugLinePrefix) {
+ bugLine = line
+ break
+ }
+ }
+ if len(bugLine) <= len(bugLinePrefix) {
+ return output
+ }
+ bugList := strings.Split(bugLine[len(bugLinePrefix):], ",")
+ for _, bug := range bugList {
+ bug := strings.TrimSpace(bug)
+ for prefix, replacement := range bugPatternToReplacement {
+ if match := prefix.FindString(bug); match != "" {
+ output = append(output, replacement+bug[len(match):])
+ }
+ }
+ }
+ return output
+}
+
+func releaseNote(commit *git.Commit) string {
+ msgSplit := strings.Split(commit.Message, "\n")
+ for _, line := range msgSplit {
+ line = strings.TrimSpace(line)
+ if strings.HasPrefix(line, releaseNoteLinePrefix) {
+ return line[len(releaseNoteLinePrefix):]
+ }
+ }
+ return ""
+}
+
+func commitTime(commit *git.Commit) string {
+ if commit.Committer != nil {
+ return commit.Committer.Time.AsTime().Format(time.RFC1123)
+ }
+ return "None"
+}
+
+// ParseGitCommit converts a git.Commit object into a
+// Commit object with processed fields
+func parseGitCommit(commit *git.Commit) (*Commit, error) {
+ if commit == nil {
+ return nil, errors.New("ParseCommit: Input should not be nil")
+ }
+ return &Commit{
+ SHA: commit.Id,
+ AuthorName: author(commit),
+ CommitterName: committer(commit),
+ Subject: subject(commit),
+ Bugs: bugs(commit),
+ ReleaseNote: releaseNote(commit),
+ CommitTime: commitTime(commit),
+ }, nil
+}
+
+// ParseGitCommitLog converts a slice of git.Commit objects
+// into a slice of Commit objects with processed fields
+func ParseGitCommitLog(commits []*git.Commit) ([]*Commit, error) {
+ if commits == nil {
+ return nil, errors.New("ParseCommitLog: Input should not be nil")
+ }
+ output := make([]*Commit, len(commits))
+ for i, commit := range commits {
+ parsedCommit, err := parseGitCommit(commit)
+ if err != nil {
+ return nil, errors.New("ParseCommitLog: Input slice contains nil pointer")
+ }
+ output[i] = parsedCommit
+ }
+ return output, nil
+}
diff --git a/src/pkg/changelog/gitcommit_test.go b/src/pkg/changelog/gitcommit_test.go
new file mode 100644
index 0000000..268245d
--- /dev/null
+++ b/src/pkg/changelog/gitcommit_test.go
@@ -0,0 +1,349 @@
+// Copyright 2020 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package changelog
+
+import (
+ "reflect"
+ "testing"
+ "time"
+
+ "go.chromium.org/luci/common/proto/git"
+ "google.golang.org/protobuf/types/known/timestamppb"
+)
+
+const (
+ id string = "4f07bfb8463cb54227cc4cdbffc5d295edc05631"
+ tree string = "c005de2ade3f30506e7899b5c95d17f2904a598f"
+ parent string = "7645df3136c5b5e43eb1af182b0c67d78ca2d517"
+ authorName string = "Austin Yuan"
+ committerName string = "Boston Yuan"
+ timeVal string = "Sat, 01 Feb 2020 08:15:00 UTC"
+)
+
+var authorTime time.Time
+var committerTime time.Time
+
+func init() {
+ authorTime = time.Date(2019, 6, 6, 10, 50, 0, 0, time.UTC)
+ committerTime = time.Date(2020, 2, 1, 8, 15, 0, 0, time.UTC)
+}
+
+func createCommitWithMessage(message string) *git.Commit {
+ return &git.Commit{
+ Id: id,
+ Tree: tree,
+ Parents: []string{parent},
+ Author: &git.Commit_User{Name: authorName, Email: "austinyuan@google.com", Time: timestamppb.New(authorTime)},
+ Committer: &git.Commit_User{Name: committerName, Email: "bostonyuan@google.com", Time: timestamppb.New(committerTime)},
+ Message: message,
+ }
+}
+
+func TestParseGitCommitLog(t *testing.T) {
+ tests := map[string]struct {
+ Input []*git.Commit
+ SHAs []string
+ AuthorNames []string
+ CommitterNames []string
+ Subjects []string
+ Bugs [][]string
+ ReleaseNote []string
+ CommitTime []string
+ ShouldError bool
+ }{
+ "basic": {
+ Input: []*git.Commit{createCommitWithMessage(`provision_AutoUpdate: Do not stage AU payloads unless necessary
+
+Currently provisionning always stages the AU full payloads at the
+beginning. But majority of provision runs succeed by quick-provisioning
+and they never get to AU provisioning. So this is a waste of time and
+space trying to stage large files that are not going to be used. This CL
+fixes that problem.
+
+BUG=chromium:1097995
+TEST=test_that --args="value='reef-release/R85-13280.0.0'" chromeos6-row4-rack10-host19.cros.corp.google.com provision_AutoUpdate
+TEST=same as above, but changed the code to skip the quick-provisioning
+RELEASE_NOTE=Upgraded the Linux kernel to v4.14.174
+
+Change-Id: I0b6895f7860921f6bed25090d64f8489dbeeb19e
+Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2268290
+Tested-by: Amin Hassani <ahassani@chromium.org>
+Commit-Queue: Amin Hassani <ahassani@chromium.org>
+Reviewed-by: Allen Li <ayatane@chromium.org>
+Auto-Submit: Amin Hassani <ahassani@chromium.org>`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"provision_AutoUpdate: Do not stage AU payloads unless necessary"},
+ Bugs: [][]string{{"crbug/1097995"}},
+ ReleaseNote: []string{"Upgraded the Linux kernel to v4.14.174"},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "multiple bugs": {
+ Input: []*git.Commit{createCommitWithMessage(`autotest: Move host dependency check inside verifier.
+
+Moved it to minimize fail case if host is not available.
+
+BUG=chromium:1069101, chromium:1059439, b:533302,b/21114011,chromium-os:993221,chrome-os-partner:3341233
+TEST=unittests, presubmit, run local
+RELEASE_NOTE=Upgraded autotest`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"autotest: Move host dependency check inside verifier."},
+ Bugs: [][]string{{"crbug/1069101", "crbug/1059439", "b/533302", "b/21114011", "crbug/993221", "crbug/3341233"}},
+ ReleaseNote: []string{"Upgraded autotest"},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "improperly formatted bugs": {
+ Input: []*git.Commit{createCommitWithMessage(`chrome-os-partner:1224444
+
+b/3225555
+
+BUG=54985123, z, c/54811233, notabug, 0, b%21333443, -3, hello b/12321155,
+TEST=b/2222222
+RELEASE_NOTE=chromium:5556555`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"chrome-os-partner:1224444"},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{"chromium:5556555"},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "proper and improper bugs": {
+ Input: []*git.Commit{createCommitWithMessage(`autotest: Move host dependency check inside verifier.
+
+Some extra details here
+
+BUG=3, -1, b:2212344, c/54811233, chrome-os-partner:1111111, notabug, b%21333443, test b:6644322
+TEST=unittests, presubmit, run local
+RELEASE_NOTE=b/1224222`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"autotest: Move host dependency check inside verifier."},
+ Bugs: [][]string{{"b/2212344", "crbug/1111111"}},
+ ReleaseNote: []string{"b/1224222"},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "empty commit message": {
+ Input: []*git.Commit{createCommitWithMessage("")},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{""},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{""},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "only subject line": {
+ Input: []*git.Commit{createCommitWithMessage("$()!-1")},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"$()!-1"},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{""},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "no bug line and empty release line": {
+ Input: []*git.Commit{createCommitWithMessage(`autotest: Move host dependency check inside verifier.
+
+Moved it to minimize fail case if host is not available.
+AdminAudit is starting with the set of actions and all of them has to
+run if possible. By this move we allowed each verifier to check what
+required to run.
+If dependency not provided we can skip of the action.
+
+TEST=unittests, presubmit, run local
+RELEASE=`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"autotest: Move host dependency check inside verifier."},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{""},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "leading spaces for bug and release line": {
+ Input: []*git.Commit{createCommitWithMessage(`autotest: Move host dependency check inside verifier.
+
+Moved it to minimize fail case if host is not available.
+
+ BUG=chromium:1069101, chromium:1059439, b:533302,b/21114011,chromium-os:993221,chrome-os-partner:3341233
+TEST=unittests, presubmit, run local
+ RELEASE_NOTE=Upgraded autotest `)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"autotest: Move host dependency check inside verifier."},
+ Bugs: [][]string{{"crbug/1069101", "crbug/1059439", "b/533302", "b/21114011", "crbug/993221", "crbug/3341233"}},
+ ReleaseNote: []string{"Upgraded autotest"},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "empty bug line": {
+ Input: []*git.Commit{createCommitWithMessage(`autotest: Move host dependency check inside verifier.
+
+Moved it to minimize fail case if host is not available.
+AdminAudit is starting with the set of actions and all of them has to
+run if possible. By this move we allowed each verifier to check what
+required to run.
+If dependency not provided we can skip of the action.
+
+BUG=
+TEST=unittests, presubmit, run local
+RELEASE=`)},
+ SHAs: []string{id},
+ AuthorNames: []string{authorName},
+ CommitterNames: []string{committerName},
+ Subjects: []string{"autotest: Move host dependency check inside verifier."},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{""},
+ CommitTime: []string{timeVal},
+ ShouldError: false,
+ },
+ "missing fields": {
+ Input: []*git.Commit{{
+ Id: id,
+ Tree: "",
+ Parents: nil,
+ Author: nil,
+ Committer: nil,
+ Message: "",
+ }},
+ SHAs: []string{id},
+ AuthorNames: []string{"None"},
+ CommitterNames: []string{"None"},
+ Subjects: []string{""},
+ Bugs: [][]string{{}},
+ ReleaseNote: []string{""},
+ CommitTime: []string{"None"},
+ ShouldError: false,
+ },
+ "multiple commits": {
+ Input: []*git.Commit{
+ createCommitWithMessage(`This is a subject
+
+This commit has no bugs
+
+TEST=unittests, presubmit, run local
+RELEASE=`),
+ createCommitWithMessage(`autotest: Some subject
+
+This commit some bugs
+
+BUG=b/4332134, chrome-os-partner:0999212, b:11111
+TEST=unittests, presubmit, run local
+
+Change-Id: I0b6895f7860921f6bed25090d64f8489dbeeb19e
+RELEASE_NOTE=test release`),
+ createCommitWithMessage(`Third
+
+This commits has some multiple bugs, some not valid b/1221212
+
+BUG=56456651, chromium:777882, -1, b:9999999`),
+ },
+ SHAs: []string{id, id, id},
+ AuthorNames: []string{authorName, authorName, authorName},
+ CommitterNames: []string{committerName, committerName, committerName},
+ Subjects: []string{"This is a subject", "autotest: Some subject", "Third"},
+ Bugs: [][]string{{}, {"b/4332134", "crbug/0999212", "b/11111"}, {"crbug/777882", "b/9999999"}},
+ ReleaseNote: []string{"", "test release", ""},
+ CommitTime: []string{timeVal, timeVal, timeVal},
+ ShouldError: false,
+ },
+ "empty list": {
+ Input: []*git.Commit{},
+ SHAs: []string{},
+ AuthorNames: []string{},
+ CommitterNames: []string{},
+ Subjects: []string{},
+ Bugs: [][]string{},
+ ShouldError: false,
+ },
+ "nil input": {
+ Input: nil,
+ ShouldError: true,
+ },
+ "normal and nil input": {
+ Input: []*git.Commit{
+ createCommitWithMessage(`This is a subject
+
+This commit has no bugs
+
+TEST=unittests, presubmit, run local
+RELEASE_NOTE=`),
+ createCommitWithMessage(`autotest: Some subject
+
+This commit some bugs
+
+BUG=b/4332134, chrome-os-partner:0999212, b:11111
+TEST=unittests, presubmit, run local
+
+Change-Id: I0b6895f7860921f6bed25090d64f8489dbeeb19e
+RELEASE NOTE=test release`),
+ nil,
+ createCommitWithMessage(`Third
+
+This commits has some multiple bugs, some not valid b/1221212
+
+BUG=56456651, chromium:777882, -1, b:9999999`),
+ },
+ ShouldError: true,
+ },
+ }
+
+ for name, test := range tests {
+ t.Run(name, func(t *testing.T) {
+ res, err := ParseGitCommitLog(test.Input)
+ switch {
+ case (err != nil) != test.ShouldError:
+ ShouldError := "no error"
+ if test.ShouldError {
+ ShouldError = "some error"
+ }
+ t.Fatalf("expected %v, got: %v\n", ShouldError, err)
+ case test.ShouldError && (err != nil) == test.ShouldError && res == nil:
+ }
+ for i, commit := range res {
+ switch {
+ case commit.SHA != test.SHAs[i]:
+ t.Errorf("expected commitSHA %s, got %s", test.SHAs[i], commit.SHA)
+ case commit.AuthorName != test.AuthorNames[i]:
+ t.Errorf("expected authorName: %s, got: %s", test.AuthorNames[i], commit.AuthorName)
+ case commit.CommitterName != test.CommitterNames[i]:
+ t.Errorf("expected committerName %s, got %s", test.CommitterNames[i], commit.CommitterName)
+ case commit.Subject != test.Subjects[i]:
+ t.Errorf("expected subject %s, got %s", test.Subjects[i], commit.Subject)
+ case !reflect.DeepEqual(commit.Bugs, test.Bugs[i]):
+ t.Errorf("exptected bugs %#v, got %#v", test.Bugs[i], commit.Bugs)
+ case commit.ReleaseNote != test.ReleaseNote[i]:
+ t.Errorf("expected release note %s, got %s", test.ReleaseNote, commit.ReleaseNote)
+ case commit.CommitTime != test.CommitTime[i]:
+ t.Errorf("expected commit time %s, got %s", test.CommitTime, commit.CommitTime)
+ }
+ }
+ })
+ }
+}