@@ -29,22 +29,20 @@ It gives you the ability to have:
29
29
30
30
## Roadmap
31
31
32
-
33
32
This project is still under development and is subject to changes in the future.
34
33
We aim to achieve at least the following goals before releasing the first stable version.
35
34
36
35
- [x] Fetch dependencies based on git tag or branch
37
36
- [x] Cache dependencies locally by revision
38
37
- [x] Fetch transitive dependencies
39
38
- [ ] Declarative rules per dependency
40
- - [ ] Whitelisting
41
- - [ ] Blacklisting
42
- - [ ] Dependency pruning (remove `` proto ` ` files that are not needed)
39
+ - [x] Allow policies
40
+ - [ ] Deny policies
41
+ - [x ] Dependency pruning (remove ` proto ` files that are not needed)
43
42
- [ ] Prevent circular dependencies
44
43
45
44
## Getting Started
46
45
47
-
48
46
Protofetch is being released to cargo so to use it you can directly download the crate from the [ crates.io] ( https://crates.io/crates/protofetch )
49
47
and install it with ` cargo install protofetch ` .
50
48
@@ -53,6 +51,9 @@ and install it with `cargo install protofetch`.
53
51
``` sh
54
52
# -f forces lock file to be generated in every run
55
53
protofetch fetch -f
54
+
55
+ # For just lock file generation
56
+ protofetch lock
56
57
```
57
58
58
59
## Protofetch module
@@ -61,21 +62,24 @@ Each service using protofetch will require a module descriptor which uses `toml`
61
62
This descriptor is by default called ` protofetch.toml ` and is located in the root of the service's repository.
62
63
This can be changed, but it is heavily discouraged.
63
64
64
- | Field | Type | Required | Description |
65
- | ---------------| :----------------- | :----------| :---------------------------------------------------------------------------|
66
- | name | String | mandatory | the name of the defined module |
67
- | description | String | Optional | the description of the module |
68
- | proto_out_dir | String | Optional | the path to write the proto files to, relative to where the command is run |
69
- | dependencies | List [ Dependency] | Optional | The dependencies to fetch |
65
+ | Field | Type | Required | Description |
66
+ | ---------------| :-------------| :----------| :---------------------------------------------------------------------------|
67
+ | name | String | mandatory | the name of the defined module |
68
+ | description | String | Optional | the description of the module |
69
+ | proto_out_dir | String | Optional | the path to write the proto files to, relative to where the command is run |
70
+ | dependencies | [ Dependency] | Optional | The dependencies to fetch |
70
71
71
72
### Dependency format
72
73
73
- | Field | Type | Required | Description | Example |
74
- | ----------| :--------| :----------| :-----------------------------------------------------------------------------------:| -------------------------------------:|
75
- | url | String | mandatory | the address of the repo to checkout protobuf files from | "github.com/coralogix/cx-api-users/" |
76
- | revision | String | mandatory | the revision to checkout from, this can either be a tagged version or a commit hash | v0.2 |
77
- | branch | Boolean | Optional | branch can be used to override revision for testing purposes, fetches last commit | feature/v2 |
78
- | protocol | String | mandatory | protocol to use: [ ssh, https] | ssh |
74
+ | Field | Type | Required | Description | Example |
75
+ | ----------------| :---------| :----------| :-----------------------------------------------------------------------------------:| --------------------------------------------------:|
76
+ | url | String | mandatory | the address of the repo to checkout protobuf files from | "github.com/coralogix/cx-api-users/" |
77
+ | revision | String | mandatory | the revision to checkout from, this can either be a tagged version or a commit hash | v0.2 |
78
+ | branch | Boolean | Optional | branch can be used to override revision for testing purposes, fetches last commit | feature/v2 |
79
+ | protocol | String | mandatory | protocol to use: [ ssh, https] | ssh |
80
+ | allow_policies | [ String] | Optional | Allow policy rules. | "/prefix/* ", "* /subpath/* ", "/path/to/file.proto" |
81
+ | prune | bool | Optional | Whether to prune unneded transitive proto files | true /false |
82
+ | transitive | bool | Optional | Flags this dependency as transitive | true /false |
79
83
80
84
81
85
### Protofetch dependency toml example
@@ -103,7 +107,7 @@ url = "github.com/org/dep3"
103
107
revision = " a16f097eab6e64f2b711fd4b977e610791376223"
104
108
```
105
109
106
- ## HTTPS Support
110
+ ## HTTPS support
107
111
108
112
If you want to use https you need to specify credentials using one of the following:
109
113
@@ -116,3 +120,38 @@ To support https when `2FA` is enabled you must generate a personal access token
116
120
The following permissions are suficient when creating the token.
117
121
118
122
![ GitHub personal access token] ( readme-images/github-personal-access-token.png )
123
+
124
+ ## Transitive dependency support and pruning
125
+
126
+ Protofetch supports pulling transitive dependencies for your convenience.
127
+ However, there is some manual work involved if the dependencies do not define their own protofetch module.
128
+
129
+ In a situation where A depends on B, you should flag that dependency as transitive.
130
+
131
+ This is helpful especially when you take advantage of the pruning feature which allows you to only recursively fetch
132
+ the proto files you actually need. With pruning enabled, protofetch will recursively find what protofiles your root
133
+ protos depend on and fetch them for as long as they are imported (flag as transitive dependency or fetched from other modules).
134
+
135
+ Moreover, you can also use the allow_policies to scope down the root proto files you want from a dependency.
136
+ As an example, the following module depends only on A's file ` /proto/path/example.proto ` but since pruning is enabled and
137
+ B is flagged as transitive, if the allowed file has any file dependencies it will pull them and its dependencies, recursively.
138
+
139
+ ``` toml
140
+ name = " repository name"
141
+ description = " this is a repository"
142
+ proto_out_dir = " proto/src/dir/output"
143
+
144
+ [A ]
145
+ protocol = " https"
146
+ url = " github.com/org/A"
147
+ revision = " 1.3.0"
148
+ allow_policies = [" /proto/path/example.proto" ]
149
+ prune = true
150
+
151
+ [B ]
152
+ protocol = " ssh"
153
+ url = " github.com/org/B"
154
+ revision = " 5.2.0"
155
+ branch = " feature/v2"
156
+ transitive = true
157
+ ```
0 commit comments