You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2018/09/07 07:37:23 UTC

[camel-k] branch master updated (f42dedf -> ae2a059)

This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from f42dedf  Detect changes with digest and redeploy
     new ce21143  Added kamel binary
     new ae2a059  Renaming binaries and adding code generation

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |  3 +-
 Gopkg.lock                                         | 14 ++++-
 build/Makefile                                     | 12 +++-
 cmd/{camel-k => camel-k-operator}/main.go          |  0
 pkg/util/test/testing_env.go => cmd/kamel/main.go  | 22 ++++---
 config/config.yaml                                 |  2 +-
 deploy/operator.yaml                               | 12 ++--
 pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go   | 46 ++++++++++++++-
 pkg/build/local/local_builder_integration_test.go  |  1 +
 pkg/{stub/action/action.go => cmd/cmd.go}          | 26 ++++----
 .../action/action.go => cmd/config/config.go}      | 42 +++++++++----
 pkg/cmd/run/run.go                                 | 69 ++++++++++++++++++++++
 {version => pkg/cmd/version}/version.go            | 19 +++++-
 tmp/build/Dockerfile                               |  6 +-
 tmp/build/build.sh                                 |  2 +-
 tmp/codegen/boilerplate.go.txt                     | 15 +++++
 16 files changed, 243 insertions(+), 48 deletions(-)
 rename cmd/{camel-k => camel-k-operator}/main.go (100%)
 copy pkg/util/test/testing_env.go => cmd/kamel/main.go (75%)
 copy pkg/{stub/action/action.go => cmd/cmd.go} (50%)
 copy pkg/{stub/action/action.go => cmd/config/config.go} (51%)
 create mode 100644 pkg/cmd/run/run.go
 copy {version => pkg/cmd/version}/version.go (67%)


[camel-k] 01/02: Added kamel binary

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit ce211433814eca6c6218ea0c8ef4840703cfd776
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Sep 7 01:07:02 2018 +0200

    Added kamel binary
---
 .gitignore                 |  3 +-
 Gopkg.lock                 | 14 +++++++++-
 build/Makefile             |  9 ++++--
 cmd/kamel/main.go          | 36 ++++++++++++++++++++++++
 pkg/cmd/cmd.go             | 39 ++++++++++++++++++++++++++
 pkg/cmd/config/config.go   | 53 +++++++++++++++++++++++++++++++++++
 pkg/cmd/run/run.go         | 69 ++++++++++++++++++++++++++++++++++++++++++++++
 pkg/cmd/version/version.go | 37 +++++++++++++++++++++++++
 8 files changed, 256 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 319e113..1b5f6d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 # Binary files
-/camel-k
+/operator
+/kamel
 
 # We do not stage vendor directory
 /vendor
diff --git a/Gopkg.lock b/Gopkg.lock
index 08cdcda..8c9833a 100644
--- a/Gopkg.lock
+++ b/Gopkg.lock
@@ -135,6 +135,12 @@
   version = "v0.3.6"
 
 [[projects]]
+  name = "github.com/inconshreveable/mousetrap"
+  packages = ["."]
+  revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
+  version = "v1.0"
+
+[[projects]]
   name = "github.com/json-iterator/go"
   packages = ["."]
   revision = "1624edc4454b8682399def8740d46db5e4362ba4"
@@ -251,6 +257,12 @@
   version = "v1.0.6"
 
 [[projects]]
+  name = "github.com/spf13/cobra"
+  packages = ["."]
+  revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385"
+  version = "v0.0.3"
+
+[[projects]]
   name = "github.com/spf13/pflag"
   packages = ["."]
   revision = "9a97c102cda95a86cec2345a6f09f55a939babf5"
@@ -572,6 +584,6 @@
 [solve-meta]
   analyzer-name = "dep"
   analyzer-version = 1
-  inputs-digest = "fe3fc8a50615445124a1a85023b09a54b2aa9f0dfc077f6c4823b46ee4ba7ef1"
+  inputs-digest = "c389a066bf0697a6e8a5b618cb76954f299b9d346e69cc46dade09c1de436ce8"
   solver-name = "gps-cdcl"
   solver-version = 1
diff --git a/build/Makefile b/build/Makefile
index 4d9c017..7be3aed 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -1,7 +1,12 @@
 VERSION := $(shell ./build/get_version.sh)
 
-install:
-	go build -o camel-k ./cmd/camel-k/*.go
+build: build-operator build-kamel
+
+build-operator:
+	go build -o operator ./cmd/camel-k/*.go
+
+build-kamel:
+	go build -o kamel ./cmd/kamel/*.go
 
 images:
 	operator-sdk build docker.io/apache/camel-k:$(VERSION)
diff --git a/cmd/kamel/main.go b/cmd/kamel/main.go
new file mode 100644
index 0000000..bc1c1bb
--- /dev/null
+++ b/cmd/kamel/main.go
@@ -0,0 +1,36 @@
+/*
+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 main
+
+import (
+	_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
+	"fmt"
+	"os"
+	"github.com/apache/camel-k/pkg/cmd"
+)
+
+func main() {
+
+	rootCmd := cmd.NewKamelCommand()
+
+	if err := rootCmd.Execute(); err != nil {
+		fmt.Println(err)
+		os.Exit(1)
+	}
+
+}
diff --git a/pkg/cmd/cmd.go b/pkg/cmd/cmd.go
new file mode 100644
index 0000000..dacf440
--- /dev/null
+++ b/pkg/cmd/cmd.go
@@ -0,0 +1,39 @@
+/*
+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 (
+	"github.com/spf13/cobra"
+	"github.com/apache/camel-k/pkg/cmd/version"
+	"github.com/apache/camel-k/pkg/cmd/run"
+)
+
+func NewKamelCommand() *cobra.Command {
+	var rootCmd = cobra.Command{
+		Use: "kamel",
+		Short: "Kamel is a awesome client tool for running Apache Camel integrations natively on Kubernetes",
+		Long: "Apache Camel K (a.k.a. Kamel) is a lightweight integration framework\nbuilt from Apache Camel that runs natively on Kubernetes and is\nspecifically designed for serverless and microservice architectures.",
+
+	}
+
+	var kubeconfig string
+	rootCmd.PersistentFlags().StringVar(&kubeconfig, "config", "", "Path to the config file to use for CLI requests")
+
+	rootCmd.AddCommand(version.NewCmdVersion(), run.NewCmdRun())
+	return &rootCmd
+}
\ No newline at end of file
diff --git a/pkg/cmd/config/config.go b/pkg/cmd/config/config.go
new file mode 100644
index 0000000..1e8583e
--- /dev/null
+++ b/pkg/cmd/config/config.go
@@ -0,0 +1,53 @@
+/*
+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 config
+
+import (
+	"path/filepath"
+	"k8s.io/client-go/tools/clientcmd"
+	"os"
+	"k8s.io/client-go/kubernetes"
+	"github.com/spf13/cobra"
+)
+
+func NewKubeClient(cmd *cobra.Command) (*kubernetes.Clientset, error) {
+	kubeconfig := cmd.Flag("config").Value.String()
+	if kubeconfig == "" {
+		kubeconfig = filepath.Join(homeDir(), ".kube", "config")
+	}
+
+	// use the current context in kubeconfig
+	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
+	if err != nil {
+		return nil, err
+	}
+
+	// create the clientset
+	clientset, err := kubernetes.NewForConfig(config)
+	if err != nil {
+		return nil, err
+	}
+	return clientset, nil
+}
+
+func homeDir() string {
+	if h := os.Getenv("HOME"); h != "" {
+		return h
+	}
+	return os.Getenv("USERPROFILE") // windows
+}
diff --git a/pkg/cmd/run/run.go b/pkg/cmd/run/run.go
new file mode 100644
index 0000000..6510635
--- /dev/null
+++ b/pkg/cmd/run/run.go
@@ -0,0 +1,69 @@
+/*
+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 run
+
+import (
+	"github.com/spf13/cobra"
+	"errors"
+	"strconv"
+	"os"
+	"github.com/apache/camel-k/pkg/cmd/config"
+	"fmt"
+)
+
+type runCmdFlags struct {
+	language string
+}
+
+func NewCmdRun() *cobra.Command {
+	flags := runCmdFlags{}
+	cmd := cobra.Command{
+		Use:   "run [file to run]",
+		Short: "Run a integration on Kubernetes",
+		Long:  `Deploys and execute a integration pod on Kubernetes.`,
+		Args: validateArgs,
+		RunE: run,
+	}
+
+	cmd.Flags().StringVarP(&flags.language, "language", "l", "", "Programming Language used to write the file")
+
+	return &cmd
+}
+
+func validateArgs(cmd *cobra.Command, args []string) error {
+	if len(args) != 1 {
+		return errors.New("accepts 1 arg, received " + strconv.Itoa(len(args)))
+	}
+	fileName := args[0]
+	if _, err := os.Stat(fileName); err != nil && os.IsNotExist(err) {
+		return errors.New("file " + fileName + " does not exist")
+	} else if err != nil {
+		return errors.New("error while accessing file " + fileName)
+	}
+	return nil
+}
+
+func run(cmd *cobra.Command, args []string) error {
+	_, err := config.NewKubeClient(cmd)
+	if err != nil {
+		return err
+	}
+
+	fmt.Println("Now something should run")
+	return nil
+}
diff --git a/pkg/cmd/version/version.go b/pkg/cmd/version/version.go
new file mode 100644
index 0000000..5eadbfb
--- /dev/null
+++ b/pkg/cmd/version/version.go
@@ -0,0 +1,37 @@
+/*
+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 version
+
+import (
+	"github.com/spf13/cobra"
+	"fmt"
+	rootVersion "github.com/apache/camel-k/version"
+)
+
+
+func NewCmdVersion() *cobra.Command {
+	return &cobra.Command{
+		Use:   "version",
+		Short: "Display client version",
+		Long:  `Display Camel K client version.`,
+		Run: func(cmd *cobra.Command, args []string) {
+			fmt.Println("Camel K Client " + rootVersion.Version)
+		},
+	}
+}
+


[camel-k] 02/02: Renaming binaries and adding code generation

Posted by nf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit ae2a0599e7c9e912c89b4a851177b0c1b6f1eb31
Author: nferraro <ni...@gmail.com>
AuthorDate: Fri Sep 7 08:31:48 2018 +0200

    Renaming binaries and adding code generation
---
 .gitignore                                        |  2 +-
 build/Makefile                                    |  5 ++-
 cmd/{camel-k => camel-k-operator}/main.go         |  0
 config/config.yaml                                |  2 +-
 deploy/operator.yaml                              | 12 +++---
 pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go  | 46 ++++++++++++++++++++++-
 pkg/build/local/local_builder_integration_test.go |  1 +
 tmp/build/Dockerfile                              |  6 +--
 tmp/build/build.sh                                |  2 +-
 tmp/codegen/boilerplate.go.txt                    | 15 ++++++++
 10 files changed, 77 insertions(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1b5f6d1..4456437 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
 # Binary files
-/operator
+/camel-k-operator
 /kamel
 
 # We do not stage vendor directory
diff --git a/build/Makefile b/build/Makefile
index 7be3aed..cd0711f 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -3,11 +3,14 @@ VERSION := $(shell ./build/get_version.sh)
 build: build-operator build-kamel
 
 build-operator:
-	go build -o operator ./cmd/camel-k/*.go
+	go build -o camel-k-operator ./cmd/camel-k-operator/*.go
 
 build-kamel:
 	go build -o kamel ./cmd/kamel/*.go
 
+codegen:
+	./tmp/codegen/update-generated.sh
+
 images:
 	operator-sdk build docker.io/apache/camel-k:$(VERSION)
 
diff --git a/cmd/camel-k/main.go b/cmd/camel-k-operator/main.go
similarity index 100%
rename from cmd/camel-k/main.go
rename to cmd/camel-k-operator/main.go
diff --git a/config/config.yaml b/config/config.yaml
index 45de913..71ecb89 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -1,3 +1,3 @@
 apiVersion: camel.apache.org/v1alpha1
 kind: Integration
-projectName: camel-k
+projectName: camel-k-operator
diff --git a/deploy/operator.yaml b/deploy/operator.yaml
index 9d0fc83..863b21c 100644
--- a/deploy/operator.yaml
+++ b/deploy/operator.yaml
@@ -1,25 +1,25 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: camel-k
+  name: camel-k-operator
 spec:
   replicas: 1
   selector:
     matchLabels:
-      name: camel-k
+      name: camel-k-operator
   template:
     metadata:
       labels:
-        name: camel-k
+        name: camel-k-operator
     spec:
       containers:
-        - name: camel-k
+        - name: camel-k-operator
           image: docker.io/apache/camel-k:0.0.1-SNAPSHOT
           ports:
           - containerPort: 60000
             name: metrics
           command:
-          - camel-k
+          - camel-k-operator
           imagePullPolicy: Always
           env:
             - name: WATCH_NAMESPACE
@@ -27,4 +27,4 @@ spec:
                 fieldRef:
                   fieldPath: metadata.namespace
             - name: OPERATOR_NAME
-              value: "camel-k"
+              value: "camel-k-operator"
diff --git a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
index 8b2935d..213f57a 100644
--- a/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1alpha1/zz_generated.deepcopy.go
@@ -1,5 +1,22 @@
 // +build !ignore_autogenerated
 
+/*
+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.
+*/
+
 // Code generated by deepcopy-gen. DO NOT EDIT.
 
 package v1alpha1
@@ -13,7 +30,7 @@ func (in *Integration) DeepCopyInto(out *Integration) {
 	*out = *in
 	out.TypeMeta = in.TypeMeta
 	in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
-	out.Spec = in.Spec
+	in.Spec.DeepCopyInto(&out.Spec)
 	out.Status = in.Status
 	return
 }
@@ -72,6 +89,12 @@ func (in *IntegrationList) DeepCopyObject() runtime.Object {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *IntegrationSpec) DeepCopyInto(out *IntegrationSpec) {
 	*out = *in
+	if in.Replicas != nil {
+		in, out := &in.Replicas, &out.Replicas
+		*out = new(int32)
+		**out = **in
+	}
+	in.Source.DeepCopyInto(&out.Source)
 	return
 }
 
@@ -100,3 +123,24 @@ func (in *IntegrationStatus) DeepCopy() *IntegrationStatus {
 	in.DeepCopyInto(out)
 	return out
 }
+
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
+func (in *SourceSpec) DeepCopyInto(out *SourceSpec) {
+	*out = *in
+	if in.Code != nil {
+		in, out := &in.Code, &out.Code
+		*out = new(string)
+		**out = **in
+	}
+	return
+}
+
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SourceSpec.
+func (in *SourceSpec) DeepCopy() *SourceSpec {
+	if in == nil {
+		return nil
+	}
+	out := new(SourceSpec)
+	in.DeepCopyInto(out)
+	return out
+}
diff --git a/pkg/build/local/local_builder_integration_test.go b/pkg/build/local/local_builder_integration_test.go
index ff14663..8403c6c 100644
--- a/pkg/build/local/local_builder_integration_test.go
+++ b/pkg/build/local/local_builder_integration_test.go
@@ -24,6 +24,7 @@ import (
 	"context"
 	"github.com/stretchr/testify/assert"
 	build "github.com/apache/camel-k/pkg/build/api"
+	"github.com/apache/camel-k/pkg/util/test"
 )
 
 func TestBuild(t *testing.T) {
diff --git a/tmp/build/Dockerfile b/tmp/build/Dockerfile
index 09b528e..519d9b7 100644
--- a/tmp/build/Dockerfile
+++ b/tmp/build/Dockerfile
@@ -1,6 +1,6 @@
 FROM alpine:3.6
 
-RUN adduser -D camel-k
-USER camel-k
+RUN adduser -D camel-k-operator
+USER camel-k-operator
 
-ADD tmp/_output/bin/camel-k /usr/local/bin/camel-k
+ADD tmp/_output/bin/camel-k-operator /usr/local/bin/camel-k-operator
diff --git a/tmp/build/build.sh b/tmp/build/build.sh
index 6755c89..4b3d433 100755
--- a/tmp/build/build.sh
+++ b/tmp/build/build.sh
@@ -11,7 +11,7 @@ fi
 
 BIN_DIR="$(pwd)/tmp/_output/bin"
 mkdir -p ${BIN_DIR}
-PROJECT_NAME="camel-k"
+PROJECT_NAME="camel-k-operator"
 REPO_PATH="github.com/apache/camel-k"
 BUILD_PATH="${REPO_PATH}/cmd/${PROJECT_NAME}"
 echo "building "${PROJECT_NAME}"..."
diff --git a/tmp/codegen/boilerplate.go.txt b/tmp/codegen/boilerplate.go.txt
index 8b13789..c61bcc7 100644
--- a/tmp/codegen/boilerplate.go.txt
+++ b/tmp/codegen/boilerplate.go.txt
@@ -1 +1,16 @@
+/*
+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.
+*/