forked from apache/camel-k
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix apache#324: use standard deployment when knative-services are not…
… needed
- Loading branch information
1 parent
6ea21ff
commit 715a1b9
Showing
10 changed files
with
453 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
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 trait | ||
|
||
import ( | ||
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1" | ||
"github.com/apache/camel-k/pkg/client" | ||
"github.com/apache/camel-k/pkg/metadata" | ||
"golang.org/x/net/context" | ||
) | ||
|
||
// ControllerStrategy determines the kind of controller that needs to be created for the integration | ||
type ControllerStrategy string | ||
|
||
// List of controller strategies | ||
const ( | ||
ControllerStrategyDeployment = "deployment" | ||
ControllerStrategyKnativeService = "knative-service" | ||
) | ||
|
||
// DetermineControllerStrategy determines the type of controller that should be used for the integration | ||
func DetermineControllerStrategy(ctx context.Context, c client.Client, e *Environment) (ControllerStrategy, error) { | ||
if e.DetermineProfile() != v1alpha1.TraitProfileKnative { | ||
return ControllerStrategyDeployment, nil | ||
} | ||
|
||
sources := e.Integration.Sources() | ||
var err error | ||
if sources, err = GetEnrichedSources(ctx, c, e, sources); err != nil { | ||
return "", err | ||
} | ||
|
||
// In Knative profile: use knative service only if needed | ||
meta := metadata.ExtractAll(sources) | ||
if !meta.RequiresHTTPService { | ||
return ControllerStrategyDeployment, nil | ||
} | ||
|
||
return ControllerStrategyKnativeService, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.