score-spec / score-k8s

A reference Score implementation that targets Kubernetes
https://docs.score.dev/docs/score-implementation/score-k8s/
Apache License 2.0
26 stars 13 forks source link

Improve error messaging on unsupported resource types #31

Closed sujaya-sys closed 2 months ago

sujaya-sys commented 2 months ago

Context

score-k8s does currently not support an "environment" resource. In a recent community meeting we discussed the following:

  1. Until we have a clear idea of how to interpret "environment" in score-k8s (possibly a config map?) we'd recommend users to implement a custom resource provisioner for their use case. This is being discussed in https://github.com/score-spec/score-k8s/issues/24

  2. Additionally do we want to improve our error messaging to make this more clear. This is the improvement we'd like to tackle as part of the present issue

How to reproduce

Set up a Score spec with an environment resource, for example

apiVersion: score.dev/v1b1
metadata:
  name: my-sample-workload
containers:
  my-sample-container:
    image: .
    variables:
      ENV_VAR: ${resources.env.my-env-var}
resources:
 env:
  type: environment

Run score-k8s

score-k8s init
score-k8s generate score.yaml

You will receive this error:

Error: failed to provision resources: resource 'environment.default#my-sample-workload.env' is not supported by any provisioner

Requirements

Improve error message to

Error: failed to provision resources: The resource 'environment.default#my-sample-workload.env' is not supported by any existing provisioner. Please implement a custom resource provisioner to support this resource type.