Registry Plugin - RegistryAccess Interface

I’m working on a plugin to push a generic artifact to a GitLab repository. I’ve got the basic implementation down for pushing to GitLab, but after building and attempting to use the plugin, I hit this error message:

$ waypoint build

» Building gitlab-test...
  Performing operation locally
! The plugin requested does not define an AccessInfoFunc() in its Registry plugin.
  This is an internal error and should be reported to the author of the plugin.

I read in the waypoint-plugin-sdk that the RegistryAccess interface is optional for a registry plugin, but without having implemented it, perhaps it is actually required… has anyone else run into this?

In the Waypoint source itself, in app_build.go, I found where the error msg is being reported:

func (op *buildOperation) Do(ctx context.Context, log hclog.Logger, app *App, _ proto.Message) (interface{}, error) {
	args := []argmapper.Arg{
		argmapper.Named("HasRegistry", op.HasRegistry),
	}

	// If there is a registry defined and it implements RegistryAccess...
	if op.Registry != nil {
		if ra, ok := op.Registry.Value.(component.RegistryAccess); ok && ra.AccessInfoFunc() != nil {
			raw, err := app.callDynamicFunc(ctx, log, nil, op.Component, ra.AccessInfoFunc())
			if err == nil {
				args = append(args, argmapper.Typed(raw))

				if pm, ok := raw.(interface {
					TypedAny() *any.Any
				}); ok {
					any := pm.TypedAny()

					// ... which we make available to build plugin.
					args = append(args, plugin.ArgNamedAny("access_info", any))
					log.Debug("injected access info")
				} else {
					log.Error("unexpected response type from callDynamicFunc", "type", hclog.Fmt("%T", raw))
					return nil, errors.New("AccessInfoFunc didn't provide a typed any")
				}
			} else {
				log.Error("error calling dynamic func", "error", err)
				return nil, err
			}
		} else {
			if ok && ra != nil && ra.AccessInfoFunc() == nil {
				return nil, status.Error(codes.Internal, "The plugin requested does not "+
					"define an AccessInfoFunc() in its Registry plugin. This is an internal "+
					"error and should be reported to the author of the plugin.")
			}
		}
	}

	return app.callDynamicFunc(ctx,
		log,
		(*component.Artifact)(nil),
		op.Component,
		op.Component.Value.(component.Builder).BuildFunc(),
		args...,
	)
}

I’m working out of this repo: GitHub - paladin-devops/waypoint-plugin-gitlab: A plugin for Hashicorp Waypoint for pushing build artifacts to GitLab

I actually got the plugin working after implementing the RegistryAccess interface (based on the implementation of the “filepath” example plugin! Still trying to understand why it was required, but happy to say it works!

For anyone curious, an example usage:

    registry {
      use "gitlab" {
        name       = "${app.name}"
        version    = "x.y.z"
        project_id = 12345678
        file_name  = "${app.name}"
        token      = "token"
      }
    }
2 Likes