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

⚠️ webhook redesign for generic case #323

Merged
merged 19 commits into from
Feb 21, 2019

Commits on Feb 21, 2019

  1. Go vet entire pkg, turn goimports back on

    This makes sure to run go vet on the examples and the alias file, and
    turns goimports back on.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    ab62d27 View commit details
    Browse the repository at this point in the history
  2. Make everything pass goimports

    We had goimports turned off.  When turned back on, it complained about a
    bunch of stuff.  This fixes that.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    f0ec881 View commit details
    Browse the repository at this point in the history
  3. Fix example_test.go to use new list options

    The example was still using the old list options arguments style (second
    argument instead of last argument), which made it fail to compile.
    
    This also makes sure we run go test on the whole project, instead of
    just pkg/...
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    eee0406 View commit details
    Browse the repository at this point in the history
  4. Fix admission webhook injection, no mgr, no client

    The webhook server logic was not handling injection correctly -- it
    implemented injection for a couple of specific fields, rather than
    receiving and dealing with an injectfunc.  This fixes that.
    
    As a side effect, it also removes the handle to manager and client from
    the webhook server, since those aren't used by the server, and should
    thus be injected from the manager.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    5963ad2 View commit details
    Browse the repository at this point in the history
  5. Flatten webhook types struct

    This flattens down the webhook package structure, removing dedicated
    `types` packages in favor of having things in the relevant places.  To
    do this, the inject interface definitions for admission were also moved
    to the admission controller location, but they actually make some amount
    of sense living there.
    
    It also renames and restructures a couple of the types for code clarity (e.g.
    WebhookTypeMutating to MutatingWebhook) or to follow the convention of
    other types in CR (e.g. Making wrapped types from core Kubernetes nested
    fields).
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    14f4abf View commit details
    Browse the repository at this point in the history
  6. Remove extraneous decoder interface

    We don't have anywhere that we actually make use of decoder as an
    interface, so switch to just have a concrete implementation.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    6dbde68 View commit details
    Browse the repository at this point in the history
  7. Extract out multi-handler support, remove builder

    This extracts out the multi-handler support into separate interfaces.
    That simplifies the code, makes it easier to test directly, and allows
    us to drop the now-extraneous Type field.  This simultaneously removes
    the builder (for now) since it doesn't actually make anything simpler.
    
    Along the way, we also refactor some common functionality out into a
    helper on reponse itself as opposed to being run by different bits of
    the webhook.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    c7969dc View commit details
    Browse the repository at this point in the history
  8. Clean up tests to follow standards

    This cleans up tests to more closely follow CR style, favoring
    behavior-style tests as opposed to pure unit tests.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    66be336 View commit details
    Browse the repository at this point in the history
  9. Clean up webhook server

    This renames a few ambigously named fields in the webhook server,
    removes some extraneous fields and methods, and removes the unnecessary
    constructor for Server.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    9a7de90 View commit details
    Browse the repository at this point in the history
  10. Remove the extraneous name field from webhooks

    It was only being used for registering metrics, and that can be done
    with the path instead.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    f46c199 View commit details
    Browse the repository at this point in the history
  11. Remove path from admission, more response helpers

    This removes the path functionality from admission webhooks, since it's
    not strictly needed.  Relevant metrics are moved up to the webhook
    server, and path is added to register.  This also introduces a couple of
    helpers that should make code a bit clearer when writing admission
    webhooks (Allowed, Denied, Patched), and an alias file to avoid
    importing both webhook and webhook/admission.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    027ce71 View commit details
    Browse the repository at this point in the history
  12. Construct and inject decoder into webhook handlers

    This ensures that decoders (which are no longer constructed in the
    manager) are properly injected into webhook handlers.  The webhook
    itself receives a scheme, which it uses to construct a decoder.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    1859301 View commit details
    Browse the repository at this point in the history
  13. Fix admission for decoding for unstructured

    Due to a weird interaction between the unstructured decoder (which
    demands APIVersion and Kind fields) and the API server (which fails to
    set those fields on the embedded object in admission requests), we can't
    use the normal decoders, nor can we call json.Unmarshal directly on the
    unstructured (since it implements an unmarshaller that calls back into
    the decoder).
    
    This detects unstructured objects, and does the right thing for them.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    107c8e9 View commit details
    Browse the repository at this point in the history
  14. Move webhook examples to an actual Go example file

    This moves the examples to an actual Go example file, so that we can be
    sure that they actually compile.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    e08eee7 View commit details
    Browse the repository at this point in the history
  15. Remove pkg/internal/admission

    It's not used anywhere any more.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    65a93df View commit details
    Browse the repository at this point in the history
  16. Rename ErrorResponse to Errored

    It's the same name used in alias.go, and it produces less-verbose code
    without loss of readability.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    1a4bbe1 View commit details
    Browse the repository at this point in the history
  17. Remove inline admission examples

    The were incorrect (would not have compiled), are mostly duplicates
    of examples/*webhook.go, and can't be easily checked for being
    up-to-date.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    a866ee9 View commit details
    Browse the repository at this point in the history
  18. Add per-webhook logging

    This gives each webhook a log, so that serving errors can be tied to a
    particuluar webhook.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    34a4153 View commit details
    Browse the repository at this point in the history
  19. Ensure the right deps are in Gopkg.log

    Nothing was missing from the tree (due to transitive deps), just missing
    from being required by Gopkg.lock.
    DirectXMan12 committed Feb 21, 2019
    Configuration menu
    Copy the full SHA
    286b0b4 View commit details
    Browse the repository at this point in the history