Skip to content

Commit 6205bc8

Browse files
committed
chore: remove machinery dependency to allow merging prior to api support
1 parent bbdba49 commit 6205bc8

File tree

6 files changed

+117
-82
lines changed

6 files changed

+117
-82
lines changed

cmd/identify_lagoonservices.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import (
99
"github.com/uselagoon/build-deploy-tool/internal/helpers"
1010
"github.com/uselagoon/build-deploy-tool/internal/identify"
1111
"github.com/uselagoon/build-deploy-tool/internal/k8s"
12-
"github.com/uselagoon/machinery/api/schema"
1312
)
1413

1514
type LagoonServices struct {
16-
Services []schema.EnvironmentService `json:"services"`
17-
Volumes []schema.EnvironmentVolume `json:"volumes"`
15+
Services []identify.EnvironmentService `json:"services"`
16+
Volumes []identify.EnvironmentVolume `json:"volumes"`
1817
}
1918

2019
var lagoonServiceIdentify = &cobra.Command{

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ require (
2121
github.com/k8up-io/k8up/v2 v2.11.3
2222
github.com/robfig/cron/v3 v3.0.1
2323
github.com/spf13/cobra v1.8.1
24-
github.com/uselagoon/machinery v0.0.35-0.20250907231937-622deb3fd70d
24+
github.com/uselagoon/machinery v0.0.34
2525
github.com/vshn/k8up v1.99.99
2626
gopkg.in/yaml.v2 v2.4.0
2727
gopkg.in/yaml.v3 v3.0.1
@@ -51,7 +51,6 @@ require (
5151
github.com/google/gofuzz v1.2.0 // indirect
5252
github.com/google/uuid v1.6.0 // indirect
5353
github.com/gorilla/websocket v1.5.3 // indirect
54-
github.com/guregu/null v4.0.0+incompatible // indirect
5554
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
5655
github.com/imdario/mergo v1.0.1 // indirect
5756
github.com/inconshreveable/mousetrap v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,6 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
444444
github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
445445
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
446446
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
447-
github.com/guregu/null v4.0.0+incompatible h1:4zw0ckM7ECd6FNNddc3Fu4aty9nTlpkkzH7dPn4/4Gw=
448-
github.com/guregu/null v4.0.0+incompatible/go.mod h1:ePGpQaN9cw0tj45IR5E5ehMvsFlLlQZAkkOXZurJ3NM=
449447
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
450448
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
451449
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -804,8 +802,8 @@ github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lP
804802
github.com/ultraware/whitespace v0.0.4/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
805803
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
806804
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
807-
github.com/uselagoon/machinery v0.0.35-0.20250907231937-622deb3fd70d h1:7qifEQS0lMjRlwRy9NbhAUUNqbvrGej6oKtesSDMaLQ=
808-
github.com/uselagoon/machinery v0.0.35-0.20250907231937-622deb3fd70d/go.mod h1:G0ujppuNR0BrtAnlmH8xDb9TDfayb4A36aeo0DYg7fQ=
805+
github.com/uselagoon/machinery v0.0.34 h1:5DsvXEyMeXmzQhjt11YH7+kZJueabovrwKTv0x7jQV8=
806+
github.com/uselagoon/machinery v0.0.34/go.mod h1:G0ujppuNR0BrtAnlmH8xDb9TDfayb4A36aeo0DYg7fQ=
809807
github.com/uudashr/gocognit v0.0.0-20190926065955-1655d0de0517/go.mod h1:j44Ayx2KW4+oB6SWMv8KsmHzZrOInQav7D3cQMJ5JUM=
810808
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
811809
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=

internal/identify/identify_lagoonservices.go

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
"github.com/uselagoon/build-deploy-tool/internal/generator"
77
servicestemplates "github.com/uselagoon/build-deploy-tool/internal/templating"
8-
"github.com/uselagoon/machinery/api/schema"
98
)
109

1110
type IdentifyServices struct {
@@ -14,9 +13,51 @@ type IdentifyServices struct {
1413
Services []string `json:"services,omitempty"`
1514
}
1615

16+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
1717
type LagoonServices struct {
18-
Services []schema.EnvironmentService `json:"services,omitempty"`
19-
Volumes []schema.EnvironmentVolume `json:"volumes,omitempty"`
18+
Services []EnvironmentService `json:"services,omitempty"`
19+
Volumes []EnvironmentVolume `json:"volumes,omitempty"`
20+
// Services []schema.EnvironmentService `json:"services,omitempty"`
21+
// Volumes []schema.EnvironmentVolume `json:"volumes,omitempty"`
22+
}
23+
24+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
25+
type EnvironmentService struct {
26+
ID int `json:"id,omitempty"`
27+
Name string `json:"name,omitempty"`
28+
Type string `json:"type,omitempty"`
29+
Updated string `json:"updated,omitempty"`
30+
Containers []ServiceContainer `json:"containers,omitempty"`
31+
Created string `json:"created,omitempty"`
32+
Abandoned bool `json:"abandoned,omitempty"` // no longer tracked in the docker-compose file
33+
}
34+
35+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
36+
type ServiceContainer struct {
37+
Name string `json:"name,omitempty"`
38+
Volumes []VolumeMount `json:"volumes,omitempty"`
39+
Ports []ContainerPort `json:"ports,omitempty"`
40+
}
41+
42+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
43+
type EnvironmentVolume struct {
44+
Name string `json:"name,omitempty"`
45+
StorageType string `json:"storageType,omitempty"`
46+
Type string `json:"type,omitempty"`
47+
Size string `json:"size,omitempty"`
48+
Abandoned bool `json:"abandoned,omitempty"` // no longer tracked in the docker-compose file
49+
}
50+
51+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
52+
type VolumeMount struct {
53+
Name string `json:"name,omitempty"`
54+
Path string `json:"path,omitempty"`
55+
}
56+
57+
// eventually replace with https://github.com/uselagoon/machinery/pull/99
58+
type ContainerPort struct {
59+
Name string `json:"name,omitempty"`
60+
Port int `json:"port,omitempty"`
2061
}
2162

2263
// LagoonServiceTemplateIdentification takes the output of the generator and returns a JSON payload that contains information
@@ -47,7 +88,7 @@ func LagoonServiceTemplateIdentification(g generator.GeneratorInput) (*IdentifyS
4788
storeType = "bulk"
4889
}
4990
}
50-
kubevol := schema.EnvironmentVolume{
91+
kubevol := EnvironmentVolume{
5192
Name: pvc.Name,
5293
StorageType: storeType,
5394
Type: pvc.Labels["lagoon.sh/service-type"],
@@ -61,33 +102,33 @@ func LagoonServiceTemplateIdentification(g generator.GeneratorInput) (*IdentifyS
61102
}
62103
for _, d := range deployments {
63104
servicesData.Deployments = append(servicesData.Deployments, d.Name)
64-
containers := []schema.ServiceContainer{}
105+
containers := []ServiceContainer{}
65106
for _, c := range d.Spec.Template.Spec.Containers {
66-
volumes := []schema.VolumeMount{}
107+
volumes := []VolumeMount{}
67108
for _, v := range c.VolumeMounts {
68109
for _, vo := range lagoonServices.Volumes {
69110
if vo.Name == v.Name {
70-
volumes = append(volumes, schema.VolumeMount{
111+
volumes = append(volumes, VolumeMount{
71112
Name: v.Name,
72113
Path: v.MountPath,
73114
})
74115
}
75116
}
76117
}
77-
ports := []schema.ContainerPort{}
118+
ports := []ContainerPort{}
78119
for _, p := range c.Ports {
79-
ports = append(ports, schema.ContainerPort{
120+
ports = append(ports, ContainerPort{
80121
Name: p.Name,
81122
Port: int(p.ContainerPort),
82123
})
83124
}
84-
containers = append(containers, schema.ServiceContainer{
125+
containers = append(containers, ServiceContainer{
85126
Name: c.Name,
86127
Volumes: volumes,
87128
Ports: ports,
88129
})
89130
}
90-
service := schema.EnvironmentService{
131+
service := EnvironmentService{
91132
Name: d.Name,
92133
Type: d.Labels["lagoon.sh/service-type"],
93134
Containers: containers,

internal/identify/identify_state.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
postgresv1 "github.com/amazeeio/dbaas-operator/apis/postgres/v1"
1010
"github.com/uselagoon/build-deploy-tool/internal/collector"
1111
"github.com/uselagoon/build-deploy-tool/internal/generator"
12-
"github.com/uselagoon/machinery/api/schema"
1312
appsv1 "k8s.io/api/apps/v1"
1413
corev1 "k8s.io/api/core/v1"
1514
)
@@ -26,8 +25,8 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
2625
error,
2726
) {
2827
lagoonServices := LagoonServices{
29-
Services: []schema.EnvironmentService{},
30-
Volumes: []schema.EnvironmentVolume{},
28+
Services: []EnvironmentService{},
29+
Volumes: []EnvironmentVolume{},
3130
}
3231
out, currentServices, err := LagoonServiceTemplateIdentification(gen)
3332
if err != nil {
@@ -47,7 +46,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
4746
// add any dbaas that should exist to the current services
4847
for _, prov := range dbaas {
4948
sp := strings.Split(prov, ":")
50-
currentServices.Services = append(currentServices.Services, schema.EnvironmentService{
49+
currentServices.Services = append(currentServices.Services, EnvironmentService{
5150
Name: sp[0],
5251
Type: sp[1],
5352
})
@@ -56,7 +55,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
5655
mariadbMatch := false
5756
var mariadbDelete []mariadbv1.MariaDBConsumer
5857
for _, exist := range state.MariaDBConsumers.Items {
59-
service := schema.EnvironmentService{
58+
service := EnvironmentService{
6059
Name: exist.Name,
6160
Type: "mariadb-dbaas",
6261
}
@@ -80,7 +79,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
8079
mongodbMatch := false
8180
var mongodbDelete []mongodbv1.MongoDBConsumer
8281
for _, exist := range state.MongoDBConsumers.Items {
83-
service := schema.EnvironmentService{
82+
service := EnvironmentService{
8483
Name: exist.Name,
8584
Type: "mongodb-dbaas",
8685
}
@@ -104,7 +103,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
104103
postgresqlMatch := false
105104
var postgresqlDelete []postgresv1.PostgreSQLConsumer
106105
for _, exist := range state.PostgreSQLConsumers.Items {
107-
service := schema.EnvironmentService{
106+
service := EnvironmentService{
108107
Name: exist.Name,
109108
Type: "postgres-dbaas",
110109
}
@@ -136,7 +135,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
136135
storeType = "bulk"
137136
}
138137
}
139-
kubevol := schema.EnvironmentVolume{
138+
kubevol := EnvironmentVolume{
140139
Name: exist.Name,
141140
StorageType: storeType,
142141
Type: exist.Labels["lagoon.sh/service-type"],
@@ -174,33 +173,33 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
174173
depMatch := false
175174
var depDelete []appsv1.Deployment
176175
for _, exist := range state.Deployments.Items {
177-
containers := []schema.ServiceContainer{}
176+
containers := []ServiceContainer{}
178177
for _, c := range exist.Spec.Template.Spec.Containers {
179-
volumes := []schema.VolumeMount{}
178+
volumes := []VolumeMount{}
180179
for _, v := range c.VolumeMounts {
181180
for _, vo := range lagoonServices.Volumes {
182181
if vo.Name == v.Name {
183-
volumes = append(volumes, schema.VolumeMount{
182+
volumes = append(volumes, VolumeMount{
184183
Name: v.Name,
185184
Path: v.MountPath,
186185
})
187186
}
188187
}
189188
}
190-
ports := []schema.ContainerPort{}
189+
ports := []ContainerPort{}
191190
for _, p := range c.Ports {
192-
ports = append(ports, schema.ContainerPort{
191+
ports = append(ports, ContainerPort{
193192
Name: p.Name,
194193
Port: int(p.ContainerPort),
195194
})
196195
}
197-
containers = append(containers, schema.ServiceContainer{
196+
containers = append(containers, ServiceContainer{
198197
Name: c.Name,
199198
Volumes: volumes,
200199
Ports: ports,
201200
})
202201
}
203-
service := schema.EnvironmentService{
202+
service := EnvironmentService{
204203
Name: exist.Name,
205204
Type: exist.Labels["lagoon.sh/service-type"],
206205
Containers: containers,
@@ -234,7 +233,7 @@ func GetCurrentState(c *collector.Collector, gen generator.GeneratorInput) (
234233
return lagoonServices, mariadbDelete, mongodbDelete, postgresqlDelete, depDelete, volDelete, servDelete, state, nil
235234
}
236235

237-
func serviceExists(services []schema.EnvironmentService, serviceName string) bool {
236+
func serviceExists(services []EnvironmentService, serviceName string) bool {
238237
for _, svc := range services {
239238
if svc.Name == serviceName {
240239
return true
@@ -243,7 +242,7 @@ func serviceExists(services []schema.EnvironmentService, serviceName string) boo
243242
return false
244243
}
245244

246-
func volumeExists(volumes []schema.EnvironmentVolume, volumeName string) bool {
245+
func volumeExists(volumes []EnvironmentVolume, volumeName string) bool {
247246
for _, vol := range volumes {
248247
if vol.Name == volumeName {
249248
return true

0 commit comments

Comments
 (0)