Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34982c122f | |||
| fb11c0c27c | |||
| 27cc67d2cf | |||
| 0fe13439b6 | |||
| fb9caec663 | |||
| e3e83630b5 | |||
| c1f06604e3 | |||
| 9091cc7682 |
59
.circleci/config.yml
Normal file
59
.circleci/config.yml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference
|
||||||
|
version: 2.1
|
||||||
|
|
||||||
|
commands:
|
||||||
|
setup-bazel:
|
||||||
|
description: |
|
||||||
|
Setup the Bazel build system used for building the repo
|
||||||
|
steps:
|
||||||
|
- run:
|
||||||
|
name: Add Bazel Apt repository
|
||||||
|
command: |
|
||||||
|
sudo apt install curl gnupg
|
||||||
|
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
|
||||||
|
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
|
||||||
|
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
|
||||||
|
- run:
|
||||||
|
name: Install Bazel from Apt
|
||||||
|
command: sudo apt update && sudo apt install bazel
|
||||||
|
|
||||||
|
# Define a job to be invoked later in a workflow.
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
|
||||||
|
jobs:
|
||||||
|
testbuild:
|
||||||
|
working_directory: ~/repo
|
||||||
|
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
|
||||||
|
docker:
|
||||||
|
- image: circleci/golang:1.15.8
|
||||||
|
# Add steps to the job
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- setup-bazel
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- go-mod-v4-{{ checksum "go.sum" }}
|
||||||
|
- run:
|
||||||
|
name: Install Dependencies
|
||||||
|
command: go mod download
|
||||||
|
- save_cache:
|
||||||
|
key: go-mod-v4-{{ checksum "go.sum" }}
|
||||||
|
paths:
|
||||||
|
- "/go/pkg/mod"
|
||||||
|
- run:
|
||||||
|
name: Run tests
|
||||||
|
command: bazel test //...
|
||||||
|
- run:
|
||||||
|
name: Run build
|
||||||
|
command: bazel build //...
|
||||||
|
- store_test_results:
|
||||||
|
path: /tmp/test-reports
|
||||||
|
|
||||||
|
# Invoke jobs via workflows
|
||||||
|
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
|
||||||
|
workflows:
|
||||||
|
testbuild:
|
||||||
|
jobs:
|
||||||
|
- testbuild
|
||||||
@@ -5,7 +5,10 @@ go_library(
|
|||||||
srcs = ["main.go"],
|
srcs = ["main.go"],
|
||||||
importpath = "git.wntrmute.dev/kyle/goutils/cmd/cruntar",
|
importpath = "git.wntrmute.dev/kyle/goutils/cmd/cruntar",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = ["//die"],
|
deps = [
|
||||||
|
"//die",
|
||||||
|
"//fileutil",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
go_binary(
|
go_binary(
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ go_library(
|
|||||||
importpath = "git.wntrmute.dev/kyle/goutils/cmd/showimp",
|
importpath = "git.wntrmute.dev/kyle/goutils/cmd/showimp",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//dbg",
|
||||||
"//die",
|
"//die",
|
||||||
"//logging",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.wntrmute.dev/kyle/goutils/config/iniconf"
|
"git.wntrmute.dev/kyle/goutils/config/iniconf"
|
||||||
@@ -139,3 +140,14 @@ func Require(key string) string {
|
|||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ListKeys returns a slice of the currently known keys.
|
||||||
|
func ListKeys() []string {
|
||||||
|
keyList := []string{}
|
||||||
|
for k := range vars {
|
||||||
|
keyList = append(keyList, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(keyList)
|
||||||
|
return keyList
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,53 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "fileutil",
|
name = "fileutil",
|
||||||
srcs = ["fileutil.go"],
|
srcs = [
|
||||||
|
"fileutil.go",
|
||||||
|
"fileutil_windows.go",
|
||||||
|
"symlinks.go",
|
||||||
|
],
|
||||||
importpath = "git.wntrmute.dev/kyle/goutils/fileutil",
|
importpath = "git.wntrmute.dev/kyle/goutils/fileutil",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = ["@org_golang_x_sys//unix"],
|
deps = select({
|
||||||
|
"@io_bazel_rules_go//go/platform:aix": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:android": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:darwin": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:dragonfly": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:illumos": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:ios": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:js": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:linux": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:netbsd": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:openbsd": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:plan9": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"@io_bazel_rules_go//go/platform:solaris": [
|
||||||
|
"@org_golang_x_sys//unix",
|
||||||
|
],
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -13,3 +13,5 @@ require (
|
|||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
|
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v2 v2.4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
require github.com/davecgh/go-spew v1.1.1
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "log",
|
|
||||||
srcs = ["logger.go"],
|
|
||||||
importpath = "git.wntrmute.dev/kyle/kdhcp/log",
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
deps = ["@com_github_hashicorp_go_syslog//:go-syslog"],
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "syslog",
|
name = "syslog",
|
||||||
srcs = ["logger.go"],
|
srcs = ["logger.go"],
|
||||||
importpath = "git.wntrmute.dev/kyle/goutils/syslog",
|
importpath = "git.wntrmute.dev/kyle/goutils/syslog",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = ["@com_github_hashicorp_go_syslog//:go-syslog"],
|
deps = [
|
||||||
|
"@com_github_davecgh_go_spew//spew",
|
||||||
|
"@com_github_hashicorp_go_syslog//:go-syslog",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
gsyslog "github.com/hashicorp/go-syslog"
|
gsyslog "github.com/hashicorp/go-syslog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -52,6 +53,12 @@ func (log *logger) println(p gsyslog.Priority, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (log *logger) spew(args ...interface{}) {
|
||||||
|
if log.p == gsyslog.LOG_DEBUG {
|
||||||
|
spew.Dump(args...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (log *logger) adjustPriority(level string) error {
|
func (log *logger) adjustPriority(level string) error {
|
||||||
priority, ok := priorities[level]
|
priority, ok := priorities[level]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -136,10 +143,12 @@ func Setup(opts *Options) error {
|
|||||||
|
|
||||||
log.p = priority
|
log.p = priority
|
||||||
|
|
||||||
var err error
|
if opts.WriteSyslog {
|
||||||
log.l, err = gsyslog.NewLogger(priority, opts.Facility, opts.Tag)
|
var err error
|
||||||
if err != nil {
|
log.l, err = gsyslog.NewLogger(priority, opts.Facility, opts.Tag)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -252,6 +261,11 @@ func Fatalf(format string, args ...interface{}) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spew will pretty print the args if the logger is set to DEBUG priority.
|
||||||
|
func Spew(args ...interface{}) {
|
||||||
|
log.spew(args...)
|
||||||
|
}
|
||||||
|
|
||||||
func ChangePriority(level string) error {
|
func ChangePriority(level string) error {
|
||||||
return log.adjustPriority(level)
|
return log.adjustPriority(level)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user