Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GlobalSpec = func(rc ResourceContext, name string, appValue raw.Map) (spec raw.Map, err error) { if _globalOptions == nil { err = fmt.Errorf("not properly inited") return } spec = _globalOptions.Values for _, plugin := range rc.Plugins() { if plugin.Name == "" || plugin.Url == "" || len(plugin.Keys) == 0 { rc.Logger().Warnf("plugin %s not loaded because its name/url/keys are empty", plugin.Name) continue } plugin.Url = strings.ReplaceAll(plugin.Url, `{cluster}`, _globalOptions.Cluster) plugin.Url = strings.ReplaceAll(plugin.Url, `{namespace}`, rc.Namespace()) plugin.Url = strings.ReplaceAll(plugin.Url, `{name}`, name) for _, item := range []string{"area", "mode", "context"} { if strings.Contains(plugin.Url, item) { var value string if value, err = raw.Get[string](appValue, item); err != nil { rc.Logger().Warnf("plugin failed to load: %s not found in app values", item) return } plugin.Url = strings.ReplaceAll(plugin.Url, "{"+item+"}", value) } } var values raw.Map if values, err = readGCSYaml(plugin.Url); err != nil { return } object := raw.Map{} for _, key := range plugin.Keys { object[key] = values[key] } spec[plugin.Name] = object } return }
var MustHaveOptions = func() *Options { if _globalOptions == nil { panic("not initialized") } return _globalOptions }
Functions ¶
func InitFromConfigMap ¶ added in v1.0.2
Types ¶
type AssetContext ¶
type AssetContext interface {
WorkPath() string
}
type ContextOption ¶
type ContextOption func(*rcImpl)
func WithLogLevel ¶
func WithLogLevel(level logrus.Level) ContextOption
func WithNamespace ¶
func WithNamespace(namespace string) ContextOption
func WithPlugins ¶ added in v1.0.2
func WithPlugins(plugins []*Plugin) ContextOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ContextOption
func WithWorkPath ¶
func WithWorkPath(workPath string) ContextOption
type ResourceContext ¶
type ResourceContext interface { AssetContext Context() context.Context Namespace() string Timeout() time.Duration Logger() *logrus.Logger Plugins() []*Plugin }
ResourceContext is an interface that extends the AssetContext interface and provides additional methods for accessing the cluster, context, namespace, timeout, and logger associated with a resource.
Methods: Cluster: Returns the cluster associated with the resource. Context: Returns the context associated with the resource. Namespace: Returns the namespace associated with the resource. Timeout: Returns the timeout duration for operations on the resource. Logger: Returns the logger associated with the resource.
func NewContext ¶
func NewContext(ctx context.Context, options ...ContextOption) ResourceContext
type Spec ¶
type Spec struct { Asset struct { Typ string `yaml:"type" json:"type"` Release string `yaml:"release" json:"release"` } `yaml:"asset" json:"asset"` App map[string]any `yaml:"app" json:"app"` }
Spec represents a specification that includes information about an asset and an application. It is used to parse specifications from YAML files or other types of input data.
Fields: Asset: A struct that contains the type and release version of the asset. App: A map that contains application-specific data.
The Asset field is tagged with `yaml:"asset"` to specify the YAML name of the field. The App field is tagged with `yaml:"app"` to specify the YAML name of the field.