forked from kubermatic/machine-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
66 lines (53 loc) · 2.67 KB
/
types.go
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
56
57
58
59
60
61
62
63
64
65
66
/*
Copyright 2019 The Machine Controller 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 types
import (
"github.com/magnusr/kubermatic-machine-controller/pkg/jsonutil"
providerconfigtypes "github.com/magnusr/kubermatic-machine-controller/pkg/providerconfig/types"
)
// RawConfig represents vsphere specific configuration.
type RawConfig struct {
TemplateVMName providerconfigtypes.ConfigVarString `json:"templateVMName"`
// Deprecated: use networks instead.
VMNetName providerconfigtypes.ConfigVarString `json:"vmNetName"`
Networks []providerconfigtypes.ConfigVarString `json:"networks"`
Username providerconfigtypes.ConfigVarString `json:"username"`
Password providerconfigtypes.ConfigVarString `json:"password"`
VSphereURL providerconfigtypes.ConfigVarString `json:"vsphereURL"`
Datacenter providerconfigtypes.ConfigVarString `json:"datacenter"`
// Cluster defines the cluster to use in vcenter.
// Only needed for vm anti affinity.
Cluster providerconfigtypes.ConfigVarString `json:"cluster"`
Folder providerconfigtypes.ConfigVarString `json:"folder"`
ResourcePool providerconfigtypes.ConfigVarString `json:"resourcePool"`
// Either Datastore or DatastoreCluster have to be provided.
DatastoreCluster providerconfigtypes.ConfigVarString `json:"datastoreCluster"`
Datastore providerconfigtypes.ConfigVarString `json:"datastore"`
CPUs int32 `json:"cpus"`
MemoryMB int64 `json:"memoryMB"`
DiskSizeGB *int64 `json:"diskSizeGB,omitempty"`
Tags []Tag `json:"tags,omitempty"`
AllowInsecure providerconfigtypes.ConfigVarBool `json:"allowInsecure"`
VMAntiAffinity providerconfigtypes.ConfigVarBool `json:"vmAntiAffinity"`
}
// Tag represents vsphere tag.
type Tag struct {
Description string `json:"description,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
CategoryID string `json:"categoryID"`
}
func GetConfig(pconfig providerconfigtypes.Config) (*RawConfig, error) {
rawConfig := &RawConfig{}
return rawConfig, jsonutil.StrictUnmarshal(pconfig.CloudProviderSpec.Raw, rawConfig)
}