dhall-haskell icon indicating copy to clipboard operation
dhall-haskell copied to clipboard

dhall-openapi: configuration file rfc

Open TristanCacqueray opened this issue 5 years ago • 3 comments
trafficstars

It seems like the openapi-to-dhall command could use some custom configuration:

  • A list of model name prefix to keep (or filter) (use-case: https://github.com/TristanCacqueray/dhall-openshift/issues/6)
  • A list of model name prefix to use for conflict resolution (use-case: https://github.com/dhall-lang/dhall-kubernetes/pull/120)

Would it be appropriate to add a configuration file to configure the output of the openapi-to-dhall command? For example, a --config FilePath command line argument to set:

{ keep : List Text --| (empty means keep all)
, drop : List Text --| (empty means no keep all)
, namespace-keep: List Text
, namespace-drop: List Text
}

With such configuration file, we could start removing the kubernetes specific bits from the existing dhall-openapi implementation, for example https://github.com/dhall-lang/dhall-haskell/blob/715ba2a8dc2d8e6f19280a9a95863119442db312/dhall-openapi/src/Dhall/Kubernetes/Convert.hs#L282-L283 would be represented as

{ namespace-drop = ["io.k8s.kubernetes.pkg.api.", "io.k8s.kubernetes.pkg.apis."]
}

Is this a good idea?

TristanCacqueray avatar Sep 17 '20 13:09 TristanCacqueray

Also note that the immediate need is to be able to select a list of object, and since that is a solution to implement the work-around for performance issues, perhaps a simpler [--keep object-name-prefix] command line argument would do the trick.

TristanCacqueray avatar Sep 17 '20 13:09 TristanCacqueray

As a note, for this to be useful, if a package such as "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" is in the list of --keep it should also bring all of its dependencies such as "io.k8s.apimachinery.pkg.apis.meta.v1.Time", ...

PierreR avatar Sep 17 '20 20:09 PierreR

Also the list might be long so a dhall configuration file could be the way to go.

PierreR avatar Sep 19 '20 17:09 PierreR