mirror of
https://github.com/kubevela/kubevela.git
synced 2026-03-04 10:41:46 +00:00
27 lines
653 B
Go
27 lines
653 B
Go
package serverlib
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/oam-dev/kubevela/pkg/server/apis"
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
)
|
|
|
|
// RetrieveComponent will get component status
|
|
func RetrieveComponent(ctx context.Context, c client.Client, applicationName, componentName, namespace string) (apis.ComponentMeta, error) {
|
|
var componentMeta apis.ComponentMeta
|
|
applicationMeta, err := RetrieveApplicationStatusByName(ctx, c, applicationName, namespace)
|
|
if err != nil {
|
|
return componentMeta, err
|
|
}
|
|
|
|
for _, com := range applicationMeta.Components {
|
|
if com.Name != componentName {
|
|
continue
|
|
}
|
|
return com, nil
|
|
}
|
|
return componentMeta, nil
|
|
}
|