Skip to content

Commit

Permalink
Check that required fields exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
busunkim96 committed May 30, 2019
1 parent af07179 commit 331e666
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions docuploader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,16 @@ def upload(

metadata = metadata_pb2.Metadata()
text_format.Merge(metadata_path.read_text(), metadata)
# TODO: Validate that the minimum metadata is set.

# Validating metadata for required fields

# TODO: Do additional validiation
if not metadata.name:
raise Exception("Metadata field 'name' is required.")
if not metadata.version:
raise Exception("Metadata field 'version' is required.")
if not metadata.language:
raise Exception("Metadata field 'language' is required.")

docuploader.log.success(
f"Looks like we're uploading {metadata.name} version {metadata.version} for {metadata.language}."
Expand All @@ -102,13 +111,9 @@ def upload(
with tempfile.NamedTemporaryFile() as fh:
fh.close()
tar_filename = fh.name

docuploader.tar.compress(documentation_path, tar_filename)

docuploader.log.success(f"Cool, I have those tarred up.")

docuploader.log.info(f"Okay, I'm sending them to the cloud™ now.")

destination_name = (
f"{metadata.language}-{metadata.name}-{metadata.version}.tar.gz"
)
Expand Down
2 changes: 1 addition & 1 deletion docuploader/protos/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ message Metadata {
string version = 3;

// The (programming) language. While this isn't enforced with an enum, you
// should use one of the following strings: python, node, ruby, dotnet,
// should use one of the following strings: python, nodejs, ruby, dotnet,
// java, go, php, cpp. In some cases you might need to use something else,
// consult googleapis-dot-dev-team@ for guidance.
string language = 4;
Expand Down

0 comments on commit 331e666

Please sign in to comment.