Skip to content

Commit

Permalink
Move image to map (#8362)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Wessendorf <[email protected]>
  • Loading branch information
matzew authored Dec 3, 2024
1 parent 408db83 commit 795e4a3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
26 changes: 15 additions & 11 deletions pkg/reconciler/integration/sink/resources/container_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ 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",
}

func MakeDeploymentSpec(sink *v1alpha1.IntegrationSink) *appsv1.Deployment {

deploy := &appsv1.Deployment{
Expand Down Expand Up @@ -148,16 +154,14 @@ func makeEnv(sink *v1alpha1.IntegrationSink) []corev1.EnvVar {
}

func selectImage(sink *v1alpha1.IntegrationSink) string {
if sink.Spec.Log != nil {
return "gcr.io/knative-nightly/log-sink:latest"
}
if sink.Spec.Aws != nil {
if sink.Spec.Aws.S3 != nil {
return "gcr.io/knative-nightly/aws-s3-source:latest"
}
if sink.Spec.Aws.SQS != nil {
return "gcr.io/knative-nightly/aws-sqs-source:latest"
}
switch {
case sink.Spec.Log != nil:
return sinkImageMap["log"]
case sink.Spec.Aws != nil && sink.Spec.Aws.S3 != nil:
return sinkImageMap["aws-s3"]
case sink.Spec.Aws != nil && sink.Spec.Aws.SQS != nil:
return sinkImageMap["aws-sqs"]
default:
return ""
}
return ""
}
33 changes: 19 additions & 14 deletions pkg/reconciler/integration/source/resources/containersource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ 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) *sourcesv1.ContainerSource {
return &sourcesv1.ContainerSource{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -114,19 +122,16 @@ func makeEnv(source *v1alpha1.IntegrationSource) []corev1.EnvVar {
}

func selectImage(source *v1alpha1.IntegrationSource) string {
if source.Spec.Timer != nil {
return "gcr.io/knative-nightly/timer-source:latest"
}
if source.Spec.Aws != nil {
if source.Spec.Aws.S3 != nil {
return "gcr.io/knative-nightly/aws-s3-source:latest"
}
if source.Spec.Aws.SQS != nil {
return "gcr.io/knative-nightly/aws-sqs-source:latest"
}
if source.Spec.Aws.DDBStreams != nil {
return "gcr.io/knative-nightly/aws-ddb-streams-source:latest"
}
switch {
case source.Spec.Timer != nil:
return sourceImageMap["timer"]
case source.Spec.Aws != nil && source.Spec.Aws.S3 != nil:
return sourceImageMap["aws-s3"]
case source.Spec.Aws != nil && source.Spec.Aws.SQS != nil:
return sourceImageMap["aws-sqs"]
case source.Spec.Aws != nil && source.Spec.Aws.DDBStreams != nil:
return sourceImageMap["aws-ddb-streams"]
default:
return ""
}
return ""
}

0 comments on commit 795e4a3

Please sign in to comment.