feat: add Timeweb Cloud provider for Woodpecker CI autoscaler

- Implement timewebcloud provider with DeployAgent, RemoveAgent, ListDeployedAgentNames
- Add minimal HTTP API client for Timeweb Cloud (create/list/delete servers)
- Register provider in main.go with CLI flags
- Add timeweb-list and timeweb-tester utilities
- Include Dockerfile and docker-compose.yml for deployment
- Update DEPLOY.md with verified OS/preset IDs
This commit is contained in:
2026-05-16 13:09:07 +03:00
commit 191cdd108f
34 changed files with 8651 additions and 0 deletions

42
utils/random_test.go Normal file
View File

@@ -0,0 +1,42 @@
package utils_test
import (
"testing"
"github.com/stretchr/testify/assert"
"go.woodpecker-ci.org/autoscaler/utils"
)
func TestRandomString(t *testing.T) {
tests := []struct {
name string
n int
want int
}{
{
name: "zero length",
n: 0,
want: 0,
},
{
name: "length 10",
n: 10,
want: 10,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
str := utils.RandomString(tt.n)
assert.Equal(t, tt.want, len(str))
})
t.Run("alphanumeric", func(t *testing.T) {
str1 := utils.RandomString(10)
for _, r := range str1 {
assert.Contains(t, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", string(r))
}
})
}
}