You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2023/05/10 10:19:08 UTC
[camel-k] 01/05: feat: remove deprecated code
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit e60235836abb3b3d1975287a0b4a22a89d8ef561
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Wed May 3 16:45:20 2023 +0200
feat: remove deprecated code
Close #4026
---
config/crd/bases/camel.apache.org_pipes.yaml | 512 -------------------
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 55 --
e2e/common/misc/kamelet_binding_test.go | 52 +-
e2e/common/misc/kamelet_binding_with_image_test.go | 47 +-
e2e/common/traits/health_test.go | 28 +-
e2e/knative/kamelet_test.go | 32 +-
e2e/native/native_binding_test.go | 11 +-
e2e/support/test_support.go | 62 ---
helm/camel-k/crds/crd-pipe.yaml | 512 -------------------
pkg/apis/camel/v1/common_types.go | 23 -
pkg/apis/camel/v1/integration_types_support.go | 10 -
pkg/apis/camel/v1/pipe_types.go | 3 -
pkg/apis/camel/v1/zz_generated.deepcopy.go | 23 -
.../camel/applyconfiguration/camel/v1/endpoint.go | 15 -
pkg/cmd/init.go | 124 -----
pkg/cmd/install.go | 26 +-
pkg/cmd/install_test.go | 8 -
pkg/cmd/local.go | 96 ----
pkg/cmd/local/container.go | 347 -------------
pkg/cmd/local/local.go | 556 ---------------------
pkg/cmd/local/local_test.go | 67 ---
pkg/cmd/local/workdir.go | 244 ---------
pkg/cmd/local_build.go | 269 ----------
pkg/cmd/local_build_test.go | 73 ---
pkg/cmd/local_inspect.go | 109 ----
pkg/cmd/local_inspect_test.go | 73 ---
pkg/cmd/local_run.go | 283 -----------
pkg/cmd/local_run_test.go | 109 ----
pkg/cmd/modeline_test.go | 43 --
pkg/cmd/promote_test.go | 14 +-
pkg/cmd/root.go | 2 -
pkg/cmd/run.go | 5 +-
pkg/cmd/run_support.go | 114 +++--
pkg/cmd/run_support_test.go | 46 --
pkg/resources/resources.go | 25 +-
pkg/trait/openapi.go | 2 +-
pkg/trait/service_test.go | 5 +-
pkg/trait/trait_configure_test.go | 4 +-
pkg/util/kubernetes/resolver.go | 13 -
pkg/util/log/log.go | 2 +-
pkg/util/resource/config.go | 21 +-
pkg/util/resource/config_test.go | 35 --
42 files changed, 199 insertions(+), 3901 deletions(-)
diff --git a/config/crd/bases/camel.apache.org_pipes.yaml b/config/crd/bases/camel.apache.org_pipes.yaml
index d1640f18e..103ac83fc 100644
--- a/config/crd/bases/camel.apache.org_pipes.yaml
+++ b/config/crd/bases/camel.apache.org_pipes.yaml
@@ -7788,176 +7788,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for an
- event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64, string,
- []interface{}, map[string]interface{} and nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for undefined
- object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format string.
- Unknown formats are ignored. The following formats
- are validated: \n - bsonobjectid: a bson object
- ID, i.e. a 24 characters hex string - uri: an
- URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid representation
- for an Internet host name, as defined by RFC
- 1034, section 3.1 [RFC1034]. - ipv4: an IPv4
- IP as parsed by Golang net.ParseIP - ipv6: an
- IPv6 IP as parsed by Golang net.ParseIP - cidr:
- a CIDR as parsed by Golang net.ParseCIDR - mac:
- a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string like
- \"0321751043\" or \"978-0321751041\" - isbn10:
- an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined by
- the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$ -
- hexcolor: an hexadecimal color code like \"#FFFFFF\"
- following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string -
- date: a date string like \"2006-01-02\" as defined
- by full-date in RFC3339 - duration: a duration
- string like \"22 ns\" as parsed by Golang time.ParseDuration
- or compatible with Scala duration format - datetime:
- a date time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior in
- external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint explicitly
type: string
@@ -8023,176 +7853,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for an
- event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64, string,
- []interface{}, map[string]interface{} and nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for undefined
- object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format string.
- Unknown formats are ignored. The following formats
- are validated: \n - bsonobjectid: a bson object
- ID, i.e. a 24 characters hex string - uri: an
- URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid representation
- for an Internet host name, as defined by RFC
- 1034, section 3.1 [RFC1034]. - ipv4: an IPv4
- IP as parsed by Golang net.ParseIP - ipv6: an
- IPv6 IP as parsed by Golang net.ParseIP - cidr:
- a CIDR as parsed by Golang net.ParseCIDR - mac:
- a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string like
- \"0321751043\" or \"978-0321751041\" - isbn10:
- an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined by
- the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$ -
- hexcolor: an hexadecimal color code like \"#FFFFFF\"
- following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string -
- date: a date string like \"2006-01-02\" as defined
- by full-date in RFC3339 - duration: a duration
- string like \"22 ns\" as parsed by Golang time.ParseDuration
- or compatible with Scala duration format - datetime:
- a date time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior in
- external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint explicitly
type: string
@@ -8262,178 +7922,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for
- an event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{} and
- nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for
- undefined object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool,
- int64, float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format
- string. Unknown formats are ignored. The following
- formats are validated: \n - bsonobjectid:
- a bson object ID, i.e. a 24 characters hex
- string - uri: an URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid
- representation for an Internet host name,
- as defined by RFC 1034, section 3.1 [RFC1034].
- - ipv4: an IPv4 IP as parsed by Golang net.ParseIP
- - ipv6: an IPv6 IP as parsed by Golang net.ParseIP
- - cidr: a CIDR as parsed by Golang net.ParseCIDR
- - mac: a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string
- like \"0321751043\" or \"978-0321751041\"
- - isbn10: an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined
- by the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$
- - hexcolor: an hexadecimal color code like
- \"#FFFFFF\" following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string
- - date: a date string like \"2006-01-02\"
- as defined by full-date in RFC3339 - duration:
- a duration string like \"22 ns\" as parsed
- by Golang time.ParseDuration or compatible
- with Scala duration format - datetime: a date
- time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior
- in external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint
explicitly
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 05067c9cb..3498ff1f9 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -1274,7 +1274,6 @@ the value to assign to the configuration (syntax may vary depending on the `Type
*Appears on:*
-* <<#_camel_apache_org_v1_ResourceSpec, ResourceSpec>>
* <<#_camel_apache_org_v1_SourceSpec, SourceSpec>>
DataSpec represents the way the source is materialized in the running `Pod`
@@ -1514,14 +1513,6 @@ URI can be used to specify the (Camel) endpoint explicitly
Properties are a key value representation of endpoint properties
-|`types` +
-*xref:#_camel_apache_org_v1_EventTypeSpec[map[github.com/apache/camel-k/v2/pkg/apis/camel/v1.TypeSlot\]github.com/apache/camel-k/v2/pkg/apis/camel/v1.EventTypeSpec]*
-|
-
-
-Types defines the data type of the data produced/consumed by the endpoint and references a given data type specification.
-Deprecated: In favor of using DataTypes
-
|`dataTypes` +
*xref:#_camel_apache_org_v1_DataTypeReference[map[github.com/apache/camel-k/v2/pkg/apis/camel/v1.TypeSlot\]github.com/apache/camel-k/v2/pkg/apis/camel/v1.DataTypeReference]*
|
@@ -1702,7 +1693,6 @@ ErrorHandlerType a type of error handler (ie, sink)
*Appears on:*
-* <<#_camel_apache_org_v1_Endpoint, Endpoint>>
* <<#_camel_apache_org_v1_KameletSpec, KameletSpec>>
EventTypeSpec represents a specification for an event type
@@ -4394,51 +4384,6 @@ Your options are to `ignore`, `fail`, or `warn` on missing or incorrect checksum
ResourceCondition is a common type for all conditions
-[#_camel_apache_org_v1_ResourceSpec]
-=== ResourceSpec
-
-ResourceSpec represent an attached resource which will be materialized as a file on the running `Pod`
-TODO: we should deprecate in future releases in favour of mount, openapi or camel traits
-
-[cols="2,2a",options="header"]
-|===
-|Field
-|Description
-
-|`DataSpec` +
-*xref:#_camel_apache_org_v1_DataSpec[DataSpec]*
-|(Members of `DataSpec` are embedded into this type.)
-
-
-the content of the resource
-
-|`type` +
-*xref:#_camel_apache_org_v1_ResourceType[ResourceType]*
-|
-
-
-the kind of data to expect
-
-|`mountPath` +
-string
-|
-
-
-the mount path on destination `Pod`
-
-
-|===
-
-[#_camel_apache_org_v1_ResourceType]
-=== ResourceType(`string` alias)
-
-*Appears on:*
-
-* <<#_camel_apache_org_v1_ResourceSpec, ResourceSpec>>
-
-ResourceType defines a kind of resource
-
-
[#_camel_apache_org_v1_RuntimeProvider]
=== RuntimeProvider(`string` alias)
diff --git a/e2e/common/misc/kamelet_binding_test.go b/e2e/common/misc/kamelet_binding_test.go
index 3b148174a..b0eb5f573 100644
--- a/e2e/common/misc/kamelet_binding_test.go
+++ b/e2e/common/misc/kamelet_binding_test.go
@@ -53,24 +53,16 @@ func TestPipe(t *testing.T) {
APIVersion: v1.SchemeGroupVersion.String(),
}
- errorHandler := map[string]interface{}{
- "sink": map[string]interface{}{
- "endpoint": map[string]interface{}{
- "ref": map[string]string{
- "kind": "Kamelet",
- "apiVersion": v1.SchemeGroupVersion.String(),
- "name": "my-own-log-sink",
- },
- "properties": map[string]string{
- "loggerName": "kameletErrorHandler",
- },
- }}}
-
t.Run("throw error test", func(t *testing.T) {
- Expect(BindKameletToWithErrorHandler(ns, "throw-error-binding", map[string]string{},
- from, to,
- map[string]string{"message": "throw Error"}, map[string]string{"loggerName": "integrationLogger"},
- errorHandler)()).To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "--error-handler", "sink:"+to.Name,
+ "-p", "source.message=throw Error",
+ "-p", "sink.loggerName=integrationLogger",
+ "-p", "error-handler.loggerName=kameletErrorHandler",
+ "--name", "throw-error-binding",
+ ).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "throw-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "throw-error-binding"), TestTimeoutShort).Should(ContainSubstring("kameletErrorHandler"))
@@ -79,10 +71,15 @@ func TestPipe(t *testing.T) {
})
t.Run("don't throw error test", func(t *testing.T) {
- Expect(BindKameletToWithErrorHandler(ns, "no-error-binding", map[string]string{},
- from, to,
- map[string]string{"message": "true"}, map[string]string{"loggerName": "integrationLogger"},
- errorHandler)()).To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "--error-handler", "sink:"+to.Name,
+ "-p", "source.message=true",
+ "-p", "sink.loggerName=integrationLogger",
+ "-p", "error-handler.loggerName=kameletErrorHandler",
+ "--name", "no-error-binding",
+ ).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "no-error-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "no-error-binding"), TestTimeoutShort).ShouldNot(ContainSubstring("kameletErrorHandler"))
@@ -108,11 +105,14 @@ func TestPipe(t *testing.T) {
APIVersion: v1.SchemeGroupVersion.String(),
}
- Expect(BindKameletTo(ns, "kb-with-traits",
- map[string]string{"trait.camel.apache.org/camel.properties": "[\"camel.prop1=a\",\"camel.prop2=b\"]"},
- from, to,
- map[string]string{"message": "hello from test"}, map[string]string{"loggerName": "integrationLogger"})()).
- To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "-p", "source.message=hello from test",
+ "-p", "sink.loggerName=integrationLogger",
+ "--annotation", "trait.camel.apache.org/camel.properties=[\"camel.prop1=a\",\"camel.prop2=b\"]",
+ "--name", "kb-with-traits",
+ ).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, "kb-with-traits"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationLogs(ns, "kb-with-traits"), TestTimeoutShort).Should(ContainSubstring("hello from test"))
diff --git a/e2e/common/misc/kamelet_binding_with_image_test.go b/e2e/common/misc/kamelet_binding_with_image_test.go
index 86dfdf799..77ddf9348 100644
--- a/e2e/common/misc/kamelet_binding_with_image_test.go
+++ b/e2e/common/misc/kamelet_binding_with_image_test.go
@@ -49,29 +49,22 @@ func TestPipeWithImage(t *testing.T) {
APIVersion: v1.SchemeGroupVersion.String(),
}
- emptyMap := map[string]string{}
-
- annotations1 := map[string]string{
- "trait.camel.apache.org/container.image": "docker.io/jmalloc/echo-server:0.3.2",
- "trait.camel.apache.org/jvm.enabled": "false",
- "trait.camel.apache.org/kamelets.enabled": "false",
- "trait.camel.apache.org/dependencies.enabled": "false",
- "test": "1",
- }
- annotations2 := map[string]string{
- "trait.camel.apache.org/container.image": "docker.io/jmalloc/echo-server:0.3.3",
- "trait.camel.apache.org/jvm.enabled": "false",
- "trait.camel.apache.org/kamelets.enabled": "false",
- "trait.camel.apache.org/dependencies.enabled": "false",
- "test": "2",
- }
bindingID := "with-image-binding"
t.Run("run with initial image", func(t *testing.T) {
- expectedImage := annotations1["trait.camel.apache.org/container.image"]
+ expectedImage := "docker.io/jmalloc/echo-server:0.3.2"
+
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
+ "--annotation", "trait.camel.apache.org/jvm.enabled=false",
+ "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
+ "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
+ "--annotation", "test=1",
+ "--name", bindingID,
+ ).Execute()).To(Succeed())
- Expect(BindKameletTo(ns, bindingID, annotations1, from, to, emptyMap, emptyMap)()).
- To(Succeed())
Eventually(IntegrationGeneration(ns, bindingID)).
Should(gstruct.PointTo(BeNumerically("==", 1)))
Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
@@ -87,10 +80,18 @@ func TestPipeWithImage(t *testing.T) {
})
t.Run("run with new image", func(t *testing.T) {
- expectedImage := annotations2["trait.camel.apache.org/container.image"]
-
- Expect(BindKameletTo(ns, bindingID, annotations2, from, to, emptyMap, emptyMap)()).
- To(Succeed())
+ expectedImage := "docker.io/jmalloc/echo-server:0.3.3"
+
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "--annotation", "trait.camel.apache.org/container.image="+expectedImage,
+ "--annotation", "trait.camel.apache.org/jvm.enabled=false",
+ "--annotation", "trait.camel.apache.org/kamelets.enabled=false",
+ "--annotation", "trait.camel.apache.org/dependencies.enabled=false",
+ "--annotation", "test=2",
+ "--name", bindingID,
+ ).Execute()).To(Succeed())
Eventually(IntegrationGeneration(ns, bindingID)).
Should(gstruct.PointTo(BeNumerically("==", 1)))
Eventually(Integration(ns, bindingID)).Should(WithTransform(Annotations, And(
diff --git a/e2e/common/traits/health_test.go b/e2e/common/traits/health_test.go
index fc15af7d1..fb73eab88 100644
--- a/e2e/common/traits/health_test.go
+++ b/e2e/common/traits/health_test.go
@@ -151,29 +151,23 @@ func TestHealthTrait(t *testing.T) {
APIVersion: camelv1.SchemeGroupVersion.String(),
}
- fromParams := map[string]string{
- "message": "Magicstring!",
- }
-
to := corev1.ObjectReference{
Kind: "Kamelet",
Name: "my-own-log-sink",
APIVersion: camelv1.SchemeGroupVersion.String(),
}
- toParams := map[string]string{
- "loggerName": "binding",
- }
-
- annotations := map[string]string{
- "trait.camel.apache.org/health.enabled": "true",
- "trait.camel.apache.org/jolokia.enabled": "true",
- "trait.camel.apache.org/jolokia.use-ssl-client-authentication": "false",
- "trait.camel.apache.org/jolokia.protocol": "http",
- }
-
- Expect(BindKameletTo(ns, name, annotations, from, to, fromParams, toParams)()).
- To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "-p", "source.message=Magicstring!",
+ "-p", "sink.loggerName=binding",
+ "--annotation", "trait.camel.apache.org/health.enabled=true",
+ "--annotation", "trait.camel.apache.org/jolokia.enabled=true",
+ "--annotation", "trait.camel.apache.org/jolokia.use-ssl-client-authentication=false",
+ "--annotation", "trait.camel.apache.org/jolokia.protocol=http",
+ "--name", name,
+ ).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
Eventually(IntegrationPhase(ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
diff --git a/e2e/knative/kamelet_test.go b/e2e/knative/kamelet_test.go
index e2598b8a3..218b997d7 100644
--- a/e2e/knative/kamelet_test.go
+++ b/e2e/knative/kamelet_test.go
@@ -59,17 +59,20 @@ func TestKameletChange(t *testing.T) {
}
timerPipe := "timer-binding"
- annotations := map[string]string{
- "trait.camel.apache.org/health.enabled": "true",
- "trait.camel.apache.org/health.readiness-initial-delay": "10",
- }
// Create the Pipe
- Expect(BindKameletTo(ns, timerPipe, annotations, from, to, map[string]string{"message": "message is Hello"}, map[string]string{})()).To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "-p", "source.message=message is Hello",
+ "--annotation", "trait.camel.apache.org/health.enabled=true",
+ "--annotation", "trait.camel.apache.org/health.readiness-initial-delay=10",
+ "--name", timerPipe,
+ ).Execute()).To(Succeed())
Eventually(IntegrationPodPhase(ns, timerPipe), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "timer-binding", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("message is Hello"))
+ Eventually(IntegrationConditionStatus(ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, timerPipe), TestTimeoutShort).Should(ContainSubstring("message is Hello"))
Eventually(PipeCondition(ns, timerPipe, v1.PipeConditionReady), TestTimeoutMedium).Should(And(
WithTransform(PipeConditionStatusExtract, Equal(corev1.ConditionTrue)),
@@ -78,11 +81,18 @@ func TestKameletChange(t *testing.T) {
))
// Update the Pipe
- Expect(BindKameletTo(ns, "timer-binding", annotations, from, to, map[string]string{"message": "message is Hi"}, map[string]string{})()).To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "-p", "source.message=message is Hi",
+ "--annotation", "trait.camel.apache.org/health.enabled=true",
+ "--annotation", "trait.camel.apache.org/health.readiness-initial-delay=10",
+ "--name", timerPipe,
+ ).Execute()).To(Succeed())
- Eventually(IntegrationPodPhase(ns, "timer-binding"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
- Eventually(IntegrationConditionStatus(ns, "timer-binding", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- Eventually(IntegrationLogs(ns, "test-kamelet-display"), TestTimeoutShort).Should(ContainSubstring("message is Hi"))
+ Eventually(IntegrationPodPhase(ns, timerPipe), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+ Eventually(IntegrationConditionStatus(ns, timerPipe, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+ Eventually(IntegrationLogs(ns, timerPipe), TestTimeoutShort).Should(ContainSubstring("message is Hi"))
Eventually(PipeCondition(ns, timerPipe, v1.PipeConditionReady), TestTimeoutMedium).
Should(And(
diff --git a/e2e/native/native_binding_test.go b/e2e/native/native_binding_test.go
index 8e6aca73a..8207e4d12 100644
--- a/e2e/native/native_binding_test.go
+++ b/e2e/native/native_binding_test.go
@@ -69,10 +69,13 @@ func TestNativeBinding(t *testing.T) {
t.Run("binding with native build", func(t *testing.T) {
bindingName := "native-binding"
- Expect(BindKameletTo(ns, bindingName,
- map[string]string{"trait.camel.apache.org/quarkus.package-type": "native"},
- from, to,
- map[string]string{"message": message}, map[string]string{})()).To(Succeed())
+ Expect(KamelBind(ns,
+ from.Name,
+ to.Name,
+ "-p", "source.message=message",
+ "--annotation", "trait.camel.apache.org/quarkus.package-type=native",
+ "--name", bindingName,
+ ).Execute()).To(Succeed())
// ====================================
// !!! THE MOST TIME-CONSUMING PART !!!
diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 4377c64b8..fd07afc60 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -2345,40 +2345,6 @@ func CreateTimerKamelet(ns string, name string) func() error {
return CreateKamelet(ns, name, flow, props, nil)
}
-// Deprecated:
-// Use KamelBind func instead
-func BindKameletTo(ns, name string, annotations map[string]string, from, to corev1.ObjectReference,
- sourceProperties, sinkProperties map[string]string) func() error {
- return BindKameletToWithErrorHandler(ns, name, annotations, from, to, sourceProperties, sinkProperties, nil)
-}
-
-// Deprecated:
-// Use KamelBind func instead
-func BindKameletToWithErrorHandler(ns, name string, annotations map[string]string, from, to corev1.ObjectReference,
- sourceProperties, sinkProperties map[string]string, errorHandler map[string]interface{}) func() error {
- return func() error {
- kb := v1.NewPipe(ns, name)
- kb.Annotations = annotations
- kb.Spec = v1.PipeSpec{
- Source: v1.Endpoint{
- Ref: &from,
- Properties: asEndpointProperties(sourceProperties),
- },
- Sink: v1.Endpoint{
- Ref: &to,
- Properties: asEndpointProperties(sinkProperties),
- },
- }
- if errorHandler != nil {
- kb.Spec.ErrorHandler = asErrorHandlerSpec(errorHandler)
- }
- _, err := kubernetes.ReplaceResource(TestContext, TestClient(), &kb)
- return err
- }
-}
-
-// Deprecated:
-// Use KamelBind func instead
func asTemplate(source map[string]interface{}) *v1.Template {
bytes, err := json.Marshal(source)
if err != nil {
@@ -2389,34 +2355,6 @@ func asTemplate(source map[string]interface{}) *v1.Template {
}
}
-// Deprecated:
-// Use KamelBind func instead
-func asErrorHandlerSpec(source map[string]interface{}) *v1.ErrorHandlerSpec {
- bytes, err := json.Marshal(source)
- if err != nil {
- failTest(err)
- }
- return &v1.ErrorHandlerSpec{
- RawMessage: bytes,
- }
-}
-
-// Deprecated:
-// Use KamelBind func instead
-func asEndpointProperties(props map[string]string) *v1.EndpointProperties {
- if props == nil {
- return &v1.EndpointProperties{}
- }
-
- bytes, err := json.Marshal(props)
- if err != nil {
- failTest(err)
- }
- return &v1.EndpointProperties{
- RawMessage: bytes,
- }
-}
-
// nolint: staticcheck
func AsTraitConfiguration(props map[string]string) *traitv1.Configuration {
bytes, err := json.Marshal(props)
diff --git a/helm/camel-k/crds/crd-pipe.yaml b/helm/camel-k/crds/crd-pipe.yaml
index d1640f18e..103ac83fc 100644
--- a/helm/camel-k/crds/crd-pipe.yaml
+++ b/helm/camel-k/crds/crd-pipe.yaml
@@ -7788,176 +7788,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for an
- event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64, string,
- []interface{}, map[string]interface{} and nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for undefined
- object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format string.
- Unknown formats are ignored. The following formats
- are validated: \n - bsonobjectid: a bson object
- ID, i.e. a 24 characters hex string - uri: an
- URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid representation
- for an Internet host name, as defined by RFC
- 1034, section 3.1 [RFC1034]. - ipv4: an IPv4
- IP as parsed by Golang net.ParseIP - ipv6: an
- IPv6 IP as parsed by Golang net.ParseIP - cidr:
- a CIDR as parsed by Golang net.ParseCIDR - mac:
- a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string like
- \"0321751043\" or \"978-0321751041\" - isbn10:
- an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined by
- the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$ -
- hexcolor: an hexadecimal color code like \"#FFFFFF\"
- following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string -
- date: a date string like \"2006-01-02\" as defined
- by full-date in RFC3339 - duration: a duration
- string like \"22 ns\" as parsed by Golang time.ParseDuration
- or compatible with Scala duration format - datetime:
- a date time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior in
- external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint explicitly
type: string
@@ -8023,176 +7853,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for an
- event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64, string,
- []interface{}, map[string]interface{} and nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for undefined
- object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format string.
- Unknown formats are ignored. The following formats
- are validated: \n - bsonobjectid: a bson object
- ID, i.e. a 24 characters hex string - uri: an
- URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid representation
- for an Internet host name, as defined by RFC
- 1034, section 3.1 [RFC1034]. - ipv4: an IPv4
- IP as parsed by Golang net.ParseIP - ipv6: an
- IPv6 IP as parsed by Golang net.ParseIP - cidr:
- a CIDR as parsed by Golang net.ParseCIDR - mac:
- a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string like
- \"0321751043\" or \"978-0321751041\" - isbn10:
- an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined by
- the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$ -
- hexcolor: an hexadecimal color code like \"#FFFFFF\"
- following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string -
- date: a date string like \"2006-01-02\" as defined
- by full-date in RFC3339 - duration: a duration
- string like \"22 ns\" as parsed by Golang time.ParseDuration
- or compatible with Scala duration format - datetime:
- a date time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior in
- external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint explicitly
type: string
@@ -8262,178 +7922,6 @@ spec:
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
type: string
type: object
- types:
- additionalProperties:
- description: 'EventTypeSpec represents a specification for
- an event type Deprecated: In favor of using DataTypeSpec'
- properties:
- mediaType:
- description: media type as expected for HTTP media types
- (ie, application/json)
- type: string
- schema:
- description: the expected schema for the event
- properties:
- $schema:
- description: JSONSchemaURL represents a schema url.
- type: string
- description:
- type: string
- example:
- description: 'JSON represents any valid JSON value.
- These types are supported: bool, int64, float64,
- string, []interface{}, map[string]interface{} and
- nil.'
- x-kubernetes-preserve-unknown-fields: true
- externalDocs:
- description: ExternalDocumentation allows referencing
- an external resource for extended documentation.
- properties:
- description:
- type: string
- url:
- type: string
- type: object
- id:
- type: string
- properties:
- additionalProperties:
- properties:
- default:
- description: default is a default value for
- undefined object fields.
- x-kubernetes-preserve-unknown-fields: true
- deprecated:
- type: boolean
- description:
- type: string
- enum:
- items:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool,
- int64, float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- type: array
- example:
- description: 'JSON represents any valid JSON
- value. These types are supported: bool, int64,
- float64, string, []interface{}, map[string]interface{}
- and nil.'
- x-kubernetes-preserve-unknown-fields: true
- exclusiveMaximum:
- type: boolean
- exclusiveMinimum:
- type: boolean
- format:
- description: "format is an OpenAPI v3 format
- string. Unknown formats are ignored. The following
- formats are validated: \n - bsonobjectid:
- a bson object ID, i.e. a 24 characters hex
- string - uri: an URI as parsed by Golang net/url.ParseRequestURI
- - email: an email address as parsed by Golang
- net/mail.ParseAddress - hostname: a valid
- representation for an Internet host name,
- as defined by RFC 1034, section 3.1 [RFC1034].
- - ipv4: an IPv4 IP as parsed by Golang net.ParseIP
- - ipv6: an IPv6 IP as parsed by Golang net.ParseIP
- - cidr: a CIDR as parsed by Golang net.ParseCIDR
- - mac: a MAC address as parsed by Golang net.ParseMAC
- - uuid: an UUID that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid3: an UUID3 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?3[0-9a-f]{3}-?[0-9a-f]{4}-?[0-9a-f]{12}$
- - uuid4: an UUID4 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?4[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - uuid5: an UUID5 that allows uppercase defined
- by the regex (?i)^[0-9a-f]{8}-?[0-9a-f]{4}-?5[0-9a-f]{3}-?[89ab][0-9a-f]{3}-?[0-9a-f]{12}$
- - isbn: an ISBN10 or ISBN13 number string
- like \"0321751043\" or \"978-0321751041\"
- - isbn10: an ISBN10 number string like \"0321751043\"
- - isbn13: an ISBN13 number string like \"978-0321751041\"
- - creditcard: a credit card number defined
- by the regex ^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\\\d{3})\\\\d{11})$
- with any non digit characters mixed in - ssn:
- a U.S. social security number following the
- regex ^\\\\d{3}[- ]?\\\\d{2}[- ]?\\\\d{4}$
- - hexcolor: an hexadecimal color code like
- \"#FFFFFF\" following the regex ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
- - rgbcolor: an RGB color code like rgb like
- \"rgb(255,255,255)\" - byte: base64 encoded
- binary data - password: any kind of string
- - date: a date string like \"2006-01-02\"
- as defined by full-date in RFC3339 - duration:
- a duration string like \"22 ns\" as parsed
- by Golang time.ParseDuration or compatible
- with Scala duration format - datetime: a date
- time string like \"2014-12-15T19:30:20.000Z\"
- as defined by date-time in RFC3339."
- type: string
- id:
- type: string
- maxItems:
- format: int64
- type: integer
- maxLength:
- format: int64
- type: integer
- maxProperties:
- format: int64
- type: integer
- maximum:
- description: A Number represents a JSON number
- literal.
- type: string
- minItems:
- format: int64
- type: integer
- minLength:
- format: int64
- type: integer
- minProperties:
- format: int64
- type: integer
- minimum:
- description: A Number represents a JSON number
- literal.
- type: string
- multipleOf:
- description: A Number represents a JSON number
- literal.
- type: string
- nullable:
- type: boolean
- pattern:
- type: string
- title:
- type: string
- type:
- type: string
- uniqueItems:
- type: boolean
- x-descriptors:
- description: XDescriptors is a list of extended
- properties that trigger a custom behavior
- in external systems
- items:
- type: string
- type: array
- type: object
- type: object
- required:
- items:
- type: string
- type: array
- title:
- type: string
- type:
- type: string
- type: object
- type: object
- description: 'Types defines the data type of the data produced/consumed
- by the endpoint and references a given data type specification.
- Deprecated: In favor of using DataTypes'
- type: object
uri:
description: URI can be used to specify the (Camel) endpoint
explicitly
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index 52978eb47..4e25c9c7e 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -335,29 +335,6 @@ const (
RuntimeProviderQuarkus RuntimeProvider = "quarkus"
)
-// ResourceSpec represent an attached resource which will be materialized as a file on the running `Pod`
-// TODO: we should deprecate in future releases in favour of mount, openapi or camel traits
-type ResourceSpec struct {
- // the content of the resource
- DataSpec `json:",inline"`
- // the kind of data to expect
- Type ResourceType `json:"type,omitempty"`
- // the mount path on destination `Pod`
- MountPath string `json:"mountPath,omitempty"`
-}
-
-// ResourceType defines a kind of resource
-type ResourceType string
-
-const (
- // ResourceTypeData represents a generic data resource (text or binary)
- ResourceTypeData ResourceType = "data"
- // ResourceTypeConfig represents a configuration resource (text only)
- ResourceTypeConfig ResourceType = "config"
- // ResourceTypeOpenAPI represents an OpenAPI specification resource
- ResourceTypeOpenAPI ResourceType = "openapi"
-)
-
// SourceSpec defines the configuration for one or more routes to be executed in a certain Camel DSL language
type SourceSpec struct {
// contains configuration related to the source code
diff --git a/pkg/apis/camel/v1/integration_types_support.go b/pkg/apis/camel/v1/integration_types_support.go
index b86319ae6..d74145b7e 100644
--- a/pkg/apis/camel/v1/integration_types_support.go
+++ b/pkg/apis/camel/v1/integration_types_support.go
@@ -192,16 +192,6 @@ func NewSourceSpec(name string, content string, language Language) SourceSpec {
}
}
-func NewResourceSpec(name string, content string, destination string, resourceType ResourceType) ResourceSpec {
- return ResourceSpec{
- DataSpec: DataSpec{
- Name: name,
- Content: content,
- },
- Type: resourceType,
- }
-}
-
// InferLanguage returns the language of the source or discovers it from file extension if not set
func (in *SourceSpec) InferLanguage() Language {
if in.Language != "" {
diff --git a/pkg/apis/camel/v1/pipe_types.go b/pkg/apis/camel/v1/pipe_types.go
index b6112c63e..03498586e 100644
--- a/pkg/apis/camel/v1/pipe_types.go
+++ b/pkg/apis/camel/v1/pipe_types.go
@@ -69,9 +69,6 @@ type Endpoint struct {
URI *string `json:"uri,omitempty"`
// Properties are a key value representation of endpoint properties
Properties *EndpointProperties `json:"properties,omitempty"`
- // Types defines the data type of the data produced/consumed by the endpoint and references a given data type specification.
- // Deprecated: In favor of using DataTypes
- Types map[TypeSlot]EventTypeSpec `json:"types,omitempty"`
// DataTypes defines the data type of the data produced/consumed by the endpoint and references a given data type specification.
DataTypes map[TypeSlot]DataTypeReference `json:"dataTypes,omitempty"`
}
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index d2a72a692..cbc0897b7 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -705,13 +705,6 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) {
*out = new(EndpointProperties)
(*in).DeepCopyInto(*out)
}
- if in.Types != nil {
- in, out := &in.Types, &out.Types
- *out = make(map[TypeSlot]EventTypeSpec, len(*in))
- for key, val := range *in {
- (*out)[key] = *val.DeepCopy()
- }
- }
if in.DataTypes != nil {
in, out := &in.DataTypes, &out.DataTypes
*out = make(map[TypeSlot]DataTypeReference, len(*in))
@@ -2400,22 +2393,6 @@ func (in *RepositoryPolicy) DeepCopy() *RepositoryPolicy {
return out
}
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *ResourceSpec) DeepCopyInto(out *ResourceSpec) {
- *out = *in
- in.DataSpec.DeepCopyInto(&out.DataSpec)
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSpec.
-func (in *ResourceSpec) DeepCopy() *ResourceSpec {
- if in == nil {
- return nil
- }
- out := new(ResourceSpec)
- in.DeepCopyInto(out)
- return out
-}
-
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RuntimeSpec) DeepCopyInto(out *RuntimeSpec) {
*out = *in
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/endpoint.go b/pkg/client/camel/applyconfiguration/camel/v1/endpoint.go
index 1cfd8b744..20c602a76 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/endpoint.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/endpoint.go
@@ -30,7 +30,6 @@ type EndpointApplyConfiguration struct {
Ref *v1.ObjectReference `json:"ref,omitempty"`
URI *string `json:"uri,omitempty"`
Properties *EndpointPropertiesApplyConfiguration `json:"properties,omitempty"`
- Types map[apiscamelv1.TypeSlot]EventTypeSpecApplyConfiguration `json:"types,omitempty"`
DataTypes map[apiscamelv1.TypeSlot]DataTypeReferenceApplyConfiguration `json:"dataTypes,omitempty"`
}
@@ -64,20 +63,6 @@ func (b *EndpointApplyConfiguration) WithProperties(value *EndpointPropertiesApp
return b
}
-// WithTypes puts the entries into the Types field in the declarative configuration
-// and returns the receiver, so that objects can be build by chaining "With" function invocations.
-// If called multiple times, the entries provided by each call will be put on the Types field,
-// overwriting an existing map entries in Types field with the same key.
-func (b *EndpointApplyConfiguration) WithTypes(entries map[apiscamelv1.TypeSlot]EventTypeSpecApplyConfiguration) *EndpointApplyConfiguration {
- if b.Types == nil && len(entries) > 0 {
- b.Types = make(map[apiscamelv1.TypeSlot]EventTypeSpecApplyConfiguration, len(entries))
- }
- for k, v := range entries {
- b.Types[k] = v
- }
- return b
-}
-
// WithDataTypes puts the entries into the DataTypes field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, the entries provided by each call will be put on the DataTypes field,
diff --git a/pkg/cmd/init.go b/pkg/cmd/init.go
deleted file mode 100644
index 9c41df9b6..000000000
--- a/pkg/cmd/init.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
- "text/template"
-
- "github.com/apache/camel-k/v2/pkg/util"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/resources"
- "github.com/spf13/cobra"
-)
-
-func newCmdInit(rootCmdOptions *RootCmdOptions) (*cobra.Command, *initCmdOptions) {
- options := initCmdOptions{
- RootCmdOptions: rootCmdOptions,
- }
- cmd := cobra.Command{
- Use: "init [flags] IntegrationFile.java",
- Short: "Initialize empty Camel K files",
- Long: `Initialize empty Camel K integrations and other resources.`,
- Deprecated: "consider using Camel JBang instead (https://camel.apache.org/manual/camel-jbang.html)",
- PreRunE: decode(&options),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.init(cmd, args); err != nil {
- return err
- }
- return nil
- },
- Annotations: map[string]string{
- offlineCommandLabel: "true",
- },
- }
-
- return &cmd, &options
-}
-
-type initCmdOptions struct {
- *RootCmdOptions
-}
-
-func (o *initCmdOptions) validate(_ *cobra.Command, args []string) error {
- if len(args) != 1 {
- return fmt.Errorf("init expects exactly 1 argument, received %d", len(args))
- }
-
- if fileName := args[0]; o.extractLanguage(fileName) == nil {
- return fmt.Errorf("unsupported file type: %s", fileName)
- }
-
- return nil
-}
-
-func (o *initCmdOptions) init(_ *cobra.Command, args []string) error {
- fileName := args[0]
- language := o.extractLanguage(fileName)
- return o.writeFromTemplate(*language, fileName)
-}
-
-func (o *initCmdOptions) writeFromTemplate(language v1.Language, fileName string) error {
- simpleName := filepath.Base(fileName)
- if idx := strings.Index(simpleName, "."); idx >= 0 {
- simpleName = simpleName[:idx]
- }
-
- type TemplateParameters struct {
- Name string
- }
- params := TemplateParameters{
- Name: simpleName,
- }
-
- rawData, err := resources.ResourceAsString(fmt.Sprintf("/templates/%s.tmpl", language))
- if err != nil {
- return err
- }
- if rawData == "" {
- return fmt.Errorf("cannot find template for language %s", string(language))
- }
- tmpl, err := template.New(string(language)).Parse(rawData)
- if err != nil {
- return err
- }
-
- return util.WithFile(fileName, os.O_RDWR|os.O_CREATE, 0o644, func(file *os.File) error {
- return tmpl.Execute(file, params)
- })
-}
-
-func (o *initCmdOptions) extractLanguage(fileName string) *v1.Language {
- if strings.HasSuffix(fileName, ".kamelet.yaml") {
- language := v1.LanguageKamelet
- return &language
- }
- for _, l := range v1.Languages {
- if strings.HasSuffix(fileName, fmt.Sprintf(".%s", string(l))) {
- return &l
- }
- }
- return nil
-}
diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go
index faafc2364..26fbcffa3 100644
--- a/pkg/cmd/install.go
+++ b/pkg/cmd/install.go
@@ -24,7 +24,6 @@ import (
"io"
"os"
"regexp"
- "strconv"
"strings"
"time"
@@ -113,9 +112,6 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
cmd.Flags().String("build-timeout", "", "Set how long the build process can last")
cmd.Flags().String("trait-profile", "", "The profile to use for traits")
- // Kaniko
- cmd.Flags().Bool("kaniko-build-cache", false, "To enable or disable the Kaniko cache. Deprecated use --build-publish-strategy-option KanikoBuildCacheEnabled=true instead")
-
// OLM
cmd.Flags().Bool("olm", true, "Try to install everything via OLM (Operator Lifecycle Manager) if available")
cmd.Flags().String("olm-operator-name", "", "Name of the Camel K operator in the OLM source or marketplace")
@@ -166,16 +162,14 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *installCmdO
type installCmdOptions struct {
*RootCmdOptions
- Wait bool `mapstructure:"wait"`
- ClusterSetupOnly bool `mapstructure:"cluster-setup"`
- SkipOperatorSetup bool `mapstructure:"skip-operator-setup"`
- SkipClusterSetup bool `mapstructure:"skip-cluster-setup"`
- SkipRegistrySetup bool `mapstructure:"skip-registry-setup"`
- SkipDefaultKameletsSetup bool `mapstructure:"skip-default-kamelets-setup"`
- ExampleSetup bool `mapstructure:"example"`
- Global bool `mapstructure:"global"`
- // Deprecated: use the BuildPublishStrategyOption "KanikoBuildCacheEnabled" instead
- KanikoBuildCache bool `mapstructure:"kaniko-build-cache"`
+ Wait bool `mapstructure:"wait"`
+ ClusterSetupOnly bool `mapstructure:"cluster-setup"`
+ SkipOperatorSetup bool `mapstructure:"skip-operator-setup"`
+ SkipClusterSetup bool `mapstructure:"skip-cluster-setup"`
+ SkipRegistrySetup bool `mapstructure:"skip-registry-setup"`
+ SkipDefaultKameletsSetup bool `mapstructure:"skip-default-kamelets-setup"`
+ ExampleSetup bool `mapstructure:"example"`
+ Global bool `mapstructure:"global"`
Save bool `mapstructure:"save" kamel:"omitsave"`
Force bool `mapstructure:"force"`
Olm bool `mapstructure:"olm"`
@@ -590,10 +584,6 @@ func (o *installCmdOptions) setupIntegrationPlatform(
}
}
}
- if platform.Spec.Build.PublishStrategy == v1.IntegrationPlatformBuildPublishStrategyKaniko && cmd.Flags().Lookup("kaniko-build-cache").Changed {
- fmt.Fprintln(cmd.OutOrStdout(), "Warn: the flag --kaniko-build-cache is deprecated, use --build-publish-strategy-option KanikoBuildCacheEnabled=true instead")
- platform.Spec.Build.AddOption(builder.KanikoBuildCacheEnabled, strconv.FormatBool(o.KanikoBuildCache))
- }
if len(o.BuildPublishStrategyOptions) > 0 {
if err = o.addBuildPublishStrategyOptions(&platform.Spec.Build); err != nil {
return nil, err
diff --git a/pkg/cmd/install_test.go b/pkg/cmd/install_test.go
index 0c53032a2..a34fdef83 100644
--- a/pkg/cmd/install_test.go
+++ b/pkg/cmd/install_test.go
@@ -66,7 +66,6 @@ func TestInstallNoFlag(t *testing.T) {
assert.Equal(t, false, installCmdOptions.SkipDefaultKameletsSetup)
assert.Equal(t, false, installCmdOptions.ExampleSetup)
assert.Equal(t, false, installCmdOptions.Global)
- assert.Equal(t, false, installCmdOptions.KanikoBuildCache)
assert.Equal(t, false, installCmdOptions.Save)
assert.Equal(t, false, installCmdOptions.Force)
assert.Equal(t, true, installCmdOptions.Olm)
@@ -157,13 +156,6 @@ func TestInstallHealthFlag(t *testing.T) {
assert.Equal(t, int32(7777), installCmdOptions.HealthPort)
}
-func TestInstallKanikoBuildCacheFlag(t *testing.T) {
- installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
- _, err := test.ExecuteCommand(rootCmd, cmdInstall, "--kaniko-build-cache")
- assert.Nil(t, err)
- assert.Equal(t, true, installCmdOptions.KanikoBuildCache)
-}
-
func TestInstallBuildPublishStrategyOptions(t *testing.T) {
installCmdOptions, rootCmd, _ := initializeInstallCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdInstall, "--build-publish-strategy-option", "foo1=bar1", "--build-publish-strategy-option", "foo2=bar2")
diff --git a/pkg/cmd/local.go b/pkg/cmd/local.go
deleted file mode 100644
index 4868defdf..000000000
--- a/pkg/cmd/local.go
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "fmt"
-
- "github.com/apache/camel-k/v2/pkg/util/camel"
- "github.com/spf13/cobra"
-)
-
-// Usage descritions of common flags that are shared across some of the subcommands.
-const (
- usageImage = `Full path to integration image including registry, e.g. "docker.io/user/app"`
- usageIntegrationDirectory = "Directory to hold local integration files"
- usagePropertyFile = "Add a property file to the integration"
- usageProperty = "Add a Camel property to the integration"
-)
-
-// newCmdLocal -- Add local kamel subcommand with several other subcommands of its own.
-func newCmdLocal(rootCmdOptions *RootCmdOptions) (*cobra.Command, *LocalCmdOptions) {
- options := LocalCmdOptions{
- RootCmdOptions: rootCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "local [sub-command]",
- Short: "Perform integration actions locally.",
- Long: `Perform integration actions locally given a set of input integration files.`,
- Deprecated: "consider using Camel JBang instead (https://camel.apache.org/manual/camel-jbang.html)",
- PersistentPreRunE: options.persistentPreRun,
- Annotations: map[string]string{
- offlineCommandLabel: "true",
- },
- }
-
- cmd.PersistentFlags().StringArrayVarP(&options.Dependencies, "dependency", "d", nil, usageDependency)
- cmd.PersistentFlags().StringArrayVar(&options.MavenRepositories, "maven-repository", nil,
- "Use a maven repository")
-
- // hidden flags for compatibility with kamel run
- cmd.PersistentFlags().StringArrayVarP(&options.Traits, "trait", "t", nil, "")
- if err := cmd.PersistentFlags().MarkHidden("trait"); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
-
- // completion support
- configureKnownCompletions(&cmd)
-
- cmd.AddCommand(cmdOnly(newCmdLocalBuild(&options)))
- cmd.AddCommand(cmdOnly(newCmdLocalInspect(&options)))
- cmd.AddCommand(cmdOnly(newCmdLocalRun(&options)))
-
- return &cmd, &options
-}
-
-type LocalCmdOptions struct {
- *RootCmdOptions
- Dependencies []string `mapstructure:"dependencies"`
- MavenRepositories []string `mapstructure:"maven-repositories"`
- Traits []string `mapstructure:"traits"`
-}
-
-func (o *LocalCmdOptions) persistentPreRun(cmd *cobra.Command, args []string) error {
- // pre-process dependencies
- for i, dependency := range o.Dependencies {
- o.Dependencies[i] = camel.NormalizeDependency(dependency)
- }
-
- // validate traits
- warnTraitUsages(cmd, o.Traits)
-
- return nil
-}
-
-func warnTraitUsages(cmd *cobra.Command, traits []string) {
- if len(traits) > 0 {
- fmt.Fprintf(cmd.ErrOrStderr(),
- "Warning: traits are specified but don't take effect for local run: %v\n", traits)
- }
-}
diff --git a/pkg/cmd/local/container.go b/pkg/cmd/local/container.go
deleted file mode 100644
index 12ab06b93..000000000
--- a/pkg/cmd/local/container.go
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 local
-
-import (
- "context"
- "errors"
- "fmt"
- "io"
- "os"
- "os/exec"
- "os/signal"
- "strings"
- "syscall"
-
- "github.com/apache/camel-k/v2/pkg/util"
- "github.com/apache/camel-k/v2/pkg/util/docker"
-)
-
-// Local Docker file system management functions.
-
-// CreateDockerBaseWorkingDirectory creates local docker base directory.
-func CreateDockerBaseWorkingDirectory() error {
- temporaryDirectory, err := os.MkdirTemp(os.TempDir(), "docker-base-")
- if err != nil {
- return err
- }
-
- // Set the Docker base directory to the default value.
- docker.BaseWorkingDirectory = temporaryDirectory
-
- return nil
-}
-
-// DeleteDockerBaseWorkingDirectory removes directory used for computing the base dependencies.
-func DeleteDockerBaseWorkingDirectory() error {
- return os.RemoveAll(docker.BaseWorkingDirectory)
-}
-
-// CreateDockerWorkingDirectory creates local docker directory.
-func CreateDockerWorkingDirectory() error {
- temporaryDirectory, err := os.MkdirTemp(os.TempDir(), "docker-")
- if err != nil {
- return err
- }
-
- // Set the Docker base directory to the default value.
- docker.IntegrationWorkingDirectory = temporaryDirectory
-
- return nil
-}
-
-// DeleteDockerWorkingDirectory removes directory used for computing the integration dependencies.
-func DeleteDockerWorkingDirectory() error {
- return os.RemoveAll(docker.IntegrationWorkingDirectory)
-}
-
-func SetDockerNetworkName(networkName string) {
- if networkName != "" {
- docker.NetworkName = networkName
- }
-}
-
-func SetDockerEnvVars(envVars []string) {
- if len(envVars) > 0 {
- util.CLIEnvVars = envVars
- }
-}
-
-func createAndBuildBaseImage(ctx context.Context, stdout, stderr io.Writer) error {
- // This ensures the Dockerfile for the base image will not end up in an undesired location.
- if docker.BaseWorkingDirectory == "" {
- return errors.New("base directory that holds the base image Dockerfile has not been set correctly")
- }
-
- // Create the base image Docker file.
- if err := docker.CreateBaseImageDockerFile(); err != nil {
- return err
- }
-
- return buildBaseImage(ctx, stdout, stderr)
-}
-
-func buildBaseImage(ctx context.Context, stdout, stderr io.Writer) error {
- // Get the Docker command arguments for building the base image and create the command.
- args := docker.BuildBaseImageArgs()
- cmd := exec.CommandContext(ctx, "docker", args...)
-
- // Set stdout and stderr.
- cmd.Stdout = stdout
- cmd.Stderr = stderr
-
- // Output executed command.
- fmt.Fprintln(cmd.Stdout, "Executing:", strings.Join(cmd.Args, " "))
-
- // Run the command.
- if err := cmd.Run(); err != nil {
- return fmt.Errorf("base image containerization did not run successfully: %w", err)
- }
-
- return nil
-}
-
-func setupDockerRegistry(containerRegistry string, image string, justBaseImage bool) error {
- docker.RegistryName = containerRegistry
- // If we build a normal image, i.e. not the base image, we need to parse
- // the location where images will be pushed.
- if !justBaseImage {
- registryName, err := docker.ExtractRegistryName(image)
- if err != nil {
- return err
- }
- docker.RegistryName = registryName
- }
-
- return nil
-}
-
-func CreateAndBuildIntegrationImage(ctx context.Context, containerRegistry string, justBaseImage bool, image string,
- propertyFiles []string, dependencies []string, routes []string, startsFromLocalFolder bool,
- stdout, stderr io.Writer) error {
- if err := setupDockerRegistry(containerRegistry, image, justBaseImage); err != nil {
- return err
- }
-
- // Create the Dockerfile and build the base image.
- if err := createAndBuildBaseImage(ctx, stdout, stderr); err != nil {
- return err
- }
-
- if justBaseImage {
- return nil
- }
-
- if docker.IntegrationWorkingDirectory == "" {
- return errors.New("integration directory that holds the image Dockerfile has not been set correctly")
- }
-
- // Create integration image if integration files were provided.
- // Copy dependencies to a dependencies folder under a local directory.
- if err := updateIntegrationDependencies(dependencies); err != nil {
- return err
- }
-
- // Copy routes to a routes folder under a local directory.
- if err := updateIntegrationRoutes(routes); err != nil {
- return err
- }
-
- // Copy quarkus files in maven subdirectory
- if err := updateQuarkusDirectory(); err != nil {
- return err
- }
-
- // Copy app files in maven subdirectory
- if err := updateAppDirectory(); err != nil {
- return err
- }
-
- // Copy lib files in maven subdirectory
- if err := updateLibDirectory(); err != nil {
- return err
- }
-
- // Get integration run command to be run inside the container. This means the command
- // has to be created with the paths which will be valid inside the container.
- containerCmd, err := getContainerIntegrationRunCommand(ctx, propertyFiles, dependencies, routes, stdout, stderr)
- if err != nil {
- return err
- }
-
- // Create the integration image Docker file.
- if err := docker.CreateIntegrationImageDockerFile(containerCmd, startsFromLocalFolder); err != nil {
- return err
- }
-
- return buildIntegrationImage(ctx, image, stdout, stderr)
-}
-
-func buildIntegrationImage(ctx context.Context, image string, stdout, stderr io.Writer) error {
- // Get the Docker command arguments for building the base image and create the command.
- args := docker.BuildIntegrationImageArgs(image, MavenWorkingDirectory)
- cmd := exec.CommandContext(ctx, "docker", args...)
-
- // Set stdout and stderr.
- cmd.Stderr = stderr
- cmd.Stdout = stdout
-
- // Output executed command.
- fmt.Fprintln(cmd.Stdout, "Executing:", strings.Join(cmd.Args, " "))
-
- // Run the command.
- if err := cmd.Run(); err != nil {
- return fmt.Errorf("integration image containerization did not run successfully: %w", err)
- }
-
- return nil
-}
-
-func RunIntegrationImage(ctx context.Context, image string, stdout, stderr io.Writer) error {
- // Stop the child process before exiting
- dockerCtx, cancel := context.WithCancel(ctx)
- cs := make(chan os.Signal, 1)
- signal.Notify(cs, os.Interrupt, syscall.SIGTERM)
- go func() {
- <-cs
- cancel()
- }()
-
- // Get the docker command line argument for running an image.
- args, err := docker.RunIntegrationImageArgs(image)
- if err != nil {
- return err
- }
-
- cmd := exec.CommandContext(dockerCtx, "docker", args...)
-
- // Set stdout and stderr.
- cmd.Stderr = stderr
- cmd.Stdout = stdout
-
- // Output executed command.
- fmt.Fprintln(cmd.Stdout, "Executing:", strings.Join(cmd.Args, " "))
-
- // Run the command.
- if err := cmd.Run(); err != nil {
- return fmt.Errorf("integration image did not run successfully: %w", err)
- }
-
- return nil
-}
-
-// getContainerIntegrationRunCommand returns the integration command which will be run inside the container.
-func getContainerIntegrationRunCommand(ctx context.Context, properties []string, dependencies []string, routes []string,
- stdout, stderr io.Writer) (*exec.Cmd, error) {
- // All paths need to be valid container paths.
- // Update property file paths.
- containerProperties := docker.ContainerizeFilePaths(properties, docker.GetContainerPropertiesDir())
- containerDependencies := docker.ContainerizeDependencyPaths(dependencies, docker.GetContainerDependenciesDir())
- containerRoutes := docker.ContainerizeFilePaths(routes, docker.GetContainerRoutesDir())
-
- return assembleIntegrationRunCommand(ctx, containerProperties, containerDependencies, containerRoutes,
- docker.GetContainerPropertiesDir(), stdout, stderr, false)
-}
-
-func RunLocalIntegration(ctx context.Context, properties []string, dependencies []string, routes []string,
- propertiesDir string, stdout, stderr io.Writer) error {
- cmd, err := assembleIntegrationRunCommand(ctx, properties, dependencies, routes,
- propertiesDir, stdout, stderr, true)
- if err != nil {
- return err
- }
-
- // Output command we are about to run.
- fmt.Fprintln(cmd.Stdout, "Executing:", strings.Join(cmd.Args, " "))
-
- // Run integration locally.
- return cmd.Run()
-}
-
-func assembleIntegrationRunCommand(ctx context.Context, properties []string, dependencies []string, routes []string,
- propertiesDir string, stdout, stderr io.Writer, local bool) (*exec.Cmd, error) {
- // Create classpath value.
- classpathValue := assembleClasspathArgValue(properties, dependencies, routes)
-
- // Create java command that runs the integration.
- javaCmd := "java"
-
- // Create java command arguments.
- args := make([]string, 0)
- args = append(args, "-cp")
- args = append(args, classpathValue)
- args = append(args, "io.quarkus.bootstrap.runner.QuarkusEntryPoint")
-
- cmd := exec.CommandContext(ctx, javaCmd, args...)
-
- // Add directory where the properties files reside. The directory is the local properties directory
- // or the properties directory inside the container.
- cmd.Env = append(cmd.Env, "CAMEL_K_CONF_D="+propertiesDir)
-
- // Add files to the command line under the CAMEL_K_ROUTES flag.
- cmd.Env = append(cmd.Env, "CAMEL_K_ROUTES="+strings.Join(formatRoutes(routes), ","))
-
- // Add any lazily evaluated environment variables.
- if local {
- // If we are running locally then this is as late as we can evaluate the
- // lazy environment variables since we are going to run the command
- // immediately after the generation of these arguments.
- setEnvVars, err := util.EvaluateCLIAndLazyEnvVars()
- if err != nil {
- return nil, err
- }
- cmd.Env = append(cmd.Env, setEnvVars...)
- } else {
- // If we are running in containerized or just building an image, we should
- // not evaluate the variables at this point since we are only generating the
- // run command and not actually running it.
- for _, lazyEnvVar := range util.ListOfLazyEvaluatedEnvVars {
- cmd.Env = append(cmd.Env, lazyEnvVar+"={{env:"+lazyEnvVar+"}}")
- }
- }
-
- // Set stdout and stderr.
- cmd.Stderr = stderr
- cmd.Stdout = stdout
-
- return cmd, nil
-}
-
-func assembleClasspathArgValue(properties []string, dependencies []string, routes []string) string {
- classpathContents := []string{}
- classpathContents = append(classpathContents, properties...)
- classpathContents = append(classpathContents, routes...)
- classpathContents = append(classpathContents, dependencies...)
- return strings.Join(classpathContents, string(os.PathListSeparator))
-}
-
-func formatRoutes(files []string) []string {
- routes := []string{}
- for _, route := range files {
- // Split route path.
- a := strings.Split(route, ".")
-
- // Extract extension.
- extension := a[len(a)-1]
-
- // Add file with extension.
- routes = append(routes, "file:"+route+"?language="+extension)
- }
-
- return routes
-}
diff --git a/pkg/cmd/local/local.go b/pkg/cmd/local/local.go
deleted file mode 100644
index ed2664353..000000000
--- a/pkg/cmd/local/local.go
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 local
-
-import (
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "os"
- "path/filepath"
- "sort"
- "strings"
-
- "github.com/scylladb/go-set/strset"
- "github.com/spf13/cobra"
-
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/builder"
- "github.com/apache/camel-k/v2/pkg/cmd/source"
- "github.com/apache/camel-k/v2/pkg/trait"
- "github.com/apache/camel-k/v2/pkg/util"
- "github.com/apache/camel-k/v2/pkg/util/camel"
- "github.com/apache/camel-k/v2/pkg/util/defaults"
- "github.com/apache/camel-k/v2/pkg/util/maven"
-)
-
-var acceptedDependencyTypes = []string{
- "bom", "camel", "camel-k", "camel-quarkus", "mvn",
- // jitpack
- "github", "gitlab", "bitbucket", "gitee", "azure",
-}
-
-// GetDependencies resolves and gets the list of dependencies from catalog and sources.
-func GetDependencies(ctx context.Context, cmd *cobra.Command, srcs, userDependencies, repositories []string,
- allDependencies bool) ([]string, error) {
- // Fetch existing catalog or create new one if one does not already exist
- catalog, err := CreateCamelCatalog(ctx)
- if err != nil {
- return nil, fmt.Errorf("failed to create Camel catalog: %w", err)
- }
-
- // Validate user-provided dependencies against Camel catalog
- camel.ValidateDependencies(catalog, userDependencies, cmd)
-
- // Get top-level dependencies from sources
- dependencies, err := getTopLevelDependencies(ctx, catalog, srcs)
- if err != nil {
- return nil, fmt.Errorf("failed to resolve dependencies from source: %w", err)
- }
-
- // Add additional user-provided dependencies
- dependencies = append(dependencies, userDependencies...)
-
- // Compute transitive dependencies
- if allDependencies {
- // Add runtime dependency since this dependency is always required for running
- // an integration. Only add this dependency if it has not been added already.
- for _, runtimeDep := range catalog.Runtime.Dependencies {
- util.StringSliceUniqueAdd(&dependencies, runtimeDep.GetDependencyID())
- }
-
- dependencies, err = getTransitiveDependencies(ctx, catalog, dependencies, repositories)
- if err != nil {
- return nil, fmt.Errorf("failed to compute transitive dependencies: %w", err)
- }
- }
-
- return dependencies, nil
-}
-
-// getTopLevelDependencies gets top-level dependencies from sources.
-func getTopLevelDependencies(ctx context.Context, catalog *camel.RuntimeCatalog, srcs []string) ([]string, error) {
- // List of top-level dependencies
- dependencies := strset.New()
-
- // Invoke the dependency inspector code for each source file
- for _, src := range srcs {
- data, _, _, err := source.LoadTextContent(ctx, src, false)
- if err != nil {
- return []string{}, err
- }
-
- sourceSpec := v1.SourceSpec{
- DataSpec: v1.DataSpec{
- Name: filepath.Base(src),
- Content: data,
- Compression: false,
- },
- }
-
- // Extract list of top-level dependencies
- srcDeps, err := trait.ExtractSourceDependencies(sourceSpec, catalog)
- if err != nil {
- return nil, err
- }
- dependencies.Merge(srcDeps)
- }
-
- return dependencies.List(), nil
-}
-
-func getTransitiveDependencies(ctx context.Context, catalog *camel.RuntimeCatalog, dependencies []string, repositories []string) ([]string, error) {
- project := builder.GenerateQuarkusProjectCommon(
- defaults.DefaultRuntimeVersion,
- catalog.GetQuarkusVersion(),
- make(map[string]string),
- )
-
- if err := camel.ManageIntegrationDependencies(&project, dependencies, catalog); err != nil {
- return nil, err
- }
-
- mc := maven.NewContext(MavenWorkingDirectory)
- mc.LocalRepository = ""
-
- if len(repositories) > 0 {
- settings, err := maven.NewSettings(maven.DefaultRepositories, maven.Repositories(repositories...))
- if err != nil {
- return nil, err
- }
- settingsData, err := util.EncodeXML(settings)
- if err != nil {
- return nil, err
- }
- mc.UserSettings = settingsData
- }
-
- // Make maven command less verbose
- mc.AdditionalArguments = append(mc.AdditionalArguments, "-q")
-
- if err := builder.BuildQuarkusRunnerCommon(ctx, mc, project); err != nil {
- return nil, err
- }
-
- // Compose artifacts list
- artifacts, err := builder.ProcessQuarkusTransitiveDependencies(mc)
- if err != nil {
- return nil, err
- }
-
- // Dump dependencies in the dependencies directory and construct the list of dependencies
- transitiveDependencies := []string{}
- for _, entry := range artifacts {
- transitiveDependencies = append(transitiveDependencies, entry.Location)
- }
- return transitiveDependencies, nil
-}
-
-func getRegularFilesInDir(directory string, dirnameInPath bool) ([]string, error) {
- var dirFiles []string
- files, err := os.ReadDir(directory)
- if err != nil {
- return nil, err
- }
-
- for _, file := range files {
- fileName := file.Name()
-
- // Do not include hidden files or sub-directories.
- if !file.IsDir() && !strings.HasPrefix(fileName, ".") {
- if dirnameInPath {
- dirFiles = append(dirFiles, filepath.Join(directory, fileName))
- } else {
- dirFiles = append(dirFiles, fileName)
- }
- }
- }
-
- return dirFiles, nil
-}
-
-func GetBuildDependencies(integrationDirectory string) ([]string, error) {
- locallyBuiltDependencies, err := getRegularFilesInDir(GetCustomDependenciesDir(integrationDirectory), true)
- if err != nil {
- return nil, err
- }
- return locallyBuiltDependencies, nil
-}
-
-func GetBuildProperties(integrationDirectory string) ([]string, error) {
- locallyBuiltProperties, err := getRegularFilesInDir(GetCustomPropertiesDir(integrationDirectory), true)
- if err != nil {
- return nil, err
- }
- return locallyBuiltProperties, nil
-}
-
-func GetBuildRoutes(integrationDirectory string) ([]string, error) {
- locallyBuiltRoutes, err := getRegularFilesInDir(GetCustomRoutesDir(integrationDirectory), true)
- if err != nil {
- return nil, err
- }
- return locallyBuiltRoutes, nil
-}
-
-func generateCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
- // A Camel catalog is required for this operation
- mvn := v1.MavenSpec{
- LocalRepository: "",
- }
- runtime := v1.RuntimeSpec{
- Version: defaults.DefaultRuntimeVersion,
- Provider: v1.RuntimeProviderQuarkus,
- }
- var providerDependencies []maven.Dependency
- var caCert [][]byte
- catalog, err := camel.GenerateCatalogCommon(ctx, nil, nil, caCert, mvn, runtime, providerDependencies)
- if err != nil {
- return nil, err
- }
-
- return catalog, nil
-}
-
-func CreateCamelCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
- // Attempt to reuse existing Camel catalog if one is present
- catalog, err := camel.DefaultCatalog()
- if err != nil {
- return nil, err
- }
-
- // Generate catalog if one was not found
- if catalog == nil {
- catalog, err = generateCatalog(ctx)
- if err != nil {
- return nil, err
- }
- }
-
- return catalog, nil
-}
-
-func OutputDependencies(dependencies []string, format string, cmd *cobra.Command) error {
- sort.Strings(dependencies)
- if format != "" {
- if err := printDependencies(format, dependencies, cmd); err != nil {
- return err
- }
- } else {
- // Print output in text form
- fmt.Fprintln(cmd.OutOrStdout(), "dependencies:")
- for _, dep := range dependencies {
- fmt.Fprintln(cmd.OutOrStdout(), dep)
- }
- }
-
- return nil
-}
-
-func printDependencies(format string, dependencies []string, cmd *cobra.Command) error {
- switch format {
- case "yaml":
- data, err := dependenciesToYAML(dependencies)
- if err != nil {
- return err
- }
- fmt.Fprint(cmd.OutOrStdout(), string(data))
- case "json":
- data, err := dependenciesToJSON(dependencies)
- if err != nil {
- return err
- }
- fmt.Fprint(cmd.OutOrStdout(), string(data))
- default:
- return fmt.Errorf("unknown output format: %s", format)
- }
- return nil
-}
-
-func dependenciesToJSON(list []string) ([]byte, error) {
- jsondata := map[string]interface{}{}
- jsondata["dependencies"] = list
- return json.Marshal(jsondata)
-}
-
-func dependenciesToYAML(list []string) ([]byte, error) {
- data, err := dependenciesToJSON(list)
- if err != nil {
- return nil, err
- }
-
- return util.JSONToYAML(data)
-}
-
-func validateFile(file string) error {
- fileExists, err := util.FileExists(file)
- if err != nil {
- return err
- }
-
- if !fileExists {
- return errors.New("File " + file + " file does not exist")
- }
-
- return nil
-}
-
-// ValidateFiles ensures existence of given files.
-func ValidateFiles(args []string) error {
- // Ensure source files exist
- for _, arg := range args {
- err := validateFile(arg)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// ValidateDependencies validates list of additional dependencies i.e. makes sure
-// that each dependency has a valid type.
-func ValidateDependencies(dependencies []string) error {
- for _, dependency := range dependencies {
- depType := strings.Split(dependency, ":")[0]
- if !util.StringSliceExists(acceptedDependencyTypes, depType) {
- return fmt.Errorf("dependency is not valid: %s", dependency)
- }
- }
-
- return nil
-}
-
-func ValidatePropertyFiles(propertyFiles []string) error {
- for _, fileName := range propertyFiles {
- if err := validatePropertyFile(fileName); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func validatePropertyFile(fileName string) error {
- if !strings.HasSuffix(fileName, ".properties") {
- return fmt.Errorf("supported property files must have a .properties extension: %s", fileName)
- }
-
- if file, err := os.Stat(fileName); err != nil {
- return fmt.Errorf("unable to access property file %s: %w", fileName, err)
- } else if file.IsDir() {
- return fmt.Errorf("property file %s is a directory", fileName)
- }
-
- return nil
-}
-
-func UpdateIntegrationProperties(properties []string, propertyFiles []string, hasIntegrationDir bool) ([]string, error) {
- // Create properties directory under Maven working directory.
- // This ensures that property files of different integrations do not clash.
- if err := CreateLocalPropertiesDirectory(); err != nil {
- return nil, err
- }
-
- // Relocate properties files to this integration's property directory.
- relocatedPropertyFiles := []string{}
- dir := GetLocalPropertiesDir()
- for _, propertyFile := range propertyFiles {
- relocatedPropertyFile := filepath.Join(dir, filepath.Base(propertyFile))
- if _, err := util.CopyFile(propertyFile, relocatedPropertyFile); err != nil {
- return nil, err
- }
- relocatedPropertyFiles = append(relocatedPropertyFiles, relocatedPropertyFile)
- }
-
- if !hasIntegrationDir {
- // Output list of properties to property file if any CLI properties were given.
- if len(properties) > 0 {
- propertyFilePath := filepath.Join(dir, "CLI.properties")
- if err := os.WriteFile(propertyFilePath, []byte(strings.Join(properties, "\n")), 0o600); err != nil {
- return nil, err
- }
- relocatedPropertyFiles = append(relocatedPropertyFiles, propertyFilePath)
- }
- }
-
- return relocatedPropertyFiles, nil
-}
-
-func updateIntegrationDependencies(dependencies []string) error {
- // Create dependencies directory under Maven working directory.
- // This ensures that dependencies will be removed after they are not needed.
- if err := createLocalDependenciesDirectory(); err != nil {
- return err
- }
-
- // Relocate dependencies files to this integration's dependencies directory
- dir := getLocalDependenciesDir()
- for _, dependency := range dependencies {
- var targetPath string
- basePath := util.SubstringFrom(dependency, util.QuarkusDependenciesBaseDirectory)
- if basePath != "" {
- targetPath = filepath.Join(dir, basePath)
- } else {
- targetPath = filepath.Join(dir, filepath.Base(dependency))
- }
- if _, err := util.CopyFile(dependency, targetPath); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func updateIntegrationRoutes(routes []string) error {
- if err := createLocalRoutesDirectory(); err != nil {
- return err
- }
-
- dir := getLocalRoutesDir()
- for _, route := range routes {
- if _, err := util.CopyFile(route, filepath.Join(dir, filepath.Base(route))); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func updateQuarkusDirectory() error {
- if err := createLocalQuarkusDirectory(); err != nil {
- return err
- }
-
- // ignore error if custom dir doesn't exist
- _ = CopyQuarkusAppFiles(util.CustomQuarkusDirectoryName, getLocalQuarkusDir())
-
- return nil
-}
-
-func updateAppDirectory() error {
- if err := createLocalAppDirectory(); err != nil {
- return err
- }
-
- // ignore error if custom dir doesn't exist
- _ = CopyAppFile(util.CustomAppDirectoryName, getLocalAppDir())
-
- return nil
-}
-
-func updateLibDirectory() error {
- if err := createLocalLibDirectory(); err != nil {
- return err
- }
-
- // ignore error if custom dir doesn't exist
- _ = CopyLibFiles(util.CustomLibDirectoryName, getLocalLibDir())
-
- return nil
-}
-
-func CopyIntegrationFilesToDirectory(files []string, directory string) ([]string, error) {
- // Create directory if one does not already exist
- if err := util.CreateDirectory(directory); err != nil {
- return nil, err
- }
-
- // Copy files to new location. Also create the list with relocated files.
- relocatedFilesList := []string{}
- for _, filePath := range files {
- newFilePath := filepath.Join(directory, filepath.Base(filePath))
- if _, err := util.CopyFile(filePath, newFilePath); err != nil {
- return relocatedFilesList, err
- }
- relocatedFilesList = append(relocatedFilesList, newFilePath)
- }
-
- return relocatedFilesList, nil
-}
-
-func CopyQuarkusAppFiles(dependenciesDir string, quarkusDir string) error {
- // Create directory if one does not already exist
- if err := util.CreateDirectory(quarkusDir); err != nil {
- return err
- }
-
- // Transfer all files with a .dat extension and all files with a *-bytecode.jar suffix.
- files, err := getRegularFilesInDir(dependenciesDir, false)
- if err != nil {
- return err
- }
- for _, file := range files {
- if strings.HasSuffix(file, ".dat") || strings.HasSuffix(file, "-bytecode.jar") {
- source := filepath.Join(dependenciesDir, file)
- destination := filepath.Join(quarkusDir, file)
- if _, err = util.CopyFile(source, destination); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-func CopyLibFiles(dependenciesDir string, libDir string) error {
- // Create directory if one does not already exist
- if err := util.CreateDirectory(libDir); err != nil {
- return err
- }
-
- fileNames, err := getRegularFilesInDir(dependenciesDir, false)
- if err != nil {
- return err
- }
-
- for _, dependencyJar := range fileNames {
- source := filepath.Join(dependenciesDir, dependencyJar)
- destination := filepath.Join(libDir, dependencyJar)
- if _, err = util.CopyFile(source, destination); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func CopyAppFile(dependenciesDir string, appDir string) error {
- // Create directory if one does not already exist
- if err := util.CreateDirectory(appDir); err != nil {
- return err
- }
-
- fileNames, err := getRegularFilesInDir(dependenciesDir, false)
- if err != nil {
- return err
- }
-
- for _, dependencyJar := range fileNames {
- if strings.HasPrefix(dependencyJar, "camel-k-integration-") {
- source := filepath.Join(dependenciesDir, dependencyJar)
- destination := filepath.Join(appDir, dependencyJar)
- if _, err = util.CopyFile(source, destination); err != nil {
- return err
- }
- }
- }
-
- return nil
-}
diff --git a/pkg/cmd/local/local_test.go b/pkg/cmd/local/local_test.go
deleted file mode 100644
index ef6f53c09..000000000
--- a/pkg/cmd/local/local_test.go
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 local
-
-import (
- "os"
- "strings"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestValidatePropertyFiles_ShouldSucceed(t *testing.T) {
- var tmpFile1 *os.File
- var err error
- if tmpFile1, err = os.CreateTemp("", "camel-k-*.properties"); err != nil {
- t.Error(err)
- }
-
- assert.Nil(t, tmpFile1.Close())
- assert.Nil(t, os.WriteFile(tmpFile1.Name(), []byte("key=value"), 0o400))
-
- inputValues := []string{tmpFile1.Name()}
- err = ValidatePropertyFiles(inputValues)
-
- assert.Nil(t, err)
-}
-
-func TestValidatePropertyFiles_ShouldFailNotAPropertiesFile(t *testing.T) {
- var tmpFile1 *os.File
- var err error
- if tmpFile1, err = os.CreateTemp("", "camel-k-"); err != nil {
- t.Error(err)
- }
-
- assert.Nil(t, tmpFile1.Close())
- assert.Nil(t, os.WriteFile(tmpFile1.Name(), []byte("key=value"), 0o400))
-
- inputValues := []string{tmpFile1.Name()}
- err = ValidatePropertyFiles(inputValues)
-
- assert.NotNil(t, err)
- assert.True(t, strings.HasPrefix(err.Error(), "supported property files must have a .properties extension"))
-}
-
-func TestValidatePropertyFiles_ShouldFailNotFound(t *testing.T) {
- inputValues := []string{"/tmp/not-found.properties"}
- err := ValidatePropertyFiles(inputValues)
-
- assert.NotNil(t, err)
- assert.True(t, strings.HasPrefix(err.Error(), "unable to access property file"))
-}
diff --git a/pkg/cmd/local/workdir.go b/pkg/cmd/local/workdir.go
deleted file mode 100644
index 97ddbde80..000000000
--- a/pkg/cmd/local/workdir.go
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 local
-
-import (
- "os"
- "path"
- "path/filepath"
- "strings"
-
- "github.com/apache/camel-k/v2/pkg/util"
-)
-
-// MavenWorkingDirectory is the directory used by Maven for an invocation of the kamel local command.
-// By default, a temporary folder will be used.
-var MavenWorkingDirectory = ""
-
-// CreateMavenWorkingDirectory creates local Maven working directory.
-func CreateMavenWorkingDirectory() error {
- temporaryDirectory, err := os.MkdirTemp(os.TempDir(), "maven-")
- if err != nil {
- return err
- }
-
- // Set the Maven directory to the default value
- MavenWorkingDirectory = temporaryDirectory
-
- return nil
-}
-
-// DeleteMavenWorkingDirectory removes local Maven working directory.
-func DeleteMavenWorkingDirectory() error {
- return os.RemoveAll(MavenWorkingDirectory)
-}
-
-// getLocalDependenciesDir returns <mavenWorkingDirectory>/dependencies.
-func getLocalDependenciesDir() string {
- return filepath.Join(MavenWorkingDirectory, util.DefaultDependenciesDirectoryName)
-}
-
-func createLocalDependenciesDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(getLocalDependenciesDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- if err := os.MkdirAll(getLocalDependenciesDir(), 0o700); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// GetLocalPropertiesDir returns <mavenWorkingDirectory>/properties.
-func GetLocalPropertiesDir() string {
- return filepath.Join(MavenWorkingDirectory, util.DefaultPropertiesDirectoryName)
-}
-
-func CreateLocalPropertiesDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(GetLocalPropertiesDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- err := os.MkdirAll(GetLocalPropertiesDir(), 0o700)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// getLocalRoutesDir returns <mavenWorkingDirectory>/routes.
-func getLocalRoutesDir() string {
- return filepath.Join(MavenWorkingDirectory, util.DefaultRoutesDirectoryName)
-}
-
-func createLocalRoutesDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(getLocalRoutesDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- if err := os.MkdirAll(getLocalRoutesDir(), 0o700); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// getLocalQuarkusDir returns <mavenWorkingDirectory>/quarkus.
-func getLocalQuarkusDir() string {
- return filepath.Join(MavenWorkingDirectory, util.CustomQuarkusDirectoryName)
-}
-
-func createLocalQuarkusDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(getLocalQuarkusDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- if err := os.MkdirAll(getLocalQuarkusDir(), 0o700); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// getLocalAppDir returns <mavenWorkingDirectory>/app.
-func getLocalAppDir() string {
- return filepath.Join(MavenWorkingDirectory, util.CustomAppDirectoryName)
-}
-
-func createLocalAppDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(getLocalAppDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- if err := os.MkdirAll(getLocalAppDir(), 0o700); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-// getLocalLibDir returns <mavenWorkingDirectory>/lib/main.
-func getLocalLibDir() string {
- return filepath.Join(MavenWorkingDirectory, util.CustomLibDirectoryName)
-}
-
-func createLocalLibDirectory() error {
- // Do not create a directory unless the maven directory contains a valid value.
- if MavenWorkingDirectory == "" {
- return nil
- }
-
- directoryExists, err := util.DirectoryExists(getLocalLibDir())
- if err != nil {
- return err
- }
-
- if !directoryExists {
- if err := os.MkdirAll(getLocalLibDir(), 0o700); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func GetCustomDependenciesDir(dir string) string {
- return filepath.Join(dir, util.DefaultDependenciesDirectoryName)
-}
-
-func GetCustomPropertiesDir(dir string) string {
- return filepath.Join(dir, util.DefaultPropertiesDirectoryName)
-}
-
-func GetCustomRoutesDir(dir string) string {
- return filepath.Join(dir, util.DefaultRoutesDirectoryName)
-}
-
-func GetCustomQuarkusDir(dir string) string {
- parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return filepath.Join(parentDir, util.CustomQuarkusDirectoryName)
-}
-
-func GetCustomLibDir(dir string) string {
- parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return filepath.Join(parentDir, util.CustomLibDirectoryName)
-}
-
-func GetCustomAppDir(dir string) string {
- parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return filepath.Join(parentDir, "app")
-}
-
-func DeleteLocalIntegrationDirs(dir string) error {
- dirs := []string{
- GetCustomQuarkusDir(dir),
- GetCustomLibDir(dir),
- GetCustomAppDir(dir),
- }
-
- for _, dir := range dirs {
- err := os.RemoveAll(dir)
- if err != nil {
- return err
- }
- }
-
- return nil
-}
diff --git a/pkg/cmd/local_build.go b/pkg/cmd/local_build.go
deleted file mode 100644
index ef6136cc7..000000000
--- a/pkg/cmd/local_build.go
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "errors"
- "fmt"
-
- "github.com/spf13/cobra"
-
- "github.com/apache/camel-k/v2/pkg/cmd/local"
- "github.com/apache/camel-k/v2/pkg/util"
-)
-
-func newCmdLocalBuild(localCmdOptions *LocalCmdOptions) (*cobra.Command, *localBuildCmdOptions) {
- options := localBuildCmdOptions{
- LocalCmdOptions: localCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "build [options]",
- Short: "Build integration images locally.",
- Long: `Build integration images locally for containerized integrations.`,
- Deprecated: "it may be removed in future versions",
- PreRunE: decode(&options),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(cmd, args); err != nil {
- return err
- }
- if err := options.init(args); err != nil {
- return err
- }
- defer func() {
- if err := options.deinit(); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
- }()
- return options.run(cmd, args)
- },
- Annotations: map[string]string{
- offlineCommandLabel: "true",
- },
- }
-
- cmd.Flags().Bool("base-image", false, "Build base image used as a starting point for any integration")
- cmd.Flags().Bool("dependencies-only", false,
- "Only output the integration dependencies. The integration-directory flag must be set.")
- cmd.Flags().String("container-registry", "",
- "Registry that holds intermediate images. This flag should only be used in conjunction with the base-image flag.")
- cmd.Flags().String("image", "", usageImage)
- cmd.Flags().String("integration-directory", "", usageIntegrationDirectory)
- cmd.Flags().StringArray("property-file", nil, usagePropertyFile)
- cmd.Flags().StringArrayP("property", "p", nil, usageProperty)
-
- return &cmd, &options
-}
-
-type localBuildCmdOptions struct {
- *LocalCmdOptions
- BaseImage bool `mapstructure:"base-image"`
- DependenciesOnly bool `mapstructure:"dependencies-only"`
- ContainerRegistry string `mapstructure:"container-registry"`
- Image string `mapstructure:"image"`
- IntegrationDirectory string `mapstructure:"integration-directory"`
- Properties []string `mapstructure:"properties"`
- PropertyFiles []string `mapstructure:"property-files"`
-}
-
-func (o *localBuildCmdOptions) validate(cmd *cobra.Command, args []string) error {
- if o.BaseImage {
- return o.validateBaseImageMode(cmd, args)
- }
-
- return o.validateIntegrationMode(args)
-}
-
-func (o *localBuildCmdOptions) validateBaseImageMode(cmd *cobra.Command, args []string) error {
- // Cannot have both integration files and the base image construction enabled.
- if len(args) > 0 {
- return errors.New("cannot use --base-image with integration files")
- }
-
- // Docker registry must be set.
- if o.ContainerRegistry == "" {
- return errors.New("--base-image requires --container-registry")
- }
-
- // If an integration directory is provided then no base image containerization can be enabled.
- if o.IntegrationDirectory != "" {
- return errors.New("cannot use --integration-directory with --base-image")
- }
-
- if o.DependenciesOnly {
- return errors.New("cannot use --dependencies-only with --base-image")
- }
-
- if len(o.Dependencies) > 0 || len(o.PropertyFiles) > 0 || len(o.Properties) > 0 {
- fmt.Fprintln(cmd.OutOrStdout(),
- "Warning: --dependency, --property, and --property-file are ignored in --base-image mode")
- }
-
- return nil
-}
-
-func (o *localBuildCmdOptions) validateIntegrationMode(args []string) error {
- if len(args) == 0 {
- if o.IntegrationDirectory == "" {
- return errors.New("either integration files, --integration-directory, or --base-image must be provided")
- }
- } else {
- if o.IntegrationDirectory == "" && o.Image == "" {
- return errors.New("either --integration-directory or --image must be provided with integration files")
- }
- }
-
- if o.ContainerRegistry != "" {
- // ContainerRegistry should only be specified when building the base image.
- return errors.New("--container-registry must be used with --base-image")
- }
-
- // The integration directory must be set when only outputting dependencies.
- if o.DependenciesOnly && o.IntegrationDirectory == "" {
- return errors.New("--dependencies-only requires --integration-directory")
- }
-
- // Validate integration files.
- if err := local.ValidateFiles(args); err != nil {
- return err
- }
-
- // Validate additional dependencies specified by the user.
- if err := local.ValidateDependencies(o.Dependencies); err != nil {
- return err
- }
-
- // Validate properties file.
- if err := local.ValidateFiles(o.PropertyFiles); err != nil {
- return err
- }
-
- return nil
-}
-
-func (o *localBuildCmdOptions) init(args []string) error {
- // Create integration directory if one is provided.
- if o.IntegrationDirectory != "" {
- if err := util.CreateDirectory(o.IntegrationDirectory); err != nil {
- return err
- }
- }
-
- if o.BaseImage || o.Image != "" {
- // If base image construction is enabled create a directory for it.
- if err := local.CreateDockerBaseWorkingDirectory(); err != nil {
- return err
- }
-
- // If integration image construction is enabled, an integration image will be built.
- if o.Image != "" {
- if err := local.CreateDockerWorkingDirectory(); err != nil {
- return err
- }
- }
- }
-
- return local.CreateMavenWorkingDirectory()
-}
-
-func (o *localBuildCmdOptions) run(cmd *cobra.Command, args []string) error {
- var dependenciesList, propertyFilesList []string
- routeFiles := args
-
- if !o.BaseImage {
- dependencies, err := local.GetDependencies(o.Context, cmd, args, o.Dependencies, o.MavenRepositories, true)
- if err != nil {
- return err
- }
-
- var propertyFiles []string
- if !o.DependenciesOnly {
- // Manage integration properties which may come from files or CLI
- propertyFiles, err = local.UpdateIntegrationProperties(o.Properties, o.PropertyFiles, false)
- if err != nil {
- return err
- }
- }
-
- dependenciesList = dependencies
- propertyFilesList = propertyFiles
-
- // Integration directory can only be used when building an integration image or when we just
- // build the integration without also building the image. A local build of the integration is
- // represented by all the files that define the integration: dependencies, properties, and routes.
- if o.IntegrationDirectory != "" {
- localDependenciesDir := local.GetCustomDependenciesDir(o.IntegrationDirectory)
- dependenciesList, err = local.CopyIntegrationFilesToDirectory(dependencies, localDependenciesDir)
- if err != nil {
- return err
- }
-
- if o.DependenciesOnly {
- // Once dependencies have been copied to local folder, we can exit.
- return nil
- }
-
- localPropertiesDir := local.GetCustomPropertiesDir(o.IntegrationDirectory)
- propertyFilesList, err = local.CopyIntegrationFilesToDirectory(propertyFiles, localPropertiesDir)
- if err != nil {
- return err
- }
-
- localRoutesDir := local.GetCustomRoutesDir(o.IntegrationDirectory)
- routeFiles, err = local.CopyIntegrationFilesToDirectory(args, localRoutesDir)
- if err != nil {
- return err
- }
-
- // The only case in which we should not execute the integration image creation is when we want to
- // just output the files that comprise the integration locally.
- if o.Image == "" {
- fmt.Fprintf(cmd.OutOrStdout(),
- "Integration directory generated: %s\n", o.IntegrationDirectory)
- return nil
- }
- }
- }
-
- if err := local.CreateAndBuildIntegrationImage(o.Context, o.ContainerRegistry, o.BaseImage, o.Image,
- propertyFilesList, dependenciesList, routeFiles, false,
- cmd.OutOrStdout(), cmd.ErrOrStderr()); err != nil {
- return err
- }
-
- return nil
-}
-
-func (o *localBuildCmdOptions) deinit() error {
- // If base image construction is enabled delete the directory for it.
- if err := local.DeleteDockerBaseWorkingDirectory(); err != nil {
- return err
- }
-
- // If integration files are provided delete the maven project folder.
- if !o.BaseImage {
- if err := local.DeleteDockerWorkingDirectory(); err != nil {
- return err
- }
- if err := local.DeleteMavenWorkingDirectory(); err != nil {
- return err
- }
- }
-
- return nil
-}
diff --git a/pkg/cmd/local_build_test.go b/pkg/cmd/local_build_test.go
deleted file mode 100644
index 1494c55f9..000000000
--- a/pkg/cmd/local_build_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "testing"
-
- "github.com/apache/camel-k/v2/pkg/util/test"
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func addTestLocalBuildCmd(rootCmdOptions *RootCmdOptions, rootCmd *cobra.Command) *localBuildCmdOptions {
- localCmd, localCmdOptions := newCmdLocal(rootCmdOptions)
- // remove predefined sub commands
- localCmd.RemoveCommand(localCmd.Commands()...)
- // add a testing version of build Command
- localBuildCmd, localBuildCmdOptions := newCmdLocalBuild(localCmdOptions)
- localBuildCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- localBuildCmd.Args = test.ArbitraryArgs
- localCmd.AddCommand(localBuildCmd)
- rootCmd.AddCommand(localCmd)
- return localBuildCmdOptions
-}
-
-func TestLocalBuildAcceptsTraits(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- addTestLocalBuildCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "build", "route.java",
- "-t", "jolokia.enabled=true",
- "--trait", "prometheus.enabled=true")
-
- require.NoError(t, err)
-}
-
-func TestLocalBuildWithDependencies(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- localBuildCmdOptions := addTestLocalBuildCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "build", "route.java",
- "-d", "camel-amqp",
- "-d", "camel:bean",
- "-d", "camel-quarkus-controlbus",
- "-d", "camel-quarkus:directvm",
- "--dependency", "mvn:test:component:1.0.0")
-
- require.NoError(t, err)
- assert.Len(t, localBuildCmdOptions.Dependencies, 5)
- assert.ElementsMatch(t, localBuildCmdOptions.Dependencies, []string{
- "camel:amqp", "camel:bean", "camel:controlbus", "camel:directvm", "mvn:test:component:1.0.0",
- })
-}
diff --git a/pkg/cmd/local_inspect.go b/pkg/cmd/local_inspect.go
deleted file mode 100644
index 5cecfdab5..000000000
--- a/pkg/cmd/local_inspect.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "errors"
- "fmt"
-
- "github.com/apache/camel-k/v2/pkg/cmd/local"
- "github.com/spf13/cobra"
-)
-
-func newCmdLocalInspect(localCmdOptions *LocalCmdOptions) (*cobra.Command, *localInspectCmdOptions) {
- options := localInspectCmdOptions{
- LocalCmdOptions: localCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "inspect [files to inspect]",
- Short: "Generate dependencies list given integration files.",
- Long: `Output dependencies for a list of integration files. By default this command returns the
-top level dependencies only. When --all-dependencies is enabled, the transitive dependencies
-will be generated by calling Maven and then printed in the selected output format.`,
- Deprecated: "it may be removed in future versions",
- PreRunE: decode(&options),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(args); err != nil {
- return err
- }
- if err := options.init(); err != nil {
- return err
- }
- defer func() {
- if err := options.deinit(); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
- }()
- return options.run(cmd, args)
- },
- Annotations: map[string]string{
- offlineCommandLabel: "true",
- },
- }
-
- cmd.Flags().Bool("all-dependencies", false, "Enable computation of transitive dependencies.")
- cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
-
- return &cmd, &options
-}
-
-type localInspectCmdOptions struct {
- *LocalCmdOptions
- AllDependencies bool `mapstructure:"all-dependencies"`
- OutputFormat string `mapstructure:"output"`
-}
-
-func (o *localInspectCmdOptions) validate(args []string) error {
- // If no source files have been provided there is nothing to inspect.
- if len(args) == 0 {
- return errors.New("no integration files have been provided")
- }
-
- if err := local.ValidateFiles(args); err != nil {
- return err
- }
-
- if err := local.ValidateDependencies(o.Dependencies); err != nil {
- return err
- }
-
- return nil
-}
-
-func (o *localInspectCmdOptions) init() error {
- return local.CreateMavenWorkingDirectory()
-}
-
-func (o *localInspectCmdOptions) run(cmd *cobra.Command, args []string) error {
- dependencies, err := local.GetDependencies(o.Context, cmd,
- args, o.Dependencies, o.MavenRepositories, o.AllDependencies)
- if err != nil {
- return err
- }
-
- if err = local.OutputDependencies(dependencies, o.OutputFormat, cmd); err != nil {
- return err
- }
-
- return nil
-}
-
-func (o *localInspectCmdOptions) deinit() error {
- return local.DeleteMavenWorkingDirectory()
-}
diff --git a/pkg/cmd/local_inspect_test.go b/pkg/cmd/local_inspect_test.go
deleted file mode 100644
index b00d07a6b..000000000
--- a/pkg/cmd/local_inspect_test.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "testing"
-
- "github.com/apache/camel-k/v2/pkg/util/test"
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func addTestLocalInspectCmd(rootCmdOptions *RootCmdOptions, rootCmd *cobra.Command) *localInspectCmdOptions {
- localCmd, localCmdOptions := newCmdLocal(rootCmdOptions)
- // remove predefined sub commands
- localCmd.RemoveCommand(localCmd.Commands()...)
- // add a testing version of inspect Command
- localInspectCmd, localInspectCmdOptions := newCmdLocalInspect(localCmdOptions)
- localInspectCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- localInspectCmd.Args = test.ArbitraryArgs
- localCmd.AddCommand(localInspectCmd)
- rootCmd.AddCommand(localCmd)
- return localInspectCmdOptions
-}
-
-func TestLocalInspectAcceptsTraits(t *testing.T) {
- rootOptions, rootCmd := kamelTestPreAddCommandInit()
- addTestLocalInspectCmd(rootOptions, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "inspect", "route.java",
- "-t", "jolokia.enabled=true",
- "--trait", "prometheus.enabled=true")
-
- require.NoError(t, err)
-}
-
-func TestLocalInspectWithDependencies(t *testing.T) {
- rootOptions, rootCmd := kamelTestPreAddCommandInit()
- options := addTestLocalInspectCmd(rootOptions, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "inspect", "route.java",
- "-d", "camel-amqp",
- "-d", "camel:bean",
- "-d", "camel-quarkus-controlbus",
- "-d", "camel-quarkus:directvm",
- "--dependency", "mvn:test:component:1.0.0")
-
- require.NoError(t, err)
- assert.Len(t, options.Dependencies, 5)
- assert.ElementsMatch(t, options.Dependencies, []string{
- "camel:amqp", "camel:bean", "camel:controlbus", "camel:directvm", "mvn:test:component:1.0.0",
- })
-}
diff --git a/pkg/cmd/local_run.go b/pkg/cmd/local_run.go
deleted file mode 100644
index ac572b752..000000000
--- a/pkg/cmd/local_run.go
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "errors"
- "fmt"
- "os"
- "os/signal"
- "syscall"
-
- "github.com/apache/camel-k/v2/pkg/cmd/local"
- "github.com/apache/camel-k/v2/pkg/util"
-
- "github.com/spf13/cobra"
-)
-
-func newCmdLocalRun(localCmdOptions *LocalCmdOptions) (*cobra.Command, *localRunCmdOptions) {
- options := localRunCmdOptions{
- LocalCmdOptions: localCmdOptions,
- }
-
- cmd := cobra.Command{
- Use: "run [integration files]",
- Short: "Run integration locally.",
- Long: `Run integration locally using the input integration files.`,
- Deprecated: "consider using Camel JBang instead (https://camel.apache.org/manual/camel-jbang.html)",
- PreRunE: decode(&options),
- RunE: func(cmd *cobra.Command, args []string) error {
- if err := options.validate(args); err != nil {
- return err
- }
- if err := options.init(); err != nil {
- return err
- }
-
- // make sure cleanup is done when process is stopped externally
- cs := make(chan os.Signal, 1)
- signal.Notify(cs, os.Interrupt, syscall.SIGTERM)
- go func() {
- <-cs
- if err := options.deinit(); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err)
- os.Exit(1)
- }
- os.Exit(0)
- }()
-
- defer func() {
- if err := options.deinit(); err != nil {
- fmt.Fprintln(cmd.ErrOrStderr(), err.Error())
- }
- }()
- return options.run(cmd, args)
- },
- Annotations: map[string]string{
- offlineCommandLabel: "true",
- },
- }
-
- cmd.Flags().Bool("containerize", false, "Run integration in a local container.")
- cmd.Flags().String("image", "", usageImage)
- cmd.Flags().String("network", "", "Custom network name to be used by the underlying Docker command.")
- cmd.Flags().String("integration-directory", "", usageIntegrationDirectory)
- cmd.Flags().StringArrayP("env", "e", nil, "Flag to specify an environment variable [--env VARIABLE=value].")
- cmd.Flags().StringArray("property-file", nil, usagePropertyFile)
- cmd.Flags().StringArrayP("property", "p", nil, usageProperty)
-
- return &cmd, &options
-}
-
-type localRunCmdOptions struct {
- *LocalCmdOptions
- Containerize bool `mapstructure:"containerize"`
- Image string `mapstructure:"image"`
- Network string `mapstructure:"network"`
- IntegrationDirectory string `mapstructure:"integration-directory"`
- EnvironmentVariables []string `mapstructure:"envs"`
- PropertyFiles []string `mapstructure:"property-files"`
- Properties []string `mapstructure:"properties"`
-}
-
-func (o *localRunCmdOptions) validate(args []string) error {
- if len(args) == 0 && o.IntegrationDirectory == "" && o.Image == "" {
- return errors.New("either integration files, --image, or --integration-directory must be provided")
- }
-
- // If containerize is set then docker image name must be set.
- if o.Containerize && o.Image == "" {
- return errors.New("--containerize requires --image")
- }
-
- // Validate integration files.
- if err := local.ValidateFiles(args); err != nil {
- return err
- }
-
- // Validate additional dependencies specified by the user.
- if err := local.ValidateDependencies(o.Dependencies); err != nil {
- return err
- }
-
- // Validate properties file.
- if err := local.ValidatePropertyFiles(o.PropertyFiles); err != nil {
- return err
- }
-
- if o.IntegrationDirectory != "" {
- if ok, err := util.DirectoryExists(o.IntegrationDirectory); err != nil {
- return err
- } else if !ok {
- return fmt.Errorf("integration directory %q does not exist", o.IntegrationDirectory)
- }
- }
-
- return nil
-}
-
-func (o *localRunCmdOptions) init() error {
- if o.Containerize {
- if err := local.CreateDockerBaseWorkingDirectory(); err != nil {
- return err
- }
- if err := local.CreateDockerWorkingDirectory(); err != nil {
- return err
- }
- }
- local.SetDockerNetworkName(o.Network)
- local.SetDockerEnvVars(o.EnvironmentVariables)
-
- return local.CreateMavenWorkingDirectory()
-}
-
-func (o *localRunCmdOptions) run(cmd *cobra.Command, args []string) error {
- // If local run is provided with an image name, it will just run the image locally and exit.
- if o.Image != "" && !o.Containerize {
- // Run image locally.
- return local.RunIntegrationImage(o.Context, o.Image, cmd.OutOrStdout(), cmd.ErrOrStderr())
- }
-
- dependencies, err := o.processDependencies(cmd, args)
- if err != nil {
- return err
- }
- propertyFiles, err := o.processPropertyFiles()
- if err != nil {
- return err
- }
- routes, err := o.processRoutes(args)
- if err != nil {
- return err
- }
-
- if o.Containerize {
- // Create, build, and run the container image.
- if err := local.CreateAndBuildIntegrationImage(o.Context, "", false, o.Image,
- propertyFiles, dependencies, routes, o.IntegrationDirectory != "",
- cmd.OutOrStdout(), cmd.ErrOrStderr()); err != nil {
- return err
- }
-
- return local.RunIntegrationImage(o.Context, o.Image, cmd.OutOrStdout(), cmd.ErrOrStderr())
- }
-
- // Run integration locally.
- return local.RunLocalIntegration(o.Context, propertyFiles, dependencies, routes, o.getPropertiesDir(),
- cmd.OutOrStdout(), cmd.ErrOrStderr())
-}
-
-func (o *localRunCmdOptions) processDependencies(cmd *cobra.Command, args []string) ([]string, error) {
- if o.IntegrationDirectory == "" {
- return local.GetDependencies(o.Context, cmd, args, o.Dependencies, o.MavenRepositories, true)
- }
-
- // Set up on the integration directory
-
- // Fetch local dependencies
- dependencies, err := local.GetBuildDependencies(o.IntegrationDirectory)
- if err != nil {
- return nil, err
- }
- if err := o.setupDependenciesForQuarkusRun(); err != nil {
- return dependencies, err
- }
-
- return dependencies, nil
-}
-
-// setupDependenciesForQuarkusRun sets up resources under the integration directory for running Quarkus app.
-func (o *localRunCmdOptions) setupDependenciesForQuarkusRun() error {
- // Local dependencies directory
- localDependenciesDir := local.GetCustomDependenciesDir(o.IntegrationDirectory)
-
- // The quarkus application files need to be at a specific location i.e.:
- // <integration_directory>/../quarkus/quarkus-application.dat
- // <integration_directory>/../quarkus/generated-bytecode.jar
- localQuarkusDir := local.GetCustomQuarkusDir(o.IntegrationDirectory)
- if err := local.CopyQuarkusAppFiles(localDependenciesDir, localQuarkusDir); err != nil {
- return err
- }
-
- // The dependency jar files need to be at a specific location i.e.:
- // <integration_directory>/../lib/main/*.jar
- localLibDir := local.GetCustomLibDir(o.IntegrationDirectory)
- if err := local.CopyLibFiles(localDependenciesDir, localLibDir); err != nil {
- return err
- }
-
- // The Camel K jar file needs to be at a specific location i.e.:
- // <integration_directory>/../app/camel-k-integration-X.X.X{-SNAPSHOT}.jar
- localAppDir := local.GetCustomAppDir(o.IntegrationDirectory)
- if err := local.CopyAppFile(localDependenciesDir, localAppDir); err != nil {
- return err
- }
-
- return nil
-}
-
-// processPropertyFiles processes integration properties which may come from files or CLI.
-func (o *localRunCmdOptions) processPropertyFiles() ([]string, error) {
- propertyFiles := o.PropertyFiles
- hasIntegrationDir := o.IntegrationDirectory != ""
- if hasIntegrationDir {
- localPropertyFiles, err := local.GetBuildProperties(o.IntegrationDirectory)
- if err != nil {
- return nil, err
- }
- propertyFiles = localPropertyFiles
- }
-
- return local.UpdateIntegrationProperties(o.Properties, propertyFiles, hasIntegrationDir)
-}
-
-func (o *localRunCmdOptions) processRoutes(args []string) ([]string, error) {
- if o.IntegrationDirectory == "" {
- return args, nil
- }
-
- return local.GetBuildRoutes(o.IntegrationDirectory)
-}
-
-func (o *localRunCmdOptions) getPropertiesDir() string {
- if o.IntegrationDirectory == "" {
- return local.GetLocalPropertiesDir()
- }
-
- return local.GetCustomPropertiesDir(o.IntegrationDirectory)
-}
-
-func (o *localRunCmdOptions) deinit() error {
- if o.Containerize {
- if err := local.DeleteDockerBaseWorkingDirectory(); err != nil {
- return err
- }
-
- if err := local.DeleteDockerWorkingDirectory(); err != nil {
- return err
- }
- }
-
- if o.IntegrationDirectory != "" {
- if err := local.DeleteLocalIntegrationDirs(o.IntegrationDirectory); err != nil {
- return err
- }
- }
-
- return local.DeleteMavenWorkingDirectory()
-}
diff --git a/pkg/cmd/local_run_test.go b/pkg/cmd/local_run_test.go
deleted file mode 100644
index 6dfa1867e..000000000
--- a/pkg/cmd/local_run_test.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one or more
-contributor license agreements. See the NOTICE file distributed with
-this work for additional information regarding copyright ownership.
-The ASF licenses this file to You 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 cmd
-
-import (
- "testing"
-
- "github.com/apache/camel-k/v2/pkg/util/test"
- "github.com/spf13/cobra"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-)
-
-func addTestLocalRunCmd(rootCmdOptions *RootCmdOptions, rootCmd *cobra.Command) *localRunCmdOptions {
- localCmd, localCmdOptions := newCmdLocal(rootCmdOptions)
- // remove predefined sub commands
- localCmd.RemoveCommand(localCmd.Commands()...)
- // add a testing version of run Command
- localRunCmd, localRunCmdOptions := newCmdLocalRun(localCmdOptions)
- localRunCmd.RunE = func(c *cobra.Command, args []string) error {
- return nil
- }
- localRunCmd.Args = test.ArbitraryArgs
- localCmd.AddCommand(localRunCmd)
- rootCmd.AddCommand(localCmd)
- return localRunCmdOptions
-}
-
-func TestLocalRunPropertyFileFlag(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- localRunCmdOptions := addTestLocalRunCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "run", "route.java",
- "--property-file", "file1.properties",
- "--property-file", "file2.properties")
-
- require.NoError(t, err)
- if len(localRunCmdOptions.PropertyFiles) != 2 {
- t.Fatalf("Property files expected to contain: \n %v elements\nGot:\n %v elements\n", 2, len(localRunCmdOptions.PropertyFiles))
- }
- if localRunCmdOptions.PropertyFiles[0] != "file1.properties" || localRunCmdOptions.PropertyFiles[1] != "file2.properties" {
- t.Fatalf("Property files expected to be: \n %v\nGot:\n %v\n", "[file1.properties, file2.properties]", localRunCmdOptions.PropertyFiles)
- }
-}
-
-func TestLocalRunPropertiesFlag(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- localRunCmdOptions := addTestLocalRunCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "run", "route.java",
- "-p", "prop1=value1",
- "-p", "prop2=value2")
-
- require.NoError(t, err)
- if len(localRunCmdOptions.Properties) != 2 {
- t.Fatalf("Additional dependencies expected to contain: \n %v elements\nGot:\n %v elements\n", 2, len(localRunCmdOptions.Properties))
- }
- if localRunCmdOptions.Properties[0] != "prop1=value1" || localRunCmdOptions.Properties[1] != "prop2=value2" {
- t.Fatalf("Additional dependencies expected to be: \n %v\nGot:\n %v\n", "[prop1=value1, prop2=value2]", localRunCmdOptions.Properties)
- }
-}
-
-func TestLocalRunAdditionalDependenciesFlag(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- localRunCmdOptions := addTestLocalRunCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "run", "route.java",
- "-d", "camel-amqp",
- "-d", "camel:bean",
- "-d", "camel-quarkus-controlbus",
- "-d", "camel-quarkus:directvm",
- "--dependency", "mvn:test:component:1.0.0")
-
- require.NoError(t, err)
- assert.Len(t, localRunCmdOptions.Dependencies, 5)
- assert.ElementsMatch(t, localRunCmdOptions.Dependencies, []string{
- "camel:amqp", "camel:bean", "camel:controlbus", "camel:directvm", "mvn:test:component:1.0.0",
- })
-}
-
-func TestLocalRunAcceptsTraits(t *testing.T) {
- options, rootCmd := kamelTestPreAddCommandInit()
- addTestLocalRunCmd(options, rootCmd)
- kamelTestPostAddCommandInit(t, rootCmd)
-
- _, err := test.ExecuteCommand(rootCmd, "local", "run", "route.java",
- "-t", "jolokia.enabled=true",
- "--trait", "prometheus.enabled=true")
-
- require.NoError(t, err)
-}
diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go
index 02c710d9f..3b5e6855c 100644
--- a/pkg/cmd/modeline_test.go
+++ b/pkg/cmd/modeline_test.go
@@ -464,49 +464,6 @@ func TestModelineRunResourceFile(t *testing.T) {
assert.NoError(t, err)
}
-func TestModelineInspectSimple(t *testing.T) {
- err := util.WithTempDir("camel-k-test-", func(dir string) error {
-
- file := `
- // camel-k: dependency=mvn:org.my:lib:1.0
- `
- fileName := filepath.Join(dir, "simple.groovy")
- err := os.WriteFile(fileName, []byte(file), 0o400)
- assert.NoError(t, err)
-
- cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "local", "inspect", fileName})
- assert.NoError(t, err)
- assert.NotNil(t, cmd)
- assert.Equal(t, []string{"local", "inspect", fileName, "--dependency=mvn:org.my:lib:1.0"}, flags)
-
- return nil
- })
-
- assert.NoError(t, err)
-}
-
-func TestModelineInspectMultipleDeps(t *testing.T) {
- err := util.WithTempDir("camel-k-test-", func(dir string) error {
-
- file := `
- // camel-k: dependency=mvn:org.my:lib:1.0
- // camel-k: dependency=camel-k:camel-dep
- `
- fileName := filepath.Join(dir, "simple.groovy")
- err := os.WriteFile(fileName, []byte(file), 0o400)
- assert.NoError(t, err)
-
- cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "local", "inspect", fileName})
- assert.NoError(t, err)
- assert.NotNil(t, cmd)
- assert.Equal(t, []string{"local", "inspect", fileName, "--dependency=mvn:org.my:lib:1.0", "--dependency=camel-k:camel-dep"}, flags)
-
- return nil
- })
-
- assert.NoError(t, err)
-}
-
func TestModelineQuotedPodTemplate(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
diff --git a/pkg/cmd/promote_test.go b/pkg/cmd/promote_test.go
index d12ceed43..d63543902 100644
--- a/pkg/cmd/promote_test.go
+++ b/pkg/cmd/promote_test.go
@@ -62,8 +62,8 @@ func TestIntegrationNotCompatible(t *testing.T) {
dstPlatform.Status.Build.RuntimeVersion = "0.0.1"
dstPlatform.Status.Phase = v1.IntegrationPlatformPhaseReady
defaultIntegration := nominalIntegration("my-it-test")
- srcCatalog := createCamelCatalog(srcPlatform)
- dstCatalog := createCamelCatalog(dstPlatform)
+ srcCatalog := createTestCamelCatalog(srcPlatform)
+ dstCatalog := createTestCamelCatalog(dstPlatform)
promoteCmdOptions, promoteCmd, _ := initializePromoteCmdOptions(t, &srcPlatform, &dstPlatform, &defaultIntegration, &srcCatalog, &dstCatalog)
_, err := test.ExecuteCommand(promoteCmd, cmdPromote, "my-it-test", "--to", "prod-namespace", "-o", "yaml", "-n", "default")
@@ -85,8 +85,8 @@ func TestIntegrationDryRun(t *testing.T) {
dstPlatform.Status.Build.RuntimeVersion = defaults.DefaultRuntimeVersion
dstPlatform.Status.Phase = v1.IntegrationPlatformPhaseReady
defaultIntegration := nominalIntegration("my-it-test")
- srcCatalog := createCamelCatalog(srcPlatform)
- dstCatalog := createCamelCatalog(dstPlatform)
+ srcCatalog := createTestCamelCatalog(srcPlatform)
+ dstCatalog := createTestCamelCatalog(dstPlatform)
promoteCmdOptions, promoteCmd, _ := initializePromoteCmdOptions(t, &srcPlatform, &dstPlatform, &defaultIntegration, &srcCatalog, &dstCatalog)
output, err := test.ExecuteCommand(promoteCmd, cmdPromote, "my-it-test", "--to", "prod-namespace", "-o", "yaml", "-n", "default")
@@ -124,8 +124,8 @@ func TestPipeDryRun(t *testing.T) {
dstPlatform.Status.Phase = v1.IntegrationPlatformPhaseReady
defaultKB := nominalPipe("my-kb-test")
defaultIntegration := nominalIntegration("my-kb-test")
- srcCatalog := createCamelCatalog(srcPlatform)
- dstCatalog := createCamelCatalog(dstPlatform)
+ srcCatalog := createTestCamelCatalog(srcPlatform)
+ dstCatalog := createTestCamelCatalog(dstPlatform)
promoteCmdOptions, promoteCmd, _ := initializePromoteCmdOptions(t, &srcPlatform, &dstPlatform, &defaultKB, &defaultIntegration, &srcCatalog, &dstCatalog)
output, err := test.ExecuteCommand(promoteCmd, cmdPromote, "my-kb-test", "--to", "prod-namespace", "-o", "yaml", "-n", "default")
@@ -155,7 +155,7 @@ func nominalPipe(name string) v1.Pipe {
return kb
}
-func createCamelCatalog(platform v1.IntegrationPlatform) v1.CamelCatalog {
+func createTestCamelCatalog(platform v1.IntegrationPlatform) v1.CamelCatalog {
c := v1.NewCamelCatalog(platform.Namespace, defaults.DefaultRuntimeVersion)
c.Spec = v1.CamelCatalogSpec{Runtime: v1.RuntimeSpec{Provider: platform.Status.Build.RuntimeProvider, Version: platform.Status.Build.RuntimeVersion}}
return c
diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go
index 47ff24d08..d20b1b30c 100644
--- a/pkg/cmd/root.go
+++ b/pkg/cmd/root.go
@@ -145,10 +145,8 @@ func addKamelSubcommands(cmd *cobra.Command, options *RootCmdOptions) {
cmd.AddCommand(cmdOnly(newCmdRebuild(options)))
cmd.AddCommand(cmdOnly(newCmdOperator()))
cmd.AddCommand(cmdOnly(newCmdBuilder(options)))
- cmd.AddCommand(cmdOnly(newCmdInit(options)))
cmd.AddCommand(cmdOnly(newCmdDebug(options)))
cmd.AddCommand(cmdOnly(newCmdDump(options)))
- cmd.AddCommand(cmdOnly(newCmdLocal(options)))
cmd.AddCommand(cmdOnly(newCmdBind(options)))
cmd.AddCommand(cmdOnly(newCmdPromote(options)))
cmd.AddCommand(newCmdKamelet(options))
diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go
index 228d1dde3..740682488 100644
--- a/pkg/cmd/run.go
+++ b/pkg/cmd/run.go
@@ -60,7 +60,6 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
- "github.com/apache/camel-k/v2/pkg/cmd/local"
"github.com/apache/camel-k/v2/pkg/cmd/source"
"github.com/apache/camel-k/v2/pkg/platform"
"github.com/apache/camel-k/v2/pkg/trait"
@@ -263,7 +262,7 @@ func (o *runCmdOptions) validate() error {
propertyFiles := filterBuildPropertyFiles(o.Properties)
propertyFiles = append(propertyFiles, filterBuildPropertyFiles(o.BuildProperties)...)
- err := local.ValidatePropertyFiles(propertyFiles)
+ err := validatePropertyFiles(propertyFiles)
if err != nil {
return err
}
@@ -823,7 +822,7 @@ func (o *runCmdOptions) applyDependencies(cmd *cobra.Command, c client.Client, i
// And the validation only warns potential misusages of Camel components at the CLI level,
// so strictness of catalog version is not necessary here.
var err error
- catalog, err = local.CreateCamelCatalog(o.Context)
+ catalog, err = createCamelCatalog(o.Context)
if err != nil {
return err
}
diff --git a/pkg/cmd/run_support.go b/pkg/cmd/run_support.go
index 8c24588fc..ee7ffb163 100644
--- a/pkg/cmd/run_support.go
+++ b/pkg/cmd/run_support.go
@@ -31,11 +31,13 @@ import (
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
- "github.com/apache/camel-k/v2/pkg/cmd/source"
"github.com/apache/camel-k/v2/pkg/util/camel"
+ "github.com/apache/camel-k/v2/pkg/util/defaults"
"github.com/apache/camel-k/v2/pkg/util/kubernetes"
+ "github.com/apache/camel-k/v2/pkg/util/maven"
"github.com/apache/camel-k/v2/pkg/util/resource"
"github.com/magiconair/properties"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
)
@@ -60,25 +62,6 @@ func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c client.Clien
if secret == nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warn:", config.Name(), "Secret not found in", integration.Namespace, "namespace, make sure to provide it before the Integration can run")
}
- case resource.StorageTypeFile:
- // Don't allow a binary non compressed resource
- rawData, contentType, err := source.LoadRawContent(ctx, config.Name())
- if err != nil {
- return nil, err
- }
- if config.ContentType() != resource.ContentTypeData && !enableCompression && source.IsBinary(contentType) {
- return nil, fmt.Errorf("you cannot provide a binary config, use a text file or check --resource flag instead")
- }
- resourceType := v1.ResourceTypeData
- if config.ContentType() == resource.ContentTypeText {
- resourceType = v1.ResourceTypeConfig
- }
- resourceSpec, err := binaryOrTextResource(filepath.Base(config.Name()), rawData, contentType, enableCompression, resourceType, config.DestinationPath())
- if err != nil {
- return nil, err
- }
-
- return resource.ConvertFileToConfigmap(ctx, c, config, integration.Namespace, integration.Name, resourceSpec.Content, resourceSpec.RawContent)
default:
// Should never reach this
return nil, fmt.Errorf("invalid option type %s", config.StorageType())
@@ -87,36 +70,6 @@ func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c client.Clien
return nil, nil
}
-func binaryOrTextResource(fileName string, data []byte, contentType string, base64Compression bool, resourceType v1.ResourceType, destinationPath string) (v1.ResourceSpec, error) {
- resourceSpec := v1.ResourceSpec{
- DataSpec: v1.DataSpec{
- Name: fileName,
- Path: destinationPath,
- ContentKey: fileName,
- ContentType: contentType,
- Compression: false,
- },
- Type: resourceType,
- }
-
- if !base64Compression && source.IsBinary(contentType) {
- resourceSpec.RawContent = data
- return resourceSpec, nil
- }
- // either is a text resource or base64 compression is enabled
- if base64Compression {
- content, err := source.CompressToString(data)
- if err != nil {
- return resourceSpec, err
- }
- resourceSpec.Content = content
- resourceSpec.Compression = true
- } else {
- resourceSpec.Content = string(data)
- }
- return resourceSpec, nil
-}
-
func filterFileLocation(maybeFileLocations []string) []string {
filteredOptions := make([]string, 0)
for _, option := range maybeFileLocations {
@@ -206,3 +159,64 @@ func downloadDependency(ctx context.Context, url url.URL) (string, error) {
}
return out.Name(), nil
}
+
+func validatePropertyFiles(propertyFiles []string) error {
+ for _, fileName := range propertyFiles {
+ if err := validatePropertyFile(fileName); err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+func validatePropertyFile(fileName string) error {
+ if !strings.HasSuffix(fileName, ".properties") {
+ return fmt.Errorf("supported property files must have a .properties extension: %s", fileName)
+ }
+
+ if file, err := os.Stat(fileName); err != nil {
+ return errors.Wrapf(err, "unable to access property file %s", fileName)
+ } else if file.IsDir() {
+ return fmt.Errorf("property file %s is a directory", fileName)
+ }
+
+ return nil
+}
+
+func createCamelCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
+ // Attempt to reuse existing Camel catalog if one is present
+ catalog, err := camel.DefaultCatalog()
+ if err != nil {
+ return nil, err
+ }
+
+ // Generate catalog if one was not found
+ if catalog == nil {
+ catalog, err = generateCatalog(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return catalog, nil
+}
+
+func generateCatalog(ctx context.Context) (*camel.RuntimeCatalog, error) {
+ // A Camel catalog is required for this operation
+ mvn := v1.MavenSpec{
+ LocalRepository: "",
+ }
+ runtime := v1.RuntimeSpec{
+ Version: defaults.DefaultRuntimeVersion,
+ Provider: v1.RuntimeProviderQuarkus,
+ }
+ var providerDependencies []maven.Dependency
+ var caCert [][]byte
+ catalog, err := camel.GenerateCatalogCommon(ctx, nil, nil, caCert, mvn, runtime, providerDependencies)
+ if err != nil {
+ return nil, err
+ }
+
+ return catalog, nil
+}
diff --git a/pkg/cmd/run_support_test.go b/pkg/cmd/run_support_test.go
index 970e81450..15ff0d93f 100644
--- a/pkg/cmd/run_support_test.go
+++ b/pkg/cmd/run_support_test.go
@@ -24,55 +24,9 @@ import (
"strings"
"testing"
- v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
- "github.com/apache/camel-k/v2/pkg/cmd/source"
"github.com/stretchr/testify/assert"
)
-func TestRunBinaryResource(t *testing.T) {
- binaryResourceSpec, err := binaryOrTextResource("file.ext", []byte{1, 2, 3, 4}, "application/octet-stream", false, v1.ResourceTypeData, "")
- assert.Nil(t, err)
- assert.Equal(t, "", binaryResourceSpec.Content)
- assert.NotNil(t, binaryResourceSpec.RawContent)
- assert.Equal(t, "file.ext", binaryResourceSpec.Name)
- assert.Equal(t, "application/octet-stream", binaryResourceSpec.ContentType)
- assert.False(t, binaryResourceSpec.Compression)
-}
-
-func TestRunBinaryCompressedResource(t *testing.T) {
- data := []byte{1, 2, 3, 4}
- base64Compressed, _ := source.CompressToString(data)
- binaryResourceSpec, err := binaryOrTextResource("file.ext", data, "application/octet-stream", true, v1.ResourceTypeData, "")
- assert.Nil(t, err)
- assert.Equal(t, base64Compressed, binaryResourceSpec.Content)
- assert.Nil(t, binaryResourceSpec.RawContent)
- assert.Equal(t, "file.ext", binaryResourceSpec.Name)
- assert.Equal(t, "application/octet-stream", binaryResourceSpec.ContentType)
- assert.True(t, binaryResourceSpec.Compression)
-}
-
-func TestRunTextResource(t *testing.T) {
- textResourceSpec, err := binaryOrTextResource("file.ext", []byte("hello world"), "text/plain", false, v1.ResourceTypeData, "")
- assert.Nil(t, err)
- assert.Equal(t, "hello world", textResourceSpec.Content)
- assert.Nil(t, textResourceSpec.RawContent)
- assert.Equal(t, "file.ext", textResourceSpec.Name)
- assert.Equal(t, "text/plain", textResourceSpec.ContentType)
- assert.False(t, textResourceSpec.Compression)
-}
-
-func TestRunTextCompressedResource(t *testing.T) {
- data := []byte("hello horld")
- base64Compressed, _ := source.CompressToString(data)
- textResourceSpec, err := binaryOrTextResource("file.ext", []byte("hello horld"), "text/plain", true, v1.ResourceTypeData, "")
- assert.Nil(t, err)
- assert.Equal(t, base64Compressed, textResourceSpec.Content)
- assert.Nil(t, textResourceSpec.RawContent)
- assert.Equal(t, "file.ext", textResourceSpec.Name)
- assert.Equal(t, "text/plain", textResourceSpec.ContentType)
- assert.True(t, textResourceSpec.Compression)
-}
-
func TestFilterFileLocation(t *testing.T) {
optionFileLocations := []string{
"file:/path/to/valid/file",
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index eef958a20..10cb52fb6 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -152,9 +152,9 @@ var assets = func() http.FileSystem {
"/crd/bases/camel.apache.org_kameletbindings.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_kameletbindings.yaml",
modTime: time.Time{},
- uncompressedSize: 574426,
+ uncompressedSize: 574267,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x6b\x73\x1b\x37\xb6\x30\x0a\x7f\xf7\xaf\x40\xc9\xa9\x47\xd2\x8e\x48\xd9\x99\x99\xd4\x8c\xdf\xa9\x9d\xd2\xc8\x72\xa2\x37\xb6\xcc\xb2\x94\xe4\x49\x39\xd9\x09\xd8\x0d\x92\xd8\xea\x06\x7a\x00\x34\x25\xe6\xf8\xfc\xf7\x53\x58\x00\xfa\xc2\x9b\xb0\x9a\x92\x46\x9e\x69\x4c\x55\xc6\xa4\xd8\xab\x71\x5b\xf7\xdb\x73\x32\xb8\xbf\xf1\xec\x39\x79\xcb\x13\x26\x34\x4b\x89\x91\xc4\xcc\x18\x39\x29\x68\x32\x63\xe4\x52\x4e\xcc\x0d\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x6b\x73\x1b\x37\xb6\x30\x0a\x7f\xf7\xaf\x40\xc9\xa9\x47\xd2\x8e\x48\xd9\x99\x99\xd4\x8c\xdf\xa9\x9d\xd2\xc8\x72\xa2\x37\xb6\xcc\xb2\x94\xe4\x49\x39\xd9\x09\xd8\x0d\x92\xd8\xea\x06\x7a\x00\x34\x25\xe6\xf8\xfc\xf7\x53\x58\x00\xfa\xc2\x9b\xb0\x9a\x92\x46\x9e\x69\x4c\x55\xc6\xa4\xd8\xab\x71\x5b\xf7\xdb\x73\x32\xb8\xbf\xf1\xec\x39\x79\xcb\x13\x26\x34\x4b\x89\x91\xc4\xcc\x18\x39\x29\x68\x32\x63\xe4\x52\x4e\xcc\x0d\x [...]
},
"/crd/bases/camel.apache.org_kamelets.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_kamelets.yaml",
@@ -166,14 +166,26 @@ var assets = func() http.FileSystem {
"/crd/bases/camel.apache.org_pipes.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_pipes.yaml",
modTime: time.Time{},
- uncompressedSize: 574151,
+ uncompressedSize: 541535,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x79\x73\x1b\x37\xb6\x38\x0c\xff\xef\x4f\x81\x92\x53\x3f\x49\x37\x22\x65\x67\x96\x9a\xf1\x3b\x75\x53\xba\xb2\xec\xe8\x8d\x2d\xb3\x2c\x25\xf9\xa5\x9c\xdc\x04\xec\x06\x49\x5c\x75\x03\x7d\x01\x34\x25\xe6\xf1\xf3\xdd\x9f\xc2\x01\xd0\x0b\x37\xe1\x34\x25\x8d\x3c\xd3\x98\xaa\x8c\x49\xb1\x4f\x63\x3b\xfb\xf6\x9c\x0c\xee\x6f\x3c\x7b\x4e\xde\xf1\x84\x09\xcd\x52\x62\x24\x31\x33\x46\x4e\x0a\x9a\xcc\x18\xb9\x94\x13\x73\x43\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\xfd\x79\x73\x1b\x37\xb6\x38\x0c\xff\xef\x4f\x81\x92\x53\x3f\x49\x37\x22\x65\x67\x96\x9a\xf1\x3b\x75\x53\xba\xb2\xec\xe8\x8d\x2d\xb3\x2c\x25\xf9\xa5\x9c\xdc\x04\xec\x06\x49\x5c\x75\x03\x7d\x01\x34\x25\xe6\xf1\xf3\xdd\x9f\xc2\x01\xd0\x0b\x37\xe1\x34\x25\x8d\x3c\xd3\x98\xaa\x8c\x49\xb1\x4f\x63\x3b\xfb\xf6\x9c\x0c\xee\x6f\x3c\x7b\x4e\xde\xf1\x84\x09\xcd\x52\x62\x24\x31\x33\x46\x4e\x0a\x9a\xcc\x18\xb9\x94\x13\x73\x43\x [...]
},
"/manager": &vfsgen۰DirInfo{
name: "manager",
modTime: time.Time{},
},
+ "/manager/bundle": &vfsgen۰DirInfo{
+ name: "bundle",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/manifests": &vfsgen۰DirInfo{
+ name: "manifests",
+ modTime: time.Time{},
+ },
+ "/manager/bundle/metadata": &vfsgen۰DirInfo{
+ name: "metadata",
+ modTime: time.Time{},
+ },
"/manager/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{
name: "operator-deployment.yaml",
modTime: time.Time{},
@@ -686,6 +698,7 @@ var assets = func() http.FileSystem {
fs["/crd/bases/camel.apache.org_pipes.yaml"].(os.FileInfo),
}
fs["/manager"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle"].(os.FileInfo),
fs["/manager/operator-deployment.yaml"].(os.FileInfo),
fs["/manager/operator-pvc.yaml"].(os.FileInfo),
fs["/manager/operator-service-account.yaml"].(os.FileInfo),
@@ -699,6 +712,10 @@ var assets = func() http.FileSystem {
fs["/manager/patch-toleration.yaml"].(os.FileInfo),
fs["/manager/patch-watch-namespace-global.yaml"].(os.FileInfo),
}
+ fs["/manager/bundle"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
+ fs["/manager/bundle/manifests"].(os.FileInfo),
+ fs["/manager/bundle/metadata"].(os.FileInfo),
+ }
fs["/prometheus"].(*vfsgen۰DirInfo).entries = []os.FileInfo{
fs["/prometheus/operator-pod-monitor.yaml"].(os.FileInfo),
fs["/prometheus/operator-prometheus-rule.yaml"].(os.FileInfo),
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 09a478066..5f2f8dc30 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -303,7 +303,7 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Dat
"camel.apache.org/source.name": resource.Name,
"camel.apache.org/source.compression": strconv.FormatBool(resource.Compression),
"camel.apache.org/source.generated": "true",
- "camel.apache.org/source.type": string(v1.ResourceTypeOpenAPI),
+ "camel.apache.org/source.type": "openapi",
"camel.apache.org/source.digest": hash,
},
},
diff --git a/pkg/trait/service_test.go b/pkg/trait/service_test.go
index b5310400e..6de827890 100644
--- a/pkg/trait/service_test.go
+++ b/pkg/trait/service_test.go
@@ -335,6 +335,7 @@ func TestServiceWithNodePort(t *testing.T) {
compressedRoute, err := gzip.CompressBase64([]byte(`from("netty-http:test").log("hello")`))
assert.NoError(t, err)
+ serviceType := traitv1.ServiceTypeNodePort
environment := Environment{
CamelCatalog: catalog,
Catalog: traitCatalog,
@@ -364,8 +365,8 @@ func TestServiceWithNodePort(t *testing.T) {
Trait: traitv1.Trait{
Enabled: pointer.Bool(true),
},
- Auto: pointer.Bool(false),
- NodePort: pointer.Bool(true),
+ Auto: pointer.Bool(false),
+ Type: &serviceType,
},
},
},
diff --git a/pkg/trait/trait_configure_test.go b/pkg/trait/trait_configure_test.go
index 66117a984..52af5df1e 100644
--- a/pkg/trait/trait_configure_test.go
+++ b/pkg/trait/trait_configure_test.go
@@ -45,8 +45,7 @@ func TestTraitConfiguration(t *testing.T) {
Trait: traitv1.Trait{
Enabled: pointer.Bool(true),
},
- Auto: pointer.Bool(true),
- NodePort: pointer.Bool(false),
+ Auto: pointer.Bool(true),
},
},
},
@@ -63,7 +62,6 @@ func TestTraitConfiguration(t *testing.T) {
require.True(t, ok)
assert.True(t, *service.Enabled)
assert.True(t, *service.Auto)
- assert.False(t, *service.NodePort)
}
func TestTraitConfigurationFromAnnotations(t *testing.T) {
diff --git a/pkg/util/kubernetes/resolver.go b/pkg/util/kubernetes/resolver.go
index a6d47be14..fef16369f 100644
--- a/pkg/util/kubernetes/resolver.go
+++ b/pkg/util/kubernetes/resolver.go
@@ -41,19 +41,6 @@ func ResolveSources(elements []v1.SourceSpec, mapLookup func(string) (*corev1.Co
return elements, nil
}
-// ResolveResource --.
-func ResolveResource(elements []v1.ResourceSpec, mapLookup func(string) (*corev1.ConfigMap, error)) ([]v1.ResourceSpec, error) {
- for i := 0; i < len(elements); i++ {
- r := &elements[i]
-
- if err := Resolve(&r.DataSpec, mapLookup); err != nil {
- return nil, err
- }
- }
-
- return elements, nil
-}
-
// Resolve --.
func Resolve(data *v1.DataSpec, mapLookup func(string) (*corev1.ConfigMap, error)) error {
// if it is a reference, get the content from the
diff --git a/pkg/util/log/log.go b/pkg/util/log/log.go
index 8f9f86569..07051df96 100644
--- a/pkg/util/log/log.go
+++ b/pkg/util/log/log.go
@@ -150,7 +150,7 @@ func (l Logger) ForPipe(target *v1.Pipe) Logger {
}
// ForKameletBinding --.
-// Deprecated: use ForBinding instead.
+// Deprecated: use ForPipe instead.
func (l Logger) ForKameletBinding(target *v1alpha1.KameletBinding) Logger {
return l.WithValues(
"api-version", target.APIVersion,
diff --git a/pkg/util/resource/config.go b/pkg/util/resource/config.go
index 3bb106597..474c14aee 100644
--- a/pkg/util/resource/config.go
+++ b/pkg/util/resource/config.go
@@ -87,8 +87,6 @@ const (
StorageTypeConfigmap StorageType = "configmap"
// StorageTypeSecret --.
StorageTypeSecret StorageType = "secret"
- // StorageTypeFile --.
- StorageTypeFile StorageType = "file"
// StorageTypePVC --.
StorageTypePVC StorageType = "pvc"
)
@@ -105,12 +103,11 @@ const (
var (
validConfigSecretRegexp = regexp.MustCompile(`^(configmap|secret)\:([\w\.\-\_\:\/@]+)$`)
- validFileRegexp = regexp.MustCompile(`^file\:([\w\.\-\_\:\/@" ]+)$`)
validResourceRegexp = regexp.MustCompile(`^([\w\.\-\_\:]+)(\/([\w\.\-\_\:]+))?(\@([\w\.\-\_\:\/]+))?$`)
)
func newConfig(storageType StorageType, contentType ContentType, value string) *Config {
- rn, mk, mp := parseResourceValue(storageType, value)
+ rn, mk, mp := parseCMOrSecretValue(value)
return &Config{
storageType: storageType,
contentType: contentType,
@@ -120,15 +117,6 @@ func newConfig(storageType StorageType, contentType ContentType, value string) *
}
}
-func parseResourceValue(storageType StorageType, value string) (string, string, string) {
- if storageType == StorageTypeFile {
- resource, maybeDestinationPath := ParseFileValue(value)
- return resource, "", maybeDestinationPath
- }
-
- return parseCMOrSecretValue(value)
-}
-
// ParseFileValue will parse a file resource/config option to return the local path and the
// destination path expected.
func ParseFileValue(value string) (string, string) {
@@ -189,13 +177,8 @@ func parse(item string, contentType ContentType) (*Config, error) {
cot = StorageTypeSecret
}
value = groups[2]
- case validFileRegexp.MatchString(item):
- // parse as file
- groups := validFileRegexp.FindStringSubmatch(item)
- cot = StorageTypeFile
- value = groups[1]
default:
- return nil, fmt.Errorf("could not match config, secret or file configuration as %s", item)
+ return nil, fmt.Errorf("could not match config or secret configuration as %s", item)
}
return newConfig(cot, contentType, value), nil
diff --git a/pkg/util/resource/config_test.go b/pkg/util/resource/config_test.go
index bb28d858b..f099a0487 100644
--- a/pkg/util/resource/config_test.go
+++ b/pkg/util/resource/config_test.go
@@ -26,9 +26,7 @@ import (
func TestParseConfigOption(t *testing.T) {
validConfigMap := "configmap:my-config_map"
validSecret := "secret:my-secret"
- validFile := "file:/tmp/my-file.txt"
notValid := "someprotocol:wrong"
- validLocation := "file:my-file.txt@/tmp/another-name.xml"
configmap, err := ParseConfig(validConfigMap)
assert.Nil(t, err)
@@ -38,17 +36,8 @@ func TestParseConfigOption(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, StorageTypeSecret, secret.storageType)
assert.Equal(t, "my-secret", secret.Name())
- file, err := ParseConfig(validFile)
- assert.Nil(t, err)
- assert.Equal(t, StorageTypeFile, file.storageType)
- assert.Equal(t, "/tmp/my-file.txt", file.Name())
_, err = ParseConfig(notValid)
assert.NotNil(t, err)
- location, err := ParseConfig(validLocation)
- assert.Nil(t, err)
- assert.Equal(t, StorageTypeFile, location.storageType)
- assert.Equal(t, "my-file.txt", location.Name())
- assert.Equal(t, "/tmp/another-name.xml", location.DestinationPath())
}
func TestParseConfigOptionAllParams(t *testing.T) {
@@ -60,9 +49,6 @@ func TestParseConfigOptionAllParams(t *testing.T) {
sec2 := "secret:sec/key"
sec3 := "secret:sec@/tmp/sec"
sec4 := "secret:sec"
- file1 := "file:/path/to/my-file.txt@/tmp/file.txt"
- file2 := "file:/path/to/my-file.txt"
- file3 := "file:/path to/my-file.txt"
parsedCm1, err := ParseConfig(cm1)
assert.Nil(t, err)
@@ -119,25 +105,4 @@ func TestParseConfigOptionAllParams(t *testing.T) {
assert.Equal(t, "sec", parsedSec4.Name())
assert.Equal(t, "", parsedSec4.Key())
assert.Equal(t, "", parsedSec4.DestinationPath())
-
- parsedFile1, err := ParseConfig(file1)
- assert.Nil(t, err)
- assert.Equal(t, StorageTypeFile, parsedFile1.StorageType())
- assert.Equal(t, "/path/to/my-file.txt", parsedFile1.Name())
- assert.Equal(t, "", parsedFile1.Key())
- assert.Equal(t, "/tmp/file.txt", parsedFile1.DestinationPath())
-
- parsedFile2, err := ParseConfig(file2)
- assert.Nil(t, err)
- assert.Equal(t, StorageTypeFile, parsedFile2.StorageType())
- assert.Equal(t, "/path/to/my-file.txt", parsedFile2.Name())
- assert.Equal(t, "", parsedFile2.Key())
- assert.Equal(t, "", parsedFile2.DestinationPath())
-
- parsedFile3, err := ParseConfig(file3)
- assert.Nil(t, err)
- assert.Equal(t, StorageTypeFile, parsedFile3.StorageType())
- assert.Equal(t, "/path to/my-file.txt", parsedFile3.Name())
- assert.Equal(t, "", parsedFile3.Key())
- assert.Equal(t, "", parsedFile3.DestinationPath())
}