Skip to content

Commit

Permalink
Move KameletRepositorySpec to common types
Browse files Browse the repository at this point in the history
The spec may be used by other types in the future, too
  • Loading branch information
christophd committed Feb 20, 2024
1 parent a772b08 commit 52d1844
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 88 deletions.
52 changes: 26 additions & 26 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ string
a base image that can be used as base layer for all images.
It can be useful if you want to provide some custom base image with further utility softwares
It can be useful if you want to provide some custom base image with further utility software
|`registry` +
*xref:#_camel_apache_org_v1_RegistrySpec[RegistrySpec]*
Expand Down Expand Up @@ -2821,30 +2821,6 @@ A human-readable message indicating details about the transition.
IntegrationPlatformConditionType defines the type of condition.
[#_camel_apache_org_v1_IntegrationPlatformKameletRepositorySpec]
=== IntegrationPlatformKameletRepositorySpec
*Appears on:*
* <<#_camel_apache_org_v1_IntegrationPlatformKameletSpec, IntegrationPlatformKameletSpec>>
IntegrationPlatformKameletRepositorySpec defines the location of the Kamelet catalog to use.
[cols="2,2a",options="header"]
|===
|Field
|Description
|`uri` +
string
|
the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
|===
[#_camel_apache_org_v1_IntegrationPlatformKameletSpec]
=== IntegrationPlatformKameletSpec
Expand All @@ -2860,7 +2836,7 @@ IntegrationPlatformKameletSpec define the behavior for all the Kamelets controll
|Description
|`repositories` +
*xref:#_camel_apache_org_v1_IntegrationPlatformKameletRepositorySpec[[\]IntegrationPlatformKameletRepositorySpec]*
*xref:#_camel_apache_org_v1_KameletRepositorySpec[[\]KameletRepositorySpec]*
|
Expand Down Expand Up @@ -3722,6 +3698,30 @@ string
the default value of the property (if any)
|===
[#_camel_apache_org_v1_KameletRepositorySpec]
=== KameletRepositorySpec
*Appears on:*
* <<#_camel_apache_org_v1_IntegrationPlatformKameletSpec, IntegrationPlatformKameletSpec>>
KameletRepositorySpec defines the location of the Kamelet catalog to use.
[cols="2,2a",options="header"]
|===
|Field
|Description
|`uri` +
string
|
the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
|===
[#_camel_apache_org_v1_KameletSpec]
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/partials/apis/crds-html.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2818,14 +2818,14 @@ string
<div>
<p>IntegrationPlatformConditionType &ndash;</p>
</div>
<h3 id="camel.apache.org/v1.IntegrationPlatformKameletRepositorySpec">IntegrationPlatformKameletRepositorySpec
<h3 id="camel.apache.org/v1.KameletRepositorySpec">KameletRepositorySpec
</h3>
<p>
(<em>Appears on:</em>
<a href="#camel.apache.org/v1.IntegrationPlatformKameletSpec">IntegrationPlatformKameletSpec</a>)
</p>
<div>
<p>IntegrationPlatformKameletRepositorySpec &ndash;</p>
<p>KameletRepositorySpec &ndash;</p>
</div>
<table>
<thead>
Expand Down Expand Up @@ -2868,8 +2868,8 @@ string
<td>
<code>repositories</code><br/>
<em>
<a href="#camel.apache.org/v1.IntegrationPlatformKameletRepositorySpec">
[]IntegrationPlatformKameletRepositorySpec
<a href="#camel.apache.org/v1.KameletRepositorySpec">
[]KameletRepositorySpec
</a>
</em>
</td>
Expand Down
12 changes: 6 additions & 6 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
baseImage:
description: a base image that can be used as base layer for all
images. It can be useful if you want to provide some custom
base image with further utility softwares
base image with further utility software
type: string
buildCatalogToolTimeout:
description: 'the timeout (in seconds) to use when creating the
Expand Down Expand Up @@ -434,8 +434,8 @@ spec:
repositories:
description: remote repository used to retrieve Kamelet catalog
items:
description: IntegrationPlatformKameletRepositorySpec defines
the location of the Kamelet catalog to use.
description: KameletRepositorySpec defines the location of the
Kamelet catalog to use.
properties:
uri:
description: the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
Expand Down Expand Up @@ -1915,7 +1915,7 @@ spec:
baseImage:
description: a base image that can be used as base layer for all
images. It can be useful if you want to provide some custom
base image with further utility softwares
base image with further utility software
type: string
buildCatalogToolTimeout:
description: 'the timeout (in seconds) to use when creating the
Expand Down Expand Up @@ -2294,8 +2294,8 @@ spec:
repositories:
description: remote repository used to retrieve Kamelet catalog
items:
description: IntegrationPlatformKameletRepositorySpec defines
the location of the Kamelet catalog to use.
description: KameletRepositorySpec defines the location of the
Kamelet catalog to use.
properties:
uri:
description: the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
Expand Down
6 changes: 6 additions & 0 deletions pkg/apis/camel/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ var BuildOrderStrategies = []BuildOrderStrategy{
BuildOrderStrategySequential,
}

// KameletRepositorySpec defines the location of the Kamelet catalog to use.
type KameletRepositorySpec struct {
// the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
URI string `json:"uri,omitempty"`
}

// ConfigurationSpec represents a generic configuration specification.
type ConfigurationSpec struct {
// represents the type of configuration, ie: property, configmap, secret, ...
Expand Down
10 changes: 2 additions & 8 deletions pkg/apis/camel/v1/integrationplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type IntegrationPlatformBuildSpec struct {
// the runtime used. Likely Camel Quarkus (we used to have main runtime which has been discontinued since version 1.5)
RuntimeProvider RuntimeProvider `json:"runtimeProvider,omitempty"`
// a base image that can be used as base layer for all images.
// It can be useful if you want to provide some custom base image with further utility softwares
// It can be useful if you want to provide some custom base image with further utility software
BaseImage string `json:"baseImage,omitempty"`
// the image registry used to push/pull Integration images
Registry RegistrySpec `json:"registry,omitempty"`
Expand All @@ -140,13 +140,7 @@ type IntegrationPlatformBuildSpec struct {
// IntegrationPlatformKameletSpec define the behavior for all the Kamelets controller by the IntegrationPlatform.
type IntegrationPlatformKameletSpec struct {
// remote repository used to retrieve Kamelet catalog
Repositories []IntegrationPlatformKameletRepositorySpec `json:"repositories,omitempty"`
}

// IntegrationPlatformKameletRepositorySpec defines the location of the Kamelet catalog to use.
type IntegrationPlatformKameletRepositorySpec struct {
// the remote repository in the format github:ORG/REPO/PATH_TO_KAMELETS_FOLDER
URI string `json:"uri,omitempty"`
Repositories []KameletRepositorySpec `json:"repositories,omitempty"`
}

// IntegrationPlatformBuildPublishStrategy defines the strategy used to package and publish an Integration base image.
Expand Down
32 changes: 16 additions & 16 deletions pkg/apis/camel/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/client/camel/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/cmd/kamelet_add_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (o *kameletAddRepoCommandOptions) run(cmd *cobra.Command, args []string) er
if err := checkURI(uri, platform.Spec.Kamelet.Repositories); err != nil {
return err
}
platform.Spec.Kamelet.Repositories = append(platform.Spec.Kamelet.Repositories, v1.IntegrationPlatformKameletRepositorySpec{
platform.Spec.Kamelet.Repositories = append(platform.Spec.Kamelet.Repositories, v1.KameletRepositorySpec{
URI: uri,
})
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func (o *kameletUpdateRepoCommandOptions) findIntegrationPlatform(cmd *cobra.Com
return nil, nil
}

func checkURI(uri string, repositories []v1.IntegrationPlatformKameletRepositorySpec) error {
func checkURI(uri string, repositories []v1.KameletRepositorySpec) error {
if !kameletRepositoryURIRegexp.MatchString(uri) {
return fmt.Errorf("malformed Kamelet repository uri %s, the expected format is github:owner/repo[/path_to_kamelets_folder][@version]", uri)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/kamelet_add_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestKameletAddRepoNonExistingFlag(t *testing.T) {
}

func TestKameletAddRepoInvalidRepositoryURI(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{}
repositories := []v1.KameletRepositorySpec{}
assert.NotNil(t, checkURI("foo", repositories))
assert.NotNil(t, checkURI("github", repositories))
assert.NotNil(t, checkURI("github:", repositories))
Expand All @@ -76,15 +76,15 @@ func TestKameletAddRepoInvalidRepositoryURI(t *testing.T) {
}

func TestKameletAddRepoValidRepositoryURI(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{}
repositories := []v1.KameletRepositorySpec{}
assert.Nil(t, checkURI("github:foo/bar", repositories))
assert.Nil(t, checkURI("github:foo/bar/some/path", repositories))
assert.Nil(t, checkURI("github:foo/[email protected]", repositories))
assert.Nil(t, checkURI("github:foo/bar/some/[email protected]", repositories))
}

func TestKameletAddRepoDuplicateRepositoryURI(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{{URI: "github:foo/bar"}}
repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar"}}
assert.NotNil(t, checkURI("github:foo/bar", repositories))
assert.Nil(t, checkURI("github:foo/bar2", repositories))
}
2 changes: 1 addition & 1 deletion pkg/cmd/kamelet_remove_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (o *kameletRemoveRepoCommandOptions) run(cmd *cobra.Command, args []string)
return c.Update(o.Context, platform)
}

func getURIIndex(uri string, repositories []v1.IntegrationPlatformKameletRepositorySpec) (int, error) {
func getURIIndex(uri string, repositories []v1.KameletRepositorySpec) (int, error) {
for i, repo := range repositories {
if repo.URI == uri {
return i, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/kamelet_remove_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ func TestKameletRemoveRepoNonExistingFlag(t *testing.T) {
}

func TestKameletRemoveRepoURINotFoundEmpty(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{}
repositories := []v1.KameletRepositorySpec{}
_, err := getURIIndex("foo", repositories)
assert.NotNil(t, err)
}

func TestKameletRemoveRepoURINotFoundNotEmpty(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{{URI: "github:foo/bar"}}
repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar"}}
_, err := getURIIndex("foo", repositories)
assert.NotNil(t, err)
}

func TestKameletRemoveRepoURIFound(t *testing.T) {
repositories := []v1.IntegrationPlatformKameletRepositorySpec{{URI: "github:foo/bar1"}, {URI: "github:foo/bar2"}, {URI: "github:foo/bar3"}}
repositories := []v1.KameletRepositorySpec{{URI: "github:foo/bar1"}, {URI: "github:foo/bar2"}, {URI: "github:foo/bar3"}}
i, err := getURIIndex("github:foo/bar2", repositories)
assert.Nil(t, err)
assert.Equal(t, 1, i)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kamelet/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ func createTestContext(uris ...string) []runtime.Object {
},
}
if len(uris) > 0 {
repos := make([]v1.IntegrationPlatformKameletRepositorySpec, 0, len(uris))
repos := make([]v1.KameletRepositorySpec, 0, len(uris))
for _, uri := range uris {
repos = append(repos, v1.IntegrationPlatformKameletRepositorySpec{
repos = append(repos, v1.KameletRepositorySpec{
URI: uri,
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func setPlatformDefaults(p *v1.IntegrationPlatform, verbose bool) error {

if len(p.Status.Kamelet.Repositories) == 0 {
log.Debugf("Integration Platform %s [%s]: setting kamelet repositories", p.Name, p.Namespace)
p.Status.Kamelet.Repositories = append(p.Status.Kamelet.Repositories, v1.IntegrationPlatformKameletRepositorySpec{
p.Status.Kamelet.Repositories = append(p.Status.Kamelet.Repositories, v1.KameletRepositorySpec{
URI: repository.DefaultRemoteRepository,
})
}
Expand Down
Loading

0 comments on commit 52d1844

Please sign in to comment.