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] Validate manifests to ensure links are unique #445

Open
brooksmtownsend opened this issue Oct 8, 2024 · 0 comments
Open

[FEAT] Validate manifests to ensure links are unique #445

brooksmtownsend opened this issue Oct 8, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest This issue is specifically designated as a good issue for Hacktoberfest help wanted Extra attention is needed

Comments

@brooksmtownsend
Copy link
Member

As of wasmCloud v1.3.0, you cannot define links from the same source on the same namespace, package, and interface but to two different targets without specifying a separate link name. This technically wasn't checked before in wasmCloud but it never worked for wasmCloud components, and only worked for capability providers because they are able to synthesize additional information in their implementations.

We need a validation rule to ensure that this is not possible when deploying a manifest, since it's just frustrating to have this pop up as an issue afterwards. In this validation rule, the following manifest should fail:

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
  name: test-link-name-uniqueness
  annotations:
    description: 'test'
spec:
  components:
    - name: http-component
      type: component
      properties:
        image: file://./build/http_hello_world_s.wasm
      traits:
        - type: spreadscaler
          properties:
            instances: 1
    - name: http-component-two
      type: component
      properties:
        image: file://./build/http_hello_world_s.wasm
      traits:
        - type: spreadscaler
          properties:
            instances: 1
    - name: httpserver
      type: capability
      properties:
        image: ghcr.io/wasmcloud/http-server:0.22.0
      traits:
        - type: link
          properties:
            target: http-component
            namespace: wasi
            package: http
            interfaces: [incoming-handler]
            source_config:
              - name: default-http
                properties:
                  address: 127.0.0.1:8080
        - type: link
          properties:
            target: http-component-two
            namespace: wasi
            package: http
            interfaces: [incoming-handler]
            source_config:
              - name: default-http-two
                properties:
                  address: 127.0.0.1:8081

Note that above the links are effectively identical, but with different targets and configuration. The correct traits block is as follows:

      traits:
        - type: link
          properties:
            target: http-component
            name: default # for clarity, specifying "default" is the same as not specifying
            namespace: wasi
            package: http
            interfaces: [incoming-handler]
            source_config:
              - name: default-http
                properties:
                  address: 127.0.0.1:8080
        - type: link
          properties:
            target: http-component-two
            name: link-two # can be named anything, but must not be "default"
            namespace: wasi
            package: http
            interfaces: [incoming-handler]
            source_config:
              - name: default-http-two
                properties:
                  address: 127.0.0.1:8081
@brooksmtownsend brooksmtownsend added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed hacktoberfest This issue is specifically designated as a good issue for Hacktoberfest labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest This issue is specifically designated as a good issue for Hacktoberfest help wanted Extra attention is needed
Projects
Status: No status
Development

No branches or pull requests

1 participant