Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions pkg/epp/plugins/typedname.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,19 @@ limitations under the License.

package plugins

// TypedName is a utility struct providing a type and a name
// to plugins.
// It implements the Plugin interface and can be embedded in
// plugins across the code to reduce boilerplate.
const (
separator = "/"
)

// TypedName is a utility struct providing a type and a name to plugins.
type TypedName struct {
// Type returns the type of the plugin.
// Type returns the type of a plugin.
Type string
// Name returns the name of this plugin instance.
// Name returns the name of a plugin instance.
Name string
}

const (
Separator = "/"
)

// String returns the type and name rendered as
// "<type>/<name>".
// String returns the type and name rendered as "<name>/<type>".
func (tn *TypedName) String() string {
return tn.Type + Separator + tn.Name
return tn.Name + separator + tn.Type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be a breaking change to existing usage though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TLDR:
nope. this field is mainly used for logging.

more details if you're interested:
TypedName was introduced recently with the understanding that we could potentially have multiple instances of the same plugin type, and then we may distinguish them by name (name is optional, type is mandatory).
the idea behind this change is to keep similar behavior as NamespacedName - so if both fields exist we get name/type, if no name was defined we get /type (instead of current implementation that returns type/).

this is similar to NamespacedName, where Name is mandatory and Ns is optional (for cluster-scoped resources), so we either get back ns/name or /name for cluster-scoped resources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

}