Skip to main content
This section explains how plugins receive target configuration.

What is a target?

A target uniquely identifies a deployment location for your infrastructure. Think of it as “where” your resources live:
  • For AWS: a region like us-east-1
  • For Kubernetes: a cluster endpoint
  • For SFTP: a server URL like sftp://files.example.com:22
Targets are stored in formae’s database in plaintext, so they must never contain secrets. The target identifies the location; credentials are provided separately.

Target vs credentials

Target configuration in requests

Every request to your plugin includes a TargetConfig field:

Define the target config type

For our SFTP plugin, the target is just the server URL. Add this to sftp.go:

Update sftp.go

Add the target configuration and credentials code. Update the imports and add the helper functions:

Config field mutability

You can annotate target config fields to tell formae which fields can be changed in place and which require a full target replace. Add @formae.ConfigFieldHint annotations to your PKL Config class:
  • createOnly = true: immutable, triggers target replace (default for unannotated fields)
  • createOnly = false: mutable, allows in-place update
For our SFTP plugin, the URL is the only config field and it identifies the deployment location, so it should be immutable. For plugins with credential-like config fields (e.g. a named profile), marking those as createOnly = false lets users switch credentials without recreating resources. See the schema annotations reference for full details.

Verify

To verify that the target configuration code compiles correctly:

Next: 04 - Plugin configuration

See also: advanced target patterns

For Target Config patterns beyond this introduction:
  • Cross-plugin Target Resolvables (Target Config field accepting upstream resolvable from another plugin’s resource): see the Grafana plugin’s Target Config, which references AWS/Compose resolvables.
  • Collection Resolvables (Mapping<String, formae.Resolvable> and similar): see the Compose plugin’s Target Config.
  • Polymorphic Target auth (abstract auth class plus KubeconfigAuth/EKSAuth/GKEAuth/… discriminated by hidden fixed type): see the Kubernetes plugin’s Target Config.