Skip to content

Commit

Permalink
fixup! fixup! reloader: allow suppressing envvar errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rexagod committed Jun 18, 2024
1 parent edf9a3f commit 2c88397
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docs/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ config:
bucket: ""
endpoint: ""
region: ""
disable_dualstack: false
aws_sdk_auth: false
access_key: ""
insecure: false
Expand Down Expand Up @@ -94,6 +95,7 @@ config:
list_objects_version: ""
bucket_lookup_type: auto
send_content_md5: true
disable_multipart: false
part_size: 67108864
sse_config:
type: ""
Expand Down
10 changes: 5 additions & 5 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func New(logger log.Logger, reg prometheus.Registerer, o *Options) *Reloader {
configEnvVarExpansionErrors: promauto.With(reg).NewGauge(
prometheus.GaugeOpts{
Name: "reloader_config_env_var_expansion_errors",
Help: "Total number of config environment variable expansions that failed.",
Help: "Number of environment variable expansions that failed during the last operation.",
},
),
reloaderInfo: promauto.With(reg).NewGaugeVec(
Expand Down Expand Up @@ -360,8 +360,8 @@ func (r *Reloader) Watch(ctx context.Context) error {
}
}

func (r *Reloader) normalize(input, output string) error {
b, err := os.ReadFile(input)
func (r *Reloader) normalize(inputFile, outputFile string) error {
b, err := os.ReadFile(inputFile)
if err != nil {
return errors.Wrap(err, "read file")
}
Expand All @@ -385,14 +385,14 @@ func (r *Reloader) normalize(input, output string) error {
return errors.Wrap(err, "expand environment variables")
}

tmpFile := output + ".tmp"
tmpFile := outputFile + ".tmp"
defer func() {
_ = os.Remove(tmpFile)
}()
if err := os.WriteFile(tmpFile, b, 0644); err != nil {
return errors.Wrap(err, "write file")
}
if err := os.Rename(tmpFile, output); err != nil {
if err := os.Rename(tmpFile, outputFile); err != nil {
return errors.Wrap(err, "rename file")
}
return nil
Expand Down

0 comments on commit 2c88397

Please sign in to comment.