Skip to content

Commit 6b56ac6

Browse files
authored
Implement logic (#5)
1 parent 0c20daa commit 6b56ac6

14 files changed

Lines changed: 153 additions & 50 deletions

.circleci/test-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- checkout
1818
# Run your orb's commands to validate them.
19-
- split-config/greet
19+
# - split-config/greet
2020
workflows:
2121
test-deploy:
2222
jobs:

.yamllint

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
extends: relaxed
22

33
rules:
4-
line-length:
5-
max: 200
6-
allow-non-breakable-inline-mappings: true
7-
4+
document-start: disable
5+
quoted-strings:
6+
quote-type: double
7+
required: false
8+
line-length:
9+
max: 200
10+
allow-non-breakable-inline-mappings: true

src/@orb.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
version: 2.1
22

33
description: >
4-
With this Orb, you can split your config.yml into multiple files.
5-
Then, when CircleCI starts, you can merge these split files before executing workflows.
4+
You can merge split files when CircleCI starts.
65
This Orb uses CUE https://cuelang.org/ to merge the configuration files.
76
87
display:
9-
home_url: "https://github.com/bufferings/orb-split-config"
10-
source_url: "https://github.com/bufferings/orb-split-config"
11-
12-
orbs:
13-
continuation: circleci/continuation@0.3.1
8+
home_url: https://github.com/bufferings/orb-split-config
9+
source_url: https://github.com/bufferings/orb-split-config
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
description: >
2+
Find configs by regex and append the result to the config list.
3+
4+
parameters:
5+
config-list-path:
6+
type: string
7+
default: /tmp/config-list
8+
description: >
9+
A file path to append config paths.
10+
Each path in this file should be relateive to the working directory.
11+
find-config-regex:
12+
type: string
13+
default: ""
14+
description: >
15+
Regex to find configs from the working directory.
16+
17+
steps:
18+
- run:
19+
environment:
20+
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
21+
PARAM_FIND_CONFIG_REGEX: <<parameters.find-config-regex>>
22+
name: Append find result
23+
command: <<include(scripts/append-find-result.sh)>>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
description: >
2+
Append fixed config paths to the config list.
3+
4+
parameters:
5+
config-list-path:
6+
type: string
7+
default: /tmp/config-list
8+
description: >
9+
A file path to append config paths.
10+
Each path in this file should be relateive to the working directory.
11+
fixed-config-paths:
12+
type: string
13+
default: ""
14+
description: >
15+
Multiline string of fixed config paths to append. One path for each line.
16+
Each path should be relateive to the working directory.
17+
18+
steps:
19+
- run:
20+
environment:
21+
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
22+
PARAM_FIXED_CONFIG_PATH: <<parameters.fixed-config-paths>>
23+
name: Append fixed paths
24+
command: <<include(scripts/append-fixed-paths.sh)>>

src/commands/generate-config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
description: >
2+
Generate config file from the config list.
3+
4+
parameters:
5+
config-list-path:
6+
type: string
7+
default: /tmp/config-list
8+
description: >
9+
A file path to append config paths.
10+
Each path in this file should be relateive to the working directory.
11+
generated-config-path:
12+
type: string
13+
default: /tmp/generated-config.yml
14+
description: >
15+
A file path for the generated config file.
16+
17+
steps:
18+
- run:
19+
environment:
20+
PARAM_CONFIG_LIST_PATH: <<parameters.config-list-path>>
21+
PARAM_GENERATED_CONFIG_PATH: <<parameters.generated-config-path>>
22+
name: Append find result
23+
command: <<include(scripts/generate-config.sh)>>

src/commands/greet.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/executors/default.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
description: >
2-
This is a sample executor using Docker and Node. If you want to provide a custom environment in your orb, insert your image here.
3-
If you do not require an executor, you can simply delete this directory.
2+
cimg/go image with CUE
43
docker:
5-
- image: 'cimg/node:<<parameters.tag>>'
4+
- image: bufferings/cimg-cue:<<parameters.tag>>
65
parameters:
76
tag:
8-
default: lts
9-
description: >
10-
Pick a specific cimg/node image variant:
11-
https://hub.docker.com/r/cimg/node/tags
127
type: string
8+
default: latest
9+
description: >
10+
Pick a specific bufferings/cimg-cue image variant:
11+
https://hub.docker.com/r/bufferings/cimg-cue/tags

src/jobs/generate-config.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
description: >
2+
Sample description
3+
4+
executor: default
5+
6+
parameters:
7+
config-list-path:
8+
type: string
9+
default: /tmp/config-list
10+
description: >
11+
A file path to append config paths.
12+
Each path in this file should be relateive to the working directory.
13+
fixed-config-paths:
14+
type: string
15+
default: ""
16+
description: >
17+
Multiline string of fixed config paths to append. One path for each line.
18+
Each path should be relateive to the working directory.
19+
find-config-regex:
20+
type: string
21+
default: ""
22+
description: >
23+
Regex to find configs from the working directory.
24+
generated-config-path:
25+
type: string
26+
default: /tmp/generated-config.yml
27+
description: >
28+
A file path for the generated config file.
29+
30+
steps:
31+
- checkout
32+
- when:
33+
condition: << parameters.fixed-config-paths >>
34+
steps:
35+
- append-fixed-paths:
36+
config-list-path: << parameters.config-list-path >>
37+
fixed-config-paths: << parameters.fixed-config-paths >>
38+
- when:
39+
condition: << parameters.find-config-regex >>
40+
steps:
41+
- append-find-result:
42+
config-list-path: << parameters.config-list-path >>
43+
find-config-regex: << parameters.find-config-regex >>
44+
- generate-config:
45+
config-list-path: << parameters.config-list-path >>
46+
generated-config-path: << parameters.generated-config-path >>

src/jobs/hello.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)