Skip to content

Instantly share code, notes, and snippets.

@Duologic
Last active July 20, 2020 14:50
Show Gist options
  • Save Duologic/875c374cd0df5a04d059fc3e5de9a3dd to your computer and use it in GitHub Desktop.
Save Duologic/875c374cd0df5a04d059fc3e5de9a3dd to your computer and use it in GitHub Desktop.

Option 1

└── lib/k.libsonnet imports vendor/k8s-alpha
    └── vendor/k8s-util imports lib/k.libsonnet
        └── library imports vendor/k8s-util
  • Known pattern, same as ksonnet-util/kausal.libsonnet
  • It is clear that the library depends on opinionated library k8s-util
  • Single import for both, k.libsonnet might be imported twice for the newcomer

Option 2

└── lib/k.libsonnet imports vendor/k8s-alpha
    └── library imports lib/k.libsonnet + vendor/k8s-util
  • Changes pattern, all libraries now have to import both
  • It is clear that the library depends on opinionated library k8s-util
  • Two imports to get both, maybe k8s-util should say k8s-mixin to make clear k8s-util doesn't do much on its own?

Option 3

└── lib/k.libsonnet imports vendor/k8s-alpha + vendor/k8s-util
    └── library import lib/k.libsonnet
  • Changes pattern, all libraries with kausal.libsonnet need to grab k.libsonnet
  • It is unclear if the library depends on opionated functions in k8s-util, might make library less portable
  • Single import for both

Option 4

└── k8s provides new entrypoint: vendor/k8s-alpha-k8s-util
    └── lib/k.libsonnet imports vendor/k8s-alpha-k8s-util
        └── library import lib/k.libsonnet
  • Changes pattern, all libraries with kausal.libsonnet need to grab k.libsonnet
  • It is unclear if the library depends on opionated functions in k8s-util, might make library less portable
  • Single import for both
@Duologic
Copy link
Author

I can come up with more options here, but it would circumvent the use of lib/k.libsonnet, but I think we want to keep the ability to switch k8s versions through k.libsonnet, which is the whole reason it exists.

@Duologic
Copy link
Author

Conclusion

└── lib/k.libsonnet imports vendor/k8s-alpha + vendor/k8s-mixin/defaults.libsonnet
    └── library import lib/k.libsonnet
  • Changes pattern, all libraries with kausal.libsonnet need to grab k.libsonnet
  • It is unclear if the library depends on opionated functions in k8s-util, might make library less portable
  • Single import for both

To make it clearer, the opinionated functions should be split into the opinionated defaults (specific for Grafana) and non-opinionated but enhanced API (which needs to move into k8s-alpha)

Steps to take:

  1. Create k8s-mixin/defaults.libsonnet, brings in api.libsonnet and utils.libsonnet
  2. Modify k.libsonnet to remove kausal-shim, bring in k8s-mixin
  3. Modify all libs to have k.libsonnet only
  4. Upstream api.libsonnet and utils.libsonnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment