spec icon indicating copy to clipboard operation
spec copied to clipboard

we should allow one kind of trait be bound to component multiple times

Open wonderflow opened this issue 4 years ago • 3 comments

As we discussed before, trait is something like properties, so one kind of trait should only bind to component once.

But recently more and more demands come up that we have to bind one kind of traits to component multiple times.

For example, ingress trait, volumeMount trait. It's common that a workload need to expose more than one port and have more than one ingress. So does volumeMount trait.

We can solve this by define ingress trait or volumeMount trait as an array. But obviously, we don't want do that intuitively( example in rudr: ingress, volumeMount).

So I suggest we should allow one kind of trait be bound to component multiple times. By default it should only bind once, but users can specify metadata.name if they want to use more than once. Just like what I said in issue https://github.com/crossplane/oam-kubernetes-runtime/issues/36

wonderflow avatar Jun 08 '20 09:06 wonderflow

Instead, I think the right way to go is defining array in trait's spec. The traits list, as part of Application Configuration, is indeed a configuration of capability instead of instance of capability.

resouer avatar Aug 13 '20 16:08 resouer

The traits in the spec is already an array. IMO, an array of array is not desirable. It seems that users can apply multiple traits of the same type to a component now already. What am I missing?

ryanzhang-oss avatar Aug 13 '20 17:08 ryanzhang-oss

@ryanzhang-oss Please check this example for more detail: https://github.com/oam-dev/catalog/issues/53

For any given trait, we prefer design it as a array/list instead of apply multiple traits of same kind (we allow this but not the best practice).

resouer avatar Aug 13 '20 18:08 resouer