-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: drop @cgrindel_bazel_starlib//updatesrc
Refactor the remaining targets that depended on @cgrindel_bazel_starlib//updatesrc. The repository has now been completely migrated to @aspect_bazel_lib//lib:write_source_files. During the refactor, we dropped the functionality to write the source files in rules_openapi. Instead, the caller side can decide how to write the source files. This makes the rules more composable and easier to use. The functionality has been moved to a macro in private/mgmtapi/api.bzl, which is used inside of scionproto/scion.
- Loading branch information
Showing
22 changed files
with
143 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
bin | ||
doc/_build | ||
docker/_build | ||
rules_openapi/tools/node_modules | ||
tools/lint/logctxcheck/testdata/src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""OpenAPI Macros | ||
Macros for generating Go code from OpenAPI specs. | ||
""" | ||
|
||
load("//tools/lint:write_source_files.bzl", "write_source_files") | ||
load("//rules_openapi:defs.bzl", _openapi_generate_go = "openapi_generate_go") | ||
|
||
def openapi_generate_go( | ||
name, | ||
client = True, | ||
server = True, | ||
spec = True, | ||
types = True, | ||
**kwargs): | ||
""" | ||
Generates Go code from an OpenAPI spec. | ||
This macro creates two additional rules: | ||
- {{name}}_files: A filegroup with the generated files. | ||
- write_files: A write_source_files rule that writes the generated files to | ||
the source directory. | ||
Args: | ||
name: The name of the rule. | ||
client: Whether to generate a client. | ||
server: Whether to generate a server. | ||
spec: Whether to generate a spec. | ||
types: Whether to generate types. | ||
**kwargs: Ad. | ||
""" | ||
|
||
_openapi_generate_go( | ||
name = name + "_gen", | ||
out_client = "client.bzl.gen.go" if client else None, | ||
out_server = "server.bzl.gen.go" if server else None, | ||
out_spec = "spec.bzl.gen.go" if spec else None, | ||
out_types = "types.bzl.gen.go" if types else None, | ||
**kwargs | ||
) | ||
|
||
out_files = [] | ||
write_files = {} | ||
for typ, gen in {"client": client, "server": server, "spec": spec, "types": types}.items(): | ||
if not gen: | ||
continue | ||
src = typ + ".bzl.gen.go" | ||
out_files.append(src) | ||
write_files[typ + ".gen.go"] = src | ||
|
||
native.filegroup( | ||
name = name, | ||
srcs = out_files, | ||
) | ||
|
||
write_source_files( | ||
name = "write_files", | ||
files = write_files, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.