-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-oauth2-secret-file-refresh
- Loading branch information
Showing
13 changed files
with
315 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
* Julien Pivotto <roidelapluie@prometheus.io> @roidelapluie | ||
* Josue (Josh) Abreu <josue.abreu@gmail.com> @gotjosh | ||
* Arthur Sens <arthur@prometheus.io> @ArthurSens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Releases | ||
|
||
## What to do know before cutting a release | ||
|
||
While `prometheus/common` does not have a formal release process. We strongly encourage you follow these steps: | ||
|
||
1. Scan the list of available issues / PRs and make sure that You attempt to merge any pull requests that appear to be ready or almost ready | ||
2. Notify the maintainers listed as part of [`MANTAINERS.md`](MAINTAINERS.md) that you're going to do a release. | ||
|
||
With those steps done, you can proceed to cut a release. | ||
|
||
## How to cut an individual release | ||
|
||
There is no automated process for cutting a release in `prometheus/common`. A manual release using GitHub's release feature via [this link](https://github.com/prometheus/prometheus/releases/new) is the best way to go. The tag name must be prefixed with a `v` e.g. `v0.53.0` and then you can use the "Generate release notes" button to generate the release note automagically ✨. No need to create a discussion or mark it a pre-release, please do mark it as the latest release if needed. | ||
|
||
## Versioning strategy | ||
|
||
We aim to adhere to [Semantic Versioning](https://semver.org/) as much as possible. For example, patch version (e.g. v0.0.x) releases should contain bugfixes only and any sort of major or minor version bump should be a minor or major release respectively. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright 2024 The Prometheus Authors | ||
// 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 templates | ||
|
||
import ( | ||
"fmt" | ||
"math" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
func convertToFloat(i interface{}) (float64, error) { | ||
switch v := i.(type) { | ||
case float64: | ||
return v, nil | ||
case string: | ||
return strconv.ParseFloat(v, 64) | ||
case int: | ||
return float64(v), nil | ||
case uint: | ||
return float64(v), nil | ||
case int64: | ||
return float64(v), nil | ||
case uint64: | ||
return float64(v), nil | ||
case time.Duration: | ||
return v.Seconds(), nil | ||
default: | ||
return 0, fmt.Errorf("can't convert %T to float", v) | ||
} | ||
} | ||
|
||
func HumanizeDuration(i interface{}) (string, error) { | ||
v, err := convertToFloat(i) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if math.IsNaN(v) || math.IsInf(v, 0) { | ||
return fmt.Sprintf("%.4g", v), nil | ||
} | ||
if v == 0 { | ||
return fmt.Sprintf("%.4gs", v), nil | ||
} | ||
if math.Abs(v) >= 1 { | ||
sign := "" | ||
if v < 0 { | ||
sign = "-" | ||
v = -v | ||
} | ||
duration := int64(v) | ||
seconds := duration % 60 | ||
minutes := (duration / 60) % 60 | ||
hours := (duration / 60 / 60) % 24 | ||
days := duration / 60 / 60 / 24 | ||
// For days to minutes, we display seconds as an integer. | ||
if days != 0 { | ||
return fmt.Sprintf("%s%dd %dh %dm %ds", sign, days, hours, minutes, seconds), nil | ||
} | ||
if hours != 0 { | ||
return fmt.Sprintf("%s%dh %dm %ds", sign, hours, minutes, seconds), nil | ||
} | ||
if minutes != 0 { | ||
return fmt.Sprintf("%s%dm %ds", sign, minutes, seconds), nil | ||
} | ||
// For seconds, we display 4 significant digits. | ||
return fmt.Sprintf("%s%.4gs", sign, v), nil | ||
} | ||
prefix := "" | ||
for _, p := range []string{"m", "u", "n", "p", "f", "a", "z", "y"} { | ||
if math.Abs(v) >= 1 { | ||
break | ||
} | ||
prefix = p | ||
v *= 1000 | ||
} | ||
return fmt.Sprintf("%.4g%ss", v, prefix), nil | ||
} |
Oops, something went wrong.