You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ke...@apache.org on 2020/12/21 07:57:34 UTC

[skywalking-eyes] branch main created (now 1667d8a)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git.


      at 1667d8a  Reorganize the directory structure to monorepo

This branch includes the following new commits:

     new 91afcff  Initial commit
     new 3f5afc5  scaffold
     new 80e525a  dev
     new b17d8db  dev
     new 1beba9e  dev
     new 42ecc96  dev
     new 3938d04  dev
     new 3938361  dev
     new cbb2a6a  Update doc
     new cbb27a7  Update doc
     new b3bff69  bugfix: cannot build
     new 0841c46  Merge pull request #1 from kezhenxu94/fix
     new a4c1cdc  chore: set up GitHub Actions to verify build from sources
     new 94847dc  Merge pull request #2 from kezhenxu94/master
     new 97ac798  feature: wrap the tool into a GitHub Action
     new 3b734e7  chore: set up GitHub Actions branding information
     new a62044d  Reshape the header check command
     new 0ca8fae  Fix license header and setup self checker (#3)
     new 9176312  Refactor the config, result, and check logic
     new ea1f818  Add `fix` command to fix license header
     new 7a47042  Add more supported fixing filetypes and update license
     new 7d3e66c  Add Java fixing type and reshape the README
     new a038166  Fix GHA description and refactor
     new 56a6344  Refactor, set version, module, asf.yaml, etc.
     new 1667d8a  Reorganize the directory structure to monorepo

The 25 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[skywalking-eyes] 19/25: Refactor the config, result, and check logic

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 9176312e255c1d9083b1cf90fb09d9bc49fa4e47
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sun Dec 20 22:43:58 2020 +0800

    Refactor the config, result, and check logic
---
 commands/header/check.go           | 49 +++++++--------------------
 pkg/header/check.go                | 52 +++++++++++-----------------
 pkg/header/config.go               | 69 ++++++++++++++++++++++++++++++++++++++
 pkg/header/{model.go => result.go} | 37 ++++++++++++++++----
 4 files changed, 132 insertions(+), 75 deletions(-)

diff --git a/commands/header/check.go b/commands/header/check.go
index b020882..9668894 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -16,11 +16,7 @@ package header
 
 import (
 	"github.com/spf13/cobra"
-	"gopkg.in/yaml.v3"
-	"io/ioutil"
-	"license-checker/internal/logger"
 	"license-checker/pkg/header"
-	"strings"
 )
 
 var (
@@ -34,43 +30,24 @@ var CheckCommand = &cobra.Command{
 	Aliases: []string{"c"},
 	RunE: func(cmd *cobra.Command, args []string) error {
 		var config header.Config
-		if err := loadConfig(&config); err != nil {
+		var result header.Result
+
+		if err := config.Parse(cfgFile); err != nil {
 			return err
 		}
-		return header.Check(&config)
-	},
-}
-
-func init() {
-	CheckCommand.Flags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
-}
-
-// loadConfig reads and parses the header check configurations in config file.
-func loadConfig(config *header.Config) error {
-	logger.Log.Infoln("Loading configuration from file:", cfgFile)
 
-	bytes, err := ioutil.ReadFile(cfgFile)
-	if err != nil {
-		return err
-	}
-
-	if err = yaml.Unmarshal(bytes, config); err != nil {
-		return err
-	}
-
-	var lines []string
-	for _, line := range strings.Split(config.License, "\n") {
-		if len(line) > 0 {
-			lines = append(lines, strings.Trim(line, header.CommentChars))
+		if err := header.Check(&config, &result); err != nil {
+			return err
 		}
-	}
-	config.License = strings.Join(lines, " ")
 
-	logger.Log.Infoln("License header is:", config.License)
+		if result.HasFailure() {
+			return result.Error()
+		}
 
-	if len(config.Paths) == 0 {
-		config.Paths = []string{"**"}
-	}
+		return nil
+	},
+}
 
-	return nil
+func init() {
+	CheckCommand.Flags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
 }
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 0defbe4..9f1cf62 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -16,7 +16,6 @@ package header
 
 import (
 	"bufio"
-	"fmt"
 	"github.com/bmatcuk/doublestar/v2"
 	"license-checker/internal/logger"
 	"os"
@@ -24,25 +23,16 @@ import (
 	"strings"
 )
 
-const CommentChars = "/*#- "
+const CommentChars = "/*#- !"
 
 // Check checks the license headers of the specified paths/globs.
-func Check(config *Config) error {
-	var result Result
-
+func Check(config *Config, result *Result) error {
 	for _, pattern := range config.Paths {
-		if err := checkPattern(pattern, &result, config); err != nil {
+		if err := checkPattern(pattern, result, config); err != nil {
 			return err
 		}
 	}
 
-	if len(result.Failure) > 0 {
-		return fmt.Errorf(
-			"The following files don't have a valid license header: \n%v",
-			strings.Join(result.Failure, "\n"),
-		)
-	}
-
 	return nil
 }
 
@@ -53,11 +43,10 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 		return err
 	}
 
-	logger.Log.Infoln("Checking matched paths:", paths)
-
 	for _, path := range paths {
-		logger.Log.Debugln("Checking path:", path)
-
+		if yes, err := config.ShouldIgnore(path); yes || err != nil {
+			continue
+		}
 		if err = checkPath(path, result, config); err != nil {
 			return err
 		}
@@ -67,6 +56,10 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 }
 
 func checkPath(path string, result *Result, config *Config) error {
+	if yes, err := config.ShouldIgnore(path); yes || err != nil {
+		return err
+	}
+
 	pathInfo, err := os.Stat(path)
 
 	if err != nil {
@@ -92,21 +85,16 @@ func checkPath(path string, result *Result, config *Config) error {
 	return nil
 }
 
+var seen = make(map[string]bool)
+
 func checkFile(file string, result *Result, config *Config) error {
-	skip := false
-	for _, ignorePattern := range config.PathsIgnore {
-		logger.Log.Debugln("Checking ignore pattern:", ignorePattern)
-
-		if ignored, err := doublestar.Match(ignorePattern, file); ignored || err != nil {
-			logger.Log.Infoln("Ignoring path:", file)
-			skip = ignored
-			break
-		}
-	}
-	if skip {
-		return nil
+	if yes, err := config.ShouldIgnore(file); yes || seen[file] || err != nil {
+		seen[file] = true
+		return err
 	}
 
+	seen[file] = true
+
 	logger.Log.Debugln("Checking file:", file)
 
 	reader, err := os.Open(file)
@@ -125,13 +113,13 @@ func checkFile(file string, result *Result, config *Config) error {
 		}
 	}
 
-	if content := strings.Join(lines, " "); !strings.Contains(content, config.License) {
+	if content := strings.Join(lines, " "); !strings.Contains(content, config.NormalizedLicense()) {
 		logger.Log.Debugln("Content is:", content)
 		logger.Log.Debugln("License is:", config.License)
 
-		result.Failure = append(result.Failure, file)
+		result.Fail(file)
 	} else {
-		result.Success = append(result.Success, file)
+		result.Succeed(file)
 	}
 
 	return nil
diff --git a/pkg/header/config.go b/pkg/header/config.go
new file mode 100644
index 0000000..7ff1371
--- /dev/null
+++ b/pkg/header/config.go
@@ -0,0 +1,69 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 header
+
+import (
+	"github.com/bmatcuk/doublestar/v2"
+	"gopkg.in/yaml.v3"
+	"io/ioutil"
+	"license-checker/internal/logger"
+	"strings"
+)
+
+type Config struct {
+	License     string   `yaml:"license"`
+	Paths       []string `yaml:"paths"`
+	PathsIgnore []string `yaml:"paths-ignore"`
+}
+
+// NormalizedLicense returns the normalized string of the license content,
+// "normalized" means the linebreaks and CommentChars are all trimmed.
+func (config *Config) NormalizedLicense() string {
+	var lines []string
+	for _, line := range strings.Split(config.License, "\n") {
+		if len(line) > 0 {
+			lines = append(lines, strings.Trim(line, CommentChars))
+		}
+	}
+	return strings.Join(lines, " ")
+}
+
+// Parse reads and parses the header check configurations in config file.
+func (config *Config) Parse(file string) error {
+	logger.Log.Infoln("Loading configuration from file:", file)
+
+	if bytes, err := ioutil.ReadFile(file); err != nil {
+		return err
+	} else if err = yaml.Unmarshal(bytes, config); err != nil {
+		return err
+	}
+
+	logger.Log.Infoln("License header is:", config.NormalizedLicense())
+
+	if len(config.Paths) == 0 {
+		config.Paths = []string{"**"}
+	}
+
+	return nil
+}
+
+func (config *Config) ShouldIgnore(path string) (bool, error) {
+	for _, ignorePattern := range config.PathsIgnore {
+		if matched, err := doublestar.Match(ignorePattern, path); matched || err != nil {
+			return matched, err
+		}
+	}
+	return false, nil
+}
diff --git a/pkg/header/model.go b/pkg/header/result.go
similarity index 51%
rename from pkg/header/model.go
rename to pkg/header/result.go
index 5af67fd..c79ce9c 100644
--- a/pkg/header/model.go
+++ b/pkg/header/result.go
@@ -14,13 +14,36 @@
 
 package header
 
-type Config struct {
-	License     string   `yaml:"license"`
-	Paths       []string `yaml:"paths"`
-	PathsIgnore []string `yaml:"paths-ignore"`
-}
+import (
+	"fmt"
+	"strings"
+)
 
 type Result struct {
-	Success []string `yaml:"success"`
-	Failure []string `yaml:"failure"`
+	Success []string
+	Failure []string
+	Ignored []string
+}
+
+func (result *Result) Fail(file string) {
+	result.Failure = append(result.Failure, file)
+}
+
+func (result *Result) Succeed(file string) {
+	result.Success = append(result.Success, file)
+}
+
+func (result *Result) Ignore(file string) {
+	result.Ignored = append(result.Ignored, file)
+}
+
+func (result *Result) HasFailure() bool {
+	return len(result.Failure) > 0
+}
+
+func (result *Result) Error() error {
+	return fmt.Errorf(
+		"The following files don't have a valid license header: \n%v",
+		strings.Join(result.Failure, "\n"),
+	)
 }


[skywalking-eyes] 03/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 80e525a476f8d9bee9fe8ed039d8d20b2b2f944b
Author: Hoshea <fg...@gmail.com>
AuthorDate: Sat Nov 21 22:44:42 2020 +0800

    dev
---
 .licenserc.json        |  48 ++++++++++++++++++++
 Makefile               |  69 +++++++++++++++++++++++++++++
 cmd/root.go            | 116 ++++++++++++++++++++++++++++++++++---------------
 config.json            |  19 --------
 config.yaml            |   3 --
 main.go                |   2 +-
 test/testcase.go       |  18 ++++++++
 test/testcase.java     |  14 ++++++
 test/testcase.md       |   0
 test/testcase3.py      |  16 +++++++
 main.go => util/str.go |  31 ++++++++++---
 util/str_test.go       |  58 +++++++++++++++++++++++++
 12 files changed, 331 insertions(+), 63 deletions(-)

diff --git a/.licenserc.json b/.licenserc.json
new file mode 100644
index 0000000..3d262cc
--- /dev/null
+++ b/.licenserc.json
@@ -0,0 +1,48 @@
+{
+  "licenseStrict": [
+    "Licensed to the Apache Software Foundation (ASF) under one or more",
+    "contributor license agreements.  See the NOTICE file distributed with",
+    "this work for additional information regarding copyright ownership.",
+    "The ASF licenses this file to You 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."
+  ],
+  "licenseLoose": [
+    "Apache License",
+    "Version 2.0"
+  ],
+  "targetFiles": [
+    "java",
+    "go",
+    "py",
+    "sh",
+    "graphql",
+    "yaml",
+    "yml"
+  ],
+  "exclude": {
+    "files": [
+      ".gitignore",
+      "NOTICE",
+      "go.mod",
+      "go.sum"
+    ],
+    "extensions": [
+      "md",
+      "xml",
+      "json"
+    ],
+    "directories": [
+      "bin",
+      ".github",
+      ".git",
+      ".idea"
+    ]
+  }
+}
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4e83903
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,69 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+#
+# 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.
+
+PROJECT = license-checker
+VERSION ?= latest
+OUT_DIR = bin
+CURDIR := $(shell pwd)
+FILES := $$(find .$$($(PACKAGE_DIRECTORIES)) -name "*.go")
+FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'
+
+GO := GO111MODULE=on go
+GO_PATH = $$($(GO) env GOPATH)
+GO_BUILD = $(GO) build
+GO_GET = $(GO) get
+GO_TEST = $(GO) test
+GO_LINT = $(GO_PATH)/bin/golangci-lint
+GO_LICENSER = $(GO_PATH)/bin/go-licenser
+
+# Ensure GOPATH is set before running build process.
+ifeq "$(GOPATH)" ""
+  $(error Please set the environment variable GOPATH before running `make`)
+endif
+
+all: clean deps lint test build
+
+tools:
+	mkdir -p $(GO_PATH)/bin
+	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.21.0
+	$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
+
+deps: tools
+	$(GO_GET) -v -t -d ./...
+
+.PHONY: lint
+lint: tools
+	@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)
+	$(GO_LINT) run -v ./...
+
+.PHONE: test
+test: clean lint
+	$(GO_TEST) ./...
+	@>&2 echo "Great, all tests passed."
+
+.PHONY: build
+build: deps
+	$(GO_BUILD) -o $(OUT_DIR)/$(PROJECT)
+
+#.PHONY: license
+#license: clean tools
+#	$(GO_LICENSER) -d -license='ASL2' .
+
+.PHONY: fix
+fix: tools
+	$(GO_LINT) run -v --fix ./...
+
+.PHONY: clean
+clean: tools
+	-rm -rf bin
diff --git a/cmd/root.go b/cmd/root.go
index 14c62b6..841fa46 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -1,5 +1,5 @@
 /*
-Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -16,23 +16,33 @@ limitations under the License.
 package cmd
 
 import (
+	"encoding/json"
 	"fmt"
 	"github.com/spf13/cobra"
+	"io/ioutil"
+	"license-checker/util"
 	"os"
-
-	homedir "github.com/mitchellh/go-homedir"
-	"github.com/spf13/viper"
+	"path/filepath"
 )
 
 var cfgFile string
+var checkPath string
+var loose bool
 
 // rootCmd represents the base command when called without any subcommands
 var rootCmd = &cobra.Command{
-	Use:   "license-checker",
-	Short: "A brief description of your application",
-
+	Use: "license-checker [flags]",
+	Long: `license-checker walks the specified path recursively and checks 
+if the specified files have the license header in the config file.`,
 	Run: func(cmd *cobra.Command, args []string) {
-		fmt.Println("Hello Cobra CLI!")
+		config, err := LoadConfig()
+		if err != nil {
+			fmt.Println(err)
+		}
+		//fmt.Println(config.TargetFiles)
+		if err := Walk(checkPath, config); err != nil {
+			fmt.Println(err)
+		}
 	},
 }
 
@@ -46,41 +56,77 @@ func Execute() {
 }
 
 func init() {
-	cobra.OnInitialize(initConfig)
+	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", ".licenserc.json", "the config file")
+	rootCmd.PersistentFlags().StringVarP(&checkPath, "path", "p", "", "the path to check (required)")
+	rootCmd.PersistentFlags().BoolVarP(&loose, "loose", "l", false, "loose mode")
+	if err := rootCmd.MarkPersistentFlagRequired("path"); err != nil {
+		fmt.Println(err)
+	}
+}
 
-	// Here you will define your flags and configuration settings.
-	// Cobra supports persistent flags, which, if defined here,
-	// will be global for your application.
+type excludeConfig struct {
+	Files       []string `json:"files"`
+	Extensions  []string `json:"extensions"`
+	Directories []string `json:"directories"`
+}
 
-	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.license-checker.yaml)")
+type Config struct {
+	LicenseStrict []string      `json:"licenseStrict"`
+	LicenseLoose  []string      `json:"licenseLoose"`
+	TargetFiles   []string      `json:"targetFiles"`
+	Exclude       excludeConfig `json:"exclude"`
+}
 
-	// Cobra also supports local flags, which will only run
-	// when this action is called directly.
-	rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+type Result struct {
+	Success []string `json:"success"`
+	Failure []string `json:"failure"`
 }
 
-// initConfig reads in config file and ENV variables if set.
-func initConfig() {
-	if cfgFile != "" {
-		// Use config file from the flag.
-		viper.SetConfigFile(cfgFile)
-	} else {
-		// Find home directory.
-		home, err := homedir.Dir()
+// LoadConfig reads in config file.
+func LoadConfig() (*Config, error) {
+	var config Config
+	bytes, err := ioutil.ReadFile(cfgFile)
+	if err != nil {
+		return nil, err
+	}
+
+	err = json.Unmarshal(bytes, &config)
+	if err != nil {
+		return nil, err
+	}
+
+	return &config, nil
+}
+
+func Walk(p string, cfg *Config) error {
+	inExcludeDir := util.InStrSliceMapKeyFunc(cfg.Exclude.Directories)
+	inExcludeExt := util.InStrSliceMapKeyFunc(cfg.Exclude.Extensions)
+	inExcludeFiles := util.InStrSliceMapKeyFunc(cfg.Exclude.Files)
+
+	err := filepath.Walk(p, func(path string, fi os.FileInfo, err error) error {
 		if err != nil {
-			fmt.Println(err)
-			os.Exit(1)
+			fmt.Println(err) // can't walk here,
+			return nil       // but continue walking elsewhere
 		}
 
-		// Search config in home directory with name ".license-checker" (without extension).
-		viper.AddConfigPath(home)
-		viper.SetConfigName(".license-checker")
-	}
+		if fi.IsDir() {
+			if inExcludeDir(fi.Name()) {
+				return filepath.SkipDir
+			}
+		} else {
+			ext := util.GetFileExtension(fi.Name())
+			if inExcludeFiles(fi.Name()) || inExcludeExt(ext) {
+				return nil
+			}
+
+			// TODO: open the file and check
+			fmt.Println(path)
+			//curDir := strings.Replace(path, fi.Name(), "", 1)
+			//fmt.Println(curDir)
+		}
 
-	viper.AutomaticEnv() // read in environment variables that match
+		return nil
+	})
 
-	// If a config file is found, read it in.
-	if err := viper.ReadInConfig(); err == nil {
-		fmt.Println("Using config file:", viper.ConfigFileUsed())
-	}
+	return err
 }
diff --git a/config.json b/config.json
deleted file mode 100644
index 10d2446..0000000
--- a/config.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
-  "**/*.{java, go, py}": [
-    "You can put multiline headers like this",
-    "Copyright Foo, Inc. and other Bar contributors.",
-    "Permission is hereby granted, free of charge, to any person obtaining a",
-    "copy of this software and associated documentation files (the",
-    "\"Software\"), to deal in the Software without restriction, including",
-    "without limitation the rights to use, copy, modify, merge, publish,",
-    "distribute, sublicense, and/or sell copies of the Software, and to permit",
-    "persons to whom the Software is furnished to do so, subject to the",
-    "following conditions:",
-    "..."
-  ],
-
-  "ignore": [
-    "lib/vendor/jquery.js", // ignore this file
-    "vendor/" // ignore all files under vendor
-  ]
-}
\ No newline at end of file
diff --git a/config.yaml b/config.yaml
deleted file mode 100644
index 4845d7a..0000000
--- a/config.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-include:
-
-exclude:
\ No newline at end of file
diff --git a/main.go b/main.go
index d2e9d49..e9f9be6 100644
--- a/main.go
+++ b/main.go
@@ -1,5 +1,5 @@
 /*
-Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
diff --git a/test/testcase.go b/test/testcase.go
new file mode 100644
index 0000000..4020ef8
--- /dev/null
+++ b/test/testcase.go
@@ -0,0 +1,18 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 test
diff --git a/test/testcase.java b/test/testcase.java
new file mode 100644
index 0000000..43a94f3
--- /dev/null
+++ b/test/testcase.java
@@ -0,0 +1,14 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You 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.
diff --git a/test/testcase.md b/test/testcase.md
new file mode 100644
index 0000000..e69de29
diff --git a/test/testcase3.py b/test/testcase3.py
new file mode 100644
index 0000000..a9fd83f
--- /dev/null
+++ b/test/testcase3.py
@@ -0,0 +1,16 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
\ No newline at end of file
diff --git a/main.go b/util/str.go
similarity index 53%
copy from main.go
copy to util/str.go
index d2e9d49..b953e48 100644
--- a/main.go
+++ b/util/str.go
@@ -1,5 +1,5 @@
 /*
-Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -13,10 +13,31 @@ 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 main
+package util
 
-import "license-checker/cmd"
+import (
+	"strings"
+)
 
-func main() {
-	cmd.Execute()
+func InStrSliceMapKeyFunc(strs []string) func(string) bool {
+	set := make(map[string]struct{})
+
+	for _, e := range strs {
+		set[e] = struct{}{}
+	}
+
+	return func(s string) bool {
+		_, ok := set[s]
+		return ok
+	}
+}
+
+func GetFileExtension(filename string) string {
+	i := strings.LastIndex(filename, ".")
+	if i != -1 {
+		if i+1 < len(filename) {
+			return filename[i+1:]
+		}
+	}
+	return ""
 }
diff --git a/util/str_test.go b/util/str_test.go
new file mode 100644
index 0000000..fce8965
--- /dev/null
+++ b/util/str_test.go
@@ -0,0 +1,58 @@
+/*
+Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+
+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 util
+
+import "testing"
+
+func TestGetFileExtension(t *testing.T) {
+	type args struct {
+		filename string
+	}
+	tests := []struct {
+		name string
+		args args
+		want string
+	}{
+		{
+			name: "txt extension",
+			args: args{
+				filename: ".abc.txt",
+			},
+			want: "txt",
+		},
+		{
+			name: "no file extensions",
+			args: args{
+				filename: ".abc.txt.",
+			},
+			want: "",
+		},
+		{
+			name: "no file extensions",
+			args: args{
+				filename: "lkjsdl",
+			},
+			want: "",
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if got := GetFileExtension(tt.args.filename); got != tt.want {
+				t.Errorf("GetFileExtension() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}


[skywalking-eyes] 24/25: Refactor, set version, module, asf.yaml, etc.

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 56a6344291bb3b784b016a0b0ec4526c88319a19
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 15:33:52 2020 +0800

    Refactor, set version, module, asf.yaml, etc.
---
 Dockerfile => .asf.yaml                            | 22 ++---
 .github/workflows/build.yaml                       | 10 ++-
 .golangci.yml                                      | 96 ++++++++++++++++++++++
 .licenserc.yaml                                    | 52 ++++++------
 Dockerfile                                         |  6 +-
 Makefile                                           | 51 ++++++------
 NOTICE                                             |  5 ++
 README.adoc                                        | 35 ++++++--
 main.go => cmd/license-eye/main.go                 |  7 +-
 commands/header/check.go                           | 12 +--
 commands/header/fix.go                             | 19 +++--
 {cmd => commands}/root.go                          | 28 ++++---
 .../testcase.go => commands/version.go             |  4 +-
 go.mod                                             |  2 +-
 .../fix/double_slash.go => config/Config.go}       | 34 ++++----
 pkg/header/check.go                                | 22 +++--
 pkg/header/config.go                               | 33 ++++++--
 pkg/header/fix/angle_bracket.go                    |  5 +-
 pkg/header/fix/double_slash.go                     |  5 +-
 pkg/header/fix/fix.go                              | 12 +--
 pkg/header/fix/hashtag.go                          |  5 +-
 pkg/header/fix/slash_asterisk.go                   |  5 +-
 pkg/header/result.go                               |  2 +-
 test/.licenserc_for_test_check.yaml                | 43 +++++-----
 test/.licenserc_for_test_fix.yaml                  | 41 ++++-----
 test/include_test/with_license/testcase.go         |  2 +-
 test/include_test/without_license/testcase.go      |  2 +-
 27 files changed, 360 insertions(+), 200 deletions(-)

diff --git a/Dockerfile b/.asf.yaml
similarity index 72%
copy from Dockerfile
copy to .asf.yaml
index a466f44..8fe2357 100644
--- a/Dockerfile
+++ b/.asf.yaml
@@ -15,18 +15,12 @@
 # specific language governing permissions and limitations
 # under the License.
 # 
-FROM golang:1.14.3-alpine AS build
 
-WORKDIR /src
-
-COPY . .
-
-RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/license-checker
-
-FROM alpine:3 AS bin
-
-COPY --from=build /bin/license-checker /bin/license-checker
-
-WORKDIR /github/workspace/
-
-ENTRYPOINT /bin/license-checker header check -v debug
+github:
+  description: Apache SkyWalking Eyes
+  homepage: https://skywalking.apache.org/
+  labels:
+    - cli
+    - tools
+    - license
+    - licensing
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1fa632a..68fcaf2 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -14,7 +14,8 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# 
+#
+
 name: Build
 
 on:
@@ -28,13 +29,16 @@ jobs:
     name: Build
     runs-on: ubuntu-latest
     steps:
+      - uses: actions/checkout@v2
+
       - uses: actions/setup-go@v2
         with:
           go-version: 1.14
 
-      - uses: actions/checkout@v2
+      - name: Lint Codes
+        run: make lint
 
-      - name: Selfcheck License
+      - name: License Check
         run: make license
 
       - name: Build
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 0000000..ca0227f
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,96 @@
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+# 
+
+linters-settings:
+  govet:
+    check-shadowing: true
+  golint:
+    min-confidence: 0
+  gocyclo:
+    min-complexity: 15
+  maligned:
+    suggest-new: true
+  dupl:
+    threshold: 200
+  goconst:
+    min-len: 2
+    min-occurrences: 2
+  depguard:
+    list-type: blacklist
+    include-go-root: true
+    packages-with-error-messages:
+      fmt: "logging is allowed only by logutils.Log"
+  misspell:
+    locale: US
+  lll:
+    line-length: 150
+  goimports:
+    local-prefixes: github.com/apache/skywalking-cli
+  gocritic:
+    enabled-tags:
+      - diagnostic
+      - experimental
+      - opinionated
+      - performance
+      - style
+    disabled-checks:
+      - ifElseChain
+  funlen:
+    lines: 100
+    statements: 50
+  whitespace:
+    multi-if: false
+    multi-func: false
+
+linters:
+  enable:
+    - bodyclose
+    - deadcode
+    - depguard
+    - dogsled
+    - dupl
+    - errcheck
+    - funlen
+    - goconst
+    - gocritic
+    - gocyclo
+    - gofmt
+    - goimports
+    - golint
+    - gosec
+    - gosimple
+    - govet
+    - ineffassign
+    - interfacer
+    - lll
+    - misspell
+    - nakedret
+    - staticcheck
+    - structcheck
+    - stylecheck
+    - typecheck
+    - unconvert
+    - unparam
+    - unused
+    - varcheck
+    - whitespace
+
+service:
+  golangci-lint-version: 1.20.x
+  prepare:
+    - echo "here I can run custom commands, but no preparation needed for this repo"
diff --git a/.licenserc.yaml b/.licenserc.yaml
index b8366ec..6aa224f 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -1,28 +1,30 @@
-license: |
-  Licensed to Apache Software Foundation (ASF) under one or more contributor
-  license agreements. See the NOTICE file distributed with
-  this work for additional information regarding copyright
-  ownership. Apache Software Foundation (ASF) licenses this file to you 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
+header:
+  license: |
+    Licensed to Apache Software Foundation (ASF) under one or more contributor
+    license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright
+    ownership. Apache Software Foundation (ASF) licenses this file to you 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
+        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.
+    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.
 
-paths-ignore:
-  - '.git/**'
-  - '.idea/**'
-  - 'bin/**'
-  - '**/*.md'
-  - '**/.DS_Store'
-  - 'test/**'
-  - 'go.mod'
-  - 'go.sum'
-  - 'LICENSE'
+  paths-ignore:
+    - '.git/**'
+    - '.idea/**'
+    - 'bin/**'
+    - '**/*.md'
+    - '**/.DS_Store'
+    - 'test/**'
+    - 'go.mod'
+    - 'go.sum'
+    - 'LICENSE'
+    - 'NOTICE'
diff --git a/Dockerfile b/Dockerfile
index a466f44..62c66ee 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -21,12 +21,12 @@ WORKDIR /src
 
 COPY . .
 
-RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/license-checker
+RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/license-eye
 
 FROM alpine:3 AS bin
 
-COPY --from=build /bin/license-checker /bin/license-checker
+COPY --from=build /bin/license-eye /bin/license-eye
 
 WORKDIR /github/workspace/
 
-ENTRYPOINT /bin/license-checker header check -v debug
+ENTRYPOINT /bin/license-eye header check -v debug
diff --git a/Makefile b/Makefile
index e2a933a..3d1612e 100644
--- a/Makefile
+++ b/Makefile
@@ -14,13 +14,16 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-# 
-PROJECT = license-checker
+#
+
+PROJECT = license-eye
 VERSION ?= latest
 OUT_DIR = bin
 CURDIR := $(shell pwd)
 FILES := $$(find .$$($(PACKAGE_DIRECTORIES)) -name "*.go")
 FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'
+ARCH := $(shell uname)
+OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
 
 GO := GO111MODULE=on go
 GO_PATH = $(shell $(GO) env GOPATH)
@@ -28,38 +31,40 @@ GO_BUILD = $(GO) build
 GO_GET = $(GO) get
 GO_TEST = $(GO) test
 GO_LINT = $(GO_PATH)/bin/golangci-lint
+GO_BUILD_LDFLAGS = -X github.com/apache/skywalking-eyes/license-eye/commands.version=$(VERSION)
 
-all: clean deps lint test build
+PLATFORMS := windows linux darwin
+os = $(word 1, $@)
+ARCH = amd64
 
-tools:
-	mkdir -p $(GO_PATH)/bin
-
-deps: tools
-	$(GO_GET) -v -t -d ./...
+all: clean lint license test build
 
 .PHONY: lint
-lint: tools
-	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.21.0
-	@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)
+lint:
+	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin
 	$(GO_LINT) run -v ./...
 
-.PHONE: test
+.PHONY: fix-lint
+fix-lint:
+	$(GO_LINT) run -v --fix ./...
+
+.PHONY: license
+license: clean
+	$(GO) run cmd/license-eye/main.go header check
+
+.PHONY: test
 test: clean lint
 	$(GO_TEST) ./...
 	@>&2 echo "Great, all tests passed."
 
-.PHONY: build
-build: deps
-	$(GO_BUILD) -o $(OUT_DIR)/$(PROJECT)
+.PHONY: $(PLATFORMS)
+$(PLATFORMS):
+	mkdir -p $(OUT_DIR)
+	GOOS=$(os) GOARCH=$(ARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(os)/$(PROJECT) cmd/license-eye/main.go
 
-.PHONY: license
-license: clean
-	$(GO) run main.go header check
-
-.PHONY: fix
-fix: tools
-	$(GO_LINT) run -v --fix ./...
+.PHONY: build
+build: windows linux darwin
 
 .PHONY: clean
-clean: tools
+clean:
 	-rm -rf bin
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..e646f51
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache SkyWalking
+Copyright 2017-2020 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.adoc b/README.adoc
index 3174252..17501c0 100644
--- a/README.adoc
+++ b/README.adoc
@@ -1,5 +1,22 @@
-= license-checker
-:repo: https://github.com/fgksgf/license-checker
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+// 
+= license-eye
+:repo: https://github.com/apache/skywalking-eyes
 
 A full-featured license guard to check and fix license headers and dependencies' licenses.
 
@@ -8,7 +25,7 @@ A full-featured license guard to check and fix license headers and dependencies'
 [subs="attributes+",source,bash]
 ----
 git clone {repo}
-cd license-checker
+cd license-eye
 make
 ----
 
@@ -16,22 +33,22 @@ make
 
 [source]
 ----
-$ license-checker
+$ license-eye
 
 A full-featured license guard to check and fix license headers and dependencies' licenses.
 
 Usage:
-  license-checker [command]
+  license-eye [command]
 
 Available Commands:
   header      License header related commands; e.g. check, fix, etc.
   help        Help about any command
 
 Flags:
-  -h, --help               help for license-checker
+  -h, --help               help for license-eye
   -v, --verbosity string   log level (debug, info, warn, error, fatal, panic (default "info")
 
-Use "license-checker [command] --help" for more information about a command.
+Use "license-eye [command] --help" for more information about a command.
 ----
 
 == Configuration
@@ -46,7 +63,7 @@ include::test/.licenserc_for_test_check.yaml[]
 
 [source]
 ----
-bin/license-checker -c test/.licenserc_for_test_fix.yaml header check
+bin/license-eye -c test/.licenserc_for_test_fix.yaml header check
 
 INFO Loading configuration from file: test/.licenserc_for_test.yaml serc_for_test.yaml
 INFO Totally checked 23 files, valid: 8, invalid: 8, ignored: 7, fixed: 0
@@ -66,7 +83,7 @@ exit status 1
 
 [source]
 ----
-bin/license-checker -c test/.licenserc_for_test_fix.yaml header fix
+bin/license-eye -c test/.licenserc_for_test_fix.yaml header fix
 
 INFO Loading configuration from file: test/.licenserc_for_test_fix.yaml
 INFO Totally checked 16 files, valid: 7, invalid: 8, ignored: 1, fixed: 8
diff --git a/main.go b/cmd/license-eye/main.go
similarity index 84%
rename from main.go
rename to cmd/license-eye/main.go
index b2f1453..4059df5 100644
--- a/main.go
+++ b/cmd/license-eye/main.go
@@ -18,13 +18,14 @@
 package main
 
 import (
-	"license-checker/cmd"
-	"license-checker/internal/logger"
 	"os"
+
+	"github.com/apache/skywalking-eyes/license-eye/commands"
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
 )
 
 func main() {
-	if err := cmd.Execute(); err != nil {
+	if err := commands.Execute(); err != nil {
 		logger.Log.Errorln(err)
 		os.Exit(1)
 	}
diff --git a/commands/header/check.go b/commands/header/check.go
index b20642f..1de9115 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -18,24 +18,26 @@
 package header
 
 import (
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/config"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
+
 	"github.com/spf13/cobra"
-	"license-checker/internal/logger"
-	"license-checker/pkg/header"
 )
 
 var CheckCommand = &cobra.Command{
 	Use:     "check",
 	Aliases: []string{"c"},
-	Long:    "`check` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
+	Long:    "check command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		var config header.Config
+		var config config.Config
 		var result header.Result
 
 		if err := config.Parse(cfgFile); err != nil {
 			return err
 		}
 
-		if err := header.Check(&config, &result); err != nil {
+		if err := header.Check(&config.Header, &result); err != nil {
 			return err
 		}
 
diff --git a/commands/header/fix.go b/commands/header/fix.go
index 624a1f0..0bc6047 100644
--- a/commands/header/fix.go
+++ b/commands/header/fix.go
@@ -19,32 +19,35 @@ package header
 
 import (
 	"fmt"
-	"github.com/spf13/cobra"
-	"license-checker/internal/logger"
-	"license-checker/pkg/header"
-	"license-checker/pkg/header/fix"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/config"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header/fix"
+
+	"github.com/spf13/cobra"
 )
 
 var FixCommand = &cobra.Command{
 	Use:     "fix",
 	Aliases: []string{"f"},
-	Long:    "`fix` command walks the specified paths recursively and fix the license header if the specified files don't have the license header in the config file.",
+	Long:    "fix command walks the specified paths recursively and fix the license header if the specified files don't have the license header.",
 	RunE: func(cmd *cobra.Command, args []string) error {
-		var config header.Config
+		var config config.Config
 		var result header.Result
 
 		if err := config.Parse(cfgFile); err != nil {
 			return err
 		}
 
-		if err := header.Check(&config, &result); err != nil {
+		if err := header.Check(&config.Header, &result); err != nil {
 			return err
 		}
 
 		var errors []string
 		for _, file := range result.Failure {
-			if err := fix.Fix(file, &config, &result); err != nil {
+			if err := fix.Fix(file, &config.Header, &result); err != nil {
 				errors = append(errors, err.Error())
 			}
 		}
diff --git a/cmd/root.go b/commands/root.go
similarity index 67%
rename from cmd/root.go
rename to commands/root.go
index 91cb6b6..ab16bf8 100644
--- a/cmd/root.go
+++ b/commands/root.go
@@ -15,41 +15,43 @@
 // specific language governing permissions and limitations
 // under the License.
 //
-package cmd
+package commands
 
 import (
+	headercommand "github.com/apache/skywalking-eyes/license-eye/commands/header"
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
-	headercommand "license-checker/commands/header"
-	"license-checker/internal/logger"
 )
 
 var (
 	verbosity string
 )
 
-// rootCmd represents the base command when called without any subcommands
-var rootCmd = &cobra.Command{
-	Use:           "license-checker command [flags]",
+// Root represents the base command when called without any subcommands
+var Root = &cobra.Command{
+	Use:           "license-eye command [flags]",
 	Long:          "A full-featured license guard to check and fix license headers and dependencies' licenses",
 	SilenceUsage:  true,
 	SilenceErrors: true,
 	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
-		if level, err := logrus.ParseLevel(verbosity); err != nil {
+		level, err := logrus.ParseLevel(verbosity)
+		if err != nil {
 			return err
-		} else {
-			logger.Log.SetLevel(level)
 		}
+		logger.Log.SetLevel(level)
 		return nil
 	},
+	Version: version,
 }
 
 // Execute sets flags to the root command appropriately.
-// This is called by main.main(). It only needs to happen once to the rootCmd.
+// This is called by main.main(). It only needs to happen once to the Root.
 func Execute() error {
-	rootCmd.PersistentFlags().StringVarP(&verbosity, "verbosity", "v", logrus.InfoLevel.String(), "log level (debug, info, warn, error, fatal, panic")
+	Root.PersistentFlags().StringVarP(&verbosity, "verbosity", "v", logrus.InfoLevel.String(), "log level (debug, info, warn, error, fatal, panic")
 
-	rootCmd.AddCommand(headercommand.Header)
+	Root.AddCommand(headercommand.Header)
 
-	return rootCmd.Execute()
+	return Root.Execute()
 }
diff --git a/test/include_test/with_license/testcase.go b/commands/version.go
similarity index 95%
copy from test/include_test/with_license/testcase.go
copy to commands/version.go
index 0f54b96..0b07316 100644
--- a/test/include_test/with_license/testcase.go
+++ b/commands/version.go
@@ -15,4 +15,6 @@
 // specific language governing permissions and limitations
 // under the License.
 //
-package with_license
+package commands
+
+var version string
diff --git a/go.mod b/go.mod
index 1ac37cf..bba41da 100644
--- a/go.mod
+++ b/go.mod
@@ -1,4 +1,4 @@
-module license-checker
+module github.com/apache/skywalking-eyes/license-eye
 
 go 1.13
 
diff --git a/pkg/header/fix/double_slash.go b/pkg/config/Config.go
similarity index 61%
copy from pkg/header/fix/double_slash.go
copy to pkg/config/Config.go
index ab2819a..3b7c417 100644
--- a/pkg/header/fix/double_slash.go
+++ b/pkg/config/Config.go
@@ -15,34 +15,34 @@
 // specific language governing permissions and limitations
 // under the License.
 //
-package fix
+package config
 
 import (
 	"io/ioutil"
-	"license-checker/pkg/header"
-	"os"
-	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
+
+	"gopkg.in/yaml.v3"
 )
 
-// DoubleSlash adds the configured license header to files whose comment starts with //.
-func DoubleSlash(file string, config *header.Config, result *header.Result) error {
-	stat, err := os.Stat(file)
-	if err != nil {
-		return err
-	}
+type Config struct {
+	Header header.ConfigHeader `yaml:"header"`
+}
 
-	content, err := ioutil.ReadFile(file)
-	if err != nil {
+// Parse reads and parses the header check configurations in config file.
+func (config *Config) Parse(file string) error {
+	logger.Log.Infoln("Loading configuration from file:", file)
+
+	if bytes, err := ioutil.ReadFile(file); err != nil {
+		return err
+	} else if err := yaml.Unmarshal(bytes, config); err != nil {
 		return err
 	}
 
-	lines := "// " + strings.Join(strings.Split(config.License, "\n"), "\n// ") + "\n"
-
-	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+	if err := config.Header.Finalize(); err != nil {
 		return err
 	}
 
-	result.Fix(file)
-
 	return nil
 }
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 31eb6c7..e851b59 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -19,17 +19,20 @@ package header
 
 import (
 	"bufio"
-	"github.com/bmatcuk/doublestar/v2"
-	"license-checker/internal/logger"
 	"os"
 	"path/filepath"
+	"regexp"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+
+	"github.com/bmatcuk/doublestar/v2"
 )
 
-const CommentChars = "/*#- !~"
+const CommentChars = "/*#- !~'\""
 
 // Check checks the license headers of the specified paths/globs.
-func Check(config *Config, result *Result) error {
+func Check(config *ConfigHeader, result *Result) error {
 	for _, pattern := range config.Paths {
 		if err := checkPattern(pattern, result, config); err != nil {
 			return err
@@ -41,7 +44,7 @@ func Check(config *Config, result *Result) error {
 
 var seen = make(map[string]bool)
 
-func checkPattern(pattern string, result *Result, config *Config) error {
+func checkPattern(pattern string, result *Result, config *ConfigHeader) error {
 	paths, err := doublestar.Glob(pattern)
 
 	if err != nil {
@@ -53,7 +56,7 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 			result.Ignore(path)
 			continue
 		}
-		if err = checkPath(path, result, config); err != nil {
+		if err := checkPath(path, result, config); err != nil {
 			return err
 		}
 		seen[path] = true
@@ -62,7 +65,7 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 	return nil
 }
 
-func checkPath(path string, result *Result, config *Config) error {
+func checkPath(path string, result *Result, config *ConfigHeader) error {
 	defer func() { seen[path] = true }()
 
 	if yes, err := config.ShouldIgnore(path); yes || seen[path] || err != nil {
@@ -95,7 +98,7 @@ func checkPath(path string, result *Result, config *Config) error {
 }
 
 // CheckFile checks whether or not the file contains the configured license header.
-func CheckFile(file string, config *Config, result *Result) error {
+func CheckFile(file string, config *ConfigHeader, result *Result) error {
 	if yes, err := config.ShouldIgnore(file); yes || err != nil {
 		if !seen[file] {
 			result.Ignore(file)
@@ -115,7 +118,8 @@ func CheckFile(file string, config *Config, result *Result) error {
 
 	scanner := bufio.NewScanner(reader)
 	for scanner.Scan() {
-		line := strings.Trim(scanner.Text(), CommentChars)
+		line := strings.ToLower(strings.Trim(scanner.Text(), CommentChars))
+		line = regexp.MustCompile(" +").ReplaceAllString(line, " ")
 		if len(line) > 0 {
 			lines = append(lines, line)
 		}
diff --git a/pkg/header/config.go b/pkg/header/config.go
index f3629d1..6714fca 100644
--- a/pkg/header/config.go
+++ b/pkg/header/config.go
@@ -18,14 +18,17 @@
 package header
 
 import (
-	"github.com/bmatcuk/doublestar/v2"
-	"gopkg.in/yaml.v3"
 	"io/ioutil"
-	"license-checker/internal/logger"
+	"regexp"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+
+	"github.com/bmatcuk/doublestar/v2"
+	"gopkg.in/yaml.v3"
 )
 
-type Config struct {
+type ConfigHeader struct {
 	License     string   `yaml:"license"`
 	Paths       []string `yaml:"paths"`
 	PathsIgnore []string `yaml:"paths-ignore"`
@@ -33,23 +36,25 @@ type Config struct {
 
 // NormalizedLicense returns the normalized string of the license content,
 // "normalized" means the linebreaks and CommentChars are all trimmed.
-func (config *Config) NormalizedLicense() string {
+func (config *ConfigHeader) NormalizedLicense() string {
 	var lines []string
 	for _, line := range strings.Split(config.License, "\n") {
 		if len(line) > 0 {
-			lines = append(lines, strings.Trim(line, CommentChars))
+			line = strings.ToLower(strings.Trim(line, CommentChars))
+			line = regexp.MustCompile(" +").ReplaceAllString(line, " ")
+			lines = append(lines, line)
 		}
 	}
 	return strings.Join(lines, " ")
 }
 
 // Parse reads and parses the header check configurations in config file.
-func (config *Config) Parse(file string) error {
+func (config *ConfigHeader) Parse(file string) error {
 	logger.Log.Infoln("Loading configuration from file:", file)
 
 	if bytes, err := ioutil.ReadFile(file); err != nil {
 		return err
-	} else if err = yaml.Unmarshal(bytes, config); err != nil {
+	} else if err := yaml.Unmarshal(bytes, config); err != nil {
 		return err
 	}
 
@@ -62,7 +67,7 @@ func (config *Config) Parse(file string) error {
 	return nil
 }
 
-func (config *Config) ShouldIgnore(path string) (bool, error) {
+func (config *ConfigHeader) ShouldIgnore(path string) (bool, error) {
 	for _, ignorePattern := range config.PathsIgnore {
 		if matched, err := doublestar.Match(ignorePattern, path); matched || err != nil {
 			return matched, err
@@ -70,3 +75,13 @@ func (config *Config) ShouldIgnore(path string) (bool, error) {
 	}
 	return false, nil
 }
+
+func (config *ConfigHeader) Finalize() error {
+	logger.Log.Debugln("License header is:", config.NormalizedLicense())
+
+	if len(config.Paths) == 0 {
+		config.Paths = []string{"**"}
+	}
+
+	return nil
+}
diff --git a/pkg/header/fix/angle_bracket.go b/pkg/header/fix/angle_bracket.go
index ac31302..1b11bb1 100644
--- a/pkg/header/fix/angle_bracket.go
+++ b/pkg/header/fix/angle_bracket.go
@@ -20,14 +20,15 @@ package fix
 import (
 	"fmt"
 	"io/ioutil"
-	"license-checker/pkg/header"
 	"os"
 	"reflect"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
 )
 
 // AngleBracket adds the configured license header to files whose comment starts with <!--.
-func AngleBracket(file string, config *header.Config, result *header.Result) error {
+func AngleBracket(file string, config *header.ConfigHeader, result *header.Result) error {
 	stat, err := os.Stat(file)
 	if err != nil {
 		return err
diff --git a/pkg/header/fix/double_slash.go b/pkg/header/fix/double_slash.go
index ab2819a..2c7d634 100644
--- a/pkg/header/fix/double_slash.go
+++ b/pkg/header/fix/double_slash.go
@@ -19,13 +19,14 @@ package fix
 
 import (
 	"io/ioutil"
-	"license-checker/pkg/header"
 	"os"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
 )
 
 // DoubleSlash adds the configured license header to files whose comment starts with //.
-func DoubleSlash(file string, config *header.Config, result *header.Result) error {
+func DoubleSlash(file string, config *header.ConfigHeader, result *header.Result) error {
 	stat, err := os.Stat(file)
 	if err != nil {
 		return err
diff --git a/pkg/header/fix/fix.go b/pkg/header/fix/fix.go
index bba4df0..579969b 100644
--- a/pkg/header/fix/fix.go
+++ b/pkg/header/fix/fix.go
@@ -19,13 +19,15 @@ package fix
 
 import (
 	"fmt"
-	"license-checker/internal/logger"
-	"license-checker/pkg/header"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/internal/logger"
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
 )
 
-var suffixToFunc = map[string]func(string, *header.Config, *header.Result) error{
-	".go": DoubleSlash,
+var suffixToFunc = map[string]func(string, *header.ConfigHeader, *header.Result) error{
+	".go":   DoubleSlash,
+	".adoc": DoubleSlash,
 
 	".py":        Hashtag, // TODO: tackle shebang
 	".sh":        Hashtag, // TODO: tackle shebang
@@ -42,7 +44,7 @@ var suffixToFunc = map[string]func(string, *header.Config, *header.Result) error
 }
 
 // Fix adds the configured license header to the given file.
-func Fix(file string, config *header.Config, result *header.Result) error {
+func Fix(file string, config *header.ConfigHeader, result *header.Result) error {
 	var r header.Result
 	if err := header.CheckFile(file, config, &r); err != nil || !r.HasFailure() {
 		logger.Log.Warnln("Try to fix a valid file, returning:", file)
diff --git a/pkg/header/fix/hashtag.go b/pkg/header/fix/hashtag.go
index 601da4b..f467b18 100644
--- a/pkg/header/fix/hashtag.go
+++ b/pkg/header/fix/hashtag.go
@@ -19,14 +19,15 @@ package fix
 
 import (
 	"io/ioutil"
-	"license-checker/pkg/header"
 	"os"
 	"reflect"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
 )
 
 // Hashtag adds the configured license header to the files whose comment starts with #.
-func Hashtag(file string, config *header.Config, result *header.Result) error {
+func Hashtag(file string, config *header.ConfigHeader, result *header.Result) error {
 	stat, err := os.Stat(file)
 	if err != nil {
 		return err
diff --git a/pkg/header/fix/slash_asterisk.go b/pkg/header/fix/slash_asterisk.go
index adbf4e8..5a92209 100644
--- a/pkg/header/fix/slash_asterisk.go
+++ b/pkg/header/fix/slash_asterisk.go
@@ -19,13 +19,14 @@ package fix
 
 import (
 	"io/ioutil"
-	"license-checker/pkg/header"
 	"os"
 	"strings"
+
+	"github.com/apache/skywalking-eyes/license-eye/pkg/header"
 )
 
 // SlashAsterisk adds the configured license header to files whose comment starts with /**.
-func SlashAsterisk(file string, config *header.Config, result *header.Result) error {
+func SlashAsterisk(file string, config *header.ConfigHeader, result *header.Result) error {
 	stat, err := os.Stat(file)
 	if err != nil {
 		return err
diff --git a/pkg/header/result.go b/pkg/header/result.go
index ea17fb6..068fe75 100644
--- a/pkg/header/result.go
+++ b/pkg/header/result.go
@@ -51,7 +51,7 @@ func (result *Result) HasFailure() bool {
 
 func (result *Result) Error() error {
 	return fmt.Errorf(
-		"The following files don't have a valid license header: \n%v",
+		"the following files don't have a valid license header: \n%v",
 		strings.Join(result.Failure, "\n"),
 	)
 }
diff --git a/test/.licenserc_for_test_check.yaml b/test/.licenserc_for_test_check.yaml
index b4c1eb8..cad5ecb 100644
--- a/test/.licenserc_for_test_check.yaml
+++ b/test/.licenserc_for_test_check.yaml
@@ -1,25 +1,26 @@
-license: |
-  Licensed to Apache Software Foundation (ASF) under one or more contributor
-  license agreements. See the NOTICE file distributed with
-  this work for additional information regarding copyright
-  ownership. Apache Software Foundation (ASF) licenses this file to you 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
+header:
+  license: |
+    Licensed to Apache Software Foundation (ASF) under one or more contributor
+    license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright
+    ownership. Apache Software Foundation (ASF) licenses this file to you 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
+        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.
+    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.
 
-paths:
-  - 'test/**'
+  paths:
+    - 'test/**'
 
-paths-ignore:
-  - '**/.DS_Store'
-  - '**/.json'
-  - '**/exclude_test/**'
+  paths-ignore:
+    - '**/.DS_Store'
+    - '**/.json'
+    - '**/exclude_test/**'
diff --git a/test/.licenserc_for_test_fix.yaml b/test/.licenserc_for_test_fix.yaml
index 27d3087..19a864b 100644
--- a/test/.licenserc_for_test_fix.yaml
+++ b/test/.licenserc_for_test_fix.yaml
@@ -1,24 +1,25 @@
-license: |
-  Licensed to Apache Software Foundation (ASF) under one or more contributor
-  license agreements. See the NOTICE file distributed with
-  this work for additional information regarding copyright
-  ownership. Apache Software Foundation (ASF) licenses this file to you 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
+header:
+  license: |
+    Licensed to Apache Software Foundation (ASF) under one or more contributor
+    license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright
+    ownership. Apache Software Foundation (ASF) licenses this file to you 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
+        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.
+    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.
 
-paths:
-  - 'test/include_test/**'
+  paths:
+    - 'test/include_test/**'
 
-paths-ignore:
-  - '**/.DS_Store'
-  - '**/.json'
+  paths-ignore:
+    - '**/.DS_Store'
+    - '**/.json'
diff --git a/test/include_test/with_license/testcase.go b/test/include_test/with_license/testcase.go
index 0f54b96..c382b60 100644
--- a/test/include_test/with_license/testcase.go
+++ b/test/include_test/with_license/testcase.go
@@ -15,4 +15,4 @@
 // specific language governing permissions and limitations
 // under the License.
 //
-package with_license
+package withlicense
diff --git a/test/include_test/without_license/testcase.go b/test/include_test/without_license/testcase.go
index fab4aaa..6ee0c67 100644
--- a/test/include_test/without_license/testcase.go
+++ b/test/include_test/without_license/testcase.go
@@ -16,4 +16,4 @@
 //    consectetur mollit voluptate magna ut ullamco pariatur proident esse commodo consectetur minim in do eu
 //     consequat ea eiusmod proident incididunt ut qui sunt consequat officia amet amet amet dolore fugiat ex.
 
-package with_license
+package withlicense


[skywalking-eyes] 04/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit b17d8dbfa1759d76515f317fa0d912e6c3791570
Author: Hoshea <fg...@gmail.com>
AuthorDate: Sat Nov 21 23:08:12 2020 +0800

    dev
---
 cmd/root.go | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/cmd/root.go b/cmd/root.go
index 841fa46..d030d02 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -16,6 +16,7 @@ limitations under the License.
 package cmd
 
 import (
+	"bufio"
 	"encoding/json"
 	"fmt"
 	"github.com/spf13/cobra"
@@ -23,6 +24,7 @@ import (
 	"license-checker/util"
 	"os"
 	"path/filepath"
+	"strings"
 )
 
 var cfgFile string
@@ -39,7 +41,7 @@ if the specified files have the license header in the config file.`,
 		if err != nil {
 			fmt.Println(err)
 		}
-		//fmt.Println(config.TargetFiles)
+
 		if err := Walk(checkPath, config); err != nil {
 			fmt.Println(err)
 		}
@@ -99,6 +101,13 @@ func LoadConfig() (*Config, error) {
 }
 
 func Walk(p string, cfg *Config) error {
+	var license []string
+	if loose {
+		license = cfg.LicenseStrict
+	} else {
+		license = cfg.LicenseLoose
+	}
+
 	inExcludeDir := util.InStrSliceMapKeyFunc(cfg.Exclude.Directories)
 	inExcludeExt := util.InStrSliceMapKeyFunc(cfg.Exclude.Extensions)
 	inExcludeFiles := util.InStrSliceMapKeyFunc(cfg.Exclude.Files)
@@ -121,8 +130,19 @@ func Walk(p string, cfg *Config) error {
 
 			// TODO: open the file and check
 			fmt.Println(path)
-			//curDir := strings.Replace(path, fi.Name(), "", 1)
-			//fmt.Println(curDir)
+
+			file, err := os.Open(path)
+			if err != nil {
+				return err
+			}
+			defer file.Close()
+
+			scanner := bufio.NewScanner(file)
+			for scanner.Scan() {
+				line := scanner.Text()
+				if strings.Contains()
+			}
+
 		}
 
 		return nil


[skywalking-eyes] 08/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 3938361f335ae063bbcb4910e850cf1bfafff5b7
Author: Hoshea <fg...@gmail.com>
AuthorDate: Mon Nov 23 20:19:55 2020 +0800

    dev
---
 README.md | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/README.md b/README.md
index e2b1381..e58ab9e 100644
--- a/README.md
+++ b/README.md
@@ -33,43 +33,43 @@ Flags:
 
 ```json
 {
+  // What to check in strict mode, the order of strings can NOT be changed arbitrarily
   "licenseStrict": [
     "Licensed to the Apache Software Foundation (ASF) under one or more",
     "contributor license agreements.  See the NOTICE file distributed with",
     "..."
   ],
+
+  // What to check in loose mode, the order of strings can NOT be changed arbitrarily
   "licenseLoose": [
     "Apache License, Version 2.0"
   ],
+
+  // license-checker will check *.java and *.go
   "targetFiles": [
     "java",
-    "go",
-    "py",
-    "sh",
-    "graphql",
-    "yaml",
-    "yml"
+    "go"
   ],
+
   "exclude": {
+    // license-checker will NOT check these files
     "files": [
       ".gitignore",
       "NOTICE",
-      "go.mod",
-      "go.sum",
-      ".DS_Store",
       "LICENSE"
     ],
+
+    // license-checker will NOT check files whose names with these extensions
     "extensions": [
       "md",
       "xml",
       "json"
     ],
+
+    // license-checker will NOT check these directories
     "directories": [
       "bin",
-      ".github",
-      ".git",
-      ".idea",
-      "test"
+      ".github"
     ]
   }
 }


[skywalking-eyes] 13/25: chore: set up GitHub Actions to verify build from sources

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit a4c1cdcd9ce879cfbd2ad271d4f6dfe65b841cd9
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Tue Dec 1 21:31:10 2020 +0800

    chore: set up GitHub Actions to verify build from sources
---
 .github/workflows/build.yaml | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 0000000..74f7320
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,37 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+name: Build
+
+on:
+  pull_request:
+  push:
+    branches:
+      - master
+
+jobs:
+  build:
+    name: Build
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/setup-go@v2
+        with:
+          go-version: 1.14
+
+      - uses: actions/checkout@v2
+
+      - name: Build
+        run: make build


[skywalking-eyes] 23/25: Fix GHA description and refactor

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit a038166940fbbfda53f34ed255178a58840c97ab
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 12:50:26 2020 +0800

    Fix GHA description and refactor
---
 action.yml                | 2 +-
 commands/header/check.go  | 7 +------
 commands/header/header.go | 7 ++++++-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/action.yml b/action.yml
index bcdf432..0494f27 100644
--- a/action.yml
+++ b/action.yml
@@ -16,7 +16,7 @@
 # under the License.
 # 
 name: License Guard
-description: A tool for checking license headers, which theoretically supports checking all types of files.
+description: A full-featured license guard to check and fix license headers and dependencies' licenses.
 branding:
   icon: book
   color: orange
diff --git a/commands/header/check.go b/commands/header/check.go
index fc17c53..b20642f 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -23,15 +23,10 @@ import (
 	"license-checker/pkg/header"
 )
 
-var (
-	// cfgFile is the config path to the config file of header command.
-	cfgFile string
-)
-
 var CheckCommand = &cobra.Command{
 	Use:     "check",
-	Long:    "`check` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
 	Aliases: []string{"c"},
+	Long:    "`check` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
 	RunE: func(cmd *cobra.Command, args []string) error {
 		var config header.Config
 		var result header.Result
diff --git a/commands/header/header.go b/commands/header/header.go
index b9e8612..8786217 100644
--- a/commands/header/header.go
+++ b/commands/header/header.go
@@ -21,11 +21,16 @@ import (
 	"github.com/spf13/cobra"
 )
 
+var (
+	// cfgFile is the config path to the config file of header command.
+	cfgFile string
+)
+
 var Header = &cobra.Command{
 	Use:     "header",
+	Aliases: []string{"h"},
 	Short:   "License header related commands; e.g. check, fix, etc.",
 	Long:    "`header` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
-	Aliases: []string{"h"},
 }
 
 func init() {


[skywalking-eyes] 15/25: feature: wrap the tool into a GitHub Action

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 97ac7986457a0850523e673b17e705dd3814c240
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Tue Dec 1 23:23:23 2020 +0800

    feature: wrap the tool into a GitHub Action
---
 Dockerfile | 31 +++++++++++++++++++++++++++++++
 Makefile   |  2 +-
 action.yml | 21 +++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..1205638
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+FROM golang:1.14.3-alpine AS build
+
+WORKDIR /src
+
+COPY . .
+
+RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/license-checker
+
+FROM alpine:3 AS bin
+
+COPY --from=build /bin/license-checker /bin/license-checker
+
+WORKDIR /github/workspace/
+
+ENTRYPOINT /bin/license-checker
diff --git a/Makefile b/Makefile
index 8e2e68e..133f4d7 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,6 @@ all: clean deps lint test build
 
 tools:
 	mkdir -p $(GO_PATH)/bin
-	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.21.0
 	#$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
 
 deps: tools
@@ -39,6 +38,7 @@ deps: tools
 
 .PHONY: lint
 lint: tools
+	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.21.0
 	@gofmt -s -l -w $(FILES) 2>&1 | $(FAIL_ON_STDOUT)
 	$(GO_LINT) run -v ./...
 
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..38207ea
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+
+name: License Checker
+description: A tool for checking license headers, which theoretically supports checking all types of files.
+runs:
+  using: docker
+  image: Dockerfile


[skywalking-eyes] 06/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 42ecc96dae3c76f19346d40471b5efc4c190be3d
Author: Hoshea <fg...@gmail.com>
AuthorDate: Mon Nov 23 19:59:33 2020 +0800

    dev
---
 .licenserc.json                                    | 10 ++-
 Makefile                                           |  2 +-
 README.md                                          | 36 ++++++++-
 cmd/root.go                                        | 91 +++++++++++++++-------
 main_test.go                                       |  1 +
 .licenserc.json => test/.licenserc_for_test.json   | 13 +---
 test/exclude_test/directories/testcase.go          |  1 +
 test/exclude_test/extensions/testcase.json         |  3 +
 test/{ => exclude_test/extensions}/testcase.md     |  0
 test/exclude_test/extensions/testcase.xml          |  4 +
 test/{ => include_test/with_license}/testcase.go   |  2 +-
 .../with_license/testcase.graphql}                 |  0
 test/{ => include_test/with_license}/testcase.java |  2 +-
 .../with_license/testcase.py}                      |  0
 .../with_license/testcase.sh}                      |  2 +
 .../with_license/testcase.yaml}                    |  2 +
 .../with_license/testcase.yml}                     |  0
 test/include_test/without_license/testcase.go      | 19 +++++
 .../without_license/testcase.graphql}              |  0
 test/include_test/without_license/testcase.java    | 17 ++++
 test/include_test/without_license/testcase.py      | 17 ++++
 .../without_license/testcase.sh}                   |  0
 .../without_license/testcase.yaml}                 |  0
 .../without_license/testcase.yml}                  |  0
 util/str.go                                        | 10 +++
 util/str_test.go                                   | 57 +++++++++++++-
 26 files changed, 242 insertions(+), 47 deletions(-)

diff --git a/.licenserc.json b/.licenserc.json
index 3d262cc..a15366c 100644
--- a/.licenserc.json
+++ b/.licenserc.json
@@ -14,8 +14,7 @@
     "limitations under the License."
   ],
   "licenseLoose": [
-    "Apache License",
-    "Version 2.0"
+    "Apache License, Version 2.0"
   ],
   "targetFiles": [
     "java",
@@ -31,7 +30,9 @@
       ".gitignore",
       "NOTICE",
       "go.mod",
-      "go.sum"
+      "go.sum",
+      ".DS_Store",
+      "LICENSE"
     ],
     "extensions": [
       "md",
@@ -42,7 +43,8 @@
       "bin",
       ".github",
       ".git",
-      ".idea"
+      ".idea",
+      "test"
     ]
   }
 }
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 4e83903..04af575 100644
--- a/Makefile
+++ b/Makefile
@@ -37,7 +37,7 @@ all: clean deps lint test build
 tools:
 	mkdir -p $(GO_PATH)/bin
 	$(GO_LINT) version || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.21.0
-	$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
+	#$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
 
 deps: tools
 	$(GO_GET) -v -t -d ./...
diff --git a/README.md b/README.md
index 6aadc5a..b637500 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,36 @@
 # license-checker
-A CLI tool for checking license headers
+
+A CLI tool for checking license headers, which theoretically supports checking all types of files.
+
+## Install
+
+```bash 
+git clone 
+cd license-checker
+make
+```
+
+## Usage
+
+```bash
+Usage: license-checker [flags]
+
+license-checker walks the specified path recursively and checks 
+if the specified files have the license header in the config file.
+
+Usage:
+  license-checker [flags]
+
+Flags:
+  -c, --config string   the config file (default ".licenserc.json")
+  -h, --help            help for license-checker
+  -l, --loose           loose mode
+  -p, --path string     the path to check (default ".")
+  -v, --verbose         verbose mode
+```
+
+## Test
+
+```bash
+bin/license-checker -p test -c test/.licenserc_for_test.json 
+```
diff --git a/cmd/root.go b/cmd/root.go
index fed1758..84873e9 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -27,9 +27,12 @@ import (
 	"strings"
 )
 
-var cfgFile string
-var checkPath string
-var loose bool
+var (
+	cfgFile   string
+	checkPath string
+	loose     bool
+	verbose   bool
+)
 
 // rootCmd represents the base command when called without any subcommands
 var rootCmd = &cobra.Command{
@@ -42,27 +45,25 @@ if the specified files have the license header in the config file.`,
 			fmt.Println(err)
 		}
 
-		if err := Walk(checkPath, config); err != nil {
+		res, err := WalkAndCheck(checkPath, config)
+		if err != nil {
 			fmt.Println(err)
 		}
+		printResult(res)
 	},
 }
 
 // Execute adds all child commands to the root command and sets flags appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
 func Execute() {
-	if err := rootCmd.Execute(); err != nil {
-		fmt.Println(err)
-		os.Exit(1)
-	}
-}
-
-func init() {
 	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", ".licenserc.json", "the config file")
-	rootCmd.PersistentFlags().StringVarP(&checkPath, "path", "p", "", "the path to check (required)")
+	rootCmd.PersistentFlags().StringVarP(&checkPath, "path", "p", ".", "the path to check")
 	rootCmd.PersistentFlags().BoolVarP(&loose, "loose", "l", false, "loose mode")
-	if err := rootCmd.MarkPersistentFlagRequired("path"); err != nil {
+	rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
+
+	if err := rootCmd.Execute(); err != nil {
 		fmt.Println(err)
+		os.Exit(1)
 	}
 }
 
@@ -100,18 +101,19 @@ func LoadConfig() (*Config, error) {
 	return &config, nil
 }
 
-func Walk(p string, cfg *Config) error {
+func WalkAndCheck(p string, cfg *Config) (*Result, error) {
 	var license []string
 	if loose {
-		license = cfg.LicenseStrict
-	} else {
 		license = cfg.LicenseLoose
+	} else {
+		license = cfg.LicenseStrict
 	}
 
 	inExcludeDir := util.InStrSliceMapKeyFunc(cfg.Exclude.Directories)
 	inExcludeExt := util.InStrSliceMapKeyFunc(cfg.Exclude.Extensions)
 	inExcludeFiles := util.InStrSliceMapKeyFunc(cfg.Exclude.Files)
 
+	var result Result
 	err := filepath.Walk(p, func(path string, fi os.FileInfo, err error) error {
 		if err != nil {
 			fmt.Println(err) // can't walk here,
@@ -119,7 +121,8 @@ func Walk(p string, cfg *Config) error {
 		}
 
 		if fi.IsDir() {
-			if inExcludeDir(fi.Name()) {
+			if inExcludeDir(fi.Name()) ||
+				inExcludeDir(util.CleanPathPrefixes(path, []string{p, string(os.PathSeparator)})) {
 				return filepath.SkipDir
 			}
 		} else {
@@ -128,25 +131,57 @@ func Walk(p string, cfg *Config) error {
 				return nil
 			}
 
-			// TODO: open the file and check
-			fmt.Println(path)
-
-			file, err := os.Open(path)
+			ok, err := CheckLicense(path, license)
 			if err != nil {
 				return err
 			}
-			defer file.Close()
 
-			scanner := bufio.NewScanner(file)
-			for scanner.Scan() {
-				line := scanner.Text()
-				//if strings.Contains()
+			if ok {
+				result.Success = append(result.Success, fmt.Sprintf("[Pass]: %s", path))
+			} else {
+				result.Failure = append(result.Failure, fmt.Sprintf("[No Specified License]: %s", path))
 			}
-
 		}
 
 		return nil
 	})
 
-	return err
+	return &result, err
+}
+
+func CheckLicense(filePath string, license []string) (bool, error) {
+	file, err := os.Open(filePath)
+	if err != nil {
+		return false, err
+	}
+	defer file.Close()
+
+	index := 0
+	scanner := bufio.NewScanner(file)
+	for scanner.Scan() && index < len(license) {
+		line := scanner.Text()
+		if strings.Contains(line, license[index]) {
+			index++
+		}
+	}
+
+	if index != len(license) {
+		return false, nil
+	}
+	return true, nil
+}
+
+func printResult(r *Result) {
+	if verbose {
+		for _, s := range r.Success {
+			fmt.Println(s)
+		}
+	}
+
+	for _, s := range r.Failure {
+		fmt.Println(s)
+	}
+
+	fmt.Printf("Total check %d files, success: %d, failure: %d\n",
+		len(r.Success)+len(r.Failure), len(r.Success), len(r.Failure))
 }
diff --git a/main_test.go b/main_test.go
new file mode 100644
index 0000000..06ab7d0
--- /dev/null
+++ b/main_test.go
@@ -0,0 +1 @@
+package main
diff --git a/.licenserc.json b/test/.licenserc_for_test.json
similarity index 87%
copy from .licenserc.json
copy to test/.licenserc_for_test.json
index 3d262cc..8eaaa64 100644
--- a/.licenserc.json
+++ b/test/.licenserc_for_test.json
@@ -14,8 +14,7 @@
     "limitations under the License."
   ],
   "licenseLoose": [
-    "Apache License",
-    "Version 2.0"
+    "Apache License, Version 2.0"
   ],
   "targetFiles": [
     "java",
@@ -28,10 +27,7 @@
   ],
   "exclude": {
     "files": [
-      ".gitignore",
-      "NOTICE",
-      "go.mod",
-      "go.sum"
+      ".DS_Store"
     ],
     "extensions": [
       "md",
@@ -39,10 +35,7 @@
       "json"
     ],
     "directories": [
-      "bin",
-      ".github",
-      ".git",
-      ".idea"
+      "exclude_test/directories"
     ]
   }
 }
\ No newline at end of file
diff --git a/test/exclude_test/directories/testcase.go b/test/exclude_test/directories/testcase.go
new file mode 100644
index 0000000..672d5e8
--- /dev/null
+++ b/test/exclude_test/directories/testcase.go
@@ -0,0 +1 @@
+package directories
diff --git a/test/exclude_test/extensions/testcase.json b/test/exclude_test/extensions/testcase.json
new file mode 100644
index 0000000..0e0dcd2
--- /dev/null
+++ b/test/exclude_test/extensions/testcase.json
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/test/testcase.md b/test/exclude_test/extensions/testcase.md
similarity index 100%
copy from test/testcase.md
copy to test/exclude_test/extensions/testcase.md
diff --git a/test/exclude_test/extensions/testcase.xml b/test/exclude_test/extensions/testcase.xml
new file mode 100644
index 0000000..02302d8
--- /dev/null
+++ b/test/exclude_test/extensions/testcase.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root>
+    <test>test</test>
+</root>
\ No newline at end of file
diff --git a/test/testcase.go b/test/include_test/with_license/testcase.go
similarity index 97%
rename from test/testcase.go
rename to test/include_test/with_license/testcase.go
index 4020ef8..6015e2e 100644
--- a/test/testcase.go
+++ b/test/include_test/with_license/testcase.go
@@ -15,4 +15,4 @@
  * limitations under the License.
  */
 
-package test
+package with_license
diff --git a/test/testcase3.py b/test/include_test/with_license/testcase.graphql
similarity index 100%
copy from test/testcase3.py
copy to test/include_test/with_license/testcase.graphql
diff --git a/test/testcase.java b/test/include_test/with_license/testcase.java
similarity index 95%
rename from test/testcase.java
rename to test/include_test/with_license/testcase.java
index 43a94f3..63f7276 100644
--- a/test/testcase.java
+++ b/test/include_test/with_license/testcase.java
@@ -11,4 +11,4 @@
 // 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.
+// limitations under the License.
diff --git a/test/testcase3.py b/test/include_test/with_license/testcase.py
similarity index 100%
copy from test/testcase3.py
copy to test/include_test/with_license/testcase.py
diff --git a/test/testcase3.py b/test/include_test/with_license/testcase.sh
similarity index 98%
copy from test/testcase3.py
copy to test/include_test/with_license/testcase.sh
index a9fd83f..c251402 100644
--- a/test/testcase3.py
+++ b/test/include_test/with_license/testcase.sh
@@ -1,3 +1,5 @@
+# /bin/bash
+
 #
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
diff --git a/test/testcase3.py b/test/include_test/with_license/testcase.yaml
similarity index 99%
copy from test/testcase3.py
copy to test/include_test/with_license/testcase.yaml
index a9fd83f..c2ff44f 100644
--- a/test/testcase3.py
+++ b/test/include_test/with_license/testcase.yaml
@@ -1,4 +1,6 @@
 #
+#
+#
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
diff --git a/test/testcase3.py b/test/include_test/with_license/testcase.yml
similarity index 100%
rename from test/testcase3.py
rename to test/include_test/with_license/testcase.yml
diff --git a/test/include_test/without_license/testcase.go b/test/include_test/without_license/testcase.go
new file mode 100644
index 0000000..fab4aaa
--- /dev/null
+++ b/test/include_test/without_license/testcase.go
@@ -0,0 +1,19 @@
+// Esse enim dolore adipisicing in cillum eiusmod excepteur quis nisi sit dolor anim anim id id nostrud nostrud tempor.
+// Elit sit enim cillum adipisicing non magna aute nostrud ullamco dolor dolore consequat ut ea occaecat veniam inci
+//  occaecat consectetur eiusmod sint eiusmod aute eu duis fugiat dolore in laboris enim eiusmod aliquip nisi aliqua
+//  nulla proident ut ut aliqua et in ad deserunt nisi anim non dolore ut commodo excepteur ut eiusmod ex exercitation
+//  in sunt cillum ullamco dolor magna ex proident elit in mollit incididunt excepteur dolor pariatur consectetur
+//  exercitation qui ut cupidatat dolor do esse tempor commodo magna ad in duis voluptate est nisi in pariatur
+//  duis mollit eiusmod est magna in velit aute anim ullamco nostrud adipisicing cupidatat non fugiat proident
+//   commodo minim sint minim pariatur nostrud sit mollit cillum dolor minim quis nisi id officia veniam
+//   mollit tempor exercitation dolore duis cillum sunt esse nostrud deserunt amet ad quis reprehenderit
+//   do in proident est incididunt voluptate et ullamco nisi dolore commodo mollit elit sint aute in occaecat
+//   excepteur do pariatur laborum occaecat ad et nisi ut est in consequat commodo consectetur consequat ullamco m
+//   ollit aute dolor velit do deserunt eu velit reprehenderit incididunt commodo duis anim dolor velit nostrud eu
+//   irure dolor mollit labore sunt consectetur ullamco sed consectetur sed sint consectetur eu fugiat amet nostrud
+//   elit reprehenderit sunt ullamco fugiat eiusmod elit est est in duis quis occaecat proident aliquip adipisicing
+//    eu sint pariatur ullamco adipisicing cupidatat sed ut pariatur ut in amet deserunt laboris consectetur in
+//    consectetur mollit voluptate magna ut ullamco pariatur proident esse commodo consectetur minim in do eu
+//     consequat ea eiusmod proident incididunt ut qui sunt consequat officia amet amet amet dolore fugiat ex.
+
+package with_license
diff --git a/test/testcase.md b/test/include_test/without_license/testcase.graphql
similarity index 100%
copy from test/testcase.md
copy to test/include_test/without_license/testcase.graphql
diff --git a/test/include_test/without_license/testcase.java b/test/include_test/without_license/testcase.java
new file mode 100644
index 0000000..0ba5691
--- /dev/null
+++ b/test/include_test/without_license/testcase.java
@@ -0,0 +1,17 @@
+// Esse enim dolore adipisicing in cillum eiusmod excepteur quis nisi sit dolor anim anim id id nostrud nostrud tempor.
+// Elit sit enim cillum adipisicing non magna aute nostrud ullamco dolor dolore consequat ut ea occaecat veniam incididunt
+//  occaecat consectetur eiusmod sint eiusmod aute eu duis fugiat dolore in laboris enim eiusmod aliquip nisi aliqua irure 
+//  nulla proident ut ut aliqua et in ad deserunt nisi anim non dolore ut commodo excepteur ut eiusmod ex exercitation 
+//  in sunt cillum ullamco dolor magna ex proident elit in mollit incididunt excepteur dolor pariatur consectetur 
+//  exercitation qui ut cupidatat dolor do esse tempor commodo magna ad in duis voluptate est nisi in pariatur 
+//  duis mollit eiusmod est magna in velit aute anim ullamco nostrud adipisicing cupidatat non fugiat proident
+//   commodo minim sint minim pariatur nostrud sit mollit cillum dolor minim quis nisi id officia veniam 
+//   mollit tempor exercitation dolore duis cillum sunt esse nostrud deserunt amet ad quis reprehenderit 
+//   do in proident est incididunt voluptate et ullamco nisi dolore commodo mollit elit sint aute in occaecat 
+//   excepteur do pariatur laborum occaecat ad et nisi ut est in consequat commodo consectetur consequat ullamco m
+//   ollit aute dolor velit do deserunt eu velit reprehenderit incididunt commodo duis anim dolor velit nostrud eu 
+//   irure dolor mollit labore sunt consectetur ullamco sed consectetur sed sint consectetur eu fugiat amet nostrud 
+//   elit reprehenderit sunt ullamco fugiat eiusmod elit est est in duis quis occaecat proident aliquip adipisicing
+//    eu sint pariatur ullamco adipisicing cupidatat sed ut pariatur ut in amet deserunt laboris consectetur in 
+//    consectetur mollit voluptate magna ut ullamco pariatur proident esse commodo consectetur minim in do eu
+//     consequat ea eiusmod proident incididunt ut qui sunt consequat officia amet amet amet dolore fugiat ex.
diff --git a/test/include_test/without_license/testcase.py b/test/include_test/without_license/testcase.py
new file mode 100644
index 0000000..5030e1c
--- /dev/null
+++ b/test/include_test/without_license/testcase.py
@@ -0,0 +1,17 @@
+# Esse enim dolore adipisicing in cillum eiusmod excepteur quis nisi sit dolor anim anim id id nostrud nostrud tempor.
+# Elit sit enim cillum adipisicing non magna aute nostrud ullamco dolor dolore consequat ut ea occaecat veniam incididunt
+#  occaecat consectetur eiusmod sint eiusmod aute eu duis fugiat dolore in laboris enim eiusmod aliquip nisi aliqua irure 
+#  nulla proident ut ut aliqua et in ad deserunt nisi anim non dolore ut commodo excepteur ut eiusmod ex exercitation 
+#  in sunt cillum ullamco dolor magna ex proident elit in mollit incididunt excepteur dolor pariatur consectetur 
+#  exercitation qui ut cupidatat dolor do esse tempor commodo magna ad in duis voluptate est nisi in pariatur 
+#  duis mollit eiusmod est magna in velit aute anim ullamco nostrud adipisicing cupidatat non fugiat proident
+#   commodo minim sint minim pariatur nostrud sit mollit cillum dolor minim quis nisi id officia veniam 
+#   mollit tempor exercitation dolore duis cillum sunt esse nostrud deserunt amet ad quis reprehenderit 
+#   do in proident est incididunt voluptate et ullamco nisi dolore commodo mollit elit sint aute in occaecat 
+#   excepteur do pariatur laborum occaecat ad et nisi ut est in consequat commodo consectetur consequat ullamco m
+#   ollit aute dolor velit do deserunt eu velit reprehenderit incididunt commodo duis anim dolor velit nostrud eu 
+#   irure dolor mollit labore sunt consectetur ullamco sed consectetur sed sint consectetur eu fugiat amet nostrud 
+#   elit reprehenderit sunt ullamco fugiat eiusmod elit est est in duis quis occaecat proident aliquip adipisicing
+#    eu sint pariatur ullamco adipisicing cupidatat sed ut pariatur ut in amet deserunt laboris consectetur in 
+#    consectetur mollit voluptate magna ut ullamco pariatur proident esse commodo consectetur minim in do eu
+#     consequat ea eiusmod proident incididunt ut qui sunt consequat officia amet amet amet dolore fugiat ex.
diff --git a/test/testcase.md b/test/include_test/without_license/testcase.sh
similarity index 100%
copy from test/testcase.md
copy to test/include_test/without_license/testcase.sh
diff --git a/test/testcase.md b/test/include_test/without_license/testcase.yaml
similarity index 100%
copy from test/testcase.md
copy to test/include_test/without_license/testcase.yaml
diff --git a/test/testcase.md b/test/include_test/without_license/testcase.yml
similarity index 100%
rename from test/testcase.md
rename to test/include_test/without_license/testcase.yml
diff --git a/util/str.go b/util/str.go
index b953e48..e907b90 100644
--- a/util/str.go
+++ b/util/str.go
@@ -41,3 +41,13 @@ func GetFileExtension(filename string) string {
 	}
 	return ""
 }
+
+func CleanPathPrefixes(path string, prefixes []string) string {
+	for _, prefix := range prefixes {
+		if strings.HasPrefix(path, prefix) && len(path) > 0 {
+			path = path[len(prefix):]
+		}
+	}
+
+	return path
+}
diff --git a/util/str_test.go b/util/str_test.go
index fce8965..cf64a96 100644
--- a/util/str_test.go
+++ b/util/str_test.go
@@ -15,7 +15,10 @@ limitations under the License.
 */
 package util
 
-import "testing"
+import (
+	"os"
+	"testing"
+)
 
 func TestGetFileExtension(t *testing.T) {
 	type args struct {
@@ -56,3 +59,55 @@ func TestGetFileExtension(t *testing.T) {
 		})
 	}
 }
+
+func Test_cleanPathPrefixes(t *testing.T) {
+	type args struct {
+		path     string
+		prefixes []string
+	}
+	tests := []struct {
+		name string
+		args args
+		want string
+	}{
+		{
+			name: "",
+			args: args{
+				path:     "test/exclude_test",
+				prefixes: []string{"test", string(os.PathSeparator)},
+			},
+			want: "exclude_test",
+		},
+		{
+			name: "",
+			args: args{
+				path:     "test/exclude_test/directories",
+				prefixes: []string{"test", string(os.PathSeparator)},
+			},
+			want: "exclude_test/directories",
+		},
+		{
+			name: "",
+			args: args{
+				path:     "./.git/",
+				prefixes: []string{".", string(os.PathSeparator)},
+			},
+			want: ".git/",
+		},
+		{
+			name: "",
+			args: args{
+				path:     "test/exclude_test/directories",
+				prefixes: []string{"test/", string(os.PathSeparator)},
+			},
+			want: "exclude_test/directories",
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if got := CleanPathPrefixes(tt.args.path, tt.args.prefixes); got != tt.want {
+				t.Errorf("CleanPathPrefixes() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}


[skywalking-eyes] 07/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 3938d041bae1278c9ca8b693348cfa68f3aef7d6
Author: Hoshea <fg...@gmail.com>
AuthorDate: Mon Nov 23 20:11:41 2020 +0800

    dev
---
 README.md    | 50 ++++++++++++++++++++++++++++++++++++++++++++++++--
 cmd/root.go  | 15 +++++++++++----
 main_test.go |  1 -
 3 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index b637500..e2b1381 100644
--- a/README.md
+++ b/README.md
@@ -5,14 +5,14 @@ A CLI tool for checking license headers, which theoretically supports checking a
 ## Install
 
 ```bash 
-git clone 
+git clone https://github.com/fgksgf/license-checker.git
 cd license-checker
 make
 ```
 
 ## Usage
 
-```bash
+```
 Usage: license-checker [flags]
 
 license-checker walks the specified path recursively and checks 
@@ -29,6 +29,52 @@ Flags:
   -v, --verbose         verbose mode
 ```
 
+## Configuration
+
+```json
+{
+  "licenseStrict": [
+    "Licensed to the Apache Software Foundation (ASF) under one or more",
+    "contributor license agreements.  See the NOTICE file distributed with",
+    "..."
+  ],
+  "licenseLoose": [
+    "Apache License, Version 2.0"
+  ],
+  "targetFiles": [
+    "java",
+    "go",
+    "py",
+    "sh",
+    "graphql",
+    "yaml",
+    "yml"
+  ],
+  "exclude": {
+    "files": [
+      ".gitignore",
+      "NOTICE",
+      "go.mod",
+      "go.sum",
+      ".DS_Store",
+      "LICENSE"
+    ],
+    "extensions": [
+      "md",
+      "xml",
+      "json"
+    ],
+    "directories": [
+      "bin",
+      ".github",
+      ".git",
+      ".idea",
+      "test"
+    ]
+  }
+}
+```
+
 ## Test
 
 ```bash
diff --git a/cmd/root.go b/cmd/root.go
index 84873e9..ef8abdf 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -28,10 +28,14 @@ import (
 )
 
 var (
-	cfgFile   string
+	// cfgFile is the path to the config file.
+	cfgFile string
+	// checkPath is the path to check license.
 	checkPath string
-	loose     bool
-	verbose   bool
+	// loose is flag to enable loose mode.
+	loose bool
+	// verbose is flag to enable verbose mode.
+	verbose bool
 )
 
 // rootCmd represents the base command when called without any subcommands
@@ -53,7 +57,7 @@ if the specified files have the license header in the config file.`,
 	},
 }
 
-// Execute adds all child commands to the root command and sets flags appropriately.
+// Execute sets flags to the root command appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
 func Execute() {
 	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", ".licenserc.json", "the config file")
@@ -101,6 +105,7 @@ func LoadConfig() (*Config, error) {
 	return &config, nil
 }
 
+// WalkAndCheck traverses the path p and check every target file's license.
 func WalkAndCheck(p string, cfg *Config) (*Result, error) {
 	var license []string
 	if loose {
@@ -149,6 +154,7 @@ func WalkAndCheck(p string, cfg *Config) (*Result, error) {
 	return &result, err
 }
 
+// CheckLicense checks license of single file.
 func CheckLicense(filePath string, license []string) (bool, error) {
 	file, err := os.Open(filePath)
 	if err != nil {
@@ -171,6 +177,7 @@ func CheckLicense(filePath string, license []string) (bool, error) {
 	return true, nil
 }
 
+// printResult prints license check result.
 func printResult(r *Result) {
 	if verbose {
 		for _, s := range r.Success {
diff --git a/main_test.go b/main_test.go
deleted file mode 100644
index 06ab7d0..0000000
--- a/main_test.go
+++ /dev/null
@@ -1 +0,0 @@
-package main


[skywalking-eyes] 16/25: chore: set up GitHub Actions branding information

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 3b734e79697720440381d77fe644607374613694
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Tue Dec 1 23:28:19 2020 +0800

    chore: set up GitHub Actions branding information
---
 action.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/action.yml b/action.yml
index 38207ea..e43035f 100644
--- a/action.yml
+++ b/action.yml
@@ -14,8 +14,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-name: License Checker
+name: License Guard
 description: A tool for checking license headers, which theoretically supports checking all types of files.
+branding:
+  icon: book
+  color: orange
 runs:
   using: docker
   image: Dockerfile


[skywalking-eyes] 17/25: Reshape the header check command

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit a62044de52cc10ae8a1c165b780a2e4265423132
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sun Dec 20 15:58:20 2020 +0800

    Reshape the header check command
---
 .licenserc.json                               |  50 --------
 .licenserc.yaml                               |  21 +++
 cmd/root.go                                   | 177 +++-----------------------
 commands/header/check.go                      |  58 +++++++++
 commands/header/header.go                     |  15 +++
 go.mod                                        |  16 +--
 go.sum                                        |  40 ++----
 internal/logger/log.go                        |  38 ++++++
 main.go                                       |  11 +-
 pkg/header/check.go                           | 124 ++++++++++++++++++
 pkg/header/model.go                           |  12 ++
 {util => pkg/util}/str.go                     |   0
 {util => pkg/util}/str_test.go                |   0
 test/include_test/without_license/testcase.md |  19 +++
 14 files changed, 326 insertions(+), 255 deletions(-)

diff --git a/.licenserc.json b/.licenserc.json
deleted file mode 100644
index a15366c..0000000
--- a/.licenserc.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
-  "licenseStrict": [
-    "Licensed to the Apache Software Foundation (ASF) under one or more",
-    "contributor license agreements.  See the NOTICE file distributed with",
-    "this work for additional information regarding copyright ownership.",
-    "The ASF licenses this file to You 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."
-  ],
-  "licenseLoose": [
-    "Apache License, Version 2.0"
-  ],
-  "targetFiles": [
-    "java",
-    "go",
-    "py",
-    "sh",
-    "graphql",
-    "yaml",
-    "yml"
-  ],
-  "exclude": {
-    "files": [
-      ".gitignore",
-      "NOTICE",
-      "go.mod",
-      "go.sum",
-      ".DS_Store",
-      "LICENSE"
-    ],
-    "extensions": [
-      "md",
-      "xml",
-      "json"
-    ],
-    "directories": [
-      "bin",
-      ".github",
-      ".git",
-      ".idea",
-      "test"
-    ]
-  }
-}
\ No newline at end of file
diff --git a/.licenserc.yaml b/.licenserc.yaml
new file mode 100644
index 0000000..c23a250
--- /dev/null
+++ b/.licenserc.yaml
@@ -0,0 +1,21 @@
+mode: strict
+
+license: >
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+
+paths:
+  - 'test/include_test'
+
+paths-ignore:
+  - '**/*.md'
diff --git a/cmd/root.go b/cmd/root.go
index ef8abdf..68cc5eb 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -16,179 +16,38 @@ limitations under the License.
 package cmd
 
 import (
-	"bufio"
-	"encoding/json"
-	"fmt"
+	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
-	"io/ioutil"
-	"license-checker/util"
-	"os"
-	"path/filepath"
-	"strings"
+	headercommand "license-checker/commands/header"
+	"license-checker/internal/logger"
 )
 
 var (
-	// cfgFile is the path to the config file.
-	cfgFile string
-	// checkPath is the path to check license.
-	checkPath string
-	// loose is flag to enable loose mode.
-	loose bool
-	// verbose is flag to enable verbose mode.
-	verbose bool
+	verbosity string
 )
 
 // rootCmd represents the base command when called without any subcommands
 var rootCmd = &cobra.Command{
-	Use: "license-checker [flags]",
-	Long: `license-checker walks the specified path recursively and checks 
-if the specified files have the license header in the config file.`,
-	Run: func(cmd *cobra.Command, args []string) {
-		config, err := LoadConfig()
-		if err != nil {
-			fmt.Println(err)
-		}
-
-		res, err := WalkAndCheck(checkPath, config)
-		if err != nil {
-			fmt.Println(err)
+	Use:           "license-checker command [flags]",
+	Long:          "license-checker walks the specified path recursively and checks if the specified files have the license header in the config file.",
+	SilenceUsage:  true,
+	SilenceErrors: true,
+	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
+		if level, err := logrus.ParseLevel(verbosity); err != nil {
+			return err
+		} else {
+			logger.Log.SetLevel(level)
 		}
-		printResult(res)
+		return nil
 	},
 }
 
 // Execute sets flags to the root command appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
-func Execute() {
-	rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", ".licenserc.json", "the config file")
-	rootCmd.PersistentFlags().StringVarP(&checkPath, "path", "p", ".", "the path to check")
-	rootCmd.PersistentFlags().BoolVarP(&loose, "loose", "l", false, "loose mode")
-	rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose mode")
-
-	if err := rootCmd.Execute(); err != nil {
-		fmt.Println(err)
-		os.Exit(1)
-	}
-}
-
-type excludeConfig struct {
-	Files       []string `json:"files"`
-	Extensions  []string `json:"extensions"`
-	Directories []string `json:"directories"`
-}
-
-type Config struct {
-	LicenseStrict []string      `json:"licenseStrict"`
-	LicenseLoose  []string      `json:"licenseLoose"`
-	TargetFiles   []string      `json:"targetFiles"`
-	Exclude       excludeConfig `json:"exclude"`
-}
-
-type Result struct {
-	Success []string `json:"success"`
-	Failure []string `json:"failure"`
-}
-
-// LoadConfig reads in config file.
-func LoadConfig() (*Config, error) {
-	var config Config
-	bytes, err := ioutil.ReadFile(cfgFile)
-	if err != nil {
-		return nil, err
-	}
-
-	err = json.Unmarshal(bytes, &config)
-	if err != nil {
-		return nil, err
-	}
-
-	return &config, nil
-}
-
-// WalkAndCheck traverses the path p and check every target file's license.
-func WalkAndCheck(p string, cfg *Config) (*Result, error) {
-	var license []string
-	if loose {
-		license = cfg.LicenseLoose
-	} else {
-		license = cfg.LicenseStrict
-	}
-
-	inExcludeDir := util.InStrSliceMapKeyFunc(cfg.Exclude.Directories)
-	inExcludeExt := util.InStrSliceMapKeyFunc(cfg.Exclude.Extensions)
-	inExcludeFiles := util.InStrSliceMapKeyFunc(cfg.Exclude.Files)
-
-	var result Result
-	err := filepath.Walk(p, func(path string, fi os.FileInfo, err error) error {
-		if err != nil {
-			fmt.Println(err) // can't walk here,
-			return nil       // but continue walking elsewhere
-		}
-
-		if fi.IsDir() {
-			if inExcludeDir(fi.Name()) ||
-				inExcludeDir(util.CleanPathPrefixes(path, []string{p, string(os.PathSeparator)})) {
-				return filepath.SkipDir
-			}
-		} else {
-			ext := util.GetFileExtension(fi.Name())
-			if inExcludeFiles(fi.Name()) || inExcludeExt(ext) {
-				return nil
-			}
-
-			ok, err := CheckLicense(path, license)
-			if err != nil {
-				return err
-			}
-
-			if ok {
-				result.Success = append(result.Success, fmt.Sprintf("[Pass]: %s", path))
-			} else {
-				result.Failure = append(result.Failure, fmt.Sprintf("[No Specified License]: %s", path))
-			}
-		}
-
-		return nil
-	})
-
-	return &result, err
-}
-
-// CheckLicense checks license of single file.
-func CheckLicense(filePath string, license []string) (bool, error) {
-	file, err := os.Open(filePath)
-	if err != nil {
-		return false, err
-	}
-	defer file.Close()
-
-	index := 0
-	scanner := bufio.NewScanner(file)
-	for scanner.Scan() && index < len(license) {
-		line := scanner.Text()
-		if strings.Contains(line, license[index]) {
-			index++
-		}
-	}
-
-	if index != len(license) {
-		return false, nil
-	}
-	return true, nil
-}
-
-// printResult prints license check result.
-func printResult(r *Result) {
-	if verbose {
-		for _, s := range r.Success {
-			fmt.Println(s)
-		}
-	}
+func Execute() error {
+	rootCmd.PersistentFlags().StringVarP(&verbosity, "verbosity", "v", logrus.InfoLevel.String(), "Log level (debug, info, warn, error, fatal, panic")
 
-	for _, s := range r.Failure {
-		fmt.Println(s)
-	}
+	rootCmd.AddCommand(headercommand.Header)
 
-	fmt.Printf("Total check %d files, success: %d, failure: %d\n",
-		len(r.Success)+len(r.Failure), len(r.Success), len(r.Failure))
+	return rootCmd.Execute()
 }
diff --git a/commands/header/check.go b/commands/header/check.go
new file mode 100644
index 0000000..24d316b
--- /dev/null
+++ b/commands/header/check.go
@@ -0,0 +1,58 @@
+package header
+
+import (
+	"github.com/spf13/cobra"
+	"gopkg.in/yaml.v3"
+	"io/ioutil"
+	"license-checker/internal/logger"
+	"license-checker/pkg/header"
+	"strings"
+)
+
+var (
+	// cfgFile is the config path to the config file of header command.
+	cfgFile string
+)
+
+var CheckCommand = &cobra.Command{
+	Use:     "check",
+	Long:    "`check` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
+	Aliases: []string{"c"},
+	RunE: func(cmd *cobra.Command, args []string) error {
+		var config header.Config
+		if err := loadConfig(&config); err != nil {
+			return err
+		}
+		return header.Check(&config)
+	},
+}
+
+func init() {
+	CheckCommand.Flags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
+}
+
+// loadConfig reads and parses the header check configurations in config file.
+func loadConfig(config *header.Config) error {
+	logger.Log.Infoln("Loading configuration from file:", cfgFile)
+
+	bytes, err := ioutil.ReadFile(cfgFile)
+	if err != nil {
+		return err
+	}
+
+	if err = yaml.Unmarshal(bytes, config); err != nil {
+		return err
+	}
+
+	var lines []string
+	for _, line := range strings.Split(config.License, "\n") {
+		if len(line) > 0 {
+			lines = append(lines, strings.Trim(line, header.CommentChars))
+		}
+	}
+	config.License = strings.Join(lines, "\n")
+
+	logger.Log.Infoln("License header is:", config.License)
+
+	return nil
+}
diff --git a/commands/header/header.go b/commands/header/header.go
new file mode 100644
index 0000000..5879a40
--- /dev/null
+++ b/commands/header/header.go
@@ -0,0 +1,15 @@
+package header
+
+import (
+	"github.com/spf13/cobra"
+)
+
+var Header = &cobra.Command{
+	Use:     "header",
+	Long:    "`header` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
+	Aliases: []string{"h"},
+}
+
+func init() {
+	Header.AddCommand(CheckCommand)
+}
diff --git a/go.mod b/go.mod
index ebaf77e..1ac37cf 100644
--- a/go.mod
+++ b/go.mod
@@ -3,18 +3,8 @@ module license-checker
 go 1.13
 
 require (
-	github.com/fsnotify/fsnotify v1.4.9 // indirect
-	github.com/magiconair/properties v1.8.4 // indirect
-	github.com/mitchellh/go-homedir v1.1.0
-	github.com/mitchellh/mapstructure v1.3.3 // indirect
-	github.com/pelletier/go-toml v1.8.1 // indirect
-	github.com/spf13/afero v1.4.1 // indirect
-	github.com/spf13/cast v1.3.1 // indirect
+	github.com/bmatcuk/doublestar/v2 v2.0.4
+	github.com/sirupsen/logrus v1.7.0
 	github.com/spf13/cobra v1.1.1
-	github.com/spf13/jwalterweatherman v1.1.0 // indirect
-	github.com/spf13/viper v1.7.1
-	golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7 // indirect
-	golang.org/x/text v0.3.4 // indirect
-	gopkg.in/ini.v1 v1.62.0 // indirect
-	gopkg.in/yaml.v2 v2.3.0 // indirect
+	gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
 )
diff --git a/go.sum b/go.sum
index cd8c883..fda907d 100644
--- a/go.sum
+++ b/go.sum
@@ -23,6 +23,9 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
 github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
+github.com/bmatcuk/doublestar/v2 v2.0.4 h1:6I6oUiT/sU27eE2OFcWqBhL1SwjyvQuOssxT4a1yidI=
+github.com/bmatcuk/doublestar/v2 v2.0.4/go.mod h1:QMmcs3H2AUQICWhfzLXz+IYln8lRQmTZRptLie8RgRw=
 github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
 github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
@@ -38,8 +41,6 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
 github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
 github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
-github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
-github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
 github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
 github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
@@ -102,15 +103,12 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
 github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
 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/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
 github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
-github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
 github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
 github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
 github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -125,8 +123,6 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
 github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
-github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
 github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@@ -134,11 +130,8 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
 github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
 github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
-github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
-github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@@ -157,36 +150,29 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb
 github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
 github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
 github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
+github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
 github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
 github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
 github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
-github.com/spf13/afero v1.4.1 h1:asw9sl74539yqavKaglDM5hFpdJVK0Y5Dr/JOgQ89nQ=
-github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
 github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
 github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
-github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
-github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
 github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
 github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
 github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
-github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
-github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
 github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
 github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
 github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
-github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
-github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
 github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
 github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -202,7 +188,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
 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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
 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=
@@ -257,16 +242,12 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
 golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7 h1:s330+6z/Ko3J0o6rvOcwXe5nzs7UT9tLKHoOXYn6uE0=
-golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 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 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
-golang.org/x/text v0.3.4/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/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -314,17 +295,14 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
 gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
 gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
 gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
-gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
-gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
 gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
-gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
+gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 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=
diff --git a/internal/logger/log.go b/internal/logger/log.go
new file mode 100644
index 0000000..4803978
--- /dev/null
+++ b/internal/logger/log.go
@@ -0,0 +1,38 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 logger
+
+import (
+	"os"
+
+	"github.com/sirupsen/logrus"
+)
+
+var Log *logrus.Logger
+
+func init() {
+	if Log == nil {
+		Log = logrus.New()
+	}
+	Log.Level = logrus.DebugLevel
+	Log.SetOutput(os.Stdout)
+	Log.SetFormatter(&logrus.TextFormatter{
+		DisableTimestamp:       true,
+		DisableLevelTruncation: true,
+	})
+}
diff --git a/main.go b/main.go
index e9f9be6..3f262a7 100644
--- a/main.go
+++ b/main.go
@@ -15,8 +15,15 @@ limitations under the License.
 */
 package main
 
-import "license-checker/cmd"
+import (
+	"license-checker/cmd"
+	"license-checker/internal/logger"
+	"os"
+)
 
 func main() {
-	cmd.Execute()
+	if err := cmd.Execute(); err != nil {
+		logger.Log.Errorln(err)
+		os.Exit(1)
+	}
 }
diff --git a/pkg/header/check.go b/pkg/header/check.go
new file mode 100644
index 0000000..aef1c8e
--- /dev/null
+++ b/pkg/header/check.go
@@ -0,0 +1,124 @@
+package header
+
+import (
+	"bufio"
+	"fmt"
+	"github.com/bmatcuk/doublestar/v2"
+	"license-checker/internal/logger"
+	"os"
+	"path/filepath"
+	"strings"
+)
+
+const CommentChars = "/*#- "
+
+// Check checks the license headers of the specified paths/globs.
+func Check(config *Config) error {
+	var result Result
+
+	for _, pattern := range config.Paths {
+		if err := checkPattern(pattern, &result, config); err != nil {
+			return err
+		}
+	}
+
+	if len(result.Failure) > 0 {
+		return fmt.Errorf(
+			"The following files don't have a valid license header: \n%v",
+			strings.Join(result.Failure, "\n"),
+		)
+	}
+
+	return nil
+}
+
+func checkPattern(pattern string, result *Result, config *Config) error {
+	paths, err := doublestar.Glob(pattern)
+
+	if err != nil {
+		return err
+	}
+
+	logger.Log.Infoln("Checking matched paths:", paths)
+
+	for _, path := range paths {
+		logger.Log.Debugln("Checking path:", path)
+
+		if err = checkPath(path, result, config); err != nil {
+			return err
+		}
+	}
+
+	return nil
+}
+
+func checkPath(path string, result *Result, config *Config) error {
+	pathInfo, err := os.Stat(path)
+
+	if err != nil {
+		return err
+	}
+
+	switch mode := pathInfo.Mode(); {
+	case mode.IsDir():
+		if err := filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
+			if info.IsDir() {
+				return nil
+			}
+			if err := checkPath(p, result, config); err != nil {
+				return err
+			}
+			return nil
+		}); err != nil {
+			return err
+		}
+	case mode.IsRegular():
+		return checkFile(path, result, config)
+	}
+	return nil
+}
+
+func checkFile(file string, result *Result, config *Config) error {
+	skip := false
+	for _, ignorePattern := range config.PathsIgnore {
+		logger.Log.Debugln("Checking ignore pattern:", ignorePattern)
+
+		if ignored, err := doublestar.Match(ignorePattern, file); ignored || err != nil {
+			logger.Log.Infoln("Ignoring path:", file)
+			skip = ignored
+			break
+		}
+	}
+	if skip {
+		return nil
+	}
+
+	logger.Log.Debugln("Checking file:", file)
+
+	reader, err := os.Open(file)
+
+	if err != nil {
+		return nil
+	}
+
+	var lines []string
+
+	scanner := bufio.NewScanner(reader)
+	for scanner.Scan() {
+		line := strings.Trim(scanner.Text(), CommentChars)
+		if len(line) > 0 {
+			lines = append(lines, line)
+		}
+	}
+
+	if content := strings.Join(lines, " "); !strings.Contains(content, config.License) {
+		logger.Log.Debugln("Content is:", content)
+		logger.Log.Debugln("License is:", config.License)
+
+		result.Failure = append(result.Failure, file)
+	} else {
+		result.Success = append(result.Success, file)
+	}
+
+	return nil
+}
diff --git a/pkg/header/model.go b/pkg/header/model.go
new file mode 100644
index 0000000..8401cae
--- /dev/null
+++ b/pkg/header/model.go
@@ -0,0 +1,12 @@
+package header
+
+type Config struct {
+	License     string   `yaml:"license"`
+	Paths       []string `yaml:"paths"`
+	PathsIgnore []string `yaml:"paths-ignore"`
+}
+
+type Result struct {
+	Success []string `yaml:"success"`
+	Failure []string `yaml:"failure"`
+}
diff --git a/util/str.go b/pkg/util/str.go
similarity index 100%
rename from util/str.go
rename to pkg/util/str.go
diff --git a/util/str_test.go b/pkg/util/str_test.go
similarity index 100%
rename from util/str_test.go
rename to pkg/util/str_test.go
diff --git a/test/include_test/without_license/testcase.md b/test/include_test/without_license/testcase.md
new file mode 100644
index 0000000..95d8ce5
--- /dev/null
+++ b/test/include_test/without_license/testcase.md
@@ -0,0 +1,19 @@
+<!--
+Esse enim dolore adipisicing in cillum eiusmod excepteur quis nisi sit dolor anim anim id id nostrud nostrud tempor.
+ Elit sit enim cillum adipisicing non magna aute nostrud ullamco dolor dolore consequat ut ea occaecat veniam incididunt
+  occaecat consectetur eiusmod sint eiusmod aute eu duis fugiat dolore in laboris enim eiusmod aliquip nisi aliqua irure
+  nulla proident ut ut aliqua et in ad deserunt nisi anim non dolore ut commodo excepteur ut eiusmod ex exercitation
+  in sunt cillum ullamco dolor magna ex proident elit in mollit incididunt excepteur dolor pariatur consectetur
+  exercitation qui ut cupidatat dolor do esse tempor commodo magna ad in duis voluptate est nisi in pariatur
+  duis mollit eiusmod est magna in velit aute anim ullamco nostrud adipisicing cupidatat non fugiat proident
+   commodo minim sint minim pariatur nostrud sit mollit cillum dolor minim quis nisi id officia veniam
+   mollit tempor exercitation dolore duis cillum sunt esse nostrud deserunt amet ad quis reprehenderit
+   do in proident est incididunt voluptate et ullamco nisi dolore commodo mollit elit sint aute in occaecat
+   excepteur do pariatur laborum occaecat ad et nisi ut est in consequat commodo consectetur consequat ullamco m
+   ollit aute dolor velit do deserunt eu velit reprehenderit incididunt commodo duis anim dolor velit nostrud eu
+   irure dolor mollit labore sunt consectetur ullamco sed consectetur sed sint consectetur eu fugiat amet nostrud
+   elit reprehenderit sunt ullamco fugiat eiusmod elit est est in duis quis occaecat proident aliquip adipisicing
+    eu sint pariatur ullamco adipisicing cupidatat sed ut pariatur ut in amet deserunt laboris consectetur in
+    consectetur mollit voluptate magna ut ullamco pariatur proident esse commodo consectetur minim in do eu
+     consequat ea eiusmod proident incididunt ut qui sunt consequat officia amet amet amet dolore fugiat ex.
+-->


[skywalking-eyes] 22/25: Add Java fixing type and reshape the README

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 7d3e66cb46dde51d478049966d448195b77b3437
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 12:30:35 2020 +0800

    Add Java fixing type and reshape the README
---
 .licenserc.yaml                                    |  1 +
 README.adoc                                        | 73 +++++++++++++++++
 README.md                                          | 91 ----------------------
 cmd/root.go                                        |  4 +-
 commands/header/check.go                           |  3 +
 commands/header/fix.go                             |  3 +
 commands/header/header.go                          |  1 +
 pkg/header/check.go                                | 10 ++-
 .../fix/{anglebracket.go => angle_bracket.go}      |  2 +-
 pkg/header/fix/{doubleslash.go => double_slash.go} |  0
 pkg/header/fix/fix.go                              | 13 +++-
 pkg/header/fix/hashtag.go                          | 13 ++--
 .../fix/{doubleslash.go => slash_asterisk.go}      |  6 +-
 pkg/header/result.go                               | 11 +++
 test/.licenserc_for_test.yaml                      | 37 ---------
 .../.licenserc_for_test_check.yaml                 | 14 ++--
 .../.licenserc_for_test_fix.yaml                   | 13 ++--
 test/include_test/with_license/testcase.go         | 25 +++---
 test/include_test/with_license/testcase.graphql    | 28 ++++---
 test/include_test/with_license/testcase.java       | 32 ++++----
 test/include_test/with_license/testcase.py         | 28 ++++---
 test/include_test/with_license/testcase.sh         | 27 ++++---
 test/include_test/with_license/testcase.yaml       | 28 ++++---
 test/include_test/with_license/testcase.yml        | 28 ++++---
 24 files changed, 245 insertions(+), 246 deletions(-)

diff --git a/.licenserc.yaml b/.licenserc.yaml
index d14df0b..b8366ec 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -21,6 +21,7 @@ paths-ignore:
   - '.idea/**'
   - 'bin/**'
   - '**/*.md'
+  - '**/.DS_Store'
   - 'test/**'
   - 'go.mod'
   - 'go.sum'
diff --git a/README.adoc b/README.adoc
new file mode 100644
index 0000000..3174252
--- /dev/null
+++ b/README.adoc
@@ -0,0 +1,73 @@
+= license-checker
+:repo: https://github.com/fgksgf/license-checker
+
+A full-featured license guard to check and fix license headers and dependencies' licenses.
+
+== Install
+
+[subs="attributes+",source,bash]
+----
+git clone {repo}
+cd license-checker
+make
+----
+
+== Usage
+
+[source]
+----
+$ license-checker
+
+A full-featured license guard to check and fix license headers and dependencies' licenses.
+
+Usage:
+  license-checker [command]
+
+Available Commands:
+  header      License header related commands; e.g. check, fix, etc.
+  help        Help about any command
+
+Flags:
+  -h, --help               help for license-checker
+  -v, --verbosity string   log level (debug, info, warn, error, fatal, panic (default "info")
+
+Use "license-checker [command] --help" for more information about a command.
+----
+
+== Configuration
+
+[source,yaml]
+.test/.licenserc_for_test.yaml
+----
+include::test/.licenserc_for_test_check.yaml[]
+----
+
+== Check
+
+[source]
+----
+bin/license-checker -c test/.licenserc_for_test_fix.yaml header check
+
+INFO Loading configuration from file: test/.licenserc_for_test.yaml serc_for_test.yaml
+INFO Totally checked 23 files, valid: 8, invalid: 8, ignored: 7, fixed: 0
+ERROR The following files don't have a valid license header:
+test/include_test/without_license/testcase.go
+test/include_test/without_license/testcase.graphql
+test/include_test/without_license/testcase.java
+test/include_test/without_license/testcase.md
+test/include_test/without_license/testcase.py
+test/include_test/without_license/testcase.sh
+test/include_test/without_license/testcase.yaml
+test/include_test/without_license/testcase.yml
+exit status 1
+----
+
+== Fix
+
+[source]
+----
+bin/license-checker -c test/.licenserc_for_test_fix.yaml header fix
+
+INFO Loading configuration from file: test/.licenserc_for_test_fix.yaml
+INFO Totally checked 16 files, valid: 7, invalid: 8, ignored: 1, fixed: 8
+----
diff --git a/README.md b/README.md
deleted file mode 100644
index d2039c0..0000000
--- a/README.md
+++ /dev/null
@@ -1,91 +0,0 @@
-# license-checker
-
-A CLI tool for checking license headers, which theoretically supports checking all types of files.
-
-## Install
-
-```bash 
-git clone https://github.com/fgksgf/license-checker.git
-cd license-checker
-make
-```
-
-## Usage
-
-```
-Usage: license-checker [flags]
-
-license-checker walks the specified path recursively and checks 
-if the specified files have the license header in the config file.
-
-Usage:
-  license-checker [flags]
-
-Flags:
-  -c, --config string   the config file (default ".licenserc.json")
-  -h, --help            help for license-checker
-  -l, --loose           loose mode
-  -p, --path string     the path to check (default ".")
-  -v, --verbose         verbose mode
-```
-
-## Configuration
-
-```
-{
-  // What to check in strict mode, the order of strings can NOT be changed arbitrarily
-  "licenseStrict": [
-    "Licensed to the Apache Software Foundation (ASF) under one or more",
-    "contributor license agreements.  See the NOTICE file distributed with",
-    "..."
-  ],
-
-  // What to check in loose mode, the order of strings can NOT be changed arbitrarily
-  "licenseLoose": [
-    "Apache License, Version 2.0"
-  ],
-
-  // license-checker will check *.java and *.go
-  "targetFiles": [
-    "java",
-    "go"
-  ],
-
-  "exclude": {
-    // license-checker will NOT check these files
-    "files": [
-      ".gitignore",
-      "NOTICE",
-      "LICENSE"
-    ],
-
-    // license-checker will NOT check files whose names with these extensions
-    "extensions": [
-      "md",
-      "xml",
-      "json"
-    ],
-
-    // license-checker will NOT check these directories
-    "directories": [
-      "bin",
-      ".github"
-    ]
-  }
-}
-```
-
-## Test
-
-```bash
-bin/license-checker -p test -c test/.licenserc_for_test.yaml
-
-[No Specified License]: test/include_test/without_license/testcase.go
-[No Specified License]: test/include_test/without_license/testcase.graphql
-[No Specified License]: test/include_test/without_license/testcase.java
-[No Specified License]: test/include_test/without_license/testcase.py
-[No Specified License]: test/include_test/without_license/testcase.sh
-[No Specified License]: test/include_test/without_license/testcase.yaml
-[No Specified License]: test/include_test/without_license/testcase.yml
-Total check 14 files, success: 7, failure: 7 
-```
diff --git a/cmd/root.go b/cmd/root.go
index e6d4b98..91cb6b6 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -31,7 +31,7 @@ var (
 // rootCmd represents the base command when called without any subcommands
 var rootCmd = &cobra.Command{
 	Use:           "license-checker command [flags]",
-	Long:          "license-checker walks the specified path recursively and checks if the specified files have the license header in the config file.",
+	Long:          "A full-featured license guard to check and fix license headers and dependencies' licenses",
 	SilenceUsage:  true,
 	SilenceErrors: true,
 	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
@@ -47,7 +47,7 @@ var rootCmd = &cobra.Command{
 // Execute sets flags to the root command appropriately.
 // This is called by main.main(). It only needs to happen once to the rootCmd.
 func Execute() error {
-	rootCmd.PersistentFlags().StringVarP(&verbosity, "verbosity", "v", logrus.InfoLevel.String(), "Log level (debug, info, warn, error, fatal, panic")
+	rootCmd.PersistentFlags().StringVarP(&verbosity, "verbosity", "v", logrus.InfoLevel.String(), "log level (debug, info, warn, error, fatal, panic")
 
 	rootCmd.AddCommand(headercommand.Header)
 
diff --git a/commands/header/check.go b/commands/header/check.go
index ef141cc..fc17c53 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -19,6 +19,7 @@ package header
 
 import (
 	"github.com/spf13/cobra"
+	"license-checker/internal/logger"
 	"license-checker/pkg/header"
 )
 
@@ -43,6 +44,8 @@ var CheckCommand = &cobra.Command{
 			return err
 		}
 
+		logger.Log.Infoln(result.String())
+
 		if result.HasFailure() {
 			return result.Error()
 		}
diff --git a/commands/header/fix.go b/commands/header/fix.go
index dc50e65..624a1f0 100644
--- a/commands/header/fix.go
+++ b/commands/header/fix.go
@@ -20,6 +20,7 @@ package header
 import (
 	"fmt"
 	"github.com/spf13/cobra"
+	"license-checker/internal/logger"
 	"license-checker/pkg/header"
 	"license-checker/pkg/header/fix"
 	"strings"
@@ -48,6 +49,8 @@ var FixCommand = &cobra.Command{
 			}
 		}
 
+		logger.Log.Infoln(result.String())
+
 		if len(errors) > 0 {
 			return fmt.Errorf(strings.Join(errors, "\n"))
 		}
diff --git a/commands/header/header.go b/commands/header/header.go
index 86d58da..b9e8612 100644
--- a/commands/header/header.go
+++ b/commands/header/header.go
@@ -23,6 +23,7 @@ import (
 
 var Header = &cobra.Command{
 	Use:     "header",
+	Short:   "License header related commands; e.g. check, fix, etc.",
 	Long:    "`header` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
 	Aliases: []string{"h"},
 }
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 006fc9c..31eb6c7 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -39,6 +39,8 @@ func Check(config *Config, result *Result) error {
 	return nil
 }
 
+var seen = make(map[string]bool)
+
 func checkPattern(pattern string, result *Result, config *Config) error {
 	paths, err := doublestar.Glob(pattern)
 
@@ -48,18 +50,18 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 
 	for _, path := range paths {
 		if yes, err := config.ShouldIgnore(path); yes || err != nil {
+			result.Ignore(path)
 			continue
 		}
 		if err = checkPath(path, result, config); err != nil {
 			return err
 		}
+		seen[path] = true
 	}
 
 	return nil
 }
 
-var seen = make(map[string]bool)
-
 func checkPath(path string, result *Result, config *Config) error {
 	defer func() { seen[path] = true }()
 
@@ -95,6 +97,9 @@ func checkPath(path string, result *Result, config *Config) error {
 // CheckFile checks whether or not the file contains the configured license header.
 func CheckFile(file string, config *Config, result *Result) error {
 	if yes, err := config.ShouldIgnore(file); yes || err != nil {
+		if !seen[file] {
+			result.Ignore(file)
+		}
 		return err
 	}
 
@@ -118,7 +123,6 @@ func CheckFile(file string, config *Config, result *Result) error {
 
 	if content := strings.Join(lines, " "); !strings.Contains(content, config.NormalizedLicense()) {
 		logger.Log.Debugln("Content is:", content)
-		logger.Log.Debugln("License is:", config.License)
 
 		result.Fail(file)
 	} else {
diff --git a/pkg/header/fix/anglebracket.go b/pkg/header/fix/angle_bracket.go
similarity index 93%
rename from pkg/header/fix/anglebracket.go
rename to pkg/header/fix/angle_bracket.go
index e027536..ac31302 100644
--- a/pkg/header/fix/anglebracket.go
+++ b/pkg/header/fix/angle_bracket.go
@@ -38,7 +38,7 @@ func AngleBracket(file string, config *header.Config, result *header.Result) err
 		return err
 	}
 
-	if !reflect.DeepEqual(content[0:5], []byte("<?xml")) { // doesn't contains xml declaration
+	if len(content) > 5 && !reflect.DeepEqual(content[0:5], []byte("<?xml")) { // doesn't contains xml declaration
 		lines := "<!--\n  ~ " + strings.Join(strings.Split(config.License, "\n"), "\n  ~ ") + "\n-->\n"
 
 		if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
diff --git a/pkg/header/fix/doubleslash.go b/pkg/header/fix/double_slash.go
similarity index 100%
copy from pkg/header/fix/doubleslash.go
copy to pkg/header/fix/double_slash.go
diff --git a/pkg/header/fix/fix.go b/pkg/header/fix/fix.go
index 48b3c47..bba4df0 100644
--- a/pkg/header/fix/fix.go
+++ b/pkg/header/fix/fix.go
@@ -25,13 +25,20 @@ import (
 )
 
 var suffixToFunc = map[string]func(string, *header.Config, *header.Result) error{
-	".go":        DoubleSlash,
+	".go": DoubleSlash,
+
+	".py":        Hashtag, // TODO: tackle shebang
+	".sh":        Hashtag, // TODO: tackle shebang
 	".yml":       Hashtag,
 	".yaml":      Hashtag,
-	"Dockerfile": Hashtag,
+	".graphql":   Hashtag,
 	"Makefile":   Hashtag,
+	"Dockerfile": Hashtag,
 	".gitignore": Hashtag,
-	".md":        AngleBracket,
+
+	".md": AngleBracket,
+
+	".java": SlashAsterisk,
 }
 
 // Fix adds the configured license header to the given file.
diff --git a/pkg/header/fix/hashtag.go b/pkg/header/fix/hashtag.go
index 761acc8..601da4b 100644
--- a/pkg/header/fix/hashtag.go
+++ b/pkg/header/fix/hashtag.go
@@ -21,6 +21,7 @@ import (
 	"io/ioutil"
 	"license-checker/pkg/header"
 	"os"
+	"reflect"
 	"strings"
 )
 
@@ -36,13 +37,15 @@ func Hashtag(file string, config *header.Config, result *header.Result) error {
 		return err
 	}
 
-	lines := "# " + strings.Join(strings.Split(config.License, "\n"), "\n# ") + "\n"
+	if len(content) >= 3 && !reflect.DeepEqual(content[0:3], []byte("#! ")) || len(content) < 3 { // doesn't contains shebang
+		lines := "# " + strings.Join(strings.Split(config.License, "\n"), "\n# ") + "\n"
 
-	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
-		return err
-	}
+		if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+			return err
+		}
 
-	result.Fix(file)
+		result.Fix(file)
+	}
 
 	return nil
 }
diff --git a/pkg/header/fix/doubleslash.go b/pkg/header/fix/slash_asterisk.go
similarity index 81%
rename from pkg/header/fix/doubleslash.go
rename to pkg/header/fix/slash_asterisk.go
index ab2819a..adbf4e8 100644
--- a/pkg/header/fix/doubleslash.go
+++ b/pkg/header/fix/slash_asterisk.go
@@ -24,8 +24,8 @@ import (
 	"strings"
 )
 
-// DoubleSlash adds the configured license header to files whose comment starts with //.
-func DoubleSlash(file string, config *header.Config, result *header.Result) error {
+// SlashAsterisk adds the configured license header to files whose comment starts with /**.
+func SlashAsterisk(file string, config *header.Config, result *header.Result) error {
 	stat, err := os.Stat(file)
 	if err != nil {
 		return err
@@ -36,7 +36,7 @@ func DoubleSlash(file string, config *header.Config, result *header.Result) erro
 		return err
 	}
 
-	lines := "// " + strings.Join(strings.Split(config.License, "\n"), "\n// ") + "\n"
+	lines := "/*\n * " + strings.Join(strings.Split(config.License, "\n"), "\n * ") + "\n */\n"
 
 	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
 		return err
diff --git a/pkg/header/result.go b/pkg/header/result.go
index e979154..ea17fb6 100644
--- a/pkg/header/result.go
+++ b/pkg/header/result.go
@@ -55,3 +55,14 @@ func (result *Result) Error() error {
 		strings.Join(result.Failure, "\n"),
 	)
 }
+
+func (result *Result) String() string {
+	return fmt.Sprintf(
+		"Totally checked %d files, valid: %d, invalid: %d, ignored: %d, fixed: %d",
+		len(result.Success)+len(result.Failure)+len(result.Ignored),
+		len(result.Success),
+		len(result.Failure),
+		len(result.Ignored),
+		len(result.Fixed),
+	)
+}
diff --git a/test/.licenserc_for_test.yaml b/test/.licenserc_for_test.yaml
deleted file mode 100644
index bc6d434..0000000
--- a/test/.licenserc_for_test.yaml
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# 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.
-
-license: >-
-  Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-  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.
-
-paths:
-  - 'test/include_test'
-
-paths-ignore:
-  - '.git/**/*'
-  - '**/*.md'
-  - '**/.DS_Store'
-  - 'exclude_test/**/*'
diff --git a/.licenserc.yaml b/test/.licenserc_for_test_check.yaml
similarity index 89%
copy from .licenserc.yaml
copy to test/.licenserc_for_test_check.yaml
index d14df0b..b4c1eb8 100644
--- a/.licenserc.yaml
+++ b/test/.licenserc_for_test_check.yaml
@@ -16,12 +16,10 @@ license: |
   specific language governing permissions and limitations
   under the License.
 
-paths-ignore:
-  - '.git/**'
-  - '.idea/**'
-  - 'bin/**'
-  - '**/*.md'
+paths:
   - 'test/**'
-  - 'go.mod'
-  - 'go.sum'
-  - 'LICENSE'
+
+paths-ignore:
+  - '**/.DS_Store'
+  - '**/.json'
+  - '**/exclude_test/**'
diff --git a/.licenserc.yaml b/test/.licenserc_for_test_fix.yaml
similarity index 88%
copy from .licenserc.yaml
copy to test/.licenserc_for_test_fix.yaml
index d14df0b..27d3087 100644
--- a/.licenserc.yaml
+++ b/test/.licenserc_for_test_fix.yaml
@@ -16,12 +16,9 @@ license: |
   specific language governing permissions and limitations
   under the License.
 
+paths:
+  - 'test/include_test/**'
+
 paths-ignore:
-  - '.git/**'
-  - '.idea/**'
-  - 'bin/**'
-  - '**/*.md'
-  - 'test/**'
-  - 'go.mod'
-  - 'go.sum'
-  - 'LICENSE'
+  - '**/.DS_Store'
+  - '**/.json'
diff --git a/test/include_test/with_license/testcase.go b/test/include_test/with_license/testcase.go
index a32a9c8..0f54b96 100644
--- a/test/include_test/with_license/testcase.go
+++ b/test/include_test/with_license/testcase.go
@@ -1,15 +1,18 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 with_license
diff --git a/test/include_test/with_license/testcase.graphql b/test/include_test/with_license/testcase.graphql
index d1d7d28..b34560e 100644
--- a/test/include_test/with_license/testcase.graphql
+++ b/test/include_test/with_license/testcase.graphql
@@ -1,13 +1,17 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+# 
+#     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.
+# 
diff --git a/test/include_test/with_license/testcase.java b/test/include_test/with_license/testcase.java
index 651fadd..a388cbc 100644
--- a/test/include_test/with_license/testcase.java
+++ b/test/include_test/with_license/testcase.java
@@ -1,14 +1,18 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// 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.
-
+/**
+ * Licensed to Apache Software Foundation (ASF) under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+ */
diff --git a/test/include_test/with_license/testcase.py b/test/include_test/with_license/testcase.py
index d1d7d28..b34560e 100644
--- a/test/include_test/with_license/testcase.py
+++ b/test/include_test/with_license/testcase.py
@@ -1,13 +1,17 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+# 
+#     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.
+# 
diff --git a/test/include_test/with_license/testcase.sh b/test/include_test/with_license/testcase.sh
index 69d2c0c..572342e 100644
--- a/test/include_test/with_license/testcase.sh
+++ b/test/include_test/with_license/testcase.sh
@@ -1,15 +1,18 @@
-# /bin/bash
-
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+#! /bin/bash
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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
+#     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.
 #
-# 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.
diff --git a/test/include_test/with_license/testcase.yaml b/test/include_test/with_license/testcase.yaml
index d1d7d28..b34560e 100644
--- a/test/include_test/with_license/testcase.yaml
+++ b/test/include_test/with_license/testcase.yaml
@@ -1,13 +1,17 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+# 
+#     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.
+# 
diff --git a/test/include_test/with_license/testcase.yml b/test/include_test/with_license/testcase.yml
index d1d7d28..b34560e 100644
--- a/test/include_test/with_license/testcase.yml
+++ b/test/include_test/with_license/testcase.yml
@@ -1,13 +1,17 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+# 
+#     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.
+# 


[skywalking-eyes] 20/25: Add `fix` command to fix license header

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit ea1f818097d8b35025f8208cd372ffb03e375352
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 10:10:32 2020 +0800

    Add `fix` command to fix license header
---
 .licenserc.yaml                      |  2 +-
 commands/header/check.go             |  4 ---
 commands/header/{check.go => fix.go} | 33 +++++++++++------------
 commands/header/header.go            |  2 ++
 go.sum                               |  8 +++++-
 main.go                              | 29 ++++++++++----------
 pkg/header/check.go                  | 18 ++++++-------
 pkg/header/config.go                 |  2 +-
 pkg/header/fix/go.go                 | 51 ++++++++++++++++++++++++++++++++++++
 pkg/header/result.go                 |  5 ++++
 10 files changed, 106 insertions(+), 48 deletions(-)

diff --git a/.licenserc.yaml b/.licenserc.yaml
index dff9cb9..14b125c 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -1,4 +1,4 @@
-license: >-
+license: |
   Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 
   Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/commands/header/check.go b/commands/header/check.go
index 9668894..3c3a39d 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -47,7 +47,3 @@ var CheckCommand = &cobra.Command{
 		return nil
 	},
 }
-
-func init() {
-	CheckCommand.Flags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
-}
diff --git a/commands/header/check.go b/commands/header/fix.go
similarity index 61%
copy from commands/header/check.go
copy to commands/header/fix.go
index 9668894..7a14789 100644
--- a/commands/header/check.go
+++ b/commands/header/fix.go
@@ -4,30 +4,28 @@
 // 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
+//     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 header
 
 import (
 	"github.com/spf13/cobra"
+	"license-checker/internal/logger"
 	"license-checker/pkg/header"
+	"license-checker/pkg/header/fix"
+	"strings"
 )
 
-var (
-	// cfgFile is the config path to the config file of header command.
-	cfgFile string
-)
-
-var CheckCommand = &cobra.Command{
-	Use:     "check",
-	Long:    "`check` command walks the specified paths recursively and checks if the specified files have the license header in the config file.",
-	Aliases: []string{"c"},
+var FixCommand = &cobra.Command{
+	Use:     "fix",
+	Aliases: []string{"f"},
+	Long:    "`fix` command walks the specified paths recursively and fix the license header if the specified files don't have the license header in the config file.",
 	RunE: func(cmd *cobra.Command, args []string) error {
 		var config header.Config
 		var result header.Result
@@ -40,14 +38,15 @@ var CheckCommand = &cobra.Command{
 			return err
 		}
 
-		if result.HasFailure() {
-			return result.Error()
+		for _, file := range result.Failure {
+			if strings.HasSuffix(file, ".go") {
+				logger.Log.Infoln("Fixing file:", file)
+				if err := fix.GoLang(file, &config, &result); err != nil {
+					return err
+				}
+			}
 		}
 
 		return nil
 	},
 }
-
-func init() {
-	CheckCommand.Flags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
-}
diff --git a/commands/header/header.go b/commands/header/header.go
index d6cb659..baa65b6 100644
--- a/commands/header/header.go
+++ b/commands/header/header.go
@@ -25,5 +25,7 @@ var Header = &cobra.Command{
 }
 
 func init() {
+	Header.PersistentFlags().StringVarP(&cfgFile, "config", "c", ".licenserc.yaml", "the config file")
 	Header.AddCommand(CheckCommand)
+	Header.AddCommand(FixCommand)
 }
diff --git a/go.sum b/go.sum
index fda907d..40b819b 100644
--- a/go.sum
+++ b/go.sum
@@ -23,7 +23,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
 github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
 github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
-github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
 github.com/bmatcuk/doublestar/v2 v2.0.4 h1:6I6oUiT/sU27eE2OFcWqBhL1SwjyvQuOssxT4a1yidI=
 github.com/bmatcuk/doublestar/v2 v2.0.4/go.mod h1:QMmcs3H2AUQICWhfzLXz+IYln8lRQmTZRptLie8RgRw=
 github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
@@ -35,6 +34,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
 github.com/cpuguy83/go-md2man/v2 v2.0.0/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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
 github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
@@ -104,8 +104,10 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
 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 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
 github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
 github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
 github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@@ -132,6 +134,7 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
 github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
@@ -172,6 +175,7 @@ github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
 github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
 github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
@@ -266,6 +270,7 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
 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-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
 golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
@@ -291,6 +296,7 @@ google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiq
 google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
 gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
 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/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
diff --git a/main.go b/main.go
index 3f262a7..9025a0d 100644
--- a/main.go
+++ b/main.go
@@ -1,18 +1,17 @@
-/*
-Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-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.
-*/
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 main
 
 import (
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 9f1cf62..32776e3 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -55,8 +55,12 @@ func checkPattern(pattern string, result *Result, config *Config) error {
 	return nil
 }
 
+var seen = make(map[string]bool)
+
 func checkPath(path string, result *Result, config *Config) error {
-	if yes, err := config.ShouldIgnore(path); yes || err != nil {
+	defer func() { seen[path] = true }()
+
+	if yes, err := config.ShouldIgnore(path); yes || seen[path] || err != nil {
 		return err
 	}
 
@@ -80,21 +84,17 @@ func checkPath(path string, result *Result, config *Config) error {
 			return err
 		}
 	case mode.IsRegular():
-		return checkFile(path, result, config)
+		return CheckFile(path, config, result)
 	}
 	return nil
 }
 
-var seen = make(map[string]bool)
-
-func checkFile(file string, result *Result, config *Config) error {
-	if yes, err := config.ShouldIgnore(file); yes || seen[file] || err != nil {
-		seen[file] = true
+// CheckFile checks whether or not the file contains the configured license header.
+func CheckFile(file string, config *Config, result *Result) error {
+	if yes, err := config.ShouldIgnore(file); yes || err != nil {
 		return err
 	}
 
-	seen[file] = true
-
 	logger.Log.Debugln("Checking file:", file)
 
 	reader, err := os.Open(file)
diff --git a/pkg/header/config.go b/pkg/header/config.go
index 7ff1371..97a9e2b 100644
--- a/pkg/header/config.go
+++ b/pkg/header/config.go
@@ -50,7 +50,7 @@ func (config *Config) Parse(file string) error {
 		return err
 	}
 
-	logger.Log.Infoln("License header is:", config.NormalizedLicense())
+	logger.Log.Debugln("License header is:", config.NormalizedLicense())
 
 	if len(config.Paths) == 0 {
 		config.Paths = []string{"**"}
diff --git a/pkg/header/fix/go.go b/pkg/header/fix/go.go
new file mode 100644
index 0000000..c0b5eac
--- /dev/null
+++ b/pkg/header/fix/go.go
@@ -0,0 +1,51 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 fix
+
+import (
+	"io/ioutil"
+	"license-checker/internal/logger"
+	"license-checker/pkg/header"
+	"os"
+	"strings"
+)
+
+func GoLang(file string, config *header.Config, result *header.Result) error {
+	var r header.Result
+	if err := header.CheckFile(file, config, &r); err != nil || !r.HasFailure() {
+		logger.Log.Warnln("Try to fix a valid file, returning:", file)
+		return err
+	}
+
+	stat, err := os.Stat(file)
+	if err != nil {
+		return err
+	}
+
+	content, err := ioutil.ReadFile(file)
+	if err != nil {
+		return err
+	}
+
+	lines := "// " + strings.Join(strings.Split(config.License, "\n"), "\n// ") + "\n"
+
+	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+		return err
+	}
+
+	result.Fix(file)
+
+	return nil
+}
diff --git a/pkg/header/result.go b/pkg/header/result.go
index c79ce9c..ac35d63 100644
--- a/pkg/header/result.go
+++ b/pkg/header/result.go
@@ -23,6 +23,7 @@ type Result struct {
 	Success []string
 	Failure []string
 	Ignored []string
+	Fixed   []string
 }
 
 func (result *Result) Fail(file string) {
@@ -37,6 +38,10 @@ func (result *Result) Ignore(file string) {
 	result.Ignored = append(result.Ignored, file)
 }
 
+func (result *Result) Fix(file string) {
+	result.Fixed = append(result.Fixed, file)
+}
+
 func (result *Result) HasFailure() bool {
 	return len(result.Failure) > 0
 }


[skywalking-eyes] 21/25: Add more supported fixing filetypes and update license

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 7a4704257468abb2d2bc34f22301ba3ea4b07ffa
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 11:08:39 2020 +0800

    Add more supported fixing filetypes and update license
---
 .github/workflows/build.yaml   | 29 ++++++++++++----------
 .gitignore                     | 29 ++++++++++++----------
 .licenserc.yaml                | 22 ++++++++++-------
 Dockerfile                     | 29 ++++++++++++----------
 Makefile                       | 29 ++++++++++++----------
 action.yml                     | 29 ++++++++++++----------
 cmd/root.go                    | 33 +++++++++++++------------
 commands/header/check.go       | 25 ++++++++++---------
 commands/header/fix.go         | 35 +++++++++++++++------------
 commands/header/header.go      | 25 ++++++++++---------
 internal/logger/log.go         | 25 ++++++++++---------
 main.go                        | 21 +++++++++-------
 pkg/header/check.go            | 27 ++++++++++++---------
 pkg/header/config.go           | 25 ++++++++++---------
 pkg/header/fix/anglebracket.go | 55 ++++++++++++++++++++++++++++++++++++++++++
 pkg/header/fix/doubleslash.go  | 48 ++++++++++++++++++++++++++++++++++++
 pkg/header/fix/fix.go          | 52 +++++++++++++++++++++++++++++++++++++++
 pkg/header/fix/go.go           | 51 ---------------------------------------
 pkg/header/fix/hashtag.go      | 48 ++++++++++++++++++++++++++++++++++++
 pkg/header/result.go           | 25 ++++++++++---------
 20 files changed, 430 insertions(+), 232 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 55f216f..1fa632a 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -1,17 +1,20 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
-
+# 
+#     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.
+# 
 name: Build
 
 on:
diff --git a/.gitignore b/.gitignore
index 1bbee36..b4c85e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,16 +1,19 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
-
+# 
+#     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.
+# 
 .idea/
 bin/
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 14b125c..d14df0b 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -1,21 +1,25 @@
 license: |
-  Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
+  Licensed to Apache Software Foundation (ASF) under one or more contributor
+  license agreements. See the NOTICE file distributed with
+  this work for additional information regarding copyright
+  ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+  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.
 
 paths-ignore:
   - '.git/**'
   - '.idea/**'
+  - 'bin/**'
   - '**/*.md'
   - 'test/**'
   - 'go.mod'
diff --git a/Dockerfile b/Dockerfile
index 602de2d..a466f44 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,17 +1,20 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
-
+# 
+#     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.
+# 
 FROM golang:1.14.3-alpine AS build
 
 WORKDIR /src
diff --git a/Makefile b/Makefile
index 6220eba..e2a933a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,20 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
-
+# 
+#     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.
+# 
 PROJECT = license-checker
 VERSION ?= latest
 OUT_DIR = bin
diff --git a/action.yml b/action.yml
index f9773c5..bcdf432 100644
--- a/action.yml
+++ b/action.yml
@@ -1,17 +1,20 @@
-# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you 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.
-
+# 
+#     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.
+# 
 name: License Guard
 description: A tool for checking license headers, which theoretically supports checking all types of files.
 branding:
diff --git a/cmd/root.go b/cmd/root.go
index 93a195e..e6d4b98 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -1,19 +1,20 @@
-/*
-Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-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.
-*/
-
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 cmd
 
 import (
diff --git a/commands/header/check.go b/commands/header/check.go
index 3c3a39d..ef141cc 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 header
 
 import (
diff --git a/commands/header/fix.go b/commands/header/fix.go
index 7a14789..dc50e65 100644
--- a/commands/header/fix.go
+++ b/commands/header/fix.go
@@ -1,22 +1,25 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+// 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 header
 
 import (
+	"fmt"
 	"github.com/spf13/cobra"
-	"license-checker/internal/logger"
 	"license-checker/pkg/header"
 	"license-checker/pkg/header/fix"
 	"strings"
@@ -38,15 +41,17 @@ var FixCommand = &cobra.Command{
 			return err
 		}
 
+		var errors []string
 		for _, file := range result.Failure {
-			if strings.HasSuffix(file, ".go") {
-				logger.Log.Infoln("Fixing file:", file)
-				if err := fix.GoLang(file, &config, &result); err != nil {
-					return err
-				}
+			if err := fix.Fix(file, &config, &result); err != nil {
+				errors = append(errors, err.Error())
 			}
 		}
 
+		if len(errors) > 0 {
+			return fmt.Errorf(strings.Join(errors, "\n"))
+		}
+
 		return nil
 	},
 }
diff --git a/commands/header/header.go b/commands/header/header.go
index baa65b6..86d58da 100644
--- a/commands/header/header.go
+++ b/commands/header/header.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 header
 
 import (
diff --git a/internal/logger/log.go b/internal/logger/log.go
index 602437b..7fc102e 100644
--- a/internal/logger/log.go
+++ b/internal/logger/log.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 logger
 
 import (
diff --git a/main.go b/main.go
index 9025a0d..b2f1453 100644
--- a/main.go
+++ b/main.go
@@ -1,16 +1,19 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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.
+// 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 main
 
diff --git a/pkg/header/check.go b/pkg/header/check.go
index 32776e3..006fc9c 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 header
 
 import (
@@ -23,7 +26,7 @@ import (
 	"strings"
 )
 
-const CommentChars = "/*#- !"
+const CommentChars = "/*#- !~"
 
 // Check checks the license headers of the specified paths/globs.
 func Check(config *Config, result *Result) error {
diff --git a/pkg/header/config.go b/pkg/header/config.go
index 97a9e2b..f3629d1 100644
--- a/pkg/header/config.go
+++ b/pkg/header/config.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 header
 
 import (
diff --git a/pkg/header/fix/anglebracket.go b/pkg/header/fix/anglebracket.go
new file mode 100644
index 0000000..e027536
--- /dev/null
+++ b/pkg/header/fix/anglebracket.go
@@ -0,0 +1,55 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 fix
+
+import (
+	"fmt"
+	"io/ioutil"
+	"license-checker/pkg/header"
+	"os"
+	"reflect"
+	"strings"
+)
+
+// AngleBracket adds the configured license header to files whose comment starts with <!--.
+func AngleBracket(file string, config *header.Config, result *header.Result) error {
+	stat, err := os.Stat(file)
+	if err != nil {
+		return err
+	}
+
+	content, err := ioutil.ReadFile(file)
+	if err != nil {
+		return err
+	}
+
+	if !reflect.DeepEqual(content[0:5], []byte("<?xml")) { // doesn't contains xml declaration
+		lines := "<!--\n  ~ " + strings.Join(strings.Split(config.License, "\n"), "\n  ~ ") + "\n-->\n"
+
+		if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+			return err
+		}
+
+		result.Fix(file)
+	} else {
+		// TODO: tackle with the "xml declaration"
+		return fmt.Errorf("xml with xml declaration is not supported yet")
+	}
+
+	return nil
+}
diff --git a/pkg/header/fix/doubleslash.go b/pkg/header/fix/doubleslash.go
new file mode 100644
index 0000000..ab2819a
--- /dev/null
+++ b/pkg/header/fix/doubleslash.go
@@ -0,0 +1,48 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 fix
+
+import (
+	"io/ioutil"
+	"license-checker/pkg/header"
+	"os"
+	"strings"
+)
+
+// DoubleSlash adds the configured license header to files whose comment starts with //.
+func DoubleSlash(file string, config *header.Config, result *header.Result) error {
+	stat, err := os.Stat(file)
+	if err != nil {
+		return err
+	}
+
+	content, err := ioutil.ReadFile(file)
+	if err != nil {
+		return err
+	}
+
+	lines := "// " + strings.Join(strings.Split(config.License, "\n"), "\n// ") + "\n"
+
+	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+		return err
+	}
+
+	result.Fix(file)
+
+	return nil
+}
diff --git a/pkg/header/fix/fix.go b/pkg/header/fix/fix.go
new file mode 100644
index 0000000..48b3c47
--- /dev/null
+++ b/pkg/header/fix/fix.go
@@ -0,0 +1,52 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 fix
+
+import (
+	"fmt"
+	"license-checker/internal/logger"
+	"license-checker/pkg/header"
+	"strings"
+)
+
+var suffixToFunc = map[string]func(string, *header.Config, *header.Result) error{
+	".go":        DoubleSlash,
+	".yml":       Hashtag,
+	".yaml":      Hashtag,
+	"Dockerfile": Hashtag,
+	"Makefile":   Hashtag,
+	".gitignore": Hashtag,
+	".md":        AngleBracket,
+}
+
+// Fix adds the configured license header to the given file.
+func Fix(file string, config *header.Config, result *header.Result) error {
+	var r header.Result
+	if err := header.CheckFile(file, config, &r); err != nil || !r.HasFailure() {
+		logger.Log.Warnln("Try to fix a valid file, returning:", file)
+		return err
+	}
+
+	for suffix, fixFunc := range suffixToFunc {
+		if strings.HasSuffix(file, suffix) {
+			return fixFunc(file, config, result)
+		}
+	}
+
+	return fmt.Errorf("file type is unsupported yet: %v", file)
+}
diff --git a/pkg/header/fix/go.go b/pkg/header/fix/go.go
deleted file mode 100644
index c0b5eac..0000000
--- a/pkg/header/fix/go.go
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// 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 fix
-
-import (
-	"io/ioutil"
-	"license-checker/internal/logger"
-	"license-checker/pkg/header"
-	"os"
-	"strings"
-)
-
-func GoLang(file string, config *header.Config, result *header.Result) error {
-	var r header.Result
-	if err := header.CheckFile(file, config, &r); err != nil || !r.HasFailure() {
-		logger.Log.Warnln("Try to fix a valid file, returning:", file)
-		return err
-	}
-
-	stat, err := os.Stat(file)
-	if err != nil {
-		return err
-	}
-
-	content, err := ioutil.ReadFile(file)
-	if err != nil {
-		return err
-	}
-
-	lines := "// " + strings.Join(strings.Split(config.License, "\n"), "\n// ") + "\n"
-
-	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
-		return err
-	}
-
-	result.Fix(file)
-
-	return nil
-}
diff --git a/pkg/header/fix/hashtag.go b/pkg/header/fix/hashtag.go
new file mode 100644
index 0000000..761acc8
--- /dev/null
+++ b/pkg/header/fix/hashtag.go
@@ -0,0 +1,48 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 fix
+
+import (
+	"io/ioutil"
+	"license-checker/pkg/header"
+	"os"
+	"strings"
+)
+
+// Hashtag adds the configured license header to the files whose comment starts with #.
+func Hashtag(file string, config *header.Config, result *header.Result) error {
+	stat, err := os.Stat(file)
+	if err != nil {
+		return err
+	}
+
+	content, err := ioutil.ReadFile(file)
+	if err != nil {
+		return err
+	}
+
+	lines := "# " + strings.Join(strings.Split(config.License, "\n"), "\n# ") + "\n"
+
+	if err := ioutil.WriteFile(file, append([]byte(lines), content...), stat.Mode()); err != nil {
+		return err
+	}
+
+	result.Fix(file)
+
+	return nil
+}
diff --git a/pkg/header/result.go b/pkg/header/result.go
index ac35d63..e979154 100644
--- a/pkg/header/result.go
+++ b/pkg/header/result.go
@@ -1,17 +1,20 @@
-// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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
+//     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.
 //
-// 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 header
 
 import (


[skywalking-eyes] 12/25: Merge pull request #1 from kezhenxu94/fix

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 0841c46fd76333c49d59a3311e965b6bdbbea69a
Merge: cbb27a7 b3bff69
Author: Hoshea Jiang <fg...@gmail.com>
AuthorDate: Tue Dec 1 21:28:23 2020 +0800

    Merge pull request #1 from kezhenxu94/fix
    
    bugfix: cannot build

 Makefile | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)


[skywalking-eyes] 14/25: Merge pull request #2 from kezhenxu94/master

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 94847dc3923ddda1a61771a636d6e91eee5c792b
Merge: 0841c46 a4c1cdc
Author: Hoshea Jiang <fg...@gmail.com>
AuthorDate: Tue Dec 1 21:48:49 2020 +0800

    Merge pull request #2 from kezhenxu94/master
    
    chore: set up GitHub Actions to verify build from sources

 .github/workflows/build.yaml | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)


[skywalking-eyes] 18/25: Fix license header and setup self checker (#3)

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 0ca8fae12cd6a2a0540a6870c094542e16382d45
Author: Zhenxu Ke <ke...@163.com>
AuthorDate: Sun Dec 20 16:37:00 2020 +0800

    Fix license header and setup self checker (#3)
---
 .github/workflows/build.yaml                    |  17 ++--
 .gitignore                                      |  16 +++-
 .licenserc.yaml                                 |  26 +++---
 Dockerfile                                      |  16 ++--
 Makefile                                        |   8 +-
 README.md                                       |   2 +-
 action.yml                                      |  14 ++-
 cmd/root.go                                     |   1 +
 commands/header/check.go                        |  20 ++++-
 commands/header/header.go                       |  14 +++
 internal/logger/log.go                          |  24 +++--
 pkg/header/check.go                             |  14 +++
 pkg/header/model.go                             |  14 +++
 pkg/util/str.go                                 |  53 -----------
 pkg/util/str_test.go                            | 113 ------------------------
 test/.licenserc_for_test.json                   |  41 ---------
 test/.licenserc_for_test.yaml                   |  37 ++++++++
 test/include_test/with_license/testcase.go      |  29 +++---
 test/include_test/with_license/testcase.graphql |  13 ++-
 test/include_test/with_license/testcase.java    |  14 +--
 test/include_test/with_license/testcase.py      |  13 ++-
 test/include_test/with_license/testcase.sh      |  13 ++-
 test/include_test/with_license/testcase.yaml    |  15 ++--
 test/include_test/with_license/testcase.yml     |  13 ++-
 24 files changed, 210 insertions(+), 330 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 74f7320..55f216f 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -1,12 +1,10 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+# 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,
@@ -33,5 +31,8 @@ jobs:
 
       - uses: actions/checkout@v2
 
+      - name: Selfcheck License
+        run: make license
+
       - name: Build
         run: make build
diff --git a/.gitignore b/.gitignore
index 8741f5d..1bbee36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,16 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+#
+# 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.
+
 .idea/
-bin/
\ No newline at end of file
+bin/
diff --git a/.licenserc.yaml b/.licenserc.yaml
index c23a250..dff9cb9 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -1,21 +1,23 @@
-mode: strict
+license: >-
+  Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+
+  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
 
-license: >
-  Licensed to the Apache Software Foundation (ASF) under one or more
-  contributor license agreements.  See the NOTICE file distributed with
-  this work for additional information regarding copyright ownership.
-  The ASF licenses this file to You 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.
 
-paths:
-  - 'test/include_test'
-
 paths-ignore:
+  - '.git/**'
+  - '.idea/**'
   - '**/*.md'
+  - 'test/**'
+  - 'go.mod'
+  - 'go.sum'
+  - 'LICENSE'
diff --git a/Dockerfile b/Dockerfile
index 1205638..602de2d 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,12 +1,10 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+# 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,
@@ -28,4 +26,4 @@ COPY --from=build /bin/license-checker /bin/license-checker
 
 WORKDIR /github/workspace/
 
-ENTRYPOINT /bin/license-checker
+ENTRYPOINT /bin/license-checker header check -v debug
diff --git a/Makefile b/Makefile
index 133f4d7..6220eba 100644
--- a/Makefile
+++ b/Makefile
@@ -25,13 +25,11 @@ GO_BUILD = $(GO) build
 GO_GET = $(GO) get
 GO_TEST = $(GO) test
 GO_LINT = $(GO_PATH)/bin/golangci-lint
-GO_LICENSER = $(GO_PATH)/bin/go-licenser
 
 all: clean deps lint test build
 
 tools:
 	mkdir -p $(GO_PATH)/bin
-	#$(GO_LICENSER) -version || GO111MODULE=off $(GO_GET) -u github.com/elastic/go-licenser
 
 deps: tools
 	$(GO_GET) -v -t -d ./...
@@ -51,9 +49,9 @@ test: clean lint
 build: deps
 	$(GO_BUILD) -o $(OUT_DIR)/$(PROJECT)
 
-#.PHONY: license
-#license: clean tools
-#	$(GO_LICENSER) -d -license='ASL2' .
+.PHONY: license
+license: clean
+	$(GO) run main.go header check
 
 .PHONY: fix
 fix: tools
diff --git a/README.md b/README.md
index 255cd15..d2039c0 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,7 @@ Flags:
 ## Test
 
 ```bash
-bin/license-checker -p test -c test/.licenserc_for_test.json
+bin/license-checker -p test -c test/.licenserc_for_test.yaml
 
 [No Specified License]: test/include_test/without_license/testcase.go
 [No Specified License]: test/include_test/without_license/testcase.graphql
diff --git a/action.yml b/action.yml
index e43035f..f9773c5 100644
--- a/action.yml
+++ b/action.yml
@@ -1,12 +1,10 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you 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
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+# 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,
diff --git a/cmd/root.go b/cmd/root.go
index 68cc5eb..93a195e 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -13,6 +13,7 @@ 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 cmd
 
 import (
diff --git a/commands/header/check.go b/commands/header/check.go
index 24d316b..b020882 100644
--- a/commands/header/check.go
+++ b/commands/header/check.go
@@ -1,3 +1,17 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 header
 
 import (
@@ -50,9 +64,13 @@ func loadConfig(config *header.Config) error {
 			lines = append(lines, strings.Trim(line, header.CommentChars))
 		}
 	}
-	config.License = strings.Join(lines, "\n")
+	config.License = strings.Join(lines, " ")
 
 	logger.Log.Infoln("License header is:", config.License)
 
+	if len(config.Paths) == 0 {
+		config.Paths = []string{"**"}
+	}
+
 	return nil
 }
diff --git a/commands/header/header.go b/commands/header/header.go
index 5879a40..d6cb659 100644
--- a/commands/header/header.go
+++ b/commands/header/header.go
@@ -1,3 +1,17 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 header
 
 import (
diff --git a/internal/logger/log.go b/internal/logger/log.go
index 4803978..602437b 100644
--- a/internal/logger/log.go
+++ b/internal/logger/log.go
@@ -1,19 +1,16 @@
-// Licensed to Apache Software Foundation (ASF) under one or more contributor
-// license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright
-// ownership. Apache Software Foundation (ASF) licenses this file to you under
-// the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License.
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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
+// 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.
+// 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 logger
 
@@ -34,5 +31,6 @@ func init() {
 	Log.SetFormatter(&logrus.TextFormatter{
 		DisableTimestamp:       true,
 		DisableLevelTruncation: true,
+		ForceColors:            true,
 	})
 }
diff --git a/pkg/header/check.go b/pkg/header/check.go
index aef1c8e..0defbe4 100644
--- a/pkg/header/check.go
+++ b/pkg/header/check.go
@@ -1,3 +1,17 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 header
 
 import (
diff --git a/pkg/header/model.go b/pkg/header/model.go
index 8401cae..5af67fd 100644
--- a/pkg/header/model.go
+++ b/pkg/header/model.go
@@ -1,3 +1,17 @@
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 header
 
 type Config struct {
diff --git a/pkg/util/str.go b/pkg/util/str.go
deleted file mode 100644
index e907b90..0000000
--- a/pkg/util/str.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-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 util
-
-import (
-	"strings"
-)
-
-func InStrSliceMapKeyFunc(strs []string) func(string) bool {
-	set := make(map[string]struct{})
-
-	for _, e := range strs {
-		set[e] = struct{}{}
-	}
-
-	return func(s string) bool {
-		_, ok := set[s]
-		return ok
-	}
-}
-
-func GetFileExtension(filename string) string {
-	i := strings.LastIndex(filename, ".")
-	if i != -1 {
-		if i+1 < len(filename) {
-			return filename[i+1:]
-		}
-	}
-	return ""
-}
-
-func CleanPathPrefixes(path string, prefixes []string) string {
-	for _, prefix := range prefixes {
-		if strings.HasPrefix(path, prefix) && len(path) > 0 {
-			path = path[len(prefix):]
-		}
-	}
-
-	return path
-}
diff --git a/pkg/util/str_test.go b/pkg/util/str_test.go
deleted file mode 100644
index cf64a96..0000000
--- a/pkg/util/str_test.go
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-Copyright © 2020 Hoshea Jiang <ho...@apache.org>
-
-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 util
-
-import (
-	"os"
-	"testing"
-)
-
-func TestGetFileExtension(t *testing.T) {
-	type args struct {
-		filename string
-	}
-	tests := []struct {
-		name string
-		args args
-		want string
-	}{
-		{
-			name: "txt extension",
-			args: args{
-				filename: ".abc.txt",
-			},
-			want: "txt",
-		},
-		{
-			name: "no file extensions",
-			args: args{
-				filename: ".abc.txt.",
-			},
-			want: "",
-		},
-		{
-			name: "no file extensions",
-			args: args{
-				filename: "lkjsdl",
-			},
-			want: "",
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := GetFileExtension(tt.args.filename); got != tt.want {
-				t.Errorf("GetFileExtension() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
-
-func Test_cleanPathPrefixes(t *testing.T) {
-	type args struct {
-		path     string
-		prefixes []string
-	}
-	tests := []struct {
-		name string
-		args args
-		want string
-	}{
-		{
-			name: "",
-			args: args{
-				path:     "test/exclude_test",
-				prefixes: []string{"test", string(os.PathSeparator)},
-			},
-			want: "exclude_test",
-		},
-		{
-			name: "",
-			args: args{
-				path:     "test/exclude_test/directories",
-				prefixes: []string{"test", string(os.PathSeparator)},
-			},
-			want: "exclude_test/directories",
-		},
-		{
-			name: "",
-			args: args{
-				path:     "./.git/",
-				prefixes: []string{".", string(os.PathSeparator)},
-			},
-			want: ".git/",
-		},
-		{
-			name: "",
-			args: args{
-				path:     "test/exclude_test/directories",
-				prefixes: []string{"test/", string(os.PathSeparator)},
-			},
-			want: "exclude_test/directories",
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			if got := CleanPathPrefixes(tt.args.path, tt.args.prefixes); got != tt.want {
-				t.Errorf("CleanPathPrefixes() = %v, want %v", got, tt.want)
-			}
-		})
-	}
-}
diff --git a/test/.licenserc_for_test.json b/test/.licenserc_for_test.json
deleted file mode 100644
index 8eaaa64..0000000
--- a/test/.licenserc_for_test.json
+++ /dev/null
@@ -1,41 +0,0 @@
-{
-  "licenseStrict": [
-    "Licensed to the Apache Software Foundation (ASF) under one or more",
-    "contributor license agreements.  See the NOTICE file distributed with",
-    "this work for additional information regarding copyright ownership.",
-    "The ASF licenses this file to You 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."
-  ],
-  "licenseLoose": [
-    "Apache License, Version 2.0"
-  ],
-  "targetFiles": [
-    "java",
-    "go",
-    "py",
-    "sh",
-    "graphql",
-    "yaml",
-    "yml"
-  ],
-  "exclude": {
-    "files": [
-      ".DS_Store"
-    ],
-    "extensions": [
-      "md",
-      "xml",
-      "json"
-    ],
-    "directories": [
-      "exclude_test/directories"
-    ]
-  }
-}
\ No newline at end of file
diff --git a/test/.licenserc_for_test.yaml b/test/.licenserc_for_test.yaml
new file mode 100644
index 0000000..bc6d434
--- /dev/null
+++ b/test/.licenserc_for_test.yaml
@@ -0,0 +1,37 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+#
+# 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.
+
+license: >-
+  Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+
+  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.
+
+paths:
+  - 'test/include_test'
+
+paths-ignore:
+  - '.git/**/*'
+  - '**/*.md'
+  - '**/.DS_Store'
+  - 'exclude_test/**/*'
diff --git a/test/include_test/with_license/testcase.go b/test/include_test/with_license/testcase.go
index 6015e2e..a32a9c8 100644
--- a/test/include_test/with_license/testcase.go
+++ b/test/include_test/with_license/testcase.go
@@ -1,18 +1,15 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
+//
+// 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 with_license
diff --git a/test/include_test/with_license/testcase.graphql b/test/include_test/with_license/testcase.graphql
index a9fd83f..d1d7d28 100644
--- a/test/include_test/with_license/testcase.graphql
+++ b/test/include_test/with_license/testcase.graphql
@@ -1,16 +1,13 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
+# 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
+# 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.
-#
\ No newline at end of file
diff --git a/test/include_test/with_license/testcase.java b/test/include_test/with_license/testcase.java
index 63f7276..651fadd 100644
--- a/test/include_test/with_license/testcase.java
+++ b/test/include_test/with_license/testcase.java
@@ -1,14 +1,14 @@
-// Licensed to the Apache Software Foundation (ASF) under one or more
-// contributor license agreements.  See the NOTICE file distributed with
-// this work for additional information regarding copyright ownership.
-// The ASF licenses this file to You 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
+// Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// 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.
+
diff --git a/test/include_test/with_license/testcase.py b/test/include_test/with_license/testcase.py
index a9fd83f..d1d7d28 100644
--- a/test/include_test/with_license/testcase.py
+++ b/test/include_test/with_license/testcase.py
@@ -1,16 +1,13 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
+# 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
+# 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.
-#
\ No newline at end of file
diff --git a/test/include_test/with_license/testcase.sh b/test/include_test/with_license/testcase.sh
index c251402..69d2c0c 100644
--- a/test/include_test/with_license/testcase.sh
+++ b/test/include_test/with_license/testcase.sh
@@ -1,18 +1,15 @@
 # /bin/bash
 
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
+# 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
+# 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.
-#
\ No newline at end of file
diff --git a/test/include_test/with_license/testcase.yaml b/test/include_test/with_license/testcase.yaml
index c2ff44f..d1d7d28 100644
--- a/test/include_test/with_license/testcase.yaml
+++ b/test/include_test/with_license/testcase.yaml
@@ -1,18 +1,13 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
+# 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
 #
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
+# 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.
-#
\ No newline at end of file
diff --git a/test/include_test/with_license/testcase.yml b/test/include_test/with_license/testcase.yml
index a9fd83f..d1d7d28 100644
--- a/test/include_test/with_license/testcase.yml
+++ b/test/include_test/with_license/testcase.yml
@@ -1,16 +1,13 @@
+# Copyright © 2020 Hoshea Jiang <ho...@apache.org>
 #
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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
+# 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
+# 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.
-#
\ No newline at end of file


[skywalking-eyes] 10/25: Update doc

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit cbb27a78d402a206ea85a672c4db6b8921ba7ba3
Author: Hoshea <fg...@gmail.com>
AuthorDate: Mon Nov 23 20:23:33 2020 +0800

    Update doc
---
 README.md | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 4857aca..255cd15 100644
--- a/README.md
+++ b/README.md
@@ -78,5 +78,14 @@ Flags:
 ## Test
 
 ```bash
-bin/license-checker -p test -c test/.licenserc_for_test.json 
+bin/license-checker -p test -c test/.licenserc_for_test.json
+
+[No Specified License]: test/include_test/without_license/testcase.go
+[No Specified License]: test/include_test/without_license/testcase.graphql
+[No Specified License]: test/include_test/without_license/testcase.java
+[No Specified License]: test/include_test/without_license/testcase.py
+[No Specified License]: test/include_test/without_license/testcase.sh
+[No Specified License]: test/include_test/without_license/testcase.yaml
+[No Specified License]: test/include_test/without_license/testcase.yml
+Total check 14 files, success: 7, failure: 7 
 ```


[skywalking-eyes] 05/25: dev

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 1beba9eed88d3bd855bc1398db5d7b54adc11c71
Author: Hoshea <fg...@gmail.com>
AuthorDate: Sat Nov 21 23:08:31 2020 +0800

    dev
---
 cmd/root.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/root.go b/cmd/root.go
index d030d02..fed1758 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -140,7 +140,7 @@ func Walk(p string, cfg *Config) error {
 			scanner := bufio.NewScanner(file)
 			for scanner.Scan() {
 				line := scanner.Text()
-				if strings.Contains()
+				//if strings.Contains()
 			}
 
 		}


[skywalking-eyes] 25/25: Reorganize the directory structure to monorepo

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 1667d8a23a687ded89f09601c48e0fb2cb6c6b1e
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Dec 21 15:56:57 2020 +0800

    Reorganize the directory structure to monorepo
---
 .../{build.yaml => license-eye-check.yaml}         | 13 +++-
 .licenserc.yaml                                    |  8 +--
 README.adoc                                        | 72 ++--------------------
 Dockerfile => license-eye/Dockerfile               |  2 +-
 Makefile => license-eye/Makefile                   |  2 +-
 README.adoc => license-eye/README.adoc             | 32 +++++-----
 {cmd => license-eye/cmd}/license-eye/main.go       |  0
 {commands => license-eye/commands}/header/check.go |  0
 {commands => license-eye/commands}/header/fix.go   |  0
 .../commands}/header/header.go                     |  0
 {commands => license-eye/commands}/root.go         |  0
 {commands => license-eye/commands}/version.go      |  0
 go.mod => license-eye/go.mod                       |  0
 go.sum => license-eye/go.sum                       |  0
 {internal => license-eye/internal}/logger/log.go   |  0
 {pkg => license-eye/pkg}/config/Config.go          |  0
 {pkg => license-eye/pkg}/header/check.go           |  0
 {pkg => license-eye/pkg}/header/config.go          |  0
 .../pkg}/header/fix/angle_bracket.go               |  0
 .../pkg}/header/fix/double_slash.go                |  0
 {pkg => license-eye/pkg}/header/fix/fix.go         |  0
 {pkg => license-eye/pkg}/header/fix/hashtag.go     |  0
 .../pkg}/header/fix/slash_asterisk.go              |  0
 {pkg => license-eye/pkg}/header/result.go          |  0
 .../testdata}/.licenserc_for_test_check.yaml       |  2 +-
 .../testdata}/.licenserc_for_test_fix.yaml         |  2 +-
 .../testdata}/exclude_test/directories/testcase.go |  0
 .../exclude_test/extensions/testcase.json          |  0
 .../testdata}/exclude_test/extensions/testcase.md  |  0
 .../testdata}/exclude_test/extensions/testcase.xml |  0
 .../include_test/with_license/testcase.go          |  0
 .../include_test/with_license/testcase.graphql     |  0
 .../include_test/with_license/testcase.java        |  0
 .../include_test/with_license/testcase.py          |  0
 .../include_test/with_license/testcase.sh          |  0
 .../include_test/with_license/testcase.yaml        |  0
 .../include_test/with_license/testcase.yml         |  0
 .../include_test/without_license/testcase.go       |  0
 .../include_test/without_license/testcase.graphql  |  0
 .../include_test/without_license/testcase.java     |  0
 .../include_test/without_license/testcase.md       |  0
 .../include_test/without_license/testcase.py       |  0
 .../include_test/without_license/testcase.sh       |  0
 .../include_test/without_license/testcase.yaml     |  0
 .../include_test/without_license/testcase.yml      |  0
 45 files changed, 38 insertions(+), 95 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/license-eye-check.yaml
similarity index 87%
rename from .github/workflows/build.yaml
rename to .github/workflows/license-eye-check.yaml
index 68fcaf2..7f65b60 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/license-eye-check.yaml
@@ -16,7 +16,7 @@
 # under the License.
 #
 
-name: Build
+name: LicenseEye
 
 on:
   pull_request:
@@ -24,9 +24,13 @@ on:
     branches:
       - master
 
+defaults:
+  run:
+    working-directory: license-eye
+
 jobs:
-  build:
-    name: Build
+  build-license-eye:
+    name: Build LicenseEye
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
@@ -41,5 +45,8 @@ jobs:
       - name: License Check
         run: make license
 
+      - name: Test
+        run: make test
+
       - name: Build
         run: make build
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 6aa224f..719351d 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -20,11 +20,11 @@ header:
   paths-ignore:
     - '.git/**'
     - '.idea/**'
-    - 'bin/**'
+    - '**/bin/**'
     - '**/*.md'
     - '**/.DS_Store'
-    - 'test/**'
-    - 'go.mod'
-    - 'go.sum'
+    - '**/testdata/**'
+    - '**/go.mod'
+    - '**/go.sum'
     - 'LICENSE'
     - 'NOTICE'
diff --git a/README.adoc b/README.adoc
index 17501c0..d89afab 100644
--- a/README.adoc
+++ b/README.adoc
@@ -15,76 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 // 
-= license-eye
-:repo: https://github.com/apache/skywalking-eyes
+= SkyWalking Eyes
 
-A full-featured license guard to check and fix license headers and dependencies' licenses.
-
-== Install
-
-[subs="attributes+",source,bash]
-----
-git clone {repo}
-cd license-eye
-make
-----
-
-== Usage
+Infra tools that are created and used by the SkyWalking Team.
 
-[source]
-----
-$ license-eye
+== License Eye
 
 A full-featured license guard to check and fix license headers and dependencies' licenses.
 
-Usage:
-  license-eye [command]
-
-Available Commands:
-  header      License header related commands; e.g. check, fix, etc.
-  help        Help about any command
-
-Flags:
-  -h, --help               help for license-eye
-  -v, --verbosity string   log level (debug, info, warn, error, fatal, panic (default "info")
-
-Use "license-eye [command] --help" for more information about a command.
-----
-
-== Configuration
-
-[source,yaml]
-.test/.licenserc_for_test.yaml
-----
-include::test/.licenserc_for_test_check.yaml[]
-----
-
-== Check
-
-[source]
-----
-bin/license-eye -c test/.licenserc_for_test_fix.yaml header check
-
-INFO Loading configuration from file: test/.licenserc_for_test.yaml serc_for_test.yaml
-INFO Totally checked 23 files, valid: 8, invalid: 8, ignored: 7, fixed: 0
-ERROR The following files don't have a valid license header:
-test/include_test/without_license/testcase.go
-test/include_test/without_license/testcase.graphql
-test/include_test/without_license/testcase.java
-test/include_test/without_license/testcase.md
-test/include_test/without_license/testcase.py
-test/include_test/without_license/testcase.sh
-test/include_test/without_license/testcase.yaml
-test/include_test/without_license/testcase.yml
-exit status 1
-----
-
-== Fix
-
-[source]
-----
-bin/license-eye -c test/.licenserc_for_test_fix.yaml header fix
-
-INFO Loading configuration from file: test/.licenserc_for_test_fix.yaml
-INFO Totally checked 16 files, valid: 7, invalid: 8, ignored: 1, fixed: 8
-----
+Read link:license-eye/README.adoc[the doc] on how to use license-eye.
diff --git a/Dockerfile b/license-eye/Dockerfile
similarity index 99%
rename from Dockerfile
rename to license-eye/Dockerfile
index 62c66ee..77731eb 100644
--- a/Dockerfile
+++ b/license-eye/Dockerfile
@@ -19,7 +19,7 @@ FROM golang:1.14.3-alpine AS build
 
 WORKDIR /src
 
-COPY . .
+COPY .. .
 
 RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /bin/license-eye
 
diff --git a/Makefile b/license-eye/Makefile
similarity index 96%
rename from Makefile
rename to license-eye/Makefile
index 3d1612e..4a662cd 100644
--- a/Makefile
+++ b/license-eye/Makefile
@@ -50,7 +50,7 @@ fix-lint:
 
 .PHONY: license
 license: clean
-	$(GO) run cmd/license-eye/main.go header check
+	$(GO) run cmd/license-eye/main.go header check -c ../.licenserc.yaml
 
 .PHONY: test
 test: clean lint
diff --git a/README.adoc b/license-eye/README.adoc
similarity index 69%
copy from README.adoc
copy to license-eye/README.adoc
index 17501c0..db47c46 100644
--- a/README.adoc
+++ b/license-eye/README.adoc
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 // 
-= license-eye
+= License-Eye
 :repo: https://github.com/apache/skywalking-eyes
 
 A full-featured license guard to check and fix license headers and dependencies' licenses.
@@ -25,7 +25,7 @@ A full-featured license guard to check and fix license headers and dependencies'
 [subs="attributes+",source,bash]
 ----
 git clone {repo}
-cd license-eye
+cd skywalking-eyes/license-eye
 make
 ----
 
@@ -54,28 +54,28 @@ Use "license-eye [command] --help" for more information about a command.
 == Configuration
 
 [source,yaml]
-.test/.licenserc_for_test.yaml
+.testdata/.licenserc_for_test.yaml
 ----
-include::test/.licenserc_for_test_check.yaml[]
+include::testdata/.licenserc_for_test_check.yaml[]
 ----
 
 == Check
 
 [source]
 ----
-bin/license-eye -c test/.licenserc_for_test_fix.yaml header check
+bin/license-eye -c testdata/.licenserc_for_test_fix.yaml header check
 
-INFO Loading configuration from file: test/.licenserc_for_test.yaml serc_for_test.yaml
+INFO Loading configuration from file: testdata/.licenserc_for_test.yaml serc_for_test.yaml
 INFO Totally checked 23 files, valid: 8, invalid: 8, ignored: 7, fixed: 0
 ERROR The following files don't have a valid license header:
-test/include_test/without_license/testcase.go
-test/include_test/without_license/testcase.graphql
-test/include_test/without_license/testcase.java
-test/include_test/without_license/testcase.md
-test/include_test/without_license/testcase.py
-test/include_test/without_license/testcase.sh
-test/include_test/without_license/testcase.yaml
-test/include_test/without_license/testcase.yml
+testdata/include_test/without_license/testcase.go
+testdata/include_test/without_license/testcase.graphql
+testdata/include_test/without_license/testcase.java
+testdata/include_test/without_license/testcase.md
+testdata/include_test/without_license/testcase.py
+testdata/include_test/without_license/testcase.sh
+testdata/include_test/without_license/testcase.yaml
+testdata/include_test/without_license/testcase.yml
 exit status 1
 ----
 
@@ -83,8 +83,8 @@ exit status 1
 
 [source]
 ----
-bin/license-eye -c test/.licenserc_for_test_fix.yaml header fix
+bin/license-eye -c testdata/.licenserc_for_test_fix.yaml header fix
 
-INFO Loading configuration from file: test/.licenserc_for_test_fix.yaml
+INFO Loading configuration from file: testdata/.licenserc_for_test_fix.yaml
 INFO Totally checked 16 files, valid: 7, invalid: 8, ignored: 1, fixed: 8
 ----
diff --git a/cmd/license-eye/main.go b/license-eye/cmd/license-eye/main.go
similarity index 100%
rename from cmd/license-eye/main.go
rename to license-eye/cmd/license-eye/main.go
diff --git a/commands/header/check.go b/license-eye/commands/header/check.go
similarity index 100%
rename from commands/header/check.go
rename to license-eye/commands/header/check.go
diff --git a/commands/header/fix.go b/license-eye/commands/header/fix.go
similarity index 100%
rename from commands/header/fix.go
rename to license-eye/commands/header/fix.go
diff --git a/commands/header/header.go b/license-eye/commands/header/header.go
similarity index 100%
rename from commands/header/header.go
rename to license-eye/commands/header/header.go
diff --git a/commands/root.go b/license-eye/commands/root.go
similarity index 100%
rename from commands/root.go
rename to license-eye/commands/root.go
diff --git a/commands/version.go b/license-eye/commands/version.go
similarity index 100%
rename from commands/version.go
rename to license-eye/commands/version.go
diff --git a/go.mod b/license-eye/go.mod
similarity index 100%
rename from go.mod
rename to license-eye/go.mod
diff --git a/go.sum b/license-eye/go.sum
similarity index 100%
rename from go.sum
rename to license-eye/go.sum
diff --git a/internal/logger/log.go b/license-eye/internal/logger/log.go
similarity index 100%
rename from internal/logger/log.go
rename to license-eye/internal/logger/log.go
diff --git a/pkg/config/Config.go b/license-eye/pkg/config/Config.go
similarity index 100%
rename from pkg/config/Config.go
rename to license-eye/pkg/config/Config.go
diff --git a/pkg/header/check.go b/license-eye/pkg/header/check.go
similarity index 100%
rename from pkg/header/check.go
rename to license-eye/pkg/header/check.go
diff --git a/pkg/header/config.go b/license-eye/pkg/header/config.go
similarity index 100%
rename from pkg/header/config.go
rename to license-eye/pkg/header/config.go
diff --git a/pkg/header/fix/angle_bracket.go b/license-eye/pkg/header/fix/angle_bracket.go
similarity index 100%
rename from pkg/header/fix/angle_bracket.go
rename to license-eye/pkg/header/fix/angle_bracket.go
diff --git a/pkg/header/fix/double_slash.go b/license-eye/pkg/header/fix/double_slash.go
similarity index 100%
rename from pkg/header/fix/double_slash.go
rename to license-eye/pkg/header/fix/double_slash.go
diff --git a/pkg/header/fix/fix.go b/license-eye/pkg/header/fix/fix.go
similarity index 100%
rename from pkg/header/fix/fix.go
rename to license-eye/pkg/header/fix/fix.go
diff --git a/pkg/header/fix/hashtag.go b/license-eye/pkg/header/fix/hashtag.go
similarity index 100%
rename from pkg/header/fix/hashtag.go
rename to license-eye/pkg/header/fix/hashtag.go
diff --git a/pkg/header/fix/slash_asterisk.go b/license-eye/pkg/header/fix/slash_asterisk.go
similarity index 100%
rename from pkg/header/fix/slash_asterisk.go
rename to license-eye/pkg/header/fix/slash_asterisk.go
diff --git a/pkg/header/result.go b/license-eye/pkg/header/result.go
similarity index 100%
rename from pkg/header/result.go
rename to license-eye/pkg/header/result.go
diff --git a/test/.licenserc_for_test_check.yaml b/license-eye/testdata/.licenserc_for_test_check.yaml
similarity index 97%
rename from test/.licenserc_for_test_check.yaml
rename to license-eye/testdata/.licenserc_for_test_check.yaml
index cad5ecb..1ae329e 100644
--- a/test/.licenserc_for_test_check.yaml
+++ b/license-eye/testdata/.licenserc_for_test_check.yaml
@@ -18,7 +18,7 @@ header:
     under the License.
 
   paths:
-    - 'test/**'
+    - 'testdata/**'
 
   paths-ignore:
     - '**/.DS_Store'
diff --git a/test/.licenserc_for_test_fix.yaml b/license-eye/testdata/.licenserc_for_test_fix.yaml
similarity index 96%
rename from test/.licenserc_for_test_fix.yaml
rename to license-eye/testdata/.licenserc_for_test_fix.yaml
index 19a864b..008e9f4 100644
--- a/test/.licenserc_for_test_fix.yaml
+++ b/license-eye/testdata/.licenserc_for_test_fix.yaml
@@ -18,7 +18,7 @@ header:
     under the License.
 
   paths:
-    - 'test/include_test/**'
+    - 'testdata/include_test/**'
 
   paths-ignore:
     - '**/.DS_Store'
diff --git a/test/exclude_test/directories/testcase.go b/license-eye/testdata/exclude_test/directories/testcase.go
similarity index 100%
rename from test/exclude_test/directories/testcase.go
rename to license-eye/testdata/exclude_test/directories/testcase.go
diff --git a/test/exclude_test/extensions/testcase.json b/license-eye/testdata/exclude_test/extensions/testcase.json
similarity index 100%
rename from test/exclude_test/extensions/testcase.json
rename to license-eye/testdata/exclude_test/extensions/testcase.json
diff --git a/test/exclude_test/extensions/testcase.md b/license-eye/testdata/exclude_test/extensions/testcase.md
similarity index 100%
rename from test/exclude_test/extensions/testcase.md
rename to license-eye/testdata/exclude_test/extensions/testcase.md
diff --git a/test/exclude_test/extensions/testcase.xml b/license-eye/testdata/exclude_test/extensions/testcase.xml
similarity index 100%
rename from test/exclude_test/extensions/testcase.xml
rename to license-eye/testdata/exclude_test/extensions/testcase.xml
diff --git a/test/include_test/with_license/testcase.go b/license-eye/testdata/include_test/with_license/testcase.go
similarity index 100%
rename from test/include_test/with_license/testcase.go
rename to license-eye/testdata/include_test/with_license/testcase.go
diff --git a/test/include_test/with_license/testcase.graphql b/license-eye/testdata/include_test/with_license/testcase.graphql
similarity index 100%
rename from test/include_test/with_license/testcase.graphql
rename to license-eye/testdata/include_test/with_license/testcase.graphql
diff --git a/test/include_test/with_license/testcase.java b/license-eye/testdata/include_test/with_license/testcase.java
similarity index 100%
rename from test/include_test/with_license/testcase.java
rename to license-eye/testdata/include_test/with_license/testcase.java
diff --git a/test/include_test/with_license/testcase.py b/license-eye/testdata/include_test/with_license/testcase.py
similarity index 100%
rename from test/include_test/with_license/testcase.py
rename to license-eye/testdata/include_test/with_license/testcase.py
diff --git a/test/include_test/with_license/testcase.sh b/license-eye/testdata/include_test/with_license/testcase.sh
similarity index 100%
rename from test/include_test/with_license/testcase.sh
rename to license-eye/testdata/include_test/with_license/testcase.sh
diff --git a/test/include_test/with_license/testcase.yaml b/license-eye/testdata/include_test/with_license/testcase.yaml
similarity index 100%
rename from test/include_test/with_license/testcase.yaml
rename to license-eye/testdata/include_test/with_license/testcase.yaml
diff --git a/test/include_test/with_license/testcase.yml b/license-eye/testdata/include_test/with_license/testcase.yml
similarity index 100%
rename from test/include_test/with_license/testcase.yml
rename to license-eye/testdata/include_test/with_license/testcase.yml
diff --git a/test/include_test/without_license/testcase.go b/license-eye/testdata/include_test/without_license/testcase.go
similarity index 100%
rename from test/include_test/without_license/testcase.go
rename to license-eye/testdata/include_test/without_license/testcase.go
diff --git a/test/include_test/without_license/testcase.graphql b/license-eye/testdata/include_test/without_license/testcase.graphql
similarity index 100%
rename from test/include_test/without_license/testcase.graphql
rename to license-eye/testdata/include_test/without_license/testcase.graphql
diff --git a/test/include_test/without_license/testcase.java b/license-eye/testdata/include_test/without_license/testcase.java
similarity index 100%
rename from test/include_test/without_license/testcase.java
rename to license-eye/testdata/include_test/without_license/testcase.java
diff --git a/test/include_test/without_license/testcase.md b/license-eye/testdata/include_test/without_license/testcase.md
similarity index 100%
rename from test/include_test/without_license/testcase.md
rename to license-eye/testdata/include_test/without_license/testcase.md
diff --git a/test/include_test/without_license/testcase.py b/license-eye/testdata/include_test/without_license/testcase.py
similarity index 100%
rename from test/include_test/without_license/testcase.py
rename to license-eye/testdata/include_test/without_license/testcase.py
diff --git a/test/include_test/without_license/testcase.sh b/license-eye/testdata/include_test/without_license/testcase.sh
similarity index 100%
rename from test/include_test/without_license/testcase.sh
rename to license-eye/testdata/include_test/without_license/testcase.sh
diff --git a/test/include_test/without_license/testcase.yaml b/license-eye/testdata/include_test/without_license/testcase.yaml
similarity index 100%
rename from test/include_test/without_license/testcase.yaml
rename to license-eye/testdata/include_test/without_license/testcase.yaml
diff --git a/test/include_test/without_license/testcase.yml b/license-eye/testdata/include_test/without_license/testcase.yml
similarity index 100%
rename from test/include_test/without_license/testcase.yml
rename to license-eye/testdata/include_test/without_license/testcase.yml


[skywalking-eyes] 11/25: bugfix: cannot build

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit b3bff6986290aa9d7c9c15a6479373f8fdf871d7
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Tue Dec 1 21:25:05 2020 +0800

    bugfix: cannot build
---
 Makefile | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 04af575..8e2e68e 100644
--- a/Makefile
+++ b/Makefile
@@ -20,18 +20,13 @@ FILES := $$(find .$$($(PACKAGE_DIRECTORIES)) -name "*.go")
 FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'
 
 GO := GO111MODULE=on go
-GO_PATH = $$($(GO) env GOPATH)
+GO_PATH = $(shell $(GO) env GOPATH)
 GO_BUILD = $(GO) build
 GO_GET = $(GO) get
 GO_TEST = $(GO) test
 GO_LINT = $(GO_PATH)/bin/golangci-lint
 GO_LICENSER = $(GO_PATH)/bin/go-licenser
 
-# Ensure GOPATH is set before running build process.
-ifeq "$(GOPATH)" ""
-  $(error Please set the environment variable GOPATH before running `make`)
-endif
-
 all: clean deps lint test build
 
 tools:


[skywalking-eyes] 02/25: scaffold

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 3f5afc50a6cc0b2046413686a825a88e7bb1f758
Author: Hoshea <fg...@gmail.com>
AuthorDate: Wed Nov 18 20:23:24 2020 +0800

    scaffold
---
 .gitignore  |   2 +
 cmd/root.go |  86 ++++++++++++++++
 config.json |  19 ++++
 config.yaml |   3 +
 go.mod      |  20 ++++
 go.sum      | 332 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 main.go     |  22 ++++
 7 files changed, 484 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8741f5d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.idea/
+bin/
\ No newline at end of file
diff --git a/cmd/root.go b/cmd/root.go
new file mode 100644
index 0000000..14c62b6
--- /dev/null
+++ b/cmd/root.go
@@ -0,0 +1,86 @@
+/*
+Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+
+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 cmd
+
+import (
+	"fmt"
+	"github.com/spf13/cobra"
+	"os"
+
+	homedir "github.com/mitchellh/go-homedir"
+	"github.com/spf13/viper"
+)
+
+var cfgFile string
+
+// rootCmd represents the base command when called without any subcommands
+var rootCmd = &cobra.Command{
+	Use:   "license-checker",
+	Short: "A brief description of your application",
+
+	Run: func(cmd *cobra.Command, args []string) {
+		fmt.Println("Hello Cobra CLI!")
+	},
+}
+
+// Execute adds all child commands to the root command and sets flags appropriately.
+// This is called by main.main(). It only needs to happen once to the rootCmd.
+func Execute() {
+	if err := rootCmd.Execute(); err != nil {
+		fmt.Println(err)
+		os.Exit(1)
+	}
+}
+
+func init() {
+	cobra.OnInitialize(initConfig)
+
+	// Here you will define your flags and configuration settings.
+	// Cobra supports persistent flags, which, if defined here,
+	// will be global for your application.
+
+	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.license-checker.yaml)")
+
+	// Cobra also supports local flags, which will only run
+	// when this action is called directly.
+	rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
+}
+
+// initConfig reads in config file and ENV variables if set.
+func initConfig() {
+	if cfgFile != "" {
+		// Use config file from the flag.
+		viper.SetConfigFile(cfgFile)
+	} else {
+		// Find home directory.
+		home, err := homedir.Dir()
+		if err != nil {
+			fmt.Println(err)
+			os.Exit(1)
+		}
+
+		// Search config in home directory with name ".license-checker" (without extension).
+		viper.AddConfigPath(home)
+		viper.SetConfigName(".license-checker")
+	}
+
+	viper.AutomaticEnv() // read in environment variables that match
+
+	// If a config file is found, read it in.
+	if err := viper.ReadInConfig(); err == nil {
+		fmt.Println("Using config file:", viper.ConfigFileUsed())
+	}
+}
diff --git a/config.json b/config.json
new file mode 100644
index 0000000..10d2446
--- /dev/null
+++ b/config.json
@@ -0,0 +1,19 @@
+{
+  "**/*.{java, go, py}": [
+    "You can put multiline headers like this",
+    "Copyright Foo, Inc. and other Bar contributors.",
+    "Permission is hereby granted, free of charge, to any person obtaining a",
+    "copy of this software and associated documentation files (the",
+    "\"Software\"), to deal in the Software without restriction, including",
+    "without limitation the rights to use, copy, modify, merge, publish,",
+    "distribute, sublicense, and/or sell copies of the Software, and to permit",
+    "persons to whom the Software is furnished to do so, subject to the",
+    "following conditions:",
+    "..."
+  ],
+
+  "ignore": [
+    "lib/vendor/jquery.js", // ignore this file
+    "vendor/" // ignore all files under vendor
+  ]
+}
\ No newline at end of file
diff --git a/config.yaml b/config.yaml
new file mode 100644
index 0000000..4845d7a
--- /dev/null
+++ b/config.yaml
@@ -0,0 +1,3 @@
+include:
+
+exclude:
\ No newline at end of file
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..ebaf77e
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,20 @@
+module license-checker
+
+go 1.13
+
+require (
+	github.com/fsnotify/fsnotify v1.4.9 // indirect
+	github.com/magiconair/properties v1.8.4 // indirect
+	github.com/mitchellh/go-homedir v1.1.0
+	github.com/mitchellh/mapstructure v1.3.3 // indirect
+	github.com/pelletier/go-toml v1.8.1 // indirect
+	github.com/spf13/afero v1.4.1 // indirect
+	github.com/spf13/cast v1.3.1 // indirect
+	github.com/spf13/cobra v1.1.1
+	github.com/spf13/jwalterweatherman v1.1.0 // indirect
+	github.com/spf13/viper v1.7.1
+	golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7 // indirect
+	golang.org/x/text v0.3.4 // indirect
+	gopkg.in/ini.v1 v1.62.0 // indirect
+	gopkg.in/yaml.v2 v2.3.0 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..cd8c883
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,332 @@
+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/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
+cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
+cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
+cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
+cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
+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/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
+github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
+github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/cpuguy83/go-md2man/v2 v2.0.0/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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
+github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
+github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/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/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/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/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+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/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/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
+github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
+github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
+github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
+github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
+github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
+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/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
+github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
+github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+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/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
+github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
+github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
+github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
+github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+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/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
+github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
+github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
+github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
+github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
+github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
+github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
+github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
+github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
+github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
+github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.4.1 h1:asw9sl74539yqavKaglDM5hFpdJVK0Y5Dr/JOgQ89nQ=
+github.com/spf13/afero v1.4.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
+github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
+github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
+github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
+github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
+github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.7.0 h1:xVKxvI7ouOI5I+U9s2eeiUfMaWBVoXA3AWskkrqK0VM=
+github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
+github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk=
+github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
+github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+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/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/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/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-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/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/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/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/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
+golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7 h1:s330+6z/Ko3J0o6rvOcwXe5nzs7UT9tLKHoOXYn6uE0=
+golang.org/x/sys v0.0.0-20201117222635-ba5294a509c7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+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 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
+golang.org/x/text v0.3.4/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/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+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-20190328211700-ab21143f2384/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-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-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/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/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/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/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=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+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/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
+gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
+gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
+gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
+gopkg.in/yaml.v2 v2.3.0/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.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
+rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..d2e9d49
--- /dev/null
+++ b/main.go
@@ -0,0 +1,22 @@
+/*
+Copyright © 2020 NAME HERE <EMAIL ADDRESS>
+
+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 main
+
+import "license-checker/cmd"
+
+func main() {
+	cmd.Execute()
+}


[skywalking-eyes] 01/25: Initial commit

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit 91afcffcef935443199e73529c9fd495a273c975
Author: Hoshea Jiang <fg...@gmail.com>
AuthorDate: Wed Nov 18 19:45:36 2020 +0800

    Initial commit
---
 LICENSE   | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.md |   2 +
 2 files changed, 203 insertions(+)

diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..6aadc5a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# license-checker
+A CLI tool for checking license headers


[skywalking-eyes] 09/25: Update doc

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-eyes.git

commit cbb2a6a7d17adae2a3ec23696990da9bf74b92bb
Author: Hoshea <fg...@gmail.com>
AuthorDate: Mon Nov 23 20:21:31 2020 +0800

    Update doc
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e58ab9e..4857aca 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ Flags:
 
 ## Configuration
 
-```json
+```
 {
   // What to check in strict mode, the order of strings can NOT be changed arbitrarily
   "licenseStrict": [