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

Move image to map #8362

Merged
merged 1 commit into from
Dec 3, 2024
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
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 ""
Comment on lines +125 to +135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the nested if-s a bit more, but it's still readable. :)

}
return ""
}
Loading