Skip to content

Commit 5850612

Browse files
author
gentele
committed
refactor config
1 parent 5248422 commit 5850612

8 files changed

Lines changed: 132 additions & 97 deletions

File tree

pkg/devspace/config/configutil/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func loadClusterConfig(config *v1.Cluster, overwriteExistingValues bool) {
4343
}
4444

4545
if config.User == nil {
46-
config.User = &v1.User{}
46+
config.User = &v1.ClusterUser{}
4747
}
4848

4949
if config.User.Username == nil {

pkg/devspace/config/configutil/make.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ import (
77
func makeConfig() *v1.Config {
88
return &v1.Config{
99
Cluster: &v1.Cluster{
10-
User: &v1.User{},
10+
User: &v1.ClusterUser{},
1111
},
1212
DevSpace: &v1.DevSpaceConfig{
1313
PortForwarding: &[]*v1.PortForwardingConfig{},
1414
Release: &v1.Release{},
1515
Sync: &[]*v1.SyncConfig{},
1616
},
17-
Image: &v1.ImageConfig{
18-
Registry: &v1.RegistryConfig{
19-
Auth: &v1.RegistryAuth{},
20-
},
21-
},
17+
Images: &map[string]*v1.ImageConfig{},
2218
Services: &v1.ServiceConfig{
2319
InternalRegistry: &v1.InternalRegistry{
2420
Release: &v1.Release{},

pkg/devspace/config/v1/cluster.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package v1
2+
3+
//Cluster is a struct that contains data for a Kubernetes-Cluster
4+
type Cluster struct {
5+
UseKubeConfig *bool `yaml:"useKubeConfig,omitempty"`
6+
APIServer *string `yaml:"apiServer,omitempty"`
7+
CaCert *string `yaml:"caCert,omitempty"`
8+
User *ClusterUser `yaml:"user,omitempty"`
9+
}
10+
11+
//ClusterUser is a user with its username and its client certificate
12+
type ClusterUser struct {
13+
Username *string `yaml:"username,omitempty"`
14+
ClientCert *string `yaml:"clientCert,omitempty"`
15+
ClientKey *string `yaml:"clientKey,omitempty"`
16+
}

pkg/devspace/config/v1/devspace.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package v1
2+
3+
//DevSpaceConfig defines the devspace deployment
4+
type DevSpaceConfig struct {
5+
Release *Release `yaml:"release"`
6+
PortForwarding *[]*PortForwardingConfig `yaml:"portForwarding"`
7+
Sync *[]*SyncConfig `yaml:"sync"`
8+
}
9+
10+
//PortForwardingConfig defines the ports for a port forwarding to a DevSpace
11+
type PortForwardingConfig struct {
12+
Namespace *string `yaml:"namespace"`
13+
ResourceType *string `yaml:"resourceType"`
14+
LabelSelector *map[string]*string `yaml:"labelSelector"`
15+
PortMappings *[]*PortMapping `yaml:"portMappings"`
16+
}
17+
18+
//PortMapping defines the ports for a PortMapping
19+
type PortMapping struct {
20+
LocalPort *int `yaml:"localPort"`
21+
RemotePort *int `yaml:"remotePort"`
22+
}
23+
24+
//SyncConfig defines the paths for a SyncFolder
25+
type SyncConfig struct {
26+
Namespace *string `yaml:"namespace"`
27+
ResourceType *string `yaml:"resourceType"`
28+
LabelSelector *map[string]*string `yaml:"labelSelector"`
29+
LocalSubPath *string `yaml:"localSubPath"`
30+
ContainerPath *string `yaml:"containerPath"`
31+
ExcludePaths *[]string `yaml:"excludePaths"`
32+
DownloadExcludePaths *[]string `yaml:"downloadExcludePaths"`
33+
UploadExcludePaths *[]string `yaml:"uploadExcludePaths"`
34+
}

pkg/devspace/config/v1/image.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package v1
2+
3+
//ImageConfig defines the image specification
4+
type ImageConfig struct {
5+
Name *string `yaml:"name"`
6+
Tag *string `yaml:"tag"`
7+
Registry *string `yaml:"registry"`
8+
Build *BuildConfig `yaml:"build"`
9+
}
10+
11+
//BuildConfig defines the build process for an image
12+
type BuildConfig struct {
13+
ContextPath *string `yaml:"contextPath"`
14+
DockerfilePath *string `yaml:"dockerfilePath"`
15+
Engine *BuildEngine `yaml:"engine"`
16+
}
17+
18+
//BuildEngine defines which build engine to use
19+
type BuildEngine struct {
20+
Kaniko *KanikoBuildEngine `yaml:"kaniko"`
21+
Docker *DockerBuildEngine `yaml:"docker"`
22+
}
23+
24+
//KanikoBuildEngine tells the DevSpace CLI to build with Docker on Minikube or on localhost
25+
type KanikoBuildEngine struct {
26+
Enabled *bool `yaml:"enabled"`
27+
Options *DockerBuildEngineOptions `yaml:"options"`
28+
}
29+
30+
//DockerBuildEngine tells the DevSpace CLI to build with Docker on Minikube or on localhost
31+
type DockerBuildEngine struct {
32+
Enabled *bool `yaml:"enabled"`
33+
PreferMinikube *bool `yaml:"preferMinikube"`
34+
Options *DockerBuildEngineOptions `yaml:"options"`
35+
}
36+
37+
//DockerBuildEngineOptions defines options for building with DockerBuildEngine
38+
type DockerBuildEngineOptions struct {
39+
BuildArgs *map[string]*string `yaml:"buildArgs"`
40+
}

pkg/devspace/config/v1/registry.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package v1
2+
3+
//RegistryConfig defines the registry service
4+
type RegistryConfig struct {
5+
URL *string `yaml:"url,omitempty"`
6+
Auth *RegistryAuth `yaml:"auth,omitempty"`
7+
Insecure *bool `yaml:"insecure,omitempty"`
8+
}
9+
10+
//RegistryAuth is a user for the registry
11+
type RegistryAuth struct {
12+
Username *string `yaml:"username"`
13+
Password *string `yaml:"password"`
14+
}

pkg/devspace/config/v1/schema.go

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,12 @@ const Version string = "v1"
55

66
//Config defines the configuration
77
type Config struct {
8-
Version *string `yaml:"version"`
9-
DevSpace *DevSpaceConfig `yaml:"devSpace,omitempty"`
10-
Image *ImageConfig `yaml:"image,omitempty"`
11-
Cluster *Cluster `yaml:"cluster,omitempty"`
12-
Services *ServiceConfig `yaml:"services,omitempty"`
13-
}
14-
15-
//ImageConfig defines the image specification
16-
type ImageConfig struct {
17-
Name *string `yaml:"name"`
18-
Tag *string `yaml:"tag"`
19-
BuildTime *string `yaml:"buildTime"`
20-
Registry *RegistryConfig `yaml:"registry"`
21-
}
22-
23-
//DevSpaceConfig defines the devspace deployment
24-
type DevSpaceConfig struct {
25-
Release *Release `yaml:"release"`
26-
PortForwarding *[]*PortForwardingConfig `yaml:"portForwarding"`
27-
Sync *[]*SyncConfig `yaml:"sync"`
28-
}
29-
30-
//ServiceConfig defines additional services
31-
type ServiceConfig struct {
32-
Tiller *TillerConfig `yaml:"tiller,omitempty"`
33-
InternalRegistry *InternalRegistry `yaml:"internalRegistry,omitempty"`
34-
}
35-
36-
//TillerConfig defines the tiller service
37-
type TillerConfig struct {
38-
Release *Release `yaml:"release"`
39-
AppNamespaces *[]*string `yaml:"appNamespaces"`
40-
}
41-
42-
//RegistryConfig defines the registry service
43-
type RegistryConfig struct {
44-
URL *string `yaml:"url,omitempty"`
45-
Auth *RegistryAuth `yaml:"auth,omitempty"`
46-
Insecure *bool `yaml:"insecure,omitempty"`
47-
}
48-
49-
//InternalRegistry defines the deployment of an internal registry
50-
type InternalRegistry struct {
51-
Release *Release `yaml:"release,omitempty"`
52-
Host *string `yaml:"host,omitempty"`
53-
}
54-
55-
//RegistryAuth is a user for the registry
56-
type RegistryAuth struct {
57-
Username *string `yaml:"username"`
58-
Password *string `yaml:"password"`
59-
}
60-
61-
//PortForwardingConfig defines the ports for a port forwarding to a DevSpace
62-
type PortForwardingConfig struct {
63-
ResourceType *string `yaml:"resourceType"`
64-
LabelSelector *map[string]*string `yaml:"labelSelector"`
65-
PortMappings *[]*PortMapping `yaml:"portMappings"`
66-
}
67-
68-
//PortMapping defines the ports for a PortMapping
69-
type PortMapping struct {
70-
LocalPort *int `yaml:"localPort"`
71-
RemotePort *int `yaml:"remotePort"`
72-
}
73-
74-
//SyncConfig defines the paths for a SyncFolder
75-
type SyncConfig struct {
76-
ResourceType *string `yaml:"resourceType"`
77-
LabelSelector *map[string]*string `yaml:"labelSelector"`
78-
LocalSubPath *string `yaml:"localSubPath"`
79-
ContainerPath *string `yaml:"containerPath"`
80-
ExcludePaths *[]string `yaml:"excludePaths"`
81-
DownloadExcludePaths *[]string `yaml:"downloadExcludePaths"`
82-
UploadExcludePaths *[]string `yaml:"uploadExcludePaths"`
8+
Version *string `yaml:"version"`
9+
DevSpace *DevSpaceConfig `yaml:"devSpace,omitempty"`
10+
Images *map[string]*ImageConfig `yaml:"images,omitempty"`
11+
Registries *map[string]*RegistryConfig `yaml:"registries,omitempty"`
12+
Cluster *Cluster `yaml:"cluster,omitempty"`
13+
Services *ServiceConfig `yaml:"services,omitempty"`
8314
}
8415

8516
//Release defines running version of a project
@@ -88,18 +19,3 @@ type Release struct {
8819
Namespace *string `yaml:"namespace"`
8920
Values *map[interface{}]interface{} `yaml:"values,omitempty"`
9021
}
91-
92-
//Cluster is a struct that contains data for a Kubernetes-Cluster
93-
type Cluster struct {
94-
UseKubeConfig *bool `yaml:"useKubeConfig,omitempty"`
95-
APIServer *string `yaml:"apiServer,omitempty"`
96-
CaCert *string `yaml:"caCert,omitempty"`
97-
User *User `yaml:"user,omitempty"`
98-
}
99-
100-
//User is a user with its username and its client certificate
101-
type User struct {
102-
Username *string `yaml:"username,omitempty"`
103-
ClientCert *string `yaml:"clientCert,omitempty"`
104-
ClientKey *string `yaml:"clientKey,omitempty"`
105-
}

pkg/devspace/config/v1/services.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package v1
2+
3+
//ServiceConfig defines additional services
4+
type ServiceConfig struct {
5+
Tiller *TillerConfig `yaml:"tiller,omitempty"`
6+
InternalRegistry *InternalRegistry `yaml:"internalRegistry,omitempty"`
7+
}
8+
9+
//TillerConfig defines the tiller service
10+
type TillerConfig struct {
11+
Release *Release `yaml:"release"`
12+
AppNamespaces *[]*string `yaml:"appNamespaces"`
13+
}
14+
15+
//InternalRegistry defines the deployment of an internal registry
16+
type InternalRegistry struct {
17+
Release *Release `yaml:"release,omitempty"`
18+
Host *string `yaml:"host,omitempty"`
19+
}

0 commit comments

Comments
 (0)