-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.go
More file actions
55 lines (46 loc) · 1.43 KB
/
config.go
File metadata and controls
55 lines (46 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-FileCopyrightText: (C) 2025 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
// Package config provides configuration structures and validation for the Host Manager.
package config
import (
"net"
"time"
"google.golang.org/grpc/codes"
inv_errors "github.com/open-edge-platform/infra-core/inventory/v2/pkg/errors"
)
// HostMgrConfig contains configuration for the host manager..
type HostMgrConfig struct {
EnableTracing bool
EnableMetrics bool
TraceURL string
InventoryAddr string
CACertPath string
TLSKeyPath string
TLSCertPath string
InsecureGRPC bool
EnableHostDiscovery bool
DisabledProvisioning bool
EnableUUIDCache bool
UUIDCacheTTL time.Duration
UUIDCacheTTLOffset int
}
// Validate checks if the configuration is valid.
func (c HostMgrConfig) Validate() error {
if c.InventoryAddr == "" {
return inv_errors.Errorfc(codes.InvalidArgument,
"empty inventory address: %s", c.InventoryAddr)
}
_, err := net.ResolveTCPAddr("tcp", c.InventoryAddr)
if err != nil {
return inv_errors.Errorfc(codes.InvalidArgument,
"invalid inventory address %s: %s", c.InventoryAddr, err)
}
if !c.InsecureGRPC {
if c.CACertPath == "" || c.TLSCertPath == "" || c.TLSKeyPath == "" {
return inv_errors.Errorfc(codes.InvalidArgument,
"gRPC connections should be secure, but one of secrets is not provided")
}
}
return nil
}