mirror of
https://github.com/outbackdingo/proxmox-cloud-controller-manager.git
synced 2026-01-27 02:20:02 +00:00
test: cloud config
Check cluster config params.
This commit is contained in:
@@ -18,7 +18,9 @@ RUN make build-all-archs
|
||||
########################################
|
||||
|
||||
FROM --platform=${TARGETARCH} scratch AS release
|
||||
LABEL org.opencontainers.image.source https://github.com/sergelogvinov/proxmox-cloud-controller-manager
|
||||
LABEL org.opencontainers.image.source https://github.com/sergelogvinov/proxmox-cloud-controller-manager \
|
||||
org.opencontainers.image.licenses = "Apache-2.0" \
|
||||
org.opencontainers.image.description = "Proxmox VE CCM for Kubernetes"
|
||||
|
||||
COPY --from=gcr.io/distroless/static-debian11:nonroot . .
|
||||
ARG TARGETARCH
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
yaml "gopkg.in/yaml.v3"
|
||||
)
|
||||
@@ -46,6 +47,24 @@ func ReadCloudConfig(config io.Reader) (ClustersConfig, error) {
|
||||
}
|
||||
}
|
||||
|
||||
for idx, c := range cfg.Clusters {
|
||||
if c.TokenID == "" {
|
||||
return ClustersConfig{}, fmt.Errorf("cluster #%d: token_id is required", idx+1)
|
||||
}
|
||||
|
||||
if c.TokenSecret == "" {
|
||||
return ClustersConfig{}, fmt.Errorf("cluster #%d: token_secret is required", idx+1)
|
||||
}
|
||||
|
||||
if c.Region == "" {
|
||||
return ClustersConfig{}, fmt.Errorf("cluster #%d: region is required", idx+1)
|
||||
}
|
||||
|
||||
if c.URL == "" || !strings.HasPrefix(c.URL, "http") {
|
||||
return ClustersConfig{}, fmt.Errorf("cluster #%d: url is required", idx+1)
|
||||
}
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,16 @@ clusters:
|
||||
assert.NotNil(t, err)
|
||||
assert.NotNil(t, cfg)
|
||||
|
||||
// Non full config
|
||||
cfg, err = cluster.ReadCloudConfig(strings.NewReader(`
|
||||
clusters:
|
||||
- url: abcd
|
||||
region: cluster-1
|
||||
`))
|
||||
|
||||
assert.NotNil(t, err)
|
||||
assert.NotNil(t, cfg)
|
||||
|
||||
// Valid config with one cluster
|
||||
cfg, err = cluster.ReadCloudConfig(strings.NewReader(`
|
||||
clusters:
|
||||
|
||||
Reference in New Issue
Block a user