Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow dot as separator in resource id #105

Merged
merged 2 commits into from
Sep 12, 2024
Merged

Conversation

astromechza
Copy link
Member

@astromechza astromechza commented Sep 11, 2024

This PR relates to the resource id field in a spec like the following (marked by the arrow below):

apiVersion: score.dev/v1b1
metadata:
  name: example-workload
service:
  ports:
    http:
      port: 8080
...
resources:
  something:
    type: resource-type
    class: default
    id: custom-type              <-----

Currently, this field supports the same character set and syntax as other fields like the workload name, resource type, resource class, etc. In this PR we'd like to change it to also support . as a separator character in order to support resource provisioners that need relate a resource id to a workload.

The example usecase is when we want a resource id to be related to a workload in some way, for example, for example: example-workload.thing would be an identifier for a 'thing' relative to the 'example-workload' workload.

Alternatives

One alternative is to use the resource type, resource class, or a param to indicate this relation to the resource provisioner.

Resource class is not adequate here, because class is a useful provisioner differentiator: the same 'thing' relation could be returned by different classes with different behaviors over the same relation.

Resource param is not adequate here, because the provisioner that provides id: example-workload.thing may not be capable of handling example-workload.other-thing.

Resource type is not adequate here either because the output type structure of the 'thing' is the same for workload-a and workload-b.

Thus it's most natural to encode this as an id.

Shared resources

This also works well in the case of 2 workloads that want to refer to the same 'thing' relation on the example-workload.

flowchart LR
  A[workload-a] --> R("`type: res-type
class: default
id: shared.workload-c.thing`")
  B[workload-b] --> R
  subgraph workload-c
    thing
  end
  R --> thing
Loading

Signed-off-by: Ben Meier <ben.meier@humanitec.com>
@astromechza
Copy link
Member Author

Note the initial use case here is to provide a new endpoint resource type supported by all Score implementations by default which would use <workload-name>.service.<port-name> to generate the url of a service exposed by another workload.

score-v1b1.json Outdated Show resolved Hide resolved
Signed-off-by: Ben Meier <ben.meier@humanitec.com>
Copy link

@chrishumanitec chrishumanitec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@astromechza astromechza merged commit 22f600a into main Sep 12, 2024
4 checks passed
@astromechza astromechza deleted the dotted-resource-id branch September 12, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants