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

kamel install with sample #87

Merged
merged 1 commit into from
Sep 18, 2018
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
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