Skip to content

Commit

Permalink
cmd/image-builder: add deployment channel as field to the logs
Browse files Browse the repository at this point in the history
  • Loading branch information
schuellerf committed Aug 14, 2024
1 parent 49ab353 commit a485cb6
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
5 changes: 5 additions & 0 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/labstack/gommon/log"
slogger "github.com/osbuild/osbuild-composer/pkg/splunk_logger"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -73,6 +74,10 @@ func main() {
}
}

if conf.DeploymentChannel != "" {
logrus.AddHook(&slogger.EnvironmentHook{Channel: conf.DeploymentChannel})
}

if conf.SplunkHost != "" {
err = logger.AddSplunkHook(logrus.StandardLogger(), conf.SplunkHost, conf.SplunkPort, conf.SplunkToken)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/oapi-codegen/runtime v1.1.1
github.com/osbuild/community-gateway/oidc-authorizer v0.0.0-20240117171535-401ddadefd40
github.com/osbuild/images v0.73.0
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240311100454-57ebfb401131
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
github.com/prometheus/client_golang v1.19.1
github.com/redhatinsights/app-common-go v1.6.8
github.com/redhatinsights/identity v0.0.0-20220719174832-36a7b1cbeff1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ github.com/osbuild/community-gateway/oidc-authorizer v0.0.0-20240117171535-401dd
github.com/osbuild/community-gateway/oidc-authorizer v0.0.0-20240117171535-401ddadefd40/go.mod h1:CecYUdLQNeKEkEC0DOejBTaVxs8Xbr30tRtgOIpbuKo=
github.com/osbuild/images v0.73.0 h1:2mKFohG1mGh92KFr/rtkmOYTe1Oi6YT0Qdgdz5I20hE=
github.com/osbuild/images v0.73.0/go.mod h1:5xDxWmKDseAPwsnHS16AsHDM2ytCDJcsPK2uaKfvGvc=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240311100454-57ebfb401131 h1:T0XABvVgYzQ4MUfJG+WF+2+/lDHXv8ZMRf9Sqeq+N24=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240311100454-57ebfb401131/go.mod h1:z+WA+dX6qMwc7fqY5jCzESDIlg4WR2sBQezxsoXv9Ik=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d h1:r9BFPDv0uuA9k1947Jybcxs36c/pTywWS1gjeizvtcQ=
github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d/go.mod h1:zR1iu/hOuf+OQNJlk70tju9IqzzM4ycq0ectkFBm94U=
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s=
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type ImageBuilderConfig struct {
RecommendCA string `env:"RECOMMENDATIONS_CA_PATH"`
GlitchTipDSN string `env:"GLITCHTIP_DSN"`
FedoraAuth bool `env:"FEDORA_AUTH"`
DeploymentChannel string `env:"CHANNEL"`
}

func (ibc *ImageBuilderConfig) IsDebug() bool {
Expand Down
2 changes: 2 additions & 0 deletions templates/image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ objects:
key: proxy
name: recommendations-secrets
optional: true
- name: CHANNEL
value: ${CHANNEL}
volumeMounts:
- name: config-volume
mountPath: /app/config
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ github.com/osbuild/community-gateway/oidc-authorizer/pkg/identity
# github.com/osbuild/images v0.73.0
## explicit; go 1.21
github.com/osbuild/images/pkg/crypt
# github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240311100454-57ebfb401131
## explicit; go 1.19
# github.com/osbuild/osbuild-composer/pkg/splunk_logger v0.0.0-20240814102216-0239db53236d
## explicit; go 1.21
github.com/osbuild/osbuild-composer/pkg/splunk_logger
# github.com/perimeterx/marshmallow v1.1.5
## explicit; go 1.17
Expand Down

0 comments on commit a485cb6

Please sign in to comment.