Skip to content

Commit

Permalink
kamel install with example
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvolod committed Sep 18, 2018
1 parent a41ac0b commit 2c25042
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 40 deletions.
22 changes: 22 additions & 0 deletions deploy/cr-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: camel.apache.org/v1alpha1
kind: Integration
metadata:
name: example
spec:
dependencies:
- camel:groovy
source:
content: |-
// This is Camel K Groovy example route
rnd = new Random()
from('timer:groovy?period=1s')
.routeId('groovy')
.setBody()
.constant('Hello Camel K!')
.process {
it.in.headers['RandomValue'] = rnd.nextInt()
}
.to('log:info?showHeaders=true')
name: routes.groovy
22 changes: 0 additions & 22 deletions deploy/cr.yaml

This file was deleted.

35 changes: 17 additions & 18 deletions deploy/resources.go

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

9 changes: 9 additions & 0 deletions pkg/client/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
}

cmd.Flags().BoolVar(&options.clusterSetupOnly, "cluster-setup", false, "Execute cluster-wide operations only (may require admin rights)")
cmd.Flags().BoolVar(&options.exampleSetup, "example", false, "Install example integration")
cmd.ParseFlags(os.Args)

return &cmd
Expand All @@ -48,6 +49,7 @@ func NewCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command {
type installCmdOptions struct {
*RootCmdOptions
clusterSetupOnly bool
exampleSetup bool
}

func (o *installCmdOptions) install(cmd *cobra.Command, args []string) error {
Expand All @@ -74,6 +76,13 @@ func (o *installCmdOptions) install(cmd *cobra.Command, args []string) error {
return err
}

if o.exampleSetup {
err = install.Example(namespace)
if err != nil {
return err
}
}

fmt.Println("Camel K installed in namespace", namespace)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/install/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ func PlatformContexts(namespace string) error {
)
}

// Example --
func Example(namespace string) error {
return installResources(namespace,
"cr-example.yaml",
)
}

func installResources(namespace string, names ...string) error {
for _, name := range names {
if err := installResource(namespace, name); err != nil {
Expand Down

0 comments on commit 2c25042

Please sign in to comment.