Skip to content

Commit de1ec9c

Browse files
committed
feat: rename workload resource dependency into service and move dependencies configuration into environment specific config
Signed-off-by: Eugene Yarshevich <[email protected]>
1 parent 90d348d commit de1ec9c

File tree

7 files changed

+13
-41
lines changed

7 files changed

+13
-41
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# ![Score](docs/images/logo.svg) Score overview
44

5-
Score aims to improve developer producticity and experience by reducing the risk of configurtaion inconsistencies between local and remote environments. It provides developer-centric workload specification (`score.yaml`) which captures a workloads runtime requirements in a platform-agnostic manner.
5+
Score aims to improve developer productivity and experience by reducing the risk of configuration inconsistencies between local and remote environments. It provides developer-centric workload specification (`score.yaml`) which captures a workloads runtime requirements in a platform-agnostic manner.
66

77
The `score.yaml` specification file can be executed against a _Score Implementation CLI_, a conversion tool for application developers to generate environment specific configuration. In combination with environment specific parameters, the CLI tool can run your workload in the target environment by generating a platform-specific configuration file such as `docker-compose.yaml` or a Helm `values.yaml`. Learn more [here](https://github.com/score-spec/spec#-what-is-score).
88

e2e-tests/resources/outputs/example-03-dependencies-service-a-output.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ services:
33
command:
44
- -c
55
- 'while true; do echo service-a: Hello $${FRIEND}! Connecting to $${CONNECTION_STRING}...; sleep 10; done'
6-
depends_on:
7-
db:
8-
condition: service_started
9-
service-b:
10-
condition: service_started
116
entrypoint:
127
- /bin/sh
138
environment:

examples/03-dependencies/README.md

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Score uses `resources` section to describe workload's dependencies. This mechanism can be used to spin-up multi-service setups with `docker-compose`.
44

5-
For example, `service-a.yaml` score file describes a service that has two dependencies: `service-b` (another workload) and a PostgreSQL database instance:
5+
For example, `service-a.yaml` score file describes a service that has two dependencies: `service-b` (another workload), and a PostgreSQL database instance:
66

77
```yaml
88
apiVersion: score.dev/v1b1
@@ -40,10 +40,10 @@ resources:
4040
password:
4141
secret: true
4242
service-b:
43-
type: workload
43+
type: service
4444
```
4545
46-
The second workload is described in `service-b.yaml` file and has no any additional dependencies:
46+
The second workload is described in `service-b.yaml` file and does not have dependencies:
4747

4848
```yaml
4949
apiVersion: score.dev/v1b1
@@ -75,33 +75,17 @@ $ score-compose run -f ./service-b.yaml -o ./service-b.compose.yaml
7575
$ score-compose run -f ./service-a.yaml -o ./service-a.compose.yaml --env-file ./.env
7676
```
7777

78-
Resulting output file `service-a.compose.yaml` would include two dependencies on compose services `db` and `service-b`.
79-
Both should be up and running before `service-a` could start:
78+
One last step is to create a `db` service definition and enforce `service-a` dependencies in our target test environment.
79+
Common place to store non-score defined configuration and resources is a root `compose.yaml` file:
8080

8181
```yaml
8282
services:
8383
service-a:
84-
command:
85-
- -c
86-
- 'while true; do echo service-a: Hello $${FRIEND}! Connecting to $${CONNECTION_STRING}...; sleep 10; done'
8784
depends_on:
8885
db:
8986
condition: service_started
9087
service-b:
9188
condition: service_started
92-
entrypoint:
93-
- /bin/sh
94-
environment:
95-
CONNECTION_STRING: postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST-localhost}:${DB_PORT-5432}/${DB_NAME-postgres}
96-
NAME: ${NAME-World}
97-
image: busybox
98-
```
99-
100-
One last step is to ensure there is a compose `db` service definition.
101-
Common place to store non-score defined configuration and resources is a root `compose.yaml` file:
102-
103-
```yaml
104-
services:
10589
db:
10690
image: postgres:alpine
10791
restart: always

examples/03-dependencies/compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
services:
2+
service-a:
3+
depends_on:
4+
db:
5+
condition: service_started
6+
service-b:
7+
condition: service_started
28
db:
39
image: postgres:alpine
410
restart: always

examples/03-dependencies/service-a.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ resources:
3333
password:
3434
secret: true
3535
service-b:
36-
type: workload
36+
type: service

internal/compose/convert.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ func ConvertSpec(spec *score.WorkloadSpec) (*compose.Project, ExternalVariables,
3131
env[key] = &envVarVal
3232
}
3333

34-
var dependsOn = make(compose.DependsOnConfig, len(spec.Resources))
35-
for name, res := range spec.Resources {
36-
if res.Type != "environment" && res.Type != "volume" {
37-
dependsOn[name] = compose.ServiceDependency{Condition: "service_started"}
38-
}
39-
}
40-
4134
var ports []compose.ServicePortConfig
4235
if len(spec.Service.Ports) > 0 {
4336
ports = []compose.ServicePortConfig{}
@@ -87,7 +80,6 @@ func ConvertSpec(spec *score.WorkloadSpec) (*compose.Project, ExternalVariables,
8780
Entrypoint: cSpec.Command,
8881
Command: cSpec.Args,
8982
Environment: env,
90-
DependsOn: dependsOn,
9183
Ports: ports,
9284
Volumes: volumes,
9385
}

internal/compose/convert_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func TestScoreConvert(t *testing.T) {
7979
Environment: compose.MappingWithEquals{
8080
"CONNECTION_STRING": stringPtr("test connection string"),
8181
},
82-
DependsOn: make(compose.DependsOnConfig, 0),
8382
Ports: []compose.ServicePortConfig{
8483
{
8584
Published: "80",
@@ -167,10 +166,6 @@ func TestScoreConvert(t *testing.T) {
167166
ReadOnly: true,
168167
},
169168
},
170-
DependsOn: compose.DependsOnConfig{
171-
"app-db": compose.ServiceDependency{Condition: "service_started"},
172-
"dns": compose.ServiceDependency{Condition: "service_started"},
173-
},
174169
},
175170
},
176171
},

0 commit comments

Comments
 (0)