Skip to content

Formats: consider extend value types to allow format enforcing #812

Open
@Dentrax

Description

@Dentrax

Proposal

schema/valuetype is widely used enum across schemas for building custom plugins.

I propose that we can enrich this enum to validate much more different formats 1, like the following:

const (
  TypeInvalid ValueType = iota
  ...
  ...
  ...
  TypeURI
  TypeHEX
  TypeUnixTimeStamp
  TypePath
  TypeHash
  TypeVersion
  etc.
)

Use-cases

data "foo" "bar" {
 url = "docker://qux/quux"
 hash = "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b"
 path = "./path/to/file/"
 ver = "v1.0"
}

The schema would look like this:

Schema: map[string]*schema.Schema{
  "url": {
    Type:        schema.TypeURI,
  },
  "hash": {
    Type:        schema.TypeHash,
  },
  "path": {
    Type:        schema.TypePath,
  },
  "ver": {
    Type:        schema.TypeVerion,
  },
},

Attempted Solutions

We have to manually implement the algorithm that checks if given format is valid.


What do you think? We can get to it if sounds makes sense. @developer-guy @erkanzileli

Any feedback would be appreciated.

Footnotes

  1. The idea comes from securesystemslib/formats.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions