score-spec / spec

The Score Specification provides a developer-centric and platform-agnostic Workload specification to improve developer productivity and experience. It eliminates configuration inconsistencies between environments.

Home Page:https://score.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation of fields is nearly non-existent

fernando-villalba opened this issue · comments

This works and it shouldn't (look at the protocol)

apiVersion: score.dev/v1b1
metadata:
  name: frontend
containers:
  frontend:
    image: nginx:alpine
service:
  ports:
    www:
      port: 80
      protocol: Godzilla-growls-angry
      targetPort: 80

Translates with score-helm to:

containers:
  frontend:
    image:
      name: nginx:alpine
service:
  ports:
    - name: www
      port: 80
      protocol: Godzilla-growls-angry
      targetPort: 80
  type: ClusterIP

This also "works"

apiVersion: score.dev/v1b1
metadata:
  name: frontend
container-with-massive-angry-typo:
  frontend:
    image: nginx:alpine
service:
  ports:
    www:
      port: 80
      protocol: Godzilla-growls-angry
      targetPort: 80

Outputs this:

containers: {}
service:
  ports:
    - name: www
      port: 80
      protocol: Godzilla-growls-angry
      targetPort: 80
  type: ClusterIP

And it doesn't error at all, there is no validation as it exists with 0 status

In the first section, you specified an invalid protocol for the port. In the second section, you used an incorrect field name for the container, which caused it to be ignored.

Try this for the first:
apiVersion: score.dev/v1b1 metadata: name: frontend containers: frontend: image: nginx:alpine service: ports: www: port: 80 protocol: TCP # Update the protocol to a valid value, such as TCP targetPort: 80

And this for the helm-part:
apiVersion: score.dev/v1b1 metadata: name: frontend containers: # Update the field name to the correct name, which is "containers" frontend: image: nginx:alpine service: ports: www: port: 80 protocol: TCP targetPort: 80

In the first section, you specified an invalid protocol for the port. In the second section, you used an incorrect field name for the container, which caused it to be ignored.

I think that's exactly @fernando-villalba's point: these errors should be automatically detected by Score implementations to help with troubleshooting.

Duplicate of #6