fix(api-docs): time.Duration bounds fix + linting fixes [C9S-223] (#2762)

This commit is contained in:
Hannah Cooper
2026-06-04 15:14:07 +12:00
committed by GitHub
parent 580a9fdfcf
commit 916367dccb
5 changed files with 14 additions and 10 deletions
+1 -1
View File
@@ -109,7 +109,7 @@ dev-extension: build-server build-client ## Run the extension in development mod
.PHONY: docs-build docs-validate docs-clean docs-validate-clean
docs-build: init-dist ## Build docs
go mod download
cd api && $(SWAG) init -o "../dist/docs" -ot "yaml" -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 -p pascalcase --markdownFiles ./
cd api && $(SWAG) init -o "../dist/docs" -ot "yaml" -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 -p pascalcase --markdownFiles ./ --overridesFile .swaggo
docs-validate: docs-build ## Validate docs
pnpm swagger2openapi --warnOnly dist/docs/swagger.yaml -o dist/docs/openapi.yaml
+1
View File
@@ -0,0 +1 @@
replace k8s.io/apimachinery/pkg/apis/meta/v1.Duration string
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"crypto/rand"
"errors"
"io"
"slices"
)
type Nonce struct {
@@ -45,7 +46,7 @@ func (n *Nonce) Value() []byte {
func (n *Nonce) Increment() error {
// Start incrementing from the least significant byte
for i := len(n.val) - 1; i >= 0; i-- {
for i := range slices.Backward(n.val) {
// Increment the current byte
n.val[i]++
+8 -6
View File
@@ -1,6 +1,8 @@
package workflows
import (
"slices"
portainer "github.com/portainer/portainer/api"
gittypes "github.com/portainer/portainer/api/git/types"
"github.com/portainer/portainer/api/set"
@@ -61,9 +63,9 @@ func MapEdgeStackToWorkflow(es portainer.EdgeStack, gitConfig *gittypes.RepoConf
}
func StackLastSyncDate(s portainer.Stack) int64 {
for i := len(s.DeploymentStatus) - 1; i >= 0; i-- {
if s.DeploymentStatus[i].Status == portainer.StackStatusActive {
return s.DeploymentStatus[i].Time
for _, ds := range slices.Backward(s.DeploymentStatus) {
if ds.Status == portainer.StackStatusActive {
return ds.Time
}
}
return 0
@@ -84,9 +86,9 @@ func edgeStackLastSyncDate(statuses []portainer.EdgeStackStatusForEnv) int64 {
}
func endpointLastSyncDate(epStatus portainer.EdgeStackStatusForEnv) int64 {
for i := len(epStatus.Status) - 1; i >= 0; i-- {
if isEdgeStackHealthyStatus(epStatus.Status[i].Type) {
return epStatus.Status[i].Time
for _, s := range slices.Backward(epStatus.Status) {
if isEdgeStackHealthyStatus(s.Type) {
return s.Time
}
}
return 0
+2 -2
View File
@@ -18,8 +18,8 @@ import (
)
// @id StackStop
// @summary Stops a stopped Stack
// @description Stops a stopped Stack.
// @summary Stop a running Stack
// @description Stop a running Stack.
// @description **Access policy**: authenticated
// @tags stacks
// @security ApiKeyAuth