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

Allow @schema/nullable alongside @schema/type any=True #723

Closed
Tracked by #561
pivotaljohn opened this issue Aug 29, 2022 · 0 comments · Fixed by #735
Closed
Tracked by #561

Allow @schema/nullable alongside @schema/type any=True #723

pivotaljohn opened this issue Aug 29, 2022 · 0 comments · Fixed by #735
Assignees

Comments

@pivotaljohn
Copy link
Contributor

pivotaljohn commented Aug 29, 2022

(From #707 synthesis: "Allow both nullable and type any=True")


In #400 (implemented in #517), we specifically disallowed both @schema/type and @schema/nullable.

We have now found a use-case where we'd like to allow it:

#@data/values-schema
---
#! Define which storage backend is used for registry and chartmuseum to store
#! images and charts.
#@schema/validation one_not_null=["filesystem", "azure", "gcs", "s3"]
imageChartStorage:
    #@schema/nullable
    filesystem:
      rootdirectory: /storage
      #! maxthreads: 100
    #@schema/nullable   
    azure:
      accountname: "" 
      accountkey: "" 
      container: "" 
      realm: "" 
    #@schema/nullable
    gcs:
      bucket: "" 
      encodedkey: "" 
      rootdirectory: "" 
    #@schema/type any=True
    #@schema/nullable
    s3:
      region: "" 
      bucket: "" 
      accesskey: "" 
      secretkey: "" 

Fails with:

ytt: Error: Overlaying data values schema (in following order: schema.yaml):
Invalid schema
==============

@schema/nullable, and @schema/type any=True are mutually exclusive
schema.yaml:
     |
  22 |     #@schema/type any=True
  23 |     #@schema/nullable
  24 |     s3:
     |

     = found: both @schema/nullable, and @schema/type any=True annotations
     = expected: one of schema/nullable, or schema/type any=True

However — as became evident in our usability testing (i.e. #707) — it is very natural to want to both set the default value for a map item to be null and want to allow any type.

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 a pull request may close this issue.

1 participant