Skip to content

Commit

Permalink
feat(project): add support for docker-cache feature
Browse files Browse the repository at this point in the history
Resolves AB#43805
  • Loading branch information
ankitrgadiya committed Dec 23, 2024
1 parent 387181c commit 2e777ab
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
9 changes: 7 additions & 2 deletions riocli/apply/manifests/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: test-project-name
labels:
purpose: testing
version: 1.0
version: "1.0"
spec:
users:
- emailID: "[email protected]"
Expand All @@ -20,4 +20,9 @@ spec:
vpn:
enabled: true
subnets: ["10.81.0.0/16"]

dockerCache:
enabled: true
proxyDevice: "edge01"
proxyInterface: "eth0"
registrySecret: "quay"
registryURL: "https://quay.io"
21 changes: 21 additions & 0 deletions riocli/jsonschema/schemas/project-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ definitions:
properties:
enabled:
type: boolean
dockerCache:
oneOf:
- properties:
enabled:
const: false
- properties:
enabled:
const: true
proxyDevice:
type: string
proxyInterface:
type: string
registrySecret:
type: string
registryURL:
type: string
required:
- proxyDevice
- proxyInterface
- registrySecret
- registryURL
userGroup:
type: object
properties:
Expand Down
21 changes: 13 additions & 8 deletions riocli/project/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from riocli.exceptions import ResourceNotFound
from riocli.model import Model
from riocli.project.util import ProjectNotFound, find_project_guid
from riocli.v2client.error import HttpAlreadyExistsError, HttpNotFoundError
from riocli.v2client.error import HttpNotFoundError

PROJECT_READY_TIMEOUT = 150

Expand All @@ -39,19 +39,24 @@ def apply(self, *args, **kwargs) -> ApplyResult:
project["metadata"]["organizationGUID"] = Configuration().organization_guid

try:
client.create_project(project)
# We try to update before creating in Project. The DockerCache
# feature is only available in the Update API. If we instead try to
# create the Project with DockerCache feature enabled then the API
# will return BadRequest error.
guid = find_project_guid(
client, self.metadata.name, Configuration().organization_guid
)

client.update_project(guid, project)
wait(
self.is_ready,
timeout_seconds=PROJECT_READY_TIMEOUT,
sleep_seconds=(1, 30, 2),
)
return ApplyResult.CREATED
except HttpAlreadyExistsError:
guid = find_project_guid(
client, self.metadata.name, Configuration().organization_guid
)
client.update_project(guid, project)
return ApplyResult.UPDATED
except (HttpNotFoundError, ProjectNotFound):
client.create_project(project)
return ApplyResult.CREATED
except Exception as e:
raise e

Expand Down

0 comments on commit 2e777ab

Please sign in to comment.