diff --git a/api/config/crd/bases/odigos.io_instrumentations.yaml b/api/config/crd/bases/odigos.io_instrumentations.yaml new file mode 100644 index 0000000000..cac3a4bb5f --- /dev/null +++ b/api/config/crd/bases/odigos.io_instrumentations.yaml @@ -0,0 +1,148 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + labels: + metadata.labels.odigos.io/config: "1" + metadata.labels.odigos.io/system-object: "true" + name: instrumentations.odigos.io +spec: + group: odigos.io + names: + kind: Instrumentation + listKind: InstrumentationList + plural: instrumentations + singular: instrumentation + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.workload.name + name: Workload + type: string + - jsonPath: .spec.workload.kind + name: Kind + type: string + - jsonPath: .spec.workload.namespace + name: Namespace + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Instrumentation configures an application for auto-instrumentation. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + workload: + description: |- + Workload represents the workload or namespace to be instrumented. + This field is required upon creation and cannot be modified. + properties: + kind: + description: |- + 1. the pascal case representation of the workload kind + it is used in k8s api objects as the `Kind` field. + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + - namespace + type: object + x-kubernetes-validations: + - message: Workload cannot be modified + rule: self == oldSelf + required: + - workload + type: object + status: + properties: + conditions: + description: |- + Represents the observations of a instrumentationrule's current state. + Known .status.conditions.type are: "Available", "Progressing" + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentation.go b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentation.go new file mode 100644 index 0000000000..5e3c2990df --- /dev/null +++ b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentation.go @@ -0,0 +1,224 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// InstrumentationApplyConfiguration represents a declarative configuration of the Instrumentation type for use +// with apply. +type InstrumentationApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *InstrumentationSpecApplyConfiguration `json:"spec,omitempty"` + Status *InstrumentationStatusApplyConfiguration `json:"status,omitempty"` +} + +// Instrumentation constructs a declarative configuration of the Instrumentation type for use with +// apply. +func Instrumentation(name, namespace string) *InstrumentationApplyConfiguration { + b := &InstrumentationApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("Instrumentation") + b.WithAPIVersion("odigos.io/v1alpha1") + return b +} + +// WithKind sets the Kind field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Kind field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithKind(value string) *InstrumentationApplyConfiguration { + b.Kind = &value + return b +} + +// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the APIVersion field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithAPIVersion(value string) *InstrumentationApplyConfiguration { + b.APIVersion = &value + return b +} + +// WithName sets the Name field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Name field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithName(value string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Name = &value + return b +} + +// WithGenerateName sets the GenerateName field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateName field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithGenerateName(value string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.GenerateName = &value + return b +} + +// WithNamespace sets the Namespace field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Namespace field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithNamespace(value string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Namespace = &value + return b +} + +// WithUID sets the UID field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the UID field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithUID(value types.UID) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.UID = &value + return b +} + +// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the ResourceVersion field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithResourceVersion(value string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.ResourceVersion = &value + return b +} + +// WithGeneration sets the Generation field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Generation field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithGeneration(value int64) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.Generation = &value + return b +} + +// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the CreationTimestamp field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithCreationTimestamp(value metav1.Time) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.CreationTimestamp = &value + return b +} + +// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionTimestamp field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionTimestamp = &value + return b +} + +// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + b.DeletionGracePeriodSeconds = &value + return b +} + +// WithLabels puts the entries into the Labels field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Labels field, +// overwriting an existing map entries in Labels field with the same key. +func (b *InstrumentationApplyConfiguration) WithLabels(entries map[string]string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Labels == nil && len(entries) > 0 { + b.Labels = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Labels[k] = v + } + return b +} + +// WithAnnotations puts the entries into the Annotations field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, the entries provided by each call will be put on the Annotations field, +// overwriting an existing map entries in Annotations field with the same key. +func (b *InstrumentationApplyConfiguration) WithAnnotations(entries map[string]string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + if b.Annotations == nil && len(entries) > 0 { + b.Annotations = make(map[string]string, len(entries)) + } + for k, v := range entries { + b.Annotations[k] = v + } + return b +} + +// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the OwnerReferences field. +func (b *InstrumentationApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + if values[i] == nil { + panic("nil value passed to WithOwnerReferences") + } + b.OwnerReferences = append(b.OwnerReferences, *values[i]) + } + return b +} + +// WithFinalizers adds the given value to the Finalizers field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Finalizers field. +func (b *InstrumentationApplyConfiguration) WithFinalizers(values ...string) *InstrumentationApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.Finalizers = append(b.Finalizers, values[i]) + } + return b +} + +func (b *InstrumentationApplyConfiguration) ensureObjectMetaApplyConfigurationExists() { + if b.ObjectMetaApplyConfiguration == nil { + b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{} + } +} + +// WithSpec sets the Spec field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Spec field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithSpec(value *InstrumentationSpecApplyConfiguration) *InstrumentationApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Status field is set to the value of the last call. +func (b *InstrumentationApplyConfiguration) WithStatus(value *InstrumentationStatusApplyConfiguration) *InstrumentationApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *InstrumentationApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.Name +} diff --git a/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationspec.go b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationspec.go new file mode 100644 index 0000000000..dab281b1da --- /dev/null +++ b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationspec.go @@ -0,0 +1,42 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + workload "github.com/odigos-io/odigos/k8sutils/pkg/workload" +) + +// InstrumentationSpecApplyConfiguration represents a declarative configuration of the InstrumentationSpec type for use +// with apply. +type InstrumentationSpecApplyConfiguration struct { + Workload *workload.PodWorkload `json:"workload,omitempty"` +} + +// InstrumentationSpecApplyConfiguration constructs a declarative configuration of the InstrumentationSpec type for use with +// apply. +func InstrumentationSpec() *InstrumentationSpecApplyConfiguration { + return &InstrumentationSpecApplyConfiguration{} +} + +// WithWorkload sets the Workload field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the Workload field is set to the value of the last call. +func (b *InstrumentationSpecApplyConfiguration) WithWorkload(value workload.PodWorkload) *InstrumentationSpecApplyConfiguration { + b.Workload = &value + return b +} diff --git a/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationstatus.go b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationstatus.go new file mode 100644 index 0000000000..d3f06e54e4 --- /dev/null +++ b/api/generated/odigos/applyconfiguration/odigos/v1alpha1/instrumentationstatus.go @@ -0,0 +1,47 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by applyconfiguration-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// InstrumentationStatusApplyConfiguration represents a declarative configuration of the InstrumentationStatus type for use +// with apply. +type InstrumentationStatusApplyConfiguration struct { + Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"` +} + +// InstrumentationStatusApplyConfiguration constructs a declarative configuration of the InstrumentationStatus type for use with +// apply. +func InstrumentationStatus() *InstrumentationStatusApplyConfiguration { + return &InstrumentationStatusApplyConfiguration{} +} + +// WithConditions adds the given value to the Conditions field in the declarative configuration +// and returns the receiver, so that objects can be build by chaining "With" function invocations. +// If called multiple times, values provided by each call will be appended to the Conditions field. +func (b *InstrumentationStatusApplyConfiguration) WithConditions(values ...*v1.ConditionApplyConfiguration) *InstrumentationStatusApplyConfiguration { + for i := range values { + if values[i] == nil { + panic("nil value passed to WithConditions") + } + b.Conditions = append(b.Conditions, *values[i]) + } + return b +} diff --git a/api/generated/odigos/applyconfiguration/utils.go b/api/generated/odigos/applyconfiguration/utils.go index c4383287bf..6b19218397 100644 --- a/api/generated/odigos/applyconfiguration/utils.go +++ b/api/generated/odigos/applyconfiguration/utils.go @@ -59,6 +59,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &odigosv1alpha1.EnvVarApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("HeadSamplingConfig"): return &odigosv1alpha1.HeadSamplingConfigApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Instrumentation"): + return &odigosv1alpha1.InstrumentationApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("InstrumentationConfig"): return &odigosv1alpha1.InstrumentationConfigApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("InstrumentationConfigSpec"): @@ -91,6 +93,10 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &odigosv1alpha1.InstrumentationRuleSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("InstrumentationRuleStatus"): return &odigosv1alpha1.InstrumentationRuleStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstrumentationSpec"): + return &odigosv1alpha1.InstrumentationSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("InstrumentationStatus"): + return &odigosv1alpha1.InstrumentationStatusApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("InstrumentedApplication"): return &odigosv1alpha1.InstrumentedApplicationApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("InstrumentedApplicationSpec"): diff --git a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_instrumentation.go b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_instrumentation.go new file mode 100644 index 0000000000..bee026a3e9 --- /dev/null +++ b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_instrumentation.go @@ -0,0 +1,196 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + "context" + json "encoding/json" + "fmt" + + odigosv1alpha1 "github.com/odigos-io/odigos/api/generated/odigos/applyconfiguration/odigos/v1alpha1" + v1alpha1 "github.com/odigos-io/odigos/api/odigos/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" +) + +// FakeInstrumentations implements InstrumentationInterface +type FakeInstrumentations struct { + Fake *FakeOdigosV1alpha1 + ns string +} + +var instrumentationsResource = v1alpha1.SchemeGroupVersion.WithResource("instrumentations") + +var instrumentationsKind = v1alpha1.SchemeGroupVersion.WithKind("Instrumentation") + +// Get takes name of the instrumentation, and returns the corresponding instrumentation object, and an error if there is any. +func (c *FakeInstrumentations) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.Instrumentation, err error) { + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewGetActionWithOptions(instrumentationsResource, c.ns, name, options), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// List takes label and field selectors, and returns the list of Instrumentations that match those selectors. +func (c *FakeInstrumentations) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha1.InstrumentationList, err error) { + emptyResult := &v1alpha1.InstrumentationList{} + obj, err := c.Fake. + Invokes(testing.NewListActionWithOptions(instrumentationsResource, instrumentationsKind, c.ns, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.InstrumentationList{ListMeta: obj.(*v1alpha1.InstrumentationList).ListMeta} + for _, item := range obj.(*v1alpha1.InstrumentationList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested instrumentations. +func (c *FakeInstrumentations) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchActionWithOptions(instrumentationsResource, c.ns, opts)) + +} + +// Create takes the representation of a instrumentation and creates it. Returns the server's representation of the instrumentation, and an error, if there is any. +func (c *FakeInstrumentations) Create(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.CreateOptions) (result *v1alpha1.Instrumentation, err error) { + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewCreateActionWithOptions(instrumentationsResource, c.ns, instrumentation, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// Update takes the representation of a instrumentation and updates it. Returns the server's representation of the instrumentation, and an error, if there is any. +func (c *FakeInstrumentations) Update(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.UpdateOptions) (result *v1alpha1.Instrumentation, err error) { + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewUpdateActionWithOptions(instrumentationsResource, c.ns, instrumentation, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeInstrumentations) UpdateStatus(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.UpdateOptions) (result *v1alpha1.Instrumentation, err error) { + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceActionWithOptions(instrumentationsResource, "status", c.ns, instrumentation, opts), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// Delete takes name of the instrumentation and deletes it. Returns an error if one occurs. +func (c *FakeInstrumentations) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteActionWithOptions(instrumentationsResource, c.ns, name, opts), &v1alpha1.Instrumentation{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeInstrumentations) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { + action := testing.NewDeleteCollectionActionWithOptions(instrumentationsResource, c.ns, opts, listOpts) + + _, err := c.Fake.Invokes(action, &v1alpha1.InstrumentationList{}) + return err +} + +// Patch applies the patch and returns the patched instrumentation. +func (c *FakeInstrumentations) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Instrumentation, err error) { + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(instrumentationsResource, c.ns, name, pt, data, opts, subresources...), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// Apply takes the given apply declarative configuration, applies it and returns the applied instrumentation. +func (c *FakeInstrumentations) Apply(ctx context.Context, instrumentation *odigosv1alpha1.InstrumentationApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instrumentation, err error) { + if instrumentation == nil { + return nil, fmt.Errorf("instrumentation provided to Apply must not be nil") + } + data, err := json.Marshal(instrumentation) + if err != nil { + return nil, err + } + name := instrumentation.Name + if name == nil { + return nil, fmt.Errorf("instrumentation.Name must be provided to Apply") + } + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(instrumentationsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions()), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} + +// ApplyStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). +func (c *FakeInstrumentations) ApplyStatus(ctx context.Context, instrumentation *odigosv1alpha1.InstrumentationApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instrumentation, err error) { + if instrumentation == nil { + return nil, fmt.Errorf("instrumentation provided to Apply must not be nil") + } + data, err := json.Marshal(instrumentation) + if err != nil { + return nil, err + } + name := instrumentation.Name + if name == nil { + return nil, fmt.Errorf("instrumentation.Name must be provided to Apply") + } + emptyResult := &v1alpha1.Instrumentation{} + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceActionWithOptions(instrumentationsResource, c.ns, *name, types.ApplyPatchType, data, opts.ToPatchOptions(), "status"), emptyResult) + + if obj == nil { + return emptyResult, err + } + return obj.(*v1alpha1.Instrumentation), err +} diff --git a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_odigos_client.go b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_odigos_client.go index 9f70f41c2a..b9449792be 100644 --- a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_odigos_client.go +++ b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/fake/fake_odigos_client.go @@ -35,6 +35,10 @@ func (c *FakeOdigosV1alpha1) Destinations(namespace string) v1alpha1.Destination return &FakeDestinations{c, namespace} } +func (c *FakeOdigosV1alpha1) Instrumentations(namespace string) v1alpha1.InstrumentationInterface { + return &FakeInstrumentations{c, namespace} +} + func (c *FakeOdigosV1alpha1) InstrumentationConfigs(namespace string) v1alpha1.InstrumentationConfigInterface { return &FakeInstrumentationConfigs{c, namespace} } diff --git a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/generated_expansion.go b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/generated_expansion.go index a6b52f8da3..ff0918d9d7 100644 --- a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/generated_expansion.go +++ b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/generated_expansion.go @@ -21,6 +21,8 @@ type CollectorsGroupExpansion interface{} type DestinationExpansion interface{} +type InstrumentationExpansion interface{} + type InstrumentationConfigExpansion interface{} type InstrumentationInstanceExpansion interface{} diff --git a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/instrumentation.go b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/instrumentation.go new file mode 100644 index 0000000000..7a77d533d2 --- /dev/null +++ b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/instrumentation.go @@ -0,0 +1,72 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + + odigosv1alpha1 "github.com/odigos-io/odigos/api/generated/odigos/applyconfiguration/odigos/v1alpha1" + scheme "github.com/odigos-io/odigos/api/generated/odigos/clientset/versioned/scheme" + v1alpha1 "github.com/odigos-io/odigos/api/odigos/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// InstrumentationsGetter has a method to return a InstrumentationInterface. +// A group's client should implement this interface. +type InstrumentationsGetter interface { + Instrumentations(namespace string) InstrumentationInterface +} + +// InstrumentationInterface has methods to work with Instrumentation resources. +type InstrumentationInterface interface { + Create(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.CreateOptions) (*v1alpha1.Instrumentation, error) + Update(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.UpdateOptions) (*v1alpha1.Instrumentation, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, instrumentation *v1alpha1.Instrumentation, opts v1.UpdateOptions) (*v1alpha1.Instrumentation, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha1.Instrumentation, error) + List(ctx context.Context, opts v1.ListOptions) (*v1alpha1.InstrumentationList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha1.Instrumentation, err error) + Apply(ctx context.Context, instrumentation *odigosv1alpha1.InstrumentationApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instrumentation, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, instrumentation *odigosv1alpha1.InstrumentationApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha1.Instrumentation, err error) + InstrumentationExpansion +} + +// instrumentations implements InstrumentationInterface +type instrumentations struct { + *gentype.ClientWithListAndApply[*v1alpha1.Instrumentation, *v1alpha1.InstrumentationList, *odigosv1alpha1.InstrumentationApplyConfiguration] +} + +// newInstrumentations returns a Instrumentations +func newInstrumentations(c *OdigosV1alpha1Client, namespace string) *instrumentations { + return &instrumentations{ + gentype.NewClientWithListAndApply[*v1alpha1.Instrumentation, *v1alpha1.InstrumentationList, *odigosv1alpha1.InstrumentationApplyConfiguration]( + "instrumentations", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *v1alpha1.Instrumentation { return &v1alpha1.Instrumentation{} }, + func() *v1alpha1.InstrumentationList { return &v1alpha1.InstrumentationList{} }), + } +} diff --git a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/odigos_client.go b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/odigos_client.go index 06398b4927..dc535257d6 100644 --- a/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/odigos_client.go +++ b/api/generated/odigos/clientset/versioned/typed/odigos/v1alpha1/odigos_client.go @@ -29,6 +29,7 @@ type OdigosV1alpha1Interface interface { RESTClient() rest.Interface CollectorsGroupsGetter DestinationsGetter + InstrumentationsGetter InstrumentationConfigsGetter InstrumentationInstancesGetter InstrumentationRulesGetter @@ -50,6 +51,10 @@ func (c *OdigosV1alpha1Client) Destinations(namespace string) DestinationInterfa return newDestinations(c, namespace) } +func (c *OdigosV1alpha1Client) Instrumentations(namespace string) InstrumentationInterface { + return newInstrumentations(c, namespace) +} + func (c *OdigosV1alpha1Client) InstrumentationConfigs(namespace string) InstrumentationConfigInterface { return newInstrumentationConfigs(c, namespace) } diff --git a/api/generated/odigos/informers/externalversions/generic.go b/api/generated/odigos/informers/externalversions/generic.go index 4e3bd20813..f56304bd2c 100644 --- a/api/generated/odigos/informers/externalversions/generic.go +++ b/api/generated/odigos/informers/externalversions/generic.go @@ -56,6 +56,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Odigos().V1alpha1().CollectorsGroups().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("destinations"): return &genericInformer{resource: resource.GroupResource(), informer: f.Odigos().V1alpha1().Destinations().Informer()}, nil + case v1alpha1.SchemeGroupVersion.WithResource("instrumentations"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Odigos().V1alpha1().Instrumentations().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("instrumentationconfigs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Odigos().V1alpha1().InstrumentationConfigs().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("instrumentationinstances"): diff --git a/api/generated/odigos/informers/externalversions/odigos/v1alpha1/instrumentation.go b/api/generated/odigos/informers/externalversions/odigos/v1alpha1/instrumentation.go new file mode 100644 index 0000000000..2b1e116dc2 --- /dev/null +++ b/api/generated/odigos/informers/externalversions/odigos/v1alpha1/instrumentation.go @@ -0,0 +1,89 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + time "time" + + versioned "github.com/odigos-io/odigos/api/generated/odigos/clientset/versioned" + internalinterfaces "github.com/odigos-io/odigos/api/generated/odigos/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/odigos-io/odigos/api/generated/odigos/listers/odigos/v1alpha1" + odigosv1alpha1 "github.com/odigos-io/odigos/api/odigos/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// InstrumentationInformer provides access to a shared informer and lister for +// Instrumentations. +type InstrumentationInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha1.InstrumentationLister +} + +type instrumentationInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewInstrumentationInformer constructs a new informer for Instrumentation type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewInstrumentationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredInstrumentationInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredInstrumentationInformer constructs a new informer for Instrumentation type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredInstrumentationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OdigosV1alpha1().Instrumentations(namespace).List(context.TODO(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.OdigosV1alpha1().Instrumentations(namespace).Watch(context.TODO(), options) + }, + }, + &odigosv1alpha1.Instrumentation{}, + resyncPeriod, + indexers, + ) +} + +func (f *instrumentationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredInstrumentationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *instrumentationInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&odigosv1alpha1.Instrumentation{}, f.defaultInformer) +} + +func (f *instrumentationInformer) Lister() v1alpha1.InstrumentationLister { + return v1alpha1.NewInstrumentationLister(f.Informer().GetIndexer()) +} diff --git a/api/generated/odigos/informers/externalversions/odigos/v1alpha1/interface.go b/api/generated/odigos/informers/externalversions/odigos/v1alpha1/interface.go index 52778ee8de..f896b99a6f 100644 --- a/api/generated/odigos/informers/externalversions/odigos/v1alpha1/interface.go +++ b/api/generated/odigos/informers/externalversions/odigos/v1alpha1/interface.go @@ -27,6 +27,8 @@ type Interface interface { CollectorsGroups() CollectorsGroupInformer // Destinations returns a DestinationInformer. Destinations() DestinationInformer + // Instrumentations returns a InstrumentationInformer. + Instrumentations() InstrumentationInformer // InstrumentationConfigs returns a InstrumentationConfigInformer. InstrumentationConfigs() InstrumentationConfigInformer // InstrumentationInstances returns a InstrumentationInstanceInformer. @@ -62,6 +64,11 @@ func (v *version) Destinations() DestinationInformer { return &destinationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// Instrumentations returns a InstrumentationInformer. +func (v *version) Instrumentations() InstrumentationInformer { + return &instrumentationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // InstrumentationConfigs returns a InstrumentationConfigInformer. func (v *version) InstrumentationConfigs() InstrumentationConfigInformer { return &instrumentationConfigInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/api/generated/odigos/listers/odigos/v1alpha1/expansion_generated.go b/api/generated/odigos/listers/odigos/v1alpha1/expansion_generated.go index 7adce7617b..6bb59254f3 100644 --- a/api/generated/odigos/listers/odigos/v1alpha1/expansion_generated.go +++ b/api/generated/odigos/listers/odigos/v1alpha1/expansion_generated.go @@ -33,6 +33,14 @@ type DestinationListerExpansion interface{} // DestinationNamespaceLister. type DestinationNamespaceListerExpansion interface{} +// InstrumentationListerExpansion allows custom methods to be added to +// InstrumentationLister. +type InstrumentationListerExpansion interface{} + +// InstrumentationNamespaceListerExpansion allows custom methods to be added to +// InstrumentationNamespaceLister. +type InstrumentationNamespaceListerExpansion interface{} + // InstrumentationConfigListerExpansion allows custom methods to be added to // InstrumentationConfigLister. type InstrumentationConfigListerExpansion interface{} diff --git a/api/generated/odigos/listers/odigos/v1alpha1/instrumentation.go b/api/generated/odigos/listers/odigos/v1alpha1/instrumentation.go new file mode 100644 index 0000000000..d537b568cc --- /dev/null +++ b/api/generated/odigos/listers/odigos/v1alpha1/instrumentation.go @@ -0,0 +1,69 @@ +/* +Copyright 2022. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "github.com/odigos-io/odigos/api/odigos/v1alpha1" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/listers" + "k8s.io/client-go/tools/cache" +) + +// InstrumentationLister helps list Instrumentations. +// All objects returned here must be treated as read-only. +type InstrumentationLister interface { + // List lists all Instrumentations in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Instrumentation, err error) + // Instrumentations returns an object that can list and get Instrumentations. + Instrumentations(namespace string) InstrumentationNamespaceLister + InstrumentationListerExpansion +} + +// instrumentationLister implements the InstrumentationLister interface. +type instrumentationLister struct { + listers.ResourceIndexer[*v1alpha1.Instrumentation] +} + +// NewInstrumentationLister returns a new InstrumentationLister. +func NewInstrumentationLister(indexer cache.Indexer) InstrumentationLister { + return &instrumentationLister{listers.New[*v1alpha1.Instrumentation](indexer, v1alpha1.Resource("instrumentation"))} +} + +// Instrumentations returns an object that can list and get Instrumentations. +func (s *instrumentationLister) Instrumentations(namespace string) InstrumentationNamespaceLister { + return instrumentationNamespaceLister{listers.NewNamespaced[*v1alpha1.Instrumentation](s.ResourceIndexer, namespace)} +} + +// InstrumentationNamespaceLister helps list and get Instrumentations. +// All objects returned here must be treated as read-only. +type InstrumentationNamespaceLister interface { + // List lists all Instrumentations in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*v1alpha1.Instrumentation, err error) + // Get retrieves the Instrumentation from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*v1alpha1.Instrumentation, error) + InstrumentationNamespaceListerExpansion +} + +// instrumentationNamespaceLister implements the InstrumentationNamespaceLister +// interface. +type instrumentationNamespaceLister struct { + listers.ResourceIndexer[*v1alpha1.Instrumentation] +} diff --git a/api/odigos/v1alpha1/instrumentation_types.go b/api/odigos/v1alpha1/instrumentation_types.go new file mode 100644 index 0000000000..3bbc509ca1 --- /dev/null +++ b/api/odigos/v1alpha1/instrumentation_types.go @@ -0,0 +1,70 @@ +/* +Copyright 2024. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/odigos-io/odigos/k8sutils/pkg/workload" +) + +// Instrumentation configures an application for auto-instrumentation. +// +genclient +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels=metadata.labels.odigos.io/config=1 +// +kubebuilder:metadata:labels=metadata.labels.odigos.io/system-object=true +// +kubebuilder:printcolumn:name="Workload",type=string,JSONPath=`.spec.workload.name` +// +kubebuilder:printcolumn:name="Kind",type=string,JSONPath=`.spec.workload.kind` +// +kubebuilder:printcolumn:name="Namespace",type=string,JSONPath=`.spec.workload.namespace` +type Instrumentation struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec InstrumentationSpec `json:"spec,omitempty"` + Status InstrumentationStatus `json:"status,omitempty"` +} + +type InstrumentationSpec struct { + // Workload represents the workload or namespace to be instrumented. + // This field is required upon creation and cannot be modified. + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Workload cannot be modified" + Workload workload.PodWorkload `json:"workload,omitempty"` +} + +type InstrumentationStatus struct { + // Represents the observations of a instrumentationrule's current state. + // Known .status.conditions.type are: "Available", "Progressing" + // +patchMergeKey=type + // +patchStrategy=merge + // +listType=map + // +listMapKey=type + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` +} + +//+kubebuilder:object:root=true + +type InstrumentationList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Instrumentation `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Instrumentation{}, &InstrumentationList{}) +} diff --git a/api/odigos/v1alpha1/zz_generated.deepcopy.go b/api/odigos/v1alpha1/zz_generated.deepcopy.go index bc2dbb747d..2a9681af6c 100644 --- a/api/odigos/v1alpha1/zz_generated.deepcopy.go +++ b/api/odigos/v1alpha1/zz_generated.deepcopy.go @@ -386,6 +386,33 @@ func (in *HeadSamplingConfig) DeepCopy() *HeadSamplingConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Instrumentation) DeepCopyInto(out *Instrumentation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Instrumentation. +func (in *Instrumentation) DeepCopy() *Instrumentation { + if in == nil { + return nil + } + out := new(Instrumentation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Instrumentation) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstrumentationConfig) DeepCopyInto(out *InstrumentationConfig) { *out = *in @@ -750,6 +777,38 @@ func (in *InstrumentationLibraryStatus) DeepCopy() *InstrumentationLibraryStatus return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstrumentationList) DeepCopyInto(out *InstrumentationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Instrumentation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationList. +func (in *InstrumentationList) DeepCopy() *InstrumentationList { + if in == nil { + return nil + } + out := new(InstrumentationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *InstrumentationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstrumentationRule) DeepCopyInto(out *InstrumentationRule) { *out = *in @@ -874,6 +933,44 @@ func (in *InstrumentationRuleStatus) DeepCopy() *InstrumentationRuleStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstrumentationSpec) DeepCopyInto(out *InstrumentationSpec) { + *out = *in + out.Workload = in.Workload +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationSpec. +func (in *InstrumentationSpec) DeepCopy() *InstrumentationSpec { + if in == nil { + return nil + } + out := new(InstrumentationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InstrumentationStatus) DeepCopyInto(out *InstrumentationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstrumentationStatus. +func (in *InstrumentationStatus) DeepCopy() *InstrumentationStatus { + if in == nil { + return nil + } + out := new(InstrumentationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstrumentedApplication) DeepCopyInto(out *InstrumentedApplication) { *out = *in diff --git a/helm/odigos/templates/crds/odigos.io_instrumentations.yaml b/helm/odigos/templates/crds/odigos.io_instrumentations.yaml new file mode 100644 index 0000000000..cac3a4bb5f --- /dev/null +++ b/helm/odigos/templates/crds/odigos.io_instrumentations.yaml @@ -0,0 +1,148 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.16.1 + labels: + metadata.labels.odigos.io/config: "1" + metadata.labels.odigos.io/system-object: "true" + name: instrumentations.odigos.io +spec: + group: odigos.io + names: + kind: Instrumentation + listKind: InstrumentationList + plural: instrumentations + singular: instrumentation + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.workload.name + name: Workload + type: string + - jsonPath: .spec.workload.kind + name: Kind + type: string + - jsonPath: .spec.workload.namespace + name: Namespace + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: Instrumentation configures an application for auto-instrumentation. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + workload: + description: |- + Workload represents the workload or namespace to be instrumented. + This field is required upon creation and cannot be modified. + properties: + kind: + description: |- + 1. the pascal case representation of the workload kind + it is used in k8s api objects as the `Kind` field. + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + - namespace + type: object + x-kubernetes-validations: + - message: Workload cannot be modified + rule: self == oldSelf + required: + - workload + type: object + status: + properties: + conditions: + description: |- + Represents the observations of a instrumentationrule's current state. + Known .status.conditions.type are: "Available", "Progressing" + items: + description: Condition contains details for one aspect of the current + state of this API Resource. + properties: + lastTransitionTime: + description: |- + lastTransitionTime is the last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + message is a human readable message indicating details about the transition. + This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: |- + observedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: |- + reason contains a programmatic identifier indicating the reason for the condition's last transition. + Producers of specific condition types may define expected values and meanings for this field, + and whether the values are considered a guaranteed API. + The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + type: object + type: object + served: true + storage: true + subresources: + status: {}