Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
merge local and external resources (discriminate by attr)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccwienk committed Oct 27, 2020
1 parent a734e11 commit 0eefd62
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
12 changes: 10 additions & 2 deletions bindings-python/gci/componentmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class ResourceType(enum.Enum):
GENERIC = 'generic'


class ResourceRelation(enum.Enum):
LOCAL = 'local'
EXTERNAL = 'external'


@dc(frozen=True)
class ResourceAccess:
type: AccessType
Expand Down Expand Up @@ -156,8 +161,7 @@ class Component:

sources: typing.List[ComponentSource]
componentReferences: typing.List[ComponentReference]
localResources: typing.List[Resource]
externalResources: typing.List[Resource]
resources: typing.List[Resource]

labels: typing.List[Label] = dataclasses.field(default_factory=list)

Expand All @@ -166,6 +170,10 @@ def current_repository_ctx(self):
return None
return self.repositoryContexts[-1]

# XXX rm asap - keep for backards-compat
localResources: typing.List[Resource] = dataclasses.field(default_factory=list)
externalResources: typing.List[Resource] = dataclasses.field(default_factory=list)


@dc
class ComponentDescriptor:
Expand Down
3 changes: 1 addition & 2 deletions bindings-python/tests/gci/componentmodel_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def test_component():
provider=None,
sources=(),
componentReferences=(),
localResources=(),
externalResources=(),
resources=(),
labels=(),
)

Expand Down
18 changes: 7 additions & 11 deletions component-descriptor-v2-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ definitions:
description: 'base type for resources'
required:
- 'name'
- 'version' # for localResources, this must match component's version
- 'version' # for local resources, this must match component's version
- 'type'
- 'relation'
- 'access'
properties:
name:
Expand All @@ -113,6 +114,9 @@ definitions:
type: 'string'
type:
type: 'string'
relation:
type: 'string'
enum: ['local', 'external']
labels:
type: 'array'
items:
Expand Down Expand Up @@ -207,8 +211,7 @@ definitions:
- 'provider'
- 'sources'
- 'componentReferences'
- 'localResources'
- 'externalResources'
- 'resources'
properties:
name:
type: 'string' # actually: component-type w/ special restrictions
Expand All @@ -233,14 +236,7 @@ definitions:
type: 'array'
items:
$ref: '#/definitions/componentReference'
localResources:
type: 'array'
items:
anyOf:
- $ref: '#/definitions/resourceType'
- $ref: '#/definitions/ociImageResource'
- $ref: '#/definitions/genericResource'
externalResources:
resources:
type: 'array'
items:
anyOf:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ component:
version: 'v0.3.0'
labels: []

localResources:
resources:
- name: 'apiserver'
version: 'v1.7.2' # version is implied by component, i.e. v1.7.2 in this case
type: 'ociImage'
relation: 'local'
labels: []
access:
type: 'ociRegistry'
imageReference: 'eu.gcr.io/gardener-project/gardener/apiserver:v1.7.4'

externalResources:
- name: 'grafana'
version: '7.0.3'
type: 'ociImage'
relation: 'external'
labels: []
access:
type: 'ociRegistry'
Expand Down

0 comments on commit 0eefd62

Please sign in to comment.