Command traefik error: field not found, node: devPlugin

I'm learning how to create Traefik plugin by following this tutorial. I follow it exactly the same way without barely deviations. But, I encountered a problem when I try to run the plugin at 26:08.

# plugins/traefik-uiddemo.yaml
pilot:
    token: "token"

api:
  dashboard: true
  insecure: true

experimental:
  devPlugin:
    goPath: /home/user/go
    moduleName: github.com/<user>/uiddemo

entryPoints:
  http:
    address: ":8000"
    forwardedHeaders:
      insecure: true

providers:
  file: 
    filename: rules-uiddemo.yaml
# plugins/rules-uiddemo.yaml
http:
  # Add router
  routers:
    my-router:
      entryPoints:
      - http
      middlewares:
      - pluginDemo
      service: service-whoami
      rule: Path(`/whoami`)

  # Add services
  services:
    service-whoami:
      loadBalancer:
        servers:
        - url: http://localhost:5000/
        passHostHeader: false
  
  middlewares:
    plugindemo:
      plugin:
        dev:
          Foo: Bar
# plugins/src/github.com/<user>/uiddemo
package uiddemo

import (
	"context"
	"net/http"
)

// Config holds configuration passed to the plugin
type Config struct{}

// CreateConfig populates the Config struct
func CreateConfig() *Config {
	return &Config{}
}

// UIDDemo holds the necessary components of a Traefik plugin
type UIDDemo struct {
	next http.Handler
	name string
}

// New instantiates and returns the required components used to handle a HTTP request
func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) {
	return &UIDDemo{
		next: next,
		name: name,
	}, nil
}

func (u *UIDDemo) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
	rw.Write([]byte("Hello world "))
}

When I try to run and test the plugin by running this command

$ ./traefik --configfile traefik-uiddemo.yaml

I encountered this error

2022/03/17 10:34:21 command traefik error: field not found, node: devPlugin

What happened? I know the problem lies on devPlugin in traefik-uiddemo.yaml, but I just can't figure out why and how to solve it.

As far as I'm aware, goPath refers to my Go Path on my computer and moduleName refers to the module name of the plugin I use. I'm missing something.

Hello @panah,

Since Traefik v2.5 (Local private plugins. by ldez · Pull Request #8224 · traefik/traefik · GitHub), devPlugin was replaced by localPlugins.

Hope it helps :slight_smile:

2 Likes

Thanks! So that's why some articles I read use localPlugins.

Anyway, do you have any plan to update the documentation? Some docs like this still use devPlugin and it doesn't tell us about the depreciation.

Indeed, something has to be done about that :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.