-
-
Save damz/7767135 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/platform_foundation/container/apis/slug.py b/platform_foundation/container/apis/slug.py | |
index 4b069a4..77490e9 100644 | |
--- a/platform_foundation/container/apis/slug.py | |
+++ b/platform_foundation/container/apis/slug.py | |
@@ -14,30 +14,27 @@ class SlugApi(object): | |
self._slugs = slugs | |
@rpcmethod | |
- def upload(self, name, path): | |
+ def upload(self, project_name, branch_name, commit_id, path): | |
""" | |
Upload a slug. | |
""" | |
+ | |
+ # Generate the URL of the object. | |
+ object_path = "%s-%s-%s" % (...) | |
+ | |
# Upload the slug to the storage. | |
- with self._blob_service.upload(os.path.basename(path)) as o: | |
+ with self._blob_service.upload(object_path) as o: | |
i = self._open_container_file(path) | |
shutil.copyfileobj(i, o) | |
- o.commit() | |
+ url = o.commit() | |
# Update the slug information. | |
- try: | |
- self._slugs[name].url = os.path.basename(path) | |
- self._slugs[name].updated_date = time.time() | |
- except KeyError: | |
- self._slugs.add( | |
- name=name, | |
- url=os.path.basename(path), | |
- created_date=time.time(), | |
- updated_date=time.time(), | |
- owner=self._container_name | |
- ) | |
- | |
- return self._slugs[name] | |
+ return self._slugs.add( | |
+ project_name=project_name, | |
+ branch_name=branch_name, | |
+ commit_id=commit_id, | |
+ url="slug:%s" % object_path, | |
+ ) | |
def _open_container_file(self, filename): | |
args = [ | |
diff --git a/platform_foundation/infrastructure/cluster/application.py b/platform_foundation/infrastructure/cluster/application.py | |
new file mode 100644 | |
index 0000000..5197310 | |
--- /dev/null | |
+++ b/platform_foundation/infrastructure/cluster/application.py | |
@@ -0,0 +1,37 @@ | |
+ | |
+ | |
+class Application(object): | |
+ def __init__(self): | |
+ #: A reference to a :py:class:`ApplicationSlug` object. | |
+ self.slug = None | |
+ | |
+ #: The revision of the slug to deploy. | |
+ self.slug_revision = None | |
+ | |
+ #: A dict of additional mounts below the slug. | |
+ self.mounts = {} | |
+ | |
+ | |
+class ApplicationSlug(BaseObject): | |
+ project_id = ObjectProperty("project_id", | |
+ title="The ID of the project this application slug belongs to.") | |
+ | |
+ branch_id = ObjectProperty("branch_id", | |
+ title="The ID of the branch this application slug belongs to.") | |
+ | |
+ commit_id = ObjectProperty("commit_id", | |
+ title="The ID of the commit (SHA for Git).") | |
+ | |
+ url = ObjectProperty("url", | |
+ title="Slug URL.") | |
+ | |
+ created_date = ObjectProperty("created_date", | |
+ title="Time of slug creation.") | |
+ | |
+ def __init__(self): | |
+ #: TODO. | |
+ pass | |
+ | |
+ | |
+class ApplicationSlugCollection(BaseCollection): | |
+ pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment