diff --git a/api/addon.go b/api/addon.go index 152fa57ef..d08d5cb1a 100644 --- a/api/addon.go +++ b/api/addon.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" core "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" k8s "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/api/base.go b/api/base.go index 0b8ca1dfa..602ac3be4 100644 --- a/api/base.go +++ b/api/base.go @@ -14,10 +14,10 @@ import ( "github.com/gin-gonic/gin/binding" liberr "github.com/jortel/go-utils/error" "github.com/jortel/go-utils/logr" - "github.com/konveyor/tackle2-hub/api/reflect" "github.com/konveyor/tackle2-hub/api/sort" "github.com/konveyor/tackle2-hub/auth" "github.com/konveyor/tackle2-hub/model" + "github.com/konveyor/tackle2-hub/reflect" "gopkg.in/yaml.v2" "gorm.io/gorm" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/api/sort/sort.go b/api/sort/sort.go index 7654ae6d5..2e577a13a 100644 --- a/api/sort/sort.go +++ b/api/sort/sort.go @@ -4,7 +4,7 @@ import ( "strings" "github.com/gin-gonic/gin" - "github.com/konveyor/tackle2-hub/api/reflect" + "github.com/konveyor/tackle2-hub/reflect" "gorm.io/gorm" ) diff --git a/api/taskgroup.go b/api/taskgroup.go index 58a007a4c..2423d304b 100644 --- a/api/taskgroup.go +++ b/api/taskgroup.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "github.com/konveyor/tackle2-hub/model" tasking "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm/clause" diff --git a/controller/addon.go b/controller/addon.go index 0e5e4705b..35f12f71e 100644 --- a/controller/addon.go +++ b/controller/addon.go @@ -2,13 +2,15 @@ package controller import ( "context" + "strings" "github.com/go-logr/logr" logr2 "github.com/jortel/go-utils/logr" - api "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + api "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "github.com/konveyor/tackle2-hub/settings" "gorm.io/gorm" k8serr "k8s.io/apimachinery/pkg/api/errors" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apiserver/pkg/storage/names" "k8s.io/client-go/tools/record" k8s "sigs.k8s.io/controller-runtime/pkg/client" @@ -32,9 +34,10 @@ var Settings = &settings.Settings // Add the controller. func Add(mgr manager.Manager, db *gorm.DB) error { reconciler := &Reconciler{ - Client: mgr.GetClient(), - Log: log, - DB: db, + history: make(map[string]byte), + Client: mgr.GetClient(), + Log: log, + DB: db, } cnt, err := controller.New( Name, @@ -59,15 +62,18 @@ func Add(mgr manager.Manager, db *gorm.DB) error { } // Reconciler reconciles addon CRs. +// The history is used to ensure resources are reconciled +// at least once at startup. type Reconciler struct { record.EventRecorder k8s.Client - DB *gorm.DB - Log logr.Logger + DB *gorm.DB + Log logr.Logger + history map[string]byte } // Reconcile a Addon CR. -// Note: Must not a pointer receiver to ensure that the +// Note: Must not be a pointer receiver to ensure that the // logger and other state is not shared. func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (result reconcile.Result, err error) { r.Log = logr2.WithName( @@ -86,18 +92,23 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r } return } - // migrate - migrated, err := r.alpha2Migration(addon) - if migrated || err != nil { + _, found := r.history[addon.Name] + if found && addon.Reconciled() { return } - // changed. - err = r.addonChanged(addon) - if err != nil { + r.history[addon.Name] = 1 + addon.Status.Conditions = nil + addon.Status.ObservedGeneration = addon.Generation + // Changed + migrated, err := r.addonChanged(addon) + if migrated || err != nil { return } + // Ready condition. + addon.Status.Conditions = append( + addon.Status.Conditions, + r.ready(addon)) // Apply changes. - addon.Status.ObservedGeneration = addon.Generation err = r.Status().Update(context.TODO(), addon) if err != nil { return @@ -106,47 +117,50 @@ func (r Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (r return } -// addonChanged an addon has been created/updated. -func (r *Reconciler) addonChanged(addon *api.Addon) (err error) { - return -} - -// addonDeleted an addon has been deleted. -func (r *Reconciler) addonDeleted(name string) (err error) { - return -} - -// alpha2Migration migrates to alpha2. -func (r *Reconciler) alpha2Migration(addon *api.Addon) (migrated bool, err error) { - if addon.Spec.Image != nil { - if addon.Spec.Container.Image == "" { - addon.Spec.Container.Image = *addon.Spec.Image +// ready returns the ready condition. +func (r *Reconciler) ready(addon *api.Addon) (ready v1.Condition) { + ready = api.Ready + ready.LastTransitionTime = v1.Now() + ready.ObservedGeneration = addon.Status.ObservedGeneration + err := make([]string, 0) + for i := range addon.Status.Conditions { + cnd := &addon.Status.Conditions[i] + if cnd.Type == api.ValidationError { + err = append(err, cnd.Message) } - addon.Spec.Image = nil - migrated = true } - if addon.Spec.Resources != nil { - if len(addon.Spec.Container.Resources.Limits) == 0 { - addon.Spec.Container.Resources.Limits = (*addon.Spec.Resources).Limits - } - if len(addon.Spec.Container.Resources.Requests) == 0 { - addon.Spec.Container.Resources.Requests = (*addon.Spec.Resources).Requests - } - addon.Spec.Resources = nil - migrated = true - } - if addon.Spec.ImagePullPolicy != nil { - if addon.Spec.Container.ImagePullPolicy == "" { - addon.Spec.Container.ImagePullPolicy = *addon.Spec.ImagePullPolicy - } - addon.Spec.ImagePullPolicy = nil - migrated = true + if len(err) == 0 { + ready.Status = v1.ConditionTrue + ready.Reason = api.Validated + ready.Message = strings.Join(err, ";") + } else { + ready.Status = v1.ConditionFalse + ready.Reason = api.ValidationError } + return +} + +// addonChanged an addon has been created/updated. +func (r *Reconciler) addonChanged(addon *api.Addon) (migrated bool, err error) { + migrated = addon.Migrate() if migrated { err = r.Update(context.TODO(), addon) if err != nil { return } } + if addon.Spec.Container.Image == "" { + cnd := api.ImageNotDefined + cnd.LastTransitionTime = v1.Now() + cnd.ObservedGeneration = addon.Status.ObservedGeneration + addon.Status.Conditions = append( + addon.Status.Conditions, + cnd) + } + return +} + +// addonDeleted an addon has been deleted. +func (r *Reconciler) addonDeleted(name string) (err error) { return } diff --git a/generated/crd/tackle.konveyor.io_addons.yaml b/generated/crd/tackle.konveyor.io_addons.yaml index ac7d70427..8e2771521 100644 --- a/generated/crd/tackle.konveyor.io_addons.yaml +++ b/generated/crd/tackle.konveyor.io_addons.yaml @@ -16,1287 +16,6 @@ spec: scope: Namespaced versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Addon defines an addon. - 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: - description: Spec defines the desired state of the resource. - properties: - container: - description: Container defines the addon container. - properties: - args: - description: 'Arguments to the entrypoint. The container image''s - CMD is used if this is not provided. Variable references $(VAR_NAME) - are expanded using the container''s environment. If a variable - cannot be resolved, the reference in the input string will be - unchanged. Double $$ are reduced to a single $, which allows - for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - produce the string literal "$(VAR_NAME)". Escaped references - will never be expanded, regardless of whether the variable exists - or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' - items: - type: string - type: array - command: - description: 'Entrypoint array. Not executed within a shell. The - container image''s ENTRYPOINT is used if this is not provided. - Variable references $(VAR_NAME) are expanded using the container''s - environment. If a variable cannot be resolved, the reference - in the input string will be unchanged. Double $$ are reduced - to a single $, which allows for escaping the $(VAR_NAME) syntax: - i.e. "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless of whether - the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell' - items: - type: string - type: array - env: - description: List of environment variables to set in the container. - Cannot be updated. - items: - description: EnvVar represents an environment variable present - in a Container. - properties: - name: - description: Name of the environment variable. Must be a - C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded - using the previously defined environment variables in - the container and any service environment variables. If - a variable cannot be resolved, the reference in the input - string will be unchanged. Double $$ are reduced to a single - $, which allows for escaping the $(VAR_NAME) syntax: i.e. - "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)". - Escaped references will never be expanded, regardless - of whether the variable exists or not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. - Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, - metadata.namespace, `metadata.labels['''']`, - `metadata.annotations['''']`, spec.nodeName, - spec.serviceAccountName, status.hostIP, status.podIP, - status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath - is written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the - specified API version. - type: string - required: - - fieldPath - type: object - x-kubernetes-map-type: atomic - resourceFieldRef: - description: 'Selects a resource of the container: only - resources limits and requests (limits.cpu, limits.memory, - limits.ephemeral-storage, requests.cpu, requests.memory - and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, - optional for env vars' - type: string - divisor: - anyOf: - - type: integer - - type: string - description: Specifies the output format of the - exposed resources, defaults to "1" - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - x-kubernetes-map-type: atomic - secretKeyRef: - description: Selects a key of a secret in the pod's - namespace - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - x-kubernetes-map-type: atomic - type: object - required: - - name - type: object - type: array - envFrom: - description: List of sources to populate environment variables - in the container. The keys defined within a source must be a - C_IDENTIFIER. All invalid keys will be reported as an event - when the container is starting. When a key exists in multiple - sources, the value associated with the last source will take - precedence. Values defined by an Env with a duplicate key will - take precedence. Cannot be updated. - items: - description: EnvFromSource represents the source of a set of - ConfigMaps - properties: - configMapRef: - description: The ConfigMap to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the ConfigMap must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - prefix: - description: An optional identifier to prepend to each key - in the ConfigMap. Must be a C_IDENTIFIER. - type: string - secretRef: - description: The Secret to select from - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - optional: - description: Specify whether the Secret must be defined - type: boolean - type: object - x-kubernetes-map-type: atomic - type: object - type: array - image: - description: 'Container image name. More info: https://kubernetes.io/docs/concepts/containers/images - This field is optional to allow higher level config management - to default or override container images in workload controllers - like Deployments and StatefulSets.' - type: string - imagePullPolicy: - description: 'Image pull policy. One of Always, Never, IfNotPresent. - Defaults to Always if :latest tag is specified, or IfNotPresent - otherwise. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images' - type: string - lifecycle: - description: Actions that the management system should take in - response to container lifecycle events. Cannot be updated. - properties: - postStart: - description: 'PostStart is called immediately after a container - is created. If the handler fails, the container is terminated - and restarted according to its restart policy. Other management - of the container blocks until the hook completes. More info: - https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute - inside the container, the working directory for - the command is root ('/') in the container's filesystem. - The command is simply exec'd, it is not run inside - a shell, so traditional shell instructions ('|', - etc) won't work. To use a shell, you need to explicitly - call out to that shell. Exit status of 0 is treated - as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to - the pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: Deprecated. TCPSocket is NOT supported as - a LifecycleHandler and kept for the backward compatibility. - There are no validation of this field and lifecycle - hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - preStop: - description: 'PreStop is called immediately before a container - is terminated due to an API request or management event - such as liveness/startup probe failure, preemption, resource - contention, etc. The handler is not called if the container - crashes or exits. The Pod''s termination grace period countdown - begins before the PreStop hook is executed. Regardless of - the outcome of the handler, the container will eventually - terminate within the Pod''s termination grace period (unless - delayed by finalizers). Other management of the container - blocks until the hook completes or until the termination - grace period is reached. More info: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/#container-hooks' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute - inside the container, the working directory for - the command is root ('/') in the container's filesystem. - The command is simply exec'd, it is not run inside - a shell, so traditional shell instructions ('|', - etc) won't work. To use a shell, you need to explicitly - call out to that shell. Exit status of 0 is treated - as live/healthy and non-zero is unhealthy. - items: - type: string - type: array - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to - the pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. - HTTP allows repeated headers. - items: - description: HTTPHeader describes a custom header - to be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - tcpSocket: - description: Deprecated. TCPSocket is NOT supported as - a LifecycleHandler and kept for the backward compatibility. - There are no validation of this field and lifecycle - hooks will fail in runtime when tcp handler is specified. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access - on the container. Number must be in the range 1 - to 65535. Name must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - type: object - type: object - livenessProbe: - description: 'Periodic probe of container liveness. Container - will be restarted if the probe fails. Cannot be updated. More - info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - name: - description: Name of the container specified as a DNS_LABEL. Each - container in a pod must have a unique name (DNS_LABEL). Cannot - be updated. - type: string - ports: - description: List of ports to expose from the container. Not specifying - a port here DOES NOT prevent that port from being exposed. Any - port which is listening on the default "0.0.0.0" address inside - a container will be accessible from the network. Modifying this - array with strategic merge patch may corrupt the data. For more - information See https://github.com/kubernetes/kubernetes/issues/108255. - Cannot be updated. - items: - description: ContainerPort represents a network port in a single - container. - properties: - containerPort: - description: Number of port to expose on the pod's IP address. - This must be a valid port number, 0 < x < 65536. - format: int32 - type: integer - hostIP: - description: What host IP to bind the external port to. - type: string - hostPort: - description: Number of port to expose on the host. If specified, - this must be a valid port number, 0 < x < 65536. If HostNetwork - is specified, this must match ContainerPort. Most containers - do not need this. - format: int32 - type: integer - name: - description: If specified, this must be an IANA_SVC_NAME - and unique within the pod. Each named port in a pod must - have a unique name. Name for the port that can be referred - to by services. - type: string - protocol: - default: TCP - description: Protocol for port. Must be UDP, TCP, or SCTP. - Defaults to "TCP". - type: string - required: - - containerPort - type: object - type: array - x-kubernetes-list-map-keys: - - containerPort - - protocol - x-kubernetes-list-type: map - readinessProbe: - description: 'Periodic probe of container service readiness. Container - will be removed from service endpoints if the probe fails. Cannot - be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - resources: - description: 'Compute Resources required by this container. Cannot - be updated. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute - resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - securityContext: - description: 'SecurityContext defines the security options the - container should be run with. If set, the fields of SecurityContext - override the equivalent fields of PodSecurityContext. More info: - https://kubernetes.io/docs/tasks/configure-pod-container/security-context/' - properties: - allowPrivilegeEscalation: - description: 'AllowPrivilegeEscalation controls whether a - process can gain more privileges than its parent process. - This bool directly controls if the no_new_privs flag will - be set on the container process. AllowPrivilegeEscalation - is true always when the container is: 1) run as Privileged - 2) has CAP_SYS_ADMIN Note that this field cannot be set - when spec.os.name is windows.' - type: boolean - capabilities: - description: The capabilities to add/drop when running containers. - Defaults to the default set of capabilities granted by the - container runtime. Note that this field cannot be set when - spec.os.name is windows. - properties: - add: - description: Added capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - drop: - description: Removed capabilities - items: - description: Capability represent POSIX capabilities - type - type: string - type: array - type: object - privileged: - description: Run container in privileged mode. Processes in - privileged containers are essentially equivalent to root - on the host. Defaults to false. Note that this field cannot - be set when spec.os.name is windows. - type: boolean - procMount: - description: procMount denotes the type of proc mount to use - for the containers. The default is DefaultProcMount which - uses the container runtime defaults for readonly paths and - masked paths. This requires the ProcMountType feature flag - to be enabled. Note that this field cannot be set when spec.os.name - is windows. - type: string - readOnlyRootFilesystem: - description: Whether this container has a read-only root filesystem. - Default is false. Note that this field cannot be set when - spec.os.name is windows. - type: boolean - runAsGroup: - description: The GID to run the entrypoint of the container - process. Uses runtime default if unset. May also be set - in PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. Note that this field cannot be set when - spec.os.name is windows. - format: int64 - type: integer - runAsNonRoot: - description: Indicates that the container must run as a non-root - user. If true, the Kubelet will validate the image at runtime - to ensure that it does not run as UID 0 (root) and fail - to start the container if it does. If unset or false, no - such validation will be performed. May also be set in PodSecurityContext. If - set in both SecurityContext and PodSecurityContext, the - value specified in SecurityContext takes precedence. - type: boolean - runAsUser: - description: The UID to run the entrypoint of the container - process. Defaults to user specified in image metadata if - unspecified. May also be set in PodSecurityContext. If - set in both SecurityContext and PodSecurityContext, the - value specified in SecurityContext takes precedence. Note - that this field cannot be set when spec.os.name is windows. - format: int64 - type: integer - seLinuxOptions: - description: The SELinux context to be applied to the container. - If unspecified, the container runtime will allocate a random - SELinux context for each container. May also be set in - PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. Note that this field cannot be set when - spec.os.name is windows. - properties: - level: - description: Level is SELinux level label that applies - to the container. - type: string - role: - description: Role is a SELinux role label that applies - to the container. - type: string - type: - description: Type is a SELinux type label that applies - to the container. - type: string - user: - description: User is a SELinux user label that applies - to the container. - type: string - type: object - seccompProfile: - description: The seccomp options to use by this container. - If seccomp options are provided at both the pod & container - level, the container options override the pod options. Note - that this field cannot be set when spec.os.name is windows. - properties: - localhostProfile: - description: localhostProfile indicates a profile defined - in a file on the node should be used. The profile must - be preconfigured on the node to work. Must be a descending - path, relative to the kubelet's configured seccomp profile - location. Must only be set if type is "Localhost". - type: string - type: - description: "type indicates which kind of seccomp profile - will be applied. Valid options are: \n Localhost - a - profile defined in a file on the node should be used. - RuntimeDefault - the container runtime default profile - should be used. Unconfined - no profile should be applied." - type: string - required: - - type - type: object - windowsOptions: - description: The Windows specific settings applied to all - containers. If unspecified, the options from the PodSecurityContext - will be used. If set in both SecurityContext and PodSecurityContext, - the value specified in SecurityContext takes precedence. - Note that this field cannot be set when spec.os.name is - linux. - properties: - gmsaCredentialSpec: - description: GMSACredentialSpec is where the GMSA admission - webhook (https://github.com/kubernetes-sigs/windows-gmsa) - inlines the contents of the GMSA credential spec named - by the GMSACredentialSpecName field. - type: string - gmsaCredentialSpecName: - description: GMSACredentialSpecName is the name of the - GMSA credential spec to use. - type: string - hostProcess: - description: HostProcess determines if a container should - be run as a 'Host Process' container. This field is - alpha-level and will only be honored by components that - enable the WindowsHostProcessContainers feature flag. - Setting this field without the feature flag will result - in errors when validating the Pod. All of a Pod's containers - must have the same effective HostProcess value (it is - not allowed to have a mix of HostProcess containers - and non-HostProcess containers). In addition, if HostProcess - is true then HostNetwork must also be set to true. - type: boolean - runAsUserName: - description: The UserName in Windows to run the entrypoint - of the container process. Defaults to the user specified - in image metadata if unspecified. May also be set in - PodSecurityContext. If set in both SecurityContext and - PodSecurityContext, the value specified in SecurityContext - takes precedence. - type: string - type: object - type: object - startupProbe: - description: 'StartupProbe indicates that the Pod has successfully - initialized. If specified, no other probes are executed until - this completes successfully. If this probe fails, the Pod will - be restarted, just as if the livenessProbe failed. This can - be used to provide different probe parameters at the beginning - of a Pod''s lifecycle, when it might take a long time to load - data or warm a cache, than during steady-state operation. This - cannot be updated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - properties: - exec: - description: Exec specifies the action to take. - properties: - command: - description: Command is the command line to execute inside - the container, the working directory for the command is - root ('/') in the container's filesystem. The command - is simply exec'd, it is not run inside a shell, so traditional - shell instructions ('|', etc) won't work. To use a shell, - you need to explicitly call out to that shell. Exit - status of 0 is treated as live/healthy and non-zero - is unhealthy. - items: - type: string - type: array - type: object - failureThreshold: - description: Minimum consecutive failures for the probe to - be considered failed after having succeeded. Defaults to - 3. Minimum value is 1. - format: int32 - type: integer - grpc: - description: GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe - feature gate. - properties: - port: - description: Port number of the gRPC service. Number must - be in the range 1 to 65535. - format: int32 - type: integer - service: - description: "Service is the name of the service to place - in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). - \n If this is not specified, the default behavior is - defined by gRPC." - type: string - required: - - port - type: object - httpGet: - description: HTTPGet specifies the http request to perform. - properties: - host: - description: Host name to connect to, defaults to the - pod IP. You probably want to set "Host" in httpHeaders - instead. - type: string - httpHeaders: - description: Custom headers to set in the request. HTTP - allows repeated headers. - items: - description: HTTPHeader describes a custom header to - be used in HTTP probes - properties: - name: - description: The header field name - type: string - value: - description: The header field value - type: string - required: - - name - - value - type: object - type: array - path: - description: Path to access on the HTTP server. - type: string - port: - anyOf: - - type: integer - - type: string - description: Name or number of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - scheme: - description: Scheme to use for connecting to the host. - Defaults to HTTP. - type: string - required: - - port - type: object - initialDelaySeconds: - description: 'Number of seconds after the container has started - before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - periodSeconds: - description: How often (in seconds) to perform the probe. - Default to 10 seconds. Minimum value is 1. - format: int32 - type: integer - successThreshold: - description: Minimum consecutive successes for the probe to - be considered successful after having failed. Defaults to - 1. Must be 1 for liveness and startup. Minimum value is - 1. - format: int32 - type: integer - tcpSocket: - description: TCPSocket specifies an action involving a TCP - port. - properties: - host: - description: 'Optional: Host name to connect to, defaults - to the pod IP.' - type: string - port: - anyOf: - - type: integer - - type: string - description: Number or name of the port to access on the - container. Number must be in the range 1 to 65535. Name - must be an IANA_SVC_NAME. - x-kubernetes-int-or-string: true - required: - - port - type: object - terminationGracePeriodSeconds: - description: Optional duration in seconds the pod needs to - terminate gracefully upon probe failure. The grace period - is the duration in seconds after the processes running in - the pod are sent a termination signal and the time when - the processes are forcibly halted with a kill signal. Set - this value longer than the expected cleanup time for your - process. If this value is nil, the pod's terminationGracePeriodSeconds - will be used. Otherwise, this value overrides the value - provided by the pod spec. Value must be non-negative integer. - The value zero indicates stop immediately via the kill signal - (no opportunity to shut down). This is a beta field and - requires enabling ProbeTerminationGracePeriod feature gate. - Minimum value is 1. spec.terminationGracePeriodSeconds is - used if unset. - format: int64 - type: integer - timeoutSeconds: - description: 'Number of seconds after which the probe times - out. Defaults to 1 second. Minimum value is 1. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' - format: int32 - type: integer - type: object - stdin: - description: Whether this container should allocate a buffer for - stdin in the container runtime. If this is not set, reads from - stdin in the container will always result in EOF. Default is - false. - type: boolean - stdinOnce: - description: Whether the container runtime should close the stdin - channel after it has been opened by a single attach. When stdin - is true the stdin stream will remain open across multiple attach - sessions. If stdinOnce is set to true, stdin is opened on container - start, is empty until the first client attaches to stdin, and - then remains open and accepts data until the client disconnects, - at which time stdin is closed and remains closed until the container - is restarted. If this flag is false, a container processes that - reads from stdin will never receive an EOF. Default is false - type: boolean - terminationMessagePath: - description: 'Optional: Path at which the file to which the container''s - termination message will be written is mounted into the container''s - filesystem. Message written is intended to be brief final status, - such as an assertion failure message. Will be truncated by the - node if greater than 4096 bytes. The total message length across - all containers will be limited to 12kb. Defaults to /dev/termination-log. - Cannot be updated.' - type: string - terminationMessagePolicy: - description: Indicate how the termination message should be populated. - File will use the contents of terminationMessagePath to populate - the container status message on both success and failure. FallbackToLogsOnError - will use the last chunk of container log output if the termination - message file is empty and the container exited with an error. - The log output is limited to 2048 bytes or 80 lines, whichever - is smaller. Defaults to File. Cannot be updated. - type: string - tty: - description: Whether this container should allocate a TTY for - itself, also requires 'stdin' to be true. Default is false. - type: boolean - volumeDevices: - description: volumeDevices is the list of block devices to be - used by the container. - items: - description: volumeDevice describes a mapping of a raw block - device within a container. - properties: - devicePath: - description: devicePath is the path inside of the container - that the device will be mapped to. - type: string - name: - description: name must match the name of a persistentVolumeClaim - in the pod - type: string - required: - - devicePath - - name - type: object - type: array - volumeMounts: - description: Pod volumes to mount into the container's filesystem. - Cannot be updated. - items: - description: VolumeMount describes a mounting of a Volume within - a container. - properties: - mountPath: - description: Path within the container at which the volume - should be mounted. Must not contain ':'. - type: string - mountPropagation: - description: mountPropagation determines how mounts are - propagated from the host to container and the other way - around. When not set, MountPropagationNone is used. This - field is beta in 1.10. - type: string - name: - description: This must match the Name of a Volume. - type: string - readOnly: - description: Mounted read-only if true, read-write otherwise - (false or unspecified). Defaults to false. - type: boolean - subPath: - description: Path within the volume from which the container's - volume should be mounted. Defaults to "" (volume's root). - type: string - subPathExpr: - description: Expanded path within the volume from which - the container's volume should be mounted. Behaves similarly - to SubPath but environment variable references $(VAR_NAME) - are expanded using the container's environment. Defaults - to "" (volume's root). SubPathExpr and SubPath are mutually - exclusive. - type: string - required: - - mountPath - - name - type: object - type: array - workingDir: - description: Container's working directory. If not specified, - the container runtime's default will be used, which might be - configured in the container image. Cannot be updated. - type: string - required: - - name - type: object - image: - description: Addon fqin. - type: string - imagePullPolicy: - default: IfNotPresent - description: ImagePullPolicy an optional image pull policy. - enum: - - IfNotPresent - - Always - - Never - type: string - metadata: - description: Metadata details. - type: object - x-kubernetes-preserve-unknown-fields: true - resources: - description: Resource requirements. - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources - allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - selector: - description: Selector defines criteria to be selected for a task. - type: string - task: - description: Task declares task (kind) compatibility. - type: string - required: - - image - type: object - status: - description: Status defines the observed state of the resource. - properties: - observedGeneration: - description: The most recent generation observed by the controller. - format: int64 - type: integer - type: object - type: object - served: false - storage: false - subresources: - status: {} - - name: v1alpha2 schema: openAPIV3Schema: properties: @@ -2555,12 +1274,79 @@ spec: task: description: Task declares task (kind) compatibility. type: string - required: - - container type: object status: description: Status defines the observed state of the resource. properties: + conditions: + description: Resource conditions. + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", + \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge + // +listType=map // +listMapKey=type Conditions []metav1.Condition + `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" + protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + 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. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + 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 observedGeneration: description: The most recent generation observed by the controller. format: int64 diff --git a/generated/crd/tackle.konveyor.io_extensions.yaml b/generated/crd/tackle.konveyor.io_extensions.yaml index 9d9ab9cc3..8d893b9e2 100644 --- a/generated/crd/tackle.konveyor.io_extensions.yaml +++ b/generated/crd/tackle.konveyor.io_extensions.yaml @@ -16,28 +16,6 @@ spec: scope: Namespaced versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Extension defines an addon extension. - 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 - type: object - served: false - storage: false - subresources: - status: {} - - name: v1alpha2 schema: openAPIV3Schema: description: Extension defines an addon extension. diff --git a/generated/crd/tackle.konveyor.io_tackles.yaml b/generated/crd/tackle.konveyor.io_tackles.yaml index c1b8af719..00987585c 100644 --- a/generated/crd/tackle.konveyor.io_tackles.yaml +++ b/generated/crd/tackle.konveyor.io_tackles.yaml @@ -16,36 +16,6 @@ spec: scope: Namespaced versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Tackle defines a tackle application. - 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: - description: Spec defines the desired state of the resource. - type: object - x-kubernetes-preserve-unknown-fields: true - status: - description: Status defines the observed state of the resource. - type: object - x-kubernetes-preserve-unknown-fields: true - type: object - served: true - storage: false - subresources: - status: {} - - name: v1alpha2 schema: openAPIV3Schema: description: Tackle defines a tackle application. diff --git a/generated/crd/tackle.konveyor.io_tasks.yaml b/generated/crd/tackle.konveyor.io_tasks.yaml index 9f4258947..3e0c175ff 100644 --- a/generated/crd/tackle.konveyor.io_tasks.yaml +++ b/generated/crd/tackle.konveyor.io_tasks.yaml @@ -16,28 +16,6 @@ spec: scope: Namespaced versions: - name: v1alpha1 - schema: - openAPIV3Schema: - description: Task defines a hub task. - 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 - type: object - served: false - storage: false - subresources: - status: {} - - name: v1alpha2 schema: openAPIV3Schema: description: Task defines a hub task. diff --git a/k8s/api/all.go b/k8s/api/all.go index 83ccee910..8e3aa14b3 100644 --- a/k8s/api/all.go +++ b/k8s/api/all.go @@ -6,7 +6,7 @@ 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. @@ -18,7 +18,6 @@ package api import ( "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" - "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" "k8s.io/apimachinery/pkg/runtime" ) @@ -27,8 +26,7 @@ var AddToSchemes runtime.SchemeBuilder func init() { AddToSchemes = append( AddToSchemes, - v1alpha1.SchemeBuilder.AddToScheme, - v1alpha2.SchemeBuilder.AddToScheme) + v1alpha1.SchemeBuilder.AddToScheme) } func AddToScheme(s *runtime.Scheme) error { diff --git a/k8s/api/tackle/v1alpha1/addon.go b/k8s/api/tackle/v1alpha1/addon.go index 0493e4686..c06e64e70 100644 --- a/k8s/api/tackle/v1alpha1/addon.go +++ b/k8s/api/tackle/v1alpha1/addon.go @@ -22,16 +22,17 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// AddonSpec defines the desired state of an Addon. +// AddonSpec defines the desired state of the resource. type AddonSpec struct { - // Addon fqin. - Image string `json:"image"` - // ImagePullPolicy an optional image pull policy. - // +kubebuilder:default=IfNotPresent - // +kubebuilder:validation:Enum=IfNotPresent;Always;Never - ImagePullPolicy core.PullPolicy `json:"imagePullPolicy,omitempty"` - // Resource requirements. - Resources core.ResourceRequirements `json:"resources,omitempty"` + // Deprecated: Addon is deprecated. + // +kubebuilder:validation:Optional + Image *string `json:"image,omitempty"` + // Deprecated: ImagePullPolicy is deprecated. + // +kubebuilder:validation:Optional + ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"` + // Deprecated: Resources is deprecated. + // +kubebuilder:validation:Optional + Resources *core.ResourceRequirements `json:"resources,omitempty"` // // Task declares task (kind) compatibility. Task string `json:"task,omitempty"` @@ -43,28 +44,78 @@ type AddonSpec struct { Metadata runtime.RawExtension `json:"metadata,omitempty"` } -// AddonStatus defines the observed state of an Addon. +// AddonStatus defines the observed state of the resource. type AddonStatus struct { // The most recent generation observed by the controller. // +optional ObservedGeneration int64 `json:"observedGeneration,omitempty"` + // Resource conditions. + Conditions []meta.Condition `json:"conditions,omitempty"` } -// Addon defines an addon. // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true -// +kubebuilder:unservedversion +// +kubebuilder:storageversion // +kubebuilder:subresource:status type Addon struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` // Spec defines the desired state of the resource. - Spec AddonSpec `json:"spec,omitempty"` + Spec AddonSpec `json:"spec"` // Status defines the observed state of the resource. Status AddonStatus `json:"status,omitempty"` } +// Reconciled returns true when the resource has been reconciled. +func (r *Addon) Reconciled() (b bool) { + return r.Generation == r.Status.ObservedGeneration +} + +// Ready returns true when resource has the ready condition. +func (r *Addon) Ready() (ready bool) { + for _, cnd := range r.Status.Conditions { + if cnd.Type == Ready.Type && cnd.Status == meta.ConditionTrue { + ready = true + break + } + } + return +} + +// Migrate specification as needed. +func (r *Addon) Migrate() (updated bool) { + if r.Spec.Image != nil { + if r.Spec.Container.Image == "" { + r.Spec.Container.Image = *r.Spec.Image + } + r.Spec.Image = nil + updated = true + } + if r.Spec.Resources != nil { + if len(r.Spec.Container.Resources.Limits) == 0 { + r.Spec.Container.Resources.Limits = (*r.Spec.Resources).Limits + } + if len(r.Spec.Container.Resources.Requests) == 0 { + r.Spec.Container.Resources.Requests = (*r.Spec.Resources).Requests + } + r.Spec.Resources = nil + updated = true + } + if r.Spec.ImagePullPolicy != nil { + if r.Spec.Container.ImagePullPolicy == "" { + r.Spec.Container.ImagePullPolicy = *r.Spec.ImagePullPolicy + } + r.Spec.ImagePullPolicy = nil + updated = true + } + if r.Spec.Container.Name == "" { + r.Spec.Container.Name = "addon" + updated = true + } + return +} + // AddonList is a list of Addon. // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type AddonList struct { diff --git a/k8s/api/tackle/v1alpha1/extension.go b/k8s/api/tackle/v1alpha1/extension.go index 03a3fb367..c6826b586 100644 --- a/k8s/api/tackle/v1alpha1/extension.go +++ b/k8s/api/tackle/v1alpha1/extension.go @@ -17,18 +17,43 @@ limitations under the License. package v1alpha1 import ( + core "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) +// ExtensionSpec defines the desired state of the resource. +type ExtensionSpec struct { + // Addon (name) declares addon compatibility. + Addon string `json:"addon"` + // Container defines the extension container. + Container core.Container `json:"container"` + // Selector defines criteria to be included in the addon pod. + Selector string `json:"selector,omitempty"` + // Metadata details. + Metadata runtime.RawExtension `json:"metadata,omitempty"` +} + +// ExtensionStatus defines the observed state of the resource. +type ExtensionStatus struct { + // The most recent generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + // Extension defines an addon extension. // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true -// +kubebuilder:unservedversion +// +kubebuilder:storageversion // +kubebuilder:subresource:status type Extension struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` + // pec defines the desired state of the resource. + Spec ExtensionSpec `json:"spec"` + // Status defines the observed state of the resource. + Status ExtensionStatus `json:"status,omitempty"` } // ExtensionList is a list of Extension. diff --git a/k8s/api/tackle/v1alpha1/pkg.go b/k8s/api/tackle/v1alpha1/pkg.go new file mode 100644 index 000000000..9f7a3982b --- /dev/null +++ b/k8s/api/tackle/v1alpha1/pkg.go @@ -0,0 +1,23 @@ +package v1alpha1 + +import ( + meta "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +const ( + ValidationError = "ValidationError" + Validated = "Validated" +) + +var ( + Ready = meta.Condition{ + Type: "Ready", + Status: meta.ConditionTrue, + } + ImageNotDefined = meta.Condition{ + Type: ValidationError, + Status: meta.ConditionTrue, + Reason: "ImageNotDefined", + Message: "Either image or container.image must be specified.", + } +) diff --git a/k8s/api/tackle/v1alpha1/tackle.go b/k8s/api/tackle/v1alpha1/tackle.go index b237e1475..ea3e1666f 100644 --- a/k8s/api/tackle/v1alpha1/tackle.go +++ b/k8s/api/tackle/v1alpha1/tackle.go @@ -25,6 +25,7 @@ import ( // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true +// +kubebuilder:storageversion // +kubebuilder:subresource:status type Tackle struct { meta.TypeMeta `json:",inline"` diff --git a/k8s/api/tackle/v1alpha1/task.go b/k8s/api/tackle/v1alpha1/task.go index 4751b639f..fd92b9fe7 100644 --- a/k8s/api/tackle/v1alpha1/task.go +++ b/k8s/api/tackle/v1alpha1/task.go @@ -17,18 +17,64 @@ limitations under the License. package v1alpha1 import ( + "encoding/json" + meta "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" ) +// TaskSpec defines the desired state the resource. +type TaskSpec struct { + // Priority defines the task priority (0-n). + Priority int `json:"priority,omitempty"` + // Dependencies defines a list of task names on which this task depends. + Dependencies []string `json:"dependencies,omitempty"` + // Data object passed to the addon. + Data runtime.RawExtension `json:"data,omitempty"` +} + +// TaskStatus defines the observed state the resource. +type TaskStatus struct { + // The most recent generation observed by the controller. + // +optional + ObservedGeneration int64 `json:"observedGeneration,omitempty"` +} + // Task defines a hub task. // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +k8s:openapi-gen=true -// +kubebuilder:unservedversion +// +kubebuilder:storageversion // +kubebuilder:subresource:status type Task struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` + // Spec defines the desired state the resource. + Spec TaskSpec `json:"spec,omitempty"` + // Status defines the observed state the resource. + Status TaskStatus `json:"status,omitempty"` +} + +// HasDep return true if the task has the dependency. +func (r *Task) HasDep(name string) (found bool) { + for i := range r.Spec.Dependencies { + n := r.Spec.Dependencies[i] + if n == name { + found = true + break + } + } + return +} + +// Data returns the task Data as map[string]any. +func (r *Task) Data() (mp map[string]any) { + b := r.Spec.Data.Raw + if b == nil { + return + } + _ = json.Unmarshal(b, &mp) + return } // TaskList is a list of Task. diff --git a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go index d5e524a56..abc30ac83 100644 --- a/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go +++ b/k8s/api/tackle/v1alpha1/zz_generated.deepcopy.go @@ -22,6 +22,8 @@ limitations under the License. package v1alpha1 import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -31,7 +33,7 @@ func (in *Addon) DeepCopyInto(out *Addon) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. @@ -87,7 +89,21 @@ func (in *AddonList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AddonSpec) DeepCopyInto(out *AddonSpec) { *out = *in - in.Resources.DeepCopyInto(&out.Resources) + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + if in.ImagePullPolicy != nil { + in, out := &in.ImagePullPolicy, &out.ImagePullPolicy + *out = new(v1.PullPolicy) + **out = **in + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } in.Container.DeepCopyInto(&out.Container) in.Metadata.DeepCopyInto(&out.Metadata) } @@ -105,6 +121,13 @@ func (in *AddonSpec) DeepCopy() *AddonSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. @@ -122,6 +145,8 @@ func (in *Extension) DeepCopyInto(out *Extension) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension. @@ -174,6 +199,38 @@ func (in *ExtensionList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtensionSpec) DeepCopyInto(out *ExtensionSpec) { + *out = *in + in.Container.DeepCopyInto(&out.Container) + in.Metadata.DeepCopyInto(&out.Metadata) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionSpec. +func (in *ExtensionSpec) DeepCopy() *ExtensionSpec { + if in == nil { + return nil + } + out := new(ExtensionSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionStatus. +func (in *ExtensionStatus) DeepCopy() *ExtensionStatus { + if in == nil { + return nil + } + out := new(ExtensionStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Tackle) DeepCopyInto(out *Tackle) { *out = *in @@ -238,6 +295,8 @@ func (in *Task) DeepCopyInto(out *Task) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Task. @@ -289,3 +348,39 @@ func (in *TaskList) DeepCopyObject() runtime.Object { } return nil } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskSpec) DeepCopyInto(out *TaskSpec) { + *out = *in + if in.Dependencies != nil { + in, out := &in.Dependencies, &out.Dependencies + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Data.DeepCopyInto(&out.Data) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskSpec. +func (in *TaskSpec) DeepCopy() *TaskSpec { + if in == nil { + return nil + } + out := new(TaskSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TaskStatus) DeepCopyInto(out *TaskStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskStatus. +func (in *TaskStatus) DeepCopy() *TaskStatus { + if in == nil { + return nil + } + out := new(TaskStatus) + in.DeepCopyInto(out) + return out +} diff --git a/k8s/api/tackle/v1alpha2/addon.go b/k8s/api/tackle/v1alpha2/addon.go deleted file mode 100644 index e7689f221..000000000 --- a/k8s/api/tackle/v1alpha2/addon.go +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright 2019 Red Hat Inc. - -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 v1alpha2 - -import ( - core "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -// AddonSpec defines the desired state of the resource. -type AddonSpec struct { - // Deprecated: Addon is deprecated. - // +kubebuilder:validation:Optional - Image *string `json:"image,omitempty"` - // Deprecated: ImagePullPolicy is deprecated. - // +kubebuilder:validation:Optional - ImagePullPolicy *core.PullPolicy `json:"imagePullPolicy,omitempty"` - // Deprecated: Resources is deprecated. - // +kubebuilder:validation:Optional - Resources *core.ResourceRequirements `json:"resources,omitempty"` - // - // Task declares task (kind) compatibility. - Task string `json:"task,omitempty"` - // Selector defines criteria to be selected for a task. - Selector string `json:"selector,omitempty"` - // Container defines the addon container. - Container core.Container `json:"container"` - // Metadata details. - Metadata runtime.RawExtension `json:"metadata,omitempty"` -} - -// AddonStatus defines the observed state of the resource. -type AddonStatus struct { - // The most recent generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -// +kubebuilder:storageversion -// +kubebuilder:subresource:status -type Addon struct { - meta.TypeMeta `json:",inline"` - meta.ObjectMeta `json:"metadata,omitempty"` - // Spec defines the desired state of the resource. - Spec AddonSpec `json:"spec"` - // Status defines the observed state of the resource. - Status AddonStatus `json:"status,omitempty"` -} - -// AddonList is a list of Addon. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type AddonList struct { - meta.TypeMeta `json:",inline"` - meta.ListMeta `json:"metadata,omitempty"` - Items []Addon `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Addon{}, &AddonList{}) -} diff --git a/k8s/api/tackle/v1alpha2/extension.go b/k8s/api/tackle/v1alpha2/extension.go deleted file mode 100644 index c2857fdc8..000000000 --- a/k8s/api/tackle/v1alpha2/extension.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2019 Red Hat Inc. - -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 v1alpha2 - -import ( - core "k8s.io/api/core/v1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -// ExtensionSpec defines the desired state of the resource. -type ExtensionSpec struct { - // Addon (name) declares addon compatibility. - Addon string `json:"addon"` - // Container defines the extension container. - Container core.Container `json:"container"` - // Selector defines criteria to be included in the addon pod. - Selector string `json:"selector,omitempty"` - // Metadata details. - Metadata runtime.RawExtension `json:"metadata,omitempty"` -} - -// ExtensionStatus defines the observed state of the resource. -type ExtensionStatus struct { - // The most recent generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - -// Extension defines an addon extension. -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -// +kubebuilder:storageversion -// +kubebuilder:subresource:status -type Extension struct { - meta.TypeMeta `json:",inline"` - meta.ObjectMeta `json:"metadata,omitempty"` - // pec defines the desired state of the resource. - Spec ExtensionSpec `json:"spec"` - // Status defines the observed state of the resource. - Status ExtensionStatus `json:"status,omitempty"` -} - -// ExtensionList is a list of Extension. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type ExtensionList struct { - meta.TypeMeta `json:",inline"` - meta.ListMeta `json:"metadata,omitempty"` - Items []Extension `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Extension{}, &ExtensionList{}) -} diff --git a/k8s/api/tackle/v1alpha2/register.go b/k8s/api/tackle/v1alpha2/register.go deleted file mode 100644 index 4d8dd0a30..000000000 --- a/k8s/api/tackle/v1alpha2/register.go +++ /dev/null @@ -1,35 +0,0 @@ -/* -Copyright 2019 Red Hat Inc. - -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 contains API Schema definitions for the migration v1alpha1 API group. -// +k8s:openapi-gen=true -// +k8s:deepcopy-gen=package,register -// +k8s:conversion-gen=github.com/konveyor/tackle2-controller/pkg/apis/migration -// +k8s:defaulter-gen=TypeMeta -// +groupName=tackle.konveyor.io -package v1alpha2 - -import ( - "k8s.io/apimachinery/pkg/runtime/schema" - "sigs.k8s.io/controller-runtime/pkg/scheme" -) - -var SchemeGroupVersion = schema.GroupVersion{ - Group: "tackle.konveyor.io", - Version: "v1alpha2", -} - -var SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} diff --git a/k8s/api/tackle/v1alpha2/tackle.go b/k8s/api/tackle/v1alpha2/tackle.go deleted file mode 100644 index 92cdcf12b..000000000 --- a/k8s/api/tackle/v1alpha2/tackle.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2019 Red Hat Inc. - -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 v1alpha2 - -import ( - "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" - meta "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// Tackle defines a tackle application. -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -// +kubebuilder:storageversion -// +kubebuilder:subresource:status -type Tackle v1alpha1.Tackle - -// TackleList is a list of Tackle. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type TackleList struct { - meta.TypeMeta `json:",inline"` - meta.ListMeta `json:"metadata,omitempty"` - Items []Tackle `json:"items"` -} - -func init() { - SchemeBuilder.Register(&TackleList{}, &Tackle{}) -} diff --git a/k8s/api/tackle/v1alpha2/task.go b/k8s/api/tackle/v1alpha2/task.go deleted file mode 100644 index 2e5180dcf..000000000 --- a/k8s/api/tackle/v1alpha2/task.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2019 Red Hat Inc. - -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 v1alpha2 - -import ( - "encoding/json" - - meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -// TaskSpec defines the desired state the resource. -type TaskSpec struct { - // Priority defines the task priority (0-n). - Priority int `json:"priority,omitempty"` - // Dependencies defines a list of task names on which this task depends. - Dependencies []string `json:"dependencies,omitempty"` - // Data object passed to the addon. - Data runtime.RawExtension `json:"data,omitempty"` -} - -// TaskStatus defines the observed state the resource. -type TaskStatus struct { - // The most recent generation observed by the controller. - // +optional - ObservedGeneration int64 `json:"observedGeneration,omitempty"` -} - -// Task defines a hub task. -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +k8s:openapi-gen=true -// +kubebuilder:storageversion -// +kubebuilder:subresource:status -type Task struct { - meta.TypeMeta `json:",inline"` - meta.ObjectMeta `json:"metadata,omitempty"` - // Spec defines the desired state the resource. - Spec TaskSpec `json:"spec,omitempty"` - // Status defines the observed state the resource. - Status TaskStatus `json:"status,omitempty"` -} - -// HasDep return true if the task has the dependency. -func (r *Task) HasDep(name string) (found bool) { - for i := range r.Spec.Dependencies { - n := r.Spec.Dependencies[i] - if n == name { - found = true - break - } - } - return -} - -// Data returns the task Data as map[string]any. -func (r *Task) Data() (mp map[string]any) { - b := r.Spec.Data.Raw - if b == nil { - return - } - _ = json.Unmarshal(b, &mp) - return -} - -// TaskList is a list of Task. -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type TaskList struct { - meta.TypeMeta `json:",inline"` - meta.ListMeta `json:"metadata,omitempty"` - Items []Task `json:"items"` -} - -func init() { - SchemeBuilder.Register(&Task{}, &TaskList{}) -} diff --git a/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go b/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go deleted file mode 100644 index 244028496..000000000 --- a/k8s/api/tackle/v1alpha2/zz_generated.deepcopy.go +++ /dev/null @@ -1,378 +0,0 @@ -//go:build !ignore_autogenerated -// +build !ignore_autogenerated - -/* -Copyright 2019 Red Hat Inc. - -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 controller-gen. DO NOT EDIT. - -package v1alpha2 - -import ( - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Addon) DeepCopyInto(out *Addon) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Addon. -func (in *Addon) DeepCopy() *Addon { - if in == nil { - return nil - } - out := new(Addon) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Addon) 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 *AddonList) DeepCopyInto(out *AddonList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Addon, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonList. -func (in *AddonList) DeepCopy() *AddonList { - if in == nil { - return nil - } - out := new(AddonList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *AddonList) 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 *AddonSpec) DeepCopyInto(out *AddonSpec) { - *out = *in - if in.Image != nil { - in, out := &in.Image, &out.Image - *out = new(string) - **out = **in - } - if in.ImagePullPolicy != nil { - in, out := &in.ImagePullPolicy, &out.ImagePullPolicy - *out = new(v1.PullPolicy) - **out = **in - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(v1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - in.Container.DeepCopyInto(&out.Container) - in.Metadata.DeepCopyInto(&out.Metadata) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonSpec. -func (in *AddonSpec) DeepCopy() *AddonSpec { - if in == nil { - return nil - } - out := new(AddonSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AddonStatus) DeepCopyInto(out *AddonStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddonStatus. -func (in *AddonStatus) DeepCopy() *AddonStatus { - if in == nil { - return nil - } - out := new(AddonStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Extension) DeepCopyInto(out *Extension) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Extension. -func (in *Extension) DeepCopy() *Extension { - if in == nil { - return nil - } - out := new(Extension) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Extension) 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 *ExtensionList) DeepCopyInto(out *ExtensionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Extension, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionList. -func (in *ExtensionList) DeepCopy() *ExtensionList { - if in == nil { - return nil - } - out := new(ExtensionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ExtensionList) 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 *ExtensionSpec) DeepCopyInto(out *ExtensionSpec) { - *out = *in - in.Container.DeepCopyInto(&out.Container) - in.Metadata.DeepCopyInto(&out.Metadata) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionSpec. -func (in *ExtensionSpec) DeepCopy() *ExtensionSpec { - if in == nil { - return nil - } - out := new(ExtensionSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ExtensionStatus) DeepCopyInto(out *ExtensionStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtensionStatus. -func (in *ExtensionStatus) DeepCopy() *ExtensionStatus { - if in == nil { - return nil - } - out := new(ExtensionStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Tackle) DeepCopyInto(out *Tackle) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tackle. -func (in *Tackle) DeepCopy() *Tackle { - if in == nil { - return nil - } - out := new(Tackle) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Tackle) 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 *TackleList) DeepCopyInto(out *TackleList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Tackle, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TackleList. -func (in *TackleList) DeepCopy() *TackleList { - if in == nil { - return nil - } - out := new(TackleList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TackleList) 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 *Task) DeepCopyInto(out *Task) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Task. -func (in *Task) DeepCopy() *Task { - if in == nil { - return nil - } - out := new(Task) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *Task) 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 *TaskList) DeepCopyInto(out *TaskList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]Task, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskList. -func (in *TaskList) DeepCopy() *TaskList { - if in == nil { - return nil - } - out := new(TaskList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TaskList) 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 *TaskSpec) DeepCopyInto(out *TaskSpec) { - *out = *in - if in.Dependencies != nil { - in, out := &in.Dependencies, &out.Dependencies - *out = make([]string, len(*in)) - copy(*out, *in) - } - in.Data.DeepCopyInto(&out.Data) -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskSpec. -func (in *TaskSpec) DeepCopy() *TaskSpec { - if in == nil { - return nil - } - out := new(TaskSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TaskStatus) DeepCopyInto(out *TaskStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TaskStatus. -func (in *TaskStatus) DeepCopy() *TaskStatus { - if in == nil { - return nil - } - out := new(TaskStatus) - in.DeepCopyInto(out) - return out -} diff --git a/reflect/db.go b/reflect/db.go new file mode 100644 index 000000000..6b100ef3c --- /dev/null +++ b/reflect/db.go @@ -0,0 +1,27 @@ +package reflect + +import ( + "gorm.io/gorm" +) + +// Select returns DB.Select() with validated fields. +func Select(in *gorm.DB, m any, fields ...string) (out *gorm.DB) { + fields, err := HasFields(m, fields...) + out = in.Select(fields) + if err != nil { + out.Statement.Error = err + return + } + return +} + +// Omit returns DB.Omit() with validated fields. +func Omit(in *gorm.DB, m any, fields ...string) (out *gorm.DB) { + fields, err := HasFields(m, fields...) + out = in.Omit(fields...) + if err != nil { + out.Statement.Error = err + return + } + return +} diff --git a/reflect/error.go b/reflect/error.go new file mode 100644 index 000000000..c4a369c25 --- /dev/null +++ b/reflect/error.go @@ -0,0 +1,25 @@ +package reflect + +import ( + "errors" + "fmt" +) + +// FieldNotValid report field not valid. +type FieldNotValid struct { + Kind string + Name string +} + +func (e *FieldNotValid) Error() string { + return fmt.Sprintf( + "(%s) '%s' not valid.", + e.Kind, + e.Name) +} + +func (e *FieldNotValid) Is(err error) (matched bool) { + var inst *FieldNotValid + matched = errors.As(err, &inst) + return +} diff --git a/api/reflect/fields.go b/reflect/fields.go similarity index 58% rename from api/reflect/fields.go rename to reflect/fields.go index 933c7e73d..73e593c2f 100644 --- a/api/reflect/fields.go +++ b/reflect/fields.go @@ -3,9 +3,13 @@ package reflect import ( "reflect" "time" + + liberr "github.com/jortel/go-utils/error" ) // Fields returns a map of fields. +// Used for: +// - db.Updates() func Fields(m any) (mp map[string]any) { var inspect func(r any) inspect = func(r any) { @@ -82,3 +86,55 @@ func NameOf(m any) (name string) { } return } + +// HasFields returns the validated field names. +// Used for: +// - db.Omit() +// - db.Select() +func HasFields(m any, in ...string) (out []string, err error) { + mp := make(map[string]any) + var inspect func(r any) + inspect = func(r any) { + mt := reflect.TypeOf(r) + mv := reflect.ValueOf(r) + if mt.Kind() == reflect.Ptr { + mt = mt.Elem() + mv = mv.Elem() + } + for i := 0; i < mt.NumField(); i++ { + ft := mt.Field(i) + fv := mv.Field(i) + if !ft.IsExported() { + continue + } + switch fv.Kind() { + case reflect.Ptr: + inst := fv.Interface() + mp[ft.Name] = inst + case reflect.Struct: + if ft.Anonymous { + inspect(fv.Addr().Interface()) + continue + } + inst := fv.Interface() + mp[ft.Name] = inst + default: + mp[ft.Name] = fv.Interface() + } + } + } + inspect(m) + for _, name := range in { + _, found := mp[name] + if !found { + err = &FieldNotValid{ + Kind: NameOf(m), + Name: name, + } + err = liberr.Wrap(err) + return + } + } + out = in + return +} diff --git a/task/error.go b/task/error.go index b6786c86b..5063de5d1 100644 --- a/task/error.go +++ b/task/error.go @@ -110,6 +110,51 @@ func (e *AddonNotSelected) Retry() (r bool) { return } +// NotReady report that a resource does not have the ready condition. +type NotReady struct { + Kind string + Name string + Reason string +} + +func (e *NotReady) Error() string { + return fmt.Sprintf( + "(%s) '%s' not ready: %s.", + e.Kind, + e.Name, + e.Reason) +} + +func (e *NotReady) Is(err error) (matched bool) { + var inst *NotReady + matched = errors.As(err, &inst) + return +} + +func (e *NotReady) Retry() (r bool) { + return +} + +// NotReconciled report as resource has not been reconciled. +type NotReconciled struct { + Kind string + Name string +} + +func (e *NotReconciled) Error() string { + return fmt.Sprintf("(%s) '%s' not reconciled.", e.Kind, e.Name) +} + +func (e *NotReconciled) Is(err error) (matched bool) { + var inst *NotReconciled + matched = errors.As(err, &inst) + return +} + +func (e *NotReconciled) Retry() (r bool) { + return +} + // ExtensionNotFound used to report an extension referenced // by a task but cannot be found. type ExtensionNotFound struct { diff --git a/task/manager.go b/task/manager.go index 6d2f8a4c6..914c23999 100644 --- a/task/manager.go +++ b/task/manager.go @@ -2,6 +2,7 @@ package task import ( "context" + "errors" "fmt" "io" "os" @@ -17,9 +18,10 @@ import ( "github.com/jortel/go-utils/logr" "github.com/konveyor/tackle2-hub/auth" k8s2 "github.com/konveyor/tackle2-hub/k8s" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "github.com/konveyor/tackle2-hub/metrics" "github.com/konveyor/tackle2-hub/model" + "github.com/konveyor/tackle2-hub/reflect" "github.com/konveyor/tackle2-hub/settings" "gopkg.in/yaml.v2" "gorm.io/gorm" @@ -124,7 +126,11 @@ func (m *Manager) Run(ctx context.Context) { m.startReady() m.pause() } else { - Log.Error(err, "") + if errors.Is(err, &NotReconciled{}) { + Log.Info(err.Error()) + } else { + Log.Error(err, "") + } m.pause() } } @@ -182,7 +188,9 @@ func (m *Manager) Update(db *gorm.DB, requested *Task) (err error) { } switch found.State { case Created: - db = db.Select( + db = reflect.Select( + db, + requested, "UpdateUser", "Name", "Kind", @@ -209,7 +217,9 @@ func (m *Manager) Update(db *gorm.DB, requested *Task) (err error) { Pending, QuotaBlocked, Postponed: - db = db.Select( + db = reflect.Select( + db, + requested, "UpdateUser", "Name", "Locator", @@ -518,6 +528,13 @@ func (m *Manager) selectAddon(task *Task) (addon *crd.Addon, err error) { err = &AddonNotSelected{} return } + if !selected.Ready() { + err = &NotReady{ + Kind: "Addon", + Name: selected.Name, + } + return + } task.Addon = selected.Name task.Event(AddonSelected, selected) return @@ -1643,7 +1660,9 @@ func (r *Task) containsAny(str string, substr ...string) (matched bool) { // update manager controlled fields. func (r *Task) update(db *gorm.DB) (err error) { - db = db.Select( + db = reflect.Select( + db, + r.Task, "Addon", "Extensions", "State", @@ -1651,7 +1670,7 @@ func (r *Task) update(db *gorm.DB) (err error) { "Started", "Terminated", "Events", - "Error", + "Errors", "Retries", "Attached", "Pod") @@ -1903,6 +1922,13 @@ func (k *Cluster) getAddons() (err error) { for i := range list.Items { r := &list.Items[i] k.addons[r.Name] = r + if !r.Reconciled() { + err = &NotReconciled{ + Kind: r.Kind, + Name: r.Name, + } + return + } } return } diff --git a/task/task_test.go b/task/task_test.go index 80fe29bb3..e088769e0 100644 --- a/task/task_test.go +++ b/task/task_test.go @@ -3,7 +3,7 @@ package task import ( "testing" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "github.com/konveyor/tackle2-hub/model" "github.com/onsi/gomega" ) diff --git a/trigger/pkg.go b/trigger/pkg.go index 20bd344e5..189a598ad 100644 --- a/trigger/pkg.go +++ b/trigger/pkg.go @@ -4,7 +4,7 @@ import ( "context" liberr "github.com/jortel/go-utils/error" - crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha2" + crd "github.com/konveyor/tackle2-hub/k8s/api/tackle/v1alpha1" "github.com/konveyor/tackle2-hub/settings" tasking "github.com/konveyor/tackle2-hub/task" "gorm.io/gorm"