mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-12 02:15:01 +00:00
Added binary signing for darwin tarballs (#18719)
Added binary signing for darwin tarballs
This commit is contained in:
+9
-1
@@ -597,6 +597,10 @@ steps:
|
||||
- cd $WORKSPACE_DIR/go/src/github.com/gravitational/webapps
|
||||
- yarn install && yarn build-term && yarn package-term -c.extraMetadata.version=$VERSION
|
||||
environment:
|
||||
APPLE_PASSWORD:
|
||||
from_secret: APPLE_PASSWORD
|
||||
APPLE_USERNAME:
|
||||
from_secret: APPLE_USERNAME
|
||||
ARCH: amd64
|
||||
BUILDBOX_PASSWORD:
|
||||
from_secret: BUILDBOX_PASSWORD
|
||||
@@ -4273,6 +4277,10 @@ steps:
|
||||
- export PKG_CONFIG_PATH="$(build.assets/build-fido2-macos.sh pkg_config_path)"
|
||||
- make clean release OS=$OS ARCH=$ARCH FIDO2=yes TOUCHID=yes PIV=yes
|
||||
environment:
|
||||
APPLE_PASSWORD:
|
||||
from_secret: APPLE_PASSWORD
|
||||
APPLE_USERNAME:
|
||||
from_secret: APPLE_USERNAME
|
||||
ARCH: amd64
|
||||
BUILDBOX_PASSWORD:
|
||||
from_secret: BUILDBOX_PASSWORD
|
||||
@@ -18265,6 +18273,6 @@ volumes:
|
||||
temp: {}
|
||||
---
|
||||
kind: signature
|
||||
hmac: 9444b140a082dcea2c8577707f8626e0efb292ed0e16f66744ffcb13e1166cbb
|
||||
hmac: df00b73f447e6ab65125e08794a80e6ec48bdbfbd6dafdc0449ab2f87c4ecdee
|
||||
|
||||
...
|
||||
|
||||
@@ -413,6 +413,8 @@ release:
|
||||
@echo "---> $(RELEASE_MESSAGE)"
|
||||
ifeq ("$(OS)", "windows")
|
||||
$(MAKE) --no-print-directory release-windows
|
||||
else ifeq ("$(OS)", "darwin")
|
||||
$(MAKE) --no-print-directory release-darwin
|
||||
else
|
||||
$(MAKE) --no-print-directory release-unix
|
||||
endif
|
||||
@@ -460,6 +462,19 @@ build-archive:
|
||||
release-unix: clean full build-archive
|
||||
@if [ -f e/Makefile ]; then $(MAKE) -C e release; fi
|
||||
|
||||
.PHONY: release-darwin-unsigned
|
||||
release-darwin-unsigned: RELEASE:=$(RELEASE)-unsigned
|
||||
release-darwin-unsigned: clean full build-archive
|
||||
|
||||
.PHONY: release-darwin
|
||||
release-darwin: ABSOLUTE_BINARY_PATHS:=$(addprefix $(CURDIR)/,$(BINARIES))
|
||||
release-darwin: release-darwin-unsigned
|
||||
cd ./build.assets/tooling/ && \
|
||||
go run ./cmd/notarize-apple-binaries/*.go \
|
||||
--log-level=debug $(ABSOLUTE_BINARY_PATHS)
|
||||
$(MAKE) build-archive
|
||||
@if [ -f e/Makefile ]; then $(MAKE) -C e release; fi
|
||||
|
||||
#
|
||||
# make release-unix-only - Produces an Enterprise binary release tarball containing
|
||||
# teleport, tctl, and tsh *WITHOUT* also creating an OSS build tarball.
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
Copyright 2022 Gravitational, Inc.
|
||||
|
||||
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 (
|
||||
"context"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/gravitational/trace"
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/mitchellh/gon/notarize"
|
||||
"github.com/mitchellh/gon/package/zip"
|
||||
"github.com/mitchellh/gon/sign"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/gravitational/teleport/build.assets/tooling/lib/logging"
|
||||
)
|
||||
|
||||
const (
|
||||
DeveloperIdentity string = "0FFD3E3413AB4C599C53FBB1D8CA690915E33D83"
|
||||
BundleID string = "com.gravitational.teleport"
|
||||
)
|
||||
|
||||
type GonWrapper struct {
|
||||
ctx context.Context
|
||||
logger hclog.Logger
|
||||
AppleUsername string
|
||||
ApplePassword string
|
||||
BinaryPaths []string
|
||||
}
|
||||
|
||||
func NewGonWrapper(appleUsername, applePassword string, BinaryPaths []string) *GonWrapper {
|
||||
return &GonWrapper{
|
||||
ctx: context.Background(),
|
||||
logger: logging.NewHCLogLogrusAdapter(logrus.StandardLogger()),
|
||||
AppleUsername: appleUsername,
|
||||
ApplePassword: applePassword,
|
||||
BinaryPaths: BinaryPaths,
|
||||
}
|
||||
}
|
||||
|
||||
func (gw *GonWrapper) SignAndNotarizeBinaries() error {
|
||||
err := gw.SignBinaries()
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "failed to sign binaries")
|
||||
}
|
||||
|
||||
zipPath, err := gw.ZipBinaries()
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "failed to zip binaries for notarization")
|
||||
}
|
||||
defer os.RemoveAll(path.Dir(zipPath))
|
||||
|
||||
err = gw.NotarizeBinaries(zipPath)
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "failed to notarize binaries")
|
||||
}
|
||||
|
||||
gw.logger.Info("Signing and notarization complete!")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gw *GonWrapper) SignBinaries() error {
|
||||
gw.logger.Info("Signing binaries %v...", gw.BinaryPaths)
|
||||
err := sign.Sign(gw.ctx, &sign.Options{
|
||||
Files: gw.BinaryPaths,
|
||||
Identity: DeveloperIdentity,
|
||||
Logger: gw.logger,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "gon failed to sign binaries %v", gw.BinaryPaths)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gw *GonWrapper) ZipBinaries() (string, error) {
|
||||
zipFileName := "notarization.zip"
|
||||
gw.logger.Info("Zipping binaries into %q for notarization upload...", zipFileName)
|
||||
tmpDir, err := os.MkdirTemp("", "gon-zip-directory-*")
|
||||
if err != nil {
|
||||
return "", trace.Wrap(err, "failed to create temporary directory for binary zipping")
|
||||
}
|
||||
|
||||
outputPath := path.Join(tmpDir, zipFileName)
|
||||
gw.logger.Debug("Using binary zip path %q", outputPath)
|
||||
|
||||
err = zip.Zip(gw.ctx, &zip.Options{
|
||||
Files: gw.BinaryPaths,
|
||||
OutputPath: outputPath,
|
||||
Logger: gw.logger,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
os.RemoveAll(tmpDir)
|
||||
return "", trace.Wrap(err, "gon failed to zip binaries %v to zip %q", gw.BinaryPaths, outputPath)
|
||||
}
|
||||
|
||||
return outputPath, nil
|
||||
}
|
||||
|
||||
func (gw *GonWrapper) NotarizeBinaries(zipPath string) error {
|
||||
gw.logger.Info("Uploading %q to Apple for notarization ticket issuance. This may take awhile...", zipPath)
|
||||
notarizationInfo, err := notarize.Notarize(gw.ctx, ¬arize.Options{
|
||||
File: zipPath,
|
||||
BundleId: BundleID,
|
||||
Username: gw.AppleUsername,
|
||||
Password: gw.ApplePassword,
|
||||
Logger: gw.logger,
|
||||
})
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "gon failed to notarize binaries %v in zip %q with notarization info %+v",
|
||||
gw.BinaryPaths, zipPath, notarizationInfo)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2022 Gravitational, Inc.
|
||||
|
||||
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 (
|
||||
"os"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type LoggerConfig struct {
|
||||
logLevel logrus.Level
|
||||
logJSON bool
|
||||
}
|
||||
|
||||
func NewLoggerConfig(logLevel logrus.Level, logJSON bool) *LoggerConfig {
|
||||
return &LoggerConfig{
|
||||
logLevel: logLevel,
|
||||
logJSON: logJSON,
|
||||
}
|
||||
}
|
||||
|
||||
func (lc *LoggerConfig) setupLogger() {
|
||||
if lc.logJSON {
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{})
|
||||
} else {
|
||||
logrus.SetFormatter(&logrus.TextFormatter{})
|
||||
}
|
||||
logrus.SetOutput(os.Stdout)
|
||||
logrus.SetLevel(lc.logLevel)
|
||||
logrus.Debugf("Setup logger with config: %+v", lc)
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
Copyright 2022 Gravitational, Inc.
|
||||
|
||||
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 (
|
||||
"debug/macho"
|
||||
"fmt"
|
||||
|
||||
"github.com/gravitational/kingpin"
|
||||
"github.com/gravitational/trace"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const binaryArgName string = "binaries"
|
||||
|
||||
type Config struct {
|
||||
LogLevel string
|
||||
LogJSON bool
|
||||
AppleUsername string
|
||||
ApplePassword string
|
||||
BinaryPaths []string
|
||||
}
|
||||
|
||||
func main() {
|
||||
var config Config
|
||||
kingpin.Flag("log-level", "Output logging level").Default(logrus.InfoLevel.String()).EnumVar(&config.LogLevel, getLogLevelStrings()...)
|
||||
kingpin.Flag("log-json", "Enable JSON logging").Default(fmt.Sprintf("%v", false)).BoolVar(&config.LogJSON)
|
||||
kingpin.Flag("apple-username", "Apple Connect username used for notarization").Required().Envar("APPLE_USERNAME").StringVar(&config.AppleUsername)
|
||||
kingpin.Flag("apple-password", "Apple Connect password used for notarization").Required().Envar("APPLE_PASSWORD").StringVar(&config.ApplePassword)
|
||||
kingpin.Arg(binaryArgName, "Path to Apple binaries for signing and notarization").Required().Action(binaryArgValidatiorAction).ExistingFilesVar(&config.BinaryPaths)
|
||||
kingpin.Parse()
|
||||
|
||||
err := run(&config)
|
||||
|
||||
if err != nil {
|
||||
logrus.Fatal(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
func getLogLevelStrings() []string {
|
||||
logLevelStrings := make([]string, 0, len(logrus.AllLevels))
|
||||
for _, level := range logrus.AllLevels {
|
||||
logLevelStrings = append(logLevelStrings, level.String())
|
||||
}
|
||||
|
||||
return logLevelStrings
|
||||
}
|
||||
|
||||
func binaryArgValidatiorAction(pc *kingpin.ParseContext) error {
|
||||
for _, element := range pc.Elements {
|
||||
if clause, ok := element.Clause.(*kingpin.ArgClause); !ok || clause.Model().Name != binaryArgName {
|
||||
continue
|
||||
}
|
||||
|
||||
binaryPath := *element.Value
|
||||
err := verifyFileIsAppleBinary(binaryPath)
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "failed to verify that %q is a valid Apple binary for signing", binaryPath)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Returns an error if the file is not a valid Apple binary
|
||||
// Effectively does `file $BINARY | grep -ic 'mach-o'`
|
||||
func verifyFileIsAppleBinary(filePath string) error {
|
||||
// First check to see if the binary is a typical mach-o binary.
|
||||
// If it's not, it could still be a multiarch "fat" mach-o binary,
|
||||
// so we try that next. If both fail then the file is not an Apple
|
||||
// binary.
|
||||
fileHandle, err := macho.Open(filePath)
|
||||
if err != nil {
|
||||
fatFileHandle, err := macho.OpenFat(filePath)
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "the provided file %q is neither a normal or multiarch mach-o binary.", filePath)
|
||||
}
|
||||
|
||||
err = fatFileHandle.Close()
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "identified %q as a multiarch mach-o binary but failed to close the file handle", filePath)
|
||||
}
|
||||
} else {
|
||||
err := fileHandle.Close()
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "identified %q as a mach-o binary but failed to close the file handle", filePath)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func run(config *Config) error {
|
||||
// This needs to be called as soon as possible so that the logger can
|
||||
// be used when checking args
|
||||
parsedLogLevel, err := logrus.ParseLevel(config.LogLevel)
|
||||
if err != nil {
|
||||
// This should never be hit if kingpin is configured correctly
|
||||
return trace.Wrap(err, "failed to parse logrus log level")
|
||||
}
|
||||
NewLoggerConfig(parsedLogLevel, config.LogJSON).setupLogger()
|
||||
|
||||
err = NewGonWrapper(config.AppleUsername, config.ApplePassword, config.BinaryPaths).SignAndNotarizeBinaries()
|
||||
if err != nil {
|
||||
return trace.Wrap(err, "failed to sign and notarize binaries")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -13,21 +13,38 @@ require (
|
||||
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf
|
||||
github.com/seqsense/s3sync v1.8.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/stretchr/testify v1.2.2
|
||||
github.com/stretchr/testify v1.8.1
|
||||
golang.org/x/exp v0.0.0-20221114191408-850992195362
|
||||
golang.org/x/mod v0.6.0
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
|
||||
github.com/fatih/color v1.7.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.0.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
|
||||
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.0.0 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.6.3 // indirect
|
||||
github.com/mattn/go-colorable v0.1.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.10 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gabriel-vasile/mimetype v1.4.0 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
|
||||
github.com/golang/protobuf v1.3.2 // indirect
|
||||
github.com/google/go-github/v45 v45.2.0 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/gravitational/kingpin v2.1.10+incompatible
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
github.com/mitchellh/gon v0.2.5
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/crypto v0.4.0 // indirect
|
||||
golang.org/x/net v0.3.0 // indirect
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 h1:s6gZFSlWYmbqAuRjVTiNNhvNRfY2Wxp9nhfyel4rklc=
|
||||
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
|
||||
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
|
||||
github.com/aws/aws-sdk-go v1.44.19/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
|
||||
github.com/aws/aws-sdk-go v1.44.47 h1:uyiNvoR4wfZ8Bp4ghgbyzGFIg5knjZMUAd5S9ba9qNU=
|
||||
github.com/aws/aws-sdk-go v1.44.47/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
|
||||
@@ -8,14 +15,19 @@ github.com/cavaliergopher/rpm v1.2.0/go.mod h1:R0q3vTqa7RUvPofAZYrnjJ63hh2vngjFf
|
||||
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/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/gabriel-vasile/mimetype v1.4.0 h1:Cn9dkdYsMIu56tGho+fqzh7XmvY2YyGU0FnbhiOsEro=
|
||||
github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/protobuf v1.1.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 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
||||
@@ -28,32 +40,71 @@ github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gravitational/kingpin v2.1.10+incompatible h1:QCidzEf5zBD+IGoqytoLP10XizbqcdecKyIjhHXeVDw=
|
||||
github.com/gravitational/kingpin v2.1.10+incompatible/go.mod h1:LWxG30M3FcrjhOn3T4zz7JmBoQJ45MWZmOXgy9Ganoc=
|
||||
github.com/gravitational/trace v1.1.15 h1:dfaFcARt110nCX6RSvrcRUbvRawEYAasXyCqnhXo0Xg=
|
||||
github.com/gravitational/trace v1.1.15/go.mod h1:RvdOUHE4SHqR3oXlFFKnGzms8a5dugHygGw1bqDstYI=
|
||||
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2 h1:STV8OvzphW1vlhPFxcG8d6OIilzBSKRAoWFJt+Onu10=
|
||||
github.com/hashicorp/go-hclog v0.9.3-0.20191025211905-234833755cb2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-retryablehttp v0.6.3 h1:tuulM+WnToeqa05z83YLmKabZxrySOmJAd4mJ+s2Nfg=
|
||||
github.com/hashicorp/go-retryablehttp v0.6.3/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
|
||||
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
|
||||
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf h1:FtEj8sfIcaaBfAKrE1Cwb61YDtYq9JxChK1c7AKce7s=
|
||||
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf/go.mod h1:yrqSXGoD/4EKfF26AOGzscPOgTTJcyAwM2rpixWT+t4=
|
||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
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/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/gon v0.2.5 h1:mVWtqTzV03W0avJqmqjk9M0qls3TDUXfc9ETJaPIOWY=
|
||||
github.com/mitchellh/gon v0.2.5/go.mod h1:Ua18ZhqjZHg8VyqZo8kNHAY331ntV6nNJ9mT3s2mIo8=
|
||||
github.com/pkg/errors v0.9.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/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
|
||||
github.com/seqsense/s3sync v1.8.2 h1:oMgs3aZ07GovNc0uQ2oWYNPRN7i4foU9pwF3RhOO0Gk=
|
||||
github.com/seqsense/s3sync v1.8.2/go.mod h1:lDmrc+z24//pnnFOFzBlBX+uJwVgnv429EGdeiP0/vg=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
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/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
|
||||
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
||||
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
||||
@@ -61,6 +112,8 @@ golang.org/x/exp v0.0.0-20221114191408-850992195362 h1:NoHlPRbyl1VFI6FjwHtPQCN7w
|
||||
golang.org/x/exp v0.0.0-20221114191408-850992195362/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I=
|
||||
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
|
||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
@@ -69,9 +122,14 @@ golang.org/x/net v0.3.0 h1:VWL6FNY2bEEmsGVKabSlHu5Irp34xmMRoqb/9lF9lxk=
|
||||
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8=
|
||||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -91,10 +149,19 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
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/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
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.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
|
||||
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
/*
|
||||
Copyright 2022 Gravitational, Inc.
|
||||
|
||||
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 logging
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// All of our other tools use logrus for logging, but the gon package
|
||||
// uses https://pkg.go.dev/github.com/hashicorp/go-hclog. This is an
|
||||
// adapter that will send hclog output to logrus.
|
||||
type HCLogLogrusAdapter struct {
|
||||
name string
|
||||
logger *logrus.Logger
|
||||
impliedArgs []interface{}
|
||||
}
|
||||
|
||||
func NewHCLogLogrusAdapter(logrusLogger *logrus.Logger) *HCLogLogrusAdapter {
|
||||
return &HCLogLogrusAdapter{
|
||||
logger: logrusLogger,
|
||||
}
|
||||
}
|
||||
|
||||
// Args are alternating key, val pairs
|
||||
// keys must be strings
|
||||
// vals can be any type, but display is implementation specific
|
||||
// Emit a message and key/value pairs at a provided log level
|
||||
func (h *HCLogLogrusAdapter) Log(level hclog.Level, msg string, args ...interface{}) {
|
||||
logrusLevel := hclogLevelToLogrusLevel(level)
|
||||
msgWithImpliedArgs := fmt.Sprintf("%s %%s", msg)
|
||||
argsWithImpliedArgsString := append(args, h.createImpliedArgsString())
|
||||
h.logger.Logf(logrusLevel, msgWithImpliedArgs, argsWithImpliedArgsString)
|
||||
}
|
||||
|
||||
// Emit a message and key/value pairs at the TRACE level
|
||||
func (h *HCLogLogrusAdapter) Trace(msg string, args ...interface{}) {
|
||||
h.Log(hclog.Trace, msg, args)
|
||||
}
|
||||
|
||||
// Emit a message and key/value pairs at the DEBUG level
|
||||
func (h *HCLogLogrusAdapter) Debug(msg string, args ...interface{}) {
|
||||
h.Log(hclog.Debug, msg, args)
|
||||
}
|
||||
|
||||
// Emit a message and key/value pairs at the INFO level
|
||||
func (h *HCLogLogrusAdapter) Info(msg string, args ...interface{}) {
|
||||
h.Log(hclog.Info, msg, args)
|
||||
}
|
||||
|
||||
// Emit a message and key/value pairs at the WARN level
|
||||
func (h *HCLogLogrusAdapter) Warn(msg string, args ...interface{}) {
|
||||
h.Log(hclog.Warn, msg, args)
|
||||
}
|
||||
|
||||
// Emit a message and key/value pairs at the ERROR level
|
||||
func (h *HCLogLogrusAdapter) Error(msg string, args ...interface{}) {
|
||||
h.Log(hclog.Error, msg, args)
|
||||
}
|
||||
|
||||
// Indicate if TRACE logs would be emitted. This and the other Is* guards
|
||||
// are used to elide expensive logging code based on the current level.
|
||||
func (h *HCLogLogrusAdapter) IsTrace() bool {
|
||||
return h.logger.IsLevelEnabled(logrus.TraceLevel)
|
||||
}
|
||||
|
||||
// Indicate if DEBUG logs would be emitted. This and the other Is* guards
|
||||
func (h *HCLogLogrusAdapter) IsDebug() bool {
|
||||
return h.logger.IsLevelEnabled(logrus.DebugLevel)
|
||||
}
|
||||
|
||||
// Indicate if INFO logs would be emitted. This and the other Is* guards
|
||||
func (h *HCLogLogrusAdapter) IsInfo() bool {
|
||||
return h.logger.IsLevelEnabled(logrus.InfoLevel)
|
||||
}
|
||||
|
||||
// Indicate if WARN logs would be emitted. This and the other Is* guards
|
||||
func (h *HCLogLogrusAdapter) IsWarn() bool {
|
||||
return h.logger.IsLevelEnabled(logrus.WarnLevel)
|
||||
}
|
||||
|
||||
// Indicate if ERROR logs would be emitted. This and the other Is* guards
|
||||
func (h *HCLogLogrusAdapter) IsError() bool {
|
||||
return h.logger.IsLevelEnabled(logrus.ErrorLevel)
|
||||
}
|
||||
|
||||
// ImpliedArgs returns With key/value pairs
|
||||
func (h *HCLogLogrusAdapter) ImpliedArgs() []interface{} {
|
||||
return h.impliedArgs
|
||||
}
|
||||
|
||||
// Creates a sublogger that will always have the given key/value pairs
|
||||
func (h *HCLogLogrusAdapter) With(args ...interface{}) hclog.Logger {
|
||||
// Ensure that there is a key for every value
|
||||
if len(args)%2 != 0 {
|
||||
extraValue := args[len(args)-1]
|
||||
// Pulled from https://github.com/hashicorp/go-hclog/blob/main/intlogger.go#L731
|
||||
args[len(args)-1] = "EXTRA_VALUE_AT_END"
|
||||
args = append(args, extraValue)
|
||||
}
|
||||
|
||||
newLogger := NewHCLogLogrusAdapter(h.logger)
|
||||
newLogger.impliedArgs = append(newLogger.impliedArgs, args)
|
||||
return newLogger
|
||||
}
|
||||
|
||||
// Returns the Name of the logger
|
||||
func (h *HCLogLogrusAdapter) Name() string {
|
||||
return h.name
|
||||
}
|
||||
|
||||
// Create a logger that will prepend the name string on the front of all messages.
|
||||
// If the logger already has a name, the new value will be appended to the current
|
||||
// name. That way, a major subsystem can use this to decorate all it's own logs
|
||||
// without losing context.
|
||||
func (h *HCLogLogrusAdapter) Named(name string) hclog.Logger {
|
||||
if h.name != "" {
|
||||
name = fmt.Sprintf("%s.%s", name, h.name)
|
||||
}
|
||||
|
||||
return h.ResetNamed(name)
|
||||
}
|
||||
|
||||
// Create a logger that will prepend the name string on the front of all messages.
|
||||
// This sets the name of the logger to the value directly, unlike Named which honor
|
||||
// the current name as well.
|
||||
func (h *HCLogLogrusAdapter) ResetNamed(name string) hclog.Logger {
|
||||
newLogger := NewHCLogLogrusAdapter(h.logger)
|
||||
newLogger.name = name
|
||||
|
||||
return newLogger
|
||||
}
|
||||
|
||||
// Updates the level. This should affect all related loggers as well,
|
||||
// unless they were created with IndependentLevels. If an
|
||||
// implementation cannot update the level on the fly, it should no-op.
|
||||
func (h *HCLogLogrusAdapter) SetLevel(level hclog.Level) {
|
||||
h.logger.SetLevel(hclogLevelToLogrusLevel(level))
|
||||
}
|
||||
|
||||
// Returns the current level
|
||||
func (h *HCLogLogrusAdapter) GetLevel() hclog.Level {
|
||||
switch h.logger.GetLevel() {
|
||||
case logrus.FatalLevel, logrus.PanicLevel, logrus.ErrorLevel:
|
||||
return hclog.Error
|
||||
case logrus.WarnLevel:
|
||||
return hclog.Warn
|
||||
case logrus.InfoLevel:
|
||||
return hclog.Info
|
||||
case logrus.DebugLevel:
|
||||
return hclog.Debug
|
||||
case logrus.TraceLevel:
|
||||
return hclog.Trace
|
||||
}
|
||||
|
||||
return hclog.NoLevel
|
||||
}
|
||||
|
||||
// Return a value that conforms to the stdlib log.Logger interface
|
||||
// Options are ignored as it's not currently worth the time to implement them
|
||||
func (h *HCLogLogrusAdapter) StandardLogger(options *hclog.StandardLoggerOptions) *log.Logger {
|
||||
return log.New(h.StandardWriter(options), "", 0)
|
||||
}
|
||||
|
||||
// Return a value that conforms to io.Writer, which can be passed into log.SetOutput()
|
||||
// Options are ignored as it's not currently worth the time to implement them
|
||||
func (h *HCLogLogrusAdapter) StandardWriter(_ *hclog.StandardLoggerOptions) io.Writer {
|
||||
logrusOut := h.logger.Out
|
||||
if logrusOut != nil {
|
||||
return logrusOut
|
||||
}
|
||||
|
||||
return os.Stderr
|
||||
}
|
||||
|
||||
func hclogLevelToLogrusLevel(level hclog.Level) logrus.Level {
|
||||
// The docs for hclog also list a "Off" level, but it's not defined in the version of hclog used by gon.
|
||||
switch level {
|
||||
case hclog.Error:
|
||||
return logrus.ErrorLevel
|
||||
case hclog.Warn:
|
||||
return logrus.WarnLevel
|
||||
case hclog.Info:
|
||||
return logrus.InfoLevel
|
||||
case hclog.Debug:
|
||||
return logrus.DebugLevel
|
||||
case hclog.Trace:
|
||||
return logrus.TraceLevel
|
||||
case hclog.NoLevel:
|
||||
return logrus.InfoLevel
|
||||
}
|
||||
|
||||
return logrus.InfoLevel
|
||||
}
|
||||
|
||||
func (h *HCLogLogrusAdapter) createImpliedArgsString() string {
|
||||
keyPairCount := len(h.impliedArgs) / 2
|
||||
var argsStringBuilder strings.Builder
|
||||
for keyPairNumber := 0; keyPairNumber < keyPairCount; keyPairNumber++ {
|
||||
if argsStringBuilder.Len() != 0 {
|
||||
fmt.Fprint(&argsStringBuilder, ", ")
|
||||
}
|
||||
keyPairPosition := 2 * keyPairNumber
|
||||
key := h.impliedArgs[keyPairPosition]
|
||||
value := h.impliedArgs[keyPairPosition+1]
|
||||
fmt.Fprintf(&argsStringBuilder, "%+v=%+v", key, value)
|
||||
}
|
||||
|
||||
return argsStringBuilder.String()
|
||||
}
|
||||
@@ -499,6 +499,8 @@ func buildMacArtifactsStep(workspacePath string, b buildType, toolchainConfig to
|
||||
"ARCH": {raw: b.arch},
|
||||
"WORKSPACE_DIR": {raw: workspacePath},
|
||||
"BUILDBOX_PASSWORD": {fromSecret: "BUILDBOX_PASSWORD"},
|
||||
"APPLE_USERNAME": {fromSecret: "APPLE_USERNAME"},
|
||||
"APPLE_PASSWORD": {fromSecret: "APPLE_PASSWORD"},
|
||||
},
|
||||
Commands: darwinBuildCommands(toolchainConfig, artifactConfig),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user