Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1818: add support for Kamelet repository #1830

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions config/crd/bases/camel.apache.org_integrationplatforms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
profile:
description: TraitProfile represents lists of traits that are enabled
for the specific installation/integration
Expand Down Expand Up @@ -338,6 +350,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
phase:
description: IntegrationPlatformPhase --
type: string
Expand Down
24 changes: 24 additions & 0 deletions deploy/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
profile:
description: TraitProfile represents lists of traits that are enabled
for the specific installation/integration
Expand Down Expand Up @@ -338,6 +350,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
phase:
description: IntegrationPlatformPhase --
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
profile:
description: TraitProfile represents lists of traits that are enabled
for the specific installation/integration
Expand Down Expand Up @@ -338,6 +350,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
phase:
description: IntegrationPlatformPhase --
type: string
Expand Down
4 changes: 2 additions & 2 deletions deploy/resources.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions e2e/yaks/common/apache-kamelet-catalog/kamelet.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Feature: Camel K can run Kamelets from default catalog

Scenario: Integrations can use default catalog
Given integration logger is running
Then integration logger should print Camel K
22 changes: 22 additions & 0 deletions e2e/yaks/common/apache-kamelet-catalog/logger.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// camel-k: language=groovy

/*
* 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.
*/

// timer-source is defined in the default Camel Kamelets catalog
from('kamelet:timer-source?message=Camel+K')
.log('${body}')
26 changes: 26 additions & 0 deletions e2e/yaks/common/apache-kamelet-catalog/yaks-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

config:
namespace:
temporary: true
pre:
- name: installation
run: |
kamel install -n $YAKS_NAMESPACE

kamel run logger.groovy -w -n $YAKS_NAMESPACE
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/Masterminds/semver v1.5.0
github.com/apache/camel-k/pkg/apis/camel v0.0.0
github.com/apache/camel-k/pkg/client/camel v0.0.0
github.com/apache/camel-k/pkg/kamelet/repository v0.0.0
github.com/container-tools/spectrum v0.3.2
github.com/evanphx/json-patch v4.9.0+incompatible
github.com/fatih/structs v1.1.0
Expand Down Expand Up @@ -66,4 +67,5 @@ replace github.com/google/go-containerregistry => github.com/nicolaferraro/go-co
replace (
github.com/apache/camel-k/pkg/apis/camel => ./pkg/apis/camel
github.com/apache/camel-k/pkg/client/camel => ./pkg/client/camel
github.com/apache/camel-k/pkg/kamelet/repository => ./pkg/kamelet/repository
)
24 changes: 24 additions & 0 deletions helm/camel-k/crds/crd-integration-platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
profile:
description: TraitProfile represents lists of traits that are enabled
for the specific installation/integration
Expand Down Expand Up @@ -338,6 +350,18 @@ spec:
- value
type: object
type: array
kamelet:
description: IntegrationPlatformKameletSpec --
properties:
repositories:
items:
description: IntegrationPlatformKameletRepositorySpec --
properties:
uri:
type: string
type: object
type: array
type: object
phase:
description: IntegrationPlatformPhase --
type: string
Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/camel/v1/integrationplatform_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type IntegrationPlatformSpec struct {
Resources IntegrationPlatformResourcesSpec `json:"resources,omitempty"`
Traits map[string]TraitSpec `json:"traits,omitempty"`
Configuration []ConfigurationSpec `json:"configuration,omitempty"`
Kamelet IntegrationPlatformKameletSpec `json:"kamelet,omitempty"`
}

// IntegrationPlatformResourcesSpec contains platform related resources
Expand Down Expand Up @@ -128,6 +129,16 @@ type IntegrationPlatformRegistrySpec struct {
Organization string `json:"organization,omitempty"`
}

// IntegrationPlatformKameletSpec --
type IntegrationPlatformKameletSpec struct {
Repositories []IntegrationPlatformKameletRepositorySpec `json:"repositories,omitempty"`
}

// IntegrationPlatformKameletRepositorySpec --
type IntegrationPlatformKameletRepositorySpec struct {
URI string `json:"uri,omitempty"`
}

// IntegrationPlatformBuildStrategy enumerates all implemented build strategies
type IntegrationPlatformBuildStrategy string

Expand Down
36 changes: 36 additions & 0 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.

28 changes: 28 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"os"
"path/filepath"

camelv1 "github.com/apache/camel-k/pkg/client/camel/clientset/versioned/typed/camel/v1"
camelv1alpha1 "github.com/apache/camel-k/pkg/client/camel/clientset/versioned/typed/camel/v1alpha1"
user "github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand All @@ -42,6 +44,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/apache/camel-k/pkg/apis"
camel "github.com/apache/camel-k/pkg/client/camel/clientset/versioned"
)

const (
Expand All @@ -53,6 +56,8 @@ const (
type Client interface {
controller.Client
kubernetes.Interface
CamelV1() camelv1.CamelV1Interface
CamelV1alpha1() camelv1alpha1.CamelV1alpha1Interface
GetScheme() *runtime.Scheme
GetConfig() *rest.Config
GetCurrentNamespace(kubeConfig string) (string, error)
Expand All @@ -71,10 +76,22 @@ type Provider struct {
type defaultClient struct {
controller.Client
kubernetes.Interface
camel camel.Interface
scheme *runtime.Scheme
config *rest.Config
}

// Check interface compliance
var _ Client = &defaultClient{}

func (c *defaultClient) CamelV1() camelv1.CamelV1Interface {
return c.camel.CamelV1()
}

func (c *defaultClient) CamelV1alpha1() camelv1alpha1.CamelV1alpha1Interface {
return c.camel.CamelV1alpha1()
}

func (c *defaultClient) GetScheme() *runtime.Scheme {
return c.scheme
}
Expand Down Expand Up @@ -114,6 +131,11 @@ func NewClient(fastDiscovery bool) (Client, error) {
return nil, err
}

var camelClientset camel.Interface
if camelClientset, err = camel.NewForConfig(cfg); err != nil {
return nil, err
}

var mapper meta.RESTMapper
if fastDiscovery {
mapper = newFastDiscoveryRESTMapper(cfg)
Expand All @@ -132,6 +154,7 @@ func NewClient(fastDiscovery bool) (Client, error) {
return &defaultClient{
Client: dynClient,
Interface: clientset,
camel: camelClientset,
scheme: clientOptions.Scheme,
config: cfg,
}, nil
Expand All @@ -144,9 +167,14 @@ func FromManager(manager manager.Manager) (Client, error) {
if clientset, err = kubernetes.NewForConfig(manager.GetConfig()); err != nil {
return nil, err
}
var camelClientset camel.Interface
if camelClientset, err = camel.NewForConfig(manager.GetConfig()); err != nil {
return nil, err
}
return &defaultClient{
Client: manager.GetClient(),
Interface: clientset,
camel: camelClientset,
scheme: manager.GetScheme(),
config: manager.GetConfig(),
}, nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/kamelet/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"

"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
kameletutils "github.com/apache/camel-k/pkg/kamelet"
)

// NewInitializeAction returns a action that initializes the kamelet configuration when not provided by the user
Expand All @@ -41,5 +42,5 @@ func (action *initializeAction) CanHandle(kamelet *v1alpha1.Kamelet) bool {
}

func (action *initializeAction) Handle(ctx context.Context, kamelet *v1alpha1.Kamelet) (*v1alpha1.Kamelet, error) {
return updateStatus(kamelet)
return kameletutils.Initialize(kamelet)
}
Loading