Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
48 changes: 48 additions & 0 deletions config/core/deployments/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,54 @@ spec:
key: transform-jsonata
name: eventing-transformations-images

- name: INTEGRATION_SOURCE_TIMER_IMAGE
valueFrom:
configMapKeyRef:
key: timer-source
name: eventing-integrations-images

- name: INTEGRATION_SOURCE_AWS_S3_IMAGE
valueFrom:
configMapKeyRef:
key: aws-s3-source
name: eventing-integrations-images

- name: INTEGRATION_SOURCE_AWS_SQS_IMAGE
valueFrom:
configMapKeyRef:
key: aws-sqs-source
name: eventing-integrations-images

- name: INTEGRATION_SOURCE_AWS_DDB_STREAMS_IMAGE
valueFrom:
configMapKeyRef:
key: aws-ddb-streams-source
name: eventing-integrations-images

- name: INTEGRATION_SINK_LOG_IMAGE
valueFrom:
configMapKeyRef:
key: log-sink
name: eventing-integrations-images

- name: INTEGRATION_SINK_AWS_S3_IMAGE
valueFrom:
configMapKeyRef:
key: aws-s3-sink
name: eventing-integrations-images

- name: INTEGRATION_SINK_AWS_SQS_IMAGE
valueFrom:
configMapKeyRef:
key: aws-sqs-sink
name: eventing-integrations-images

- name: INTEGRATION_SINK_AWS_SNS_IMAGE
valueFrom:
configMapKeyRef:
key: aws-sns-sink
name: eventing-integrations-images

## Adapter settings
# - name: K_LOGGING_CONFIG
# value: ''
Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/integration/sink/integrationsink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const (
sinkName = "test-integration-sink"
sinkUID = "1234-5678-90"
testNS = "test-namespace"

logSinkImage = "quay.io/fake-image/log-sink"
)

var (
Expand All @@ -74,6 +76,7 @@ var (
)

func TestReconcile(t *testing.T) {
t.Setenv("INTEGRATION_SINK_LOG_IMAGE", logSinkImage)

table := TableTest{
{
Expand Down Expand Up @@ -202,7 +205,7 @@ func makeDeployment(sink *sinksv1alpha1.IntegrationSink, ready *corev1.Condition
Containers: []corev1.Container{
{
Name: "sink",
Image: "gcr.io/knative-nightly/log-sink:latest",
Image: logSinkImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Ports: []corev1.ContainerPort{
{
Expand Down
18 changes: 7 additions & 11 deletions pkg/reconciler/integration/sink/resources/container_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package resources

import (
"os"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -28,13 +30,6 @@ import (
"knative.dev/pkg/kmeta"
)

var sinkImageMap = map[string]string{
"log": "gcr.io/knative-nightly/log-sink:latest",
"aws-s3": "gcr.io/knative-nightly/aws-s3-sink:latest",
"aws-sqs": "gcr.io/knative-nightly/aws-sqs-sink:latest",
"aws-sns": "gcr.io/knative-nightly/aws-sns-sink:latest",
}

func MakeDeploymentSpec(sink *v1alpha1.IntegrationSink, featureFlags feature.Flags) *appsv1.Deployment {
//t := true

Expand Down Expand Up @@ -219,15 +214,16 @@ func makeEnv(sink *v1alpha1.IntegrationSink, featureFlags feature.Flags) []corev
}

func selectImage(sink *v1alpha1.IntegrationSink) string {
// Injected in ./config/core/deployments/controller.yaml
switch {
case sink.Spec.Log != nil:
return sinkImageMap["log"]
return os.Getenv("INTEGRATION_SINK_LOG_IMAGE")
case sink.Spec.Aws != nil && sink.Spec.Aws.S3 != nil:
return sinkImageMap["aws-s3"]
return os.Getenv("INTEGRATION_SINK_AWS_S3_IMAGE")
case sink.Spec.Aws != nil && sink.Spec.Aws.SQS != nil:
return sinkImageMap["aws-sqs"]
return os.Getenv("INTEGRATION_SINK_AWS_SQS_IMAGE")
case sink.Spec.Aws != nil && sink.Spec.Aws.SNS != nil:
return sinkImageMap["aws-sns"]
return os.Getenv("INTEGRATION_SINK_AWS_SNS_IMAGE")
default:
return ""
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/reconciler/integration/source/integrationsource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const (
testNS = "testnamespace"
sinkName = "testsink"
generation = 1

timerSourceImage = "quay.io/fake-image/timer-source"
)

var (
Expand All @@ -75,6 +77,7 @@ var (
)

func TestReconcile(t *testing.T) {
t.Setenv("INTEGRATION_SOURCE_TIMER_IMAGE", timerSourceImage)

table := TableTest{
{
Expand Down Expand Up @@ -242,7 +245,7 @@ func makeContainerSource(source *sourcesv1alpha1.IntegrationSource, ready *corev
Containers: []corev1.Container{
{
Name: "source",
Image: "gcr.io/knative-nightly/timer-source:latest",
Image: timerSourceImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Env: []corev1.EnvVar{
{
Expand Down
19 changes: 7 additions & 12 deletions pkg/reconciler/integration/source/resources/containersource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package resources

import (
"os"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
commonv1a1 "knative.dev/eventing/pkg/apis/common/integration/v1alpha1"
Expand All @@ -26,14 +28,6 @@ import (
"knative.dev/pkg/kmeta"
)

// TODO: replace with ConfigMap
var sourceImageMap = map[string]string{
"timer": "gcr.io/knative-nightly/timer-source:latest",
"aws-s3": "gcr.io/knative-nightly/aws-s3-source:latest",
"aws-sqs": "gcr.io/knative-nightly/aws-sqs-source:latest",
"aws-ddb-streams": "gcr.io/knative-nightly/aws-ddb-streams-source:latest",
}

func NewContainerSource(source *v1alpha1.IntegrationSource, oidc bool) *sourcesv1.ContainerSource {
return &sourcesv1.ContainerSource{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -135,15 +129,16 @@ func makeEnv(source *v1alpha1.IntegrationSource, oidc bool) []corev1.EnvVar {
}

func selectImage(source *v1alpha1.IntegrationSource) string {
// Injected in ./config/core/deployments/controller.yaml
switch {
case source.Spec.Timer != nil:
return sourceImageMap["timer"]
return os.Getenv("INTEGRATION_SOURCE_TIMER_IMAGE")
case source.Spec.Aws != nil && source.Spec.Aws.S3 != nil:
return sourceImageMap["aws-s3"]
return os.Getenv("INTEGRATION_SOURCE_AWS_S3_IMAGE")
case source.Spec.Aws != nil && source.Spec.Aws.SQS != nil:
return sourceImageMap["aws-sqs"]
return os.Getenv("INTEGRATION_SOURCE_AWS_SQS_IMAGE")
case source.Spec.Aws != nil && source.Spec.Aws.DDBStreams != nil:
return sourceImageMap["aws-ddb-streams"]
return os.Getenv("INTEGRATION_SOURCE_AWS_DDB_STREAMS_IMAGE")
default:
return ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const (
)

func TestNewContainerSource(t *testing.T) {
const timerImage = "quay.io/timer-image"
t.Setenv("INTEGRATION_SOURCE_TIMER_IMAGE", timerImage)

source := &v1alpha1.IntegrationSource{

ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -80,7 +83,7 @@ func TestNewContainerSource(t *testing.T) {
Containers: []corev1.Container{
{
Name: "source",
Image: "gcr.io/knative-nightly/timer-source:latest",
Image: timerImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Env: []corev1.EnvVar{
{Name: "CAMEL_KNATIVE_CLIENT_SSL_ENABLED", Value: "true"},
Expand Down
Loading