Package admission contains API for writing admission plugins.



    View Source
    const ProtocolVersion = 1

      ProtocolVersion will change if we have backward-incompatible changes.


      This section is empty.


      func Run

      func Run(ctx context.Context, stdin io.ReadCloser, version string, handler Handler) error

        Run executes the run loop of an admission plugin.

        It connects to the host and starts handling admission checks (each in an individual goroutine) by calling the handler.

        Blocks until the stdin closes (which indicates the plugin should terminate).


        type Handler

        type Handler func(ctx context.Context, req *protocol.Admission, info InstanceInfo) error

          Handler handles one admission request.

          Called in a separate internal goroutine. It should return a grpc status error. To decide it can use the given `info` to fetch additional data about the package instance.

          type InstanceInfo

          type InstanceInfo interface {
          	// VisitMetadata visits metadata entries attached to the package instance.
          	// Either visits all metadata or only entries with requested keys. Visits
          	// entries in order of their registration time (the most recent first).
          	// Fetches them in pages of `pageSize`. If `pageSize` is negative or zero,
          	// uses some default size.
          	// Calls `cb` for each visited entry until all entries are successfully
          	// visited or the callback returns false. Returns an error if the RPC to
          	// the CIPD backend fails.
          	VisitMetadata(ctx context.Context, keys []string, pageSize int, cb func(md *api.InstanceMetadata) bool) error

            InstanceInfo fetches additional information about a package instance being checked for admission by the handler.

            Source Files


            Path Synopsis