Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: a3hadi <[email protected]>
  • Loading branch information
ayildirim21 committed Mar 11, 2024
1 parent c56eefd commit 44ab995
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 41 deletions.
4 changes: 2 additions & 2 deletions pkg/mapper/examples/even_odd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/even-odd-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-even-odd:${TAG}" --platform linux/amd64,linux/arm64 --target even-odd . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-even-odd:${TAG}" --target even-odd .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-even-odd:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/mapper/examples/flatmap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/flatmap-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-flatmap:${TAG}" --platform linux/amd64,linux/arm64 --target flatmap . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-flatmap:${TAG}" --target flatmap .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-flatmap:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/mapper/examples/forward_message/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/forward-message-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-forward-message:${TAG}" --platform linux/amd64,linux/arm64 --target forward-message . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-forward-message:${TAG}" --target forward-message .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-forward-message:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/mapper/examples/retry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/retry main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-retry:${TAG}" --platform linux/amd64,linux/arm64 --target retry . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-retry:${TAG}" --target map-retry .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-retry:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/mapper/examples/tickgen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/tickgen-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-tickgen:${TAG}" --platform linux/amd64,linux/arm64 --target tickgen . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-tickgen:${TAG}" --target tickgen .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-tickgen:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/mapstreamer/examples/flatmap_stream/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/flatmap-stream-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/map-flatmap-stream:${TAG}" --platform linux/amd64,linux/arm64 --target flatmap_stream . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/map-flatmap-stream:${TAG}" --target flatmap_stream .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/map-flatmap-stream:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/reducer/examples/counter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/counter-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/reduce-counter:${TAG}" --platform linux/amd64,linux/arm64 --target counter . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/reduce-counter:${TAG}" --target counter .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/reduce-counter:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/reducer/examples/sum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/sum-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/reduce-sum:${TAG}" --platform linux/amd64,linux/arm64 --target sum . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/reduce-sum:${TAG}" --target sum .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/reduce-sum:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/reducestreamer/examples/counter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/counter-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/reduce-stream-counter:${TAG}" --platform linux/amd64,linux/arm64 --target counter . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/reduce-stream-counter:${TAG}" --target counter .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/reduce-stream-counter:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/reducestreamer/examples/sum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/sum-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/reduce-stream-sum:${TAG}" --platform linux/amd64,linux/arm64 --target sum . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/reduce-stream-sum:${TAG}" --target sum .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/reduce-stream-sum:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sessionreducer/examples/counter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/counter-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/session-counter:${TAG}" --platform linux/amd64,linux/arm64 --target counter . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/session-counter:${TAG}" --target counter .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/session-counter:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sideinput/examples/simple-sideinput/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/sideinput-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/sideinput-example:${TAG}" --platform linux/amd64,linux/arm64 --target sideinput . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/sideinput-example:${TAG}" --target sideinput .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/sideinput-example:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sideinput/examples/simple-sideinput/udf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/udf-sideinput-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/udf-sideinput-example:${TAG}" --platform linux/amd64,linux/arm64 --target udf-sideinput . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/udf-sideinput-example:${TAG}" --target udf-sideinput .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/udf-sideinput-example:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sinker/examples/log/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/log-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/sink-log:${TAG}" --platform linux/amd64,linux/arm64 --target log . --push

.PHONY: image
test_image: build
imageimage: build
docker build -t "quay.io/numaio/numaflow-go/sink-log:${TAG}" --target log .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/sink-log:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sourcer/examples/simple_source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/simple-source-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/source-simple-source:${TAG}" --platform linux/amd64,linux/arm64 --target simple-source . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/source-simple-source:${TAG}" --target simple-source .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/source-simple-source:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sourcetransformer/examples/assign_event_time/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/assign-event-time-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/mapt-assign-event-time:${TAG}" --platform linux/amd64,linux/arm64 --target assign-event-time . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/mapt-assign-event-time:${TAG}" --target assign-event-time .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/mapt-assign-event-time:${TAG}"; fi

Expand Down
4 changes: 2 additions & 2 deletions pkg/sourcetransformer/examples/event_time_filter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o ./dist/event-time-filter-example main.go

.PHONY: image-push
image: build
image-push: build
docker buildx build -t "quay.io/numaio/numaflow-go/mapt-event-time-filter:${TAG}" --platform linux/amd64,linux/arm64 --target event-time-filter . --push

.PHONY: image
test_image: build
image: build
docker build -t "quay.io/numaio/numaflow-go/mapt-event-time-filter:${TAG}" --target event-time-filter .
@if [ "$(PUSH)" = "true" ]; then docker push "quay.io/numaio/numaflow-go/mapt-event-time-filter:${TAG}"; fi

Expand Down
32 changes: 25 additions & 7 deletions update_examples.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash

function show_help () {
echo "Usage: $0 [-h|--help] (-bp|--build-push | -bpe|--build-push-example | -u|--update <SDK-version>)"
echo "Usage: $0 [-h|--help | -t|--tag] (-bp|--build-push | -bpe|--build-push-example | -u|--update <SDK-version>)"
echo " -h, --help Display help message and exit"
echo " -bp, --build-push Build the Dockerfiles of all the examples and push them to the quay.io registry (with tag: stable)"
echo " -bpe, --build-push-example Build the Dockerfile of the given example directory path, and push it to the quay.io registry (with tag: stable)"
echo " -bp, --build-push Build the Dockerfiles of all the examples and push them to the quay.io registry"
echo " -bpe, --build-push-example Build the Dockerfile of the given example directory path, and push it to the quay.io registry"
echo " -t, --tag To be optionally used with -bpe or -bp. Specify the tag to build with. Default tag: stable"
echo " -u, --update Update all of the examples to depend on the numaflow-go version with the specified SHA or version"
}

Expand Down Expand Up @@ -36,8 +37,10 @@ usingHelp=0
usingBuildPush=0
usingBuildPushExample=0
usingVersion=0
usingTag=0
version=""
directoryPath=""
tag="stable"

function handle_options () {
while [ $# -gt 0 ]; do
Expand All @@ -49,24 +52,35 @@ function handle_options () {
usingBuildPush=1
;;
-bpe | --build-push-example)
usingBuildPushExample=1
if [ -z "$2" ]; then
echo "Directory path not specified." >&2
show_help
exit 1
fi

usingBuildPushExample=1
directoryPath=$2
shift
;;
-t | --tag)
if [ -z "$2" ]; then
echo "Tag not specified." >&2
show_help
exit 1
fi

usingTag=1
tag=$2
shift
;;
-u | --update)
usingVersion=1
if [ -z "$2" ]; then
echo "Commit SHA or version not specified." >&2
show_help
exit 1
fi

usingVersion=1
version=$2
shift
;;
Expand Down Expand Up @@ -96,11 +110,15 @@ if [ -n "$directoryPath" ]; then
echo "Dockerfile path to use: $directoryPath"
fi

if [ -n "$tag" ]; then
echo "Using tag: $tag"
fi

if (( usingBuildPush )); then
traverse_examples "make image-push"
traverse_examples "make image-push TAG=$tag"
elif (( usingBuildPushExample )); then
cd "./$directoryPath" || exit
if ! make image-push; then
if ! make image-push TAG="$tag"; then
echo "Error: failed to run make image in $directoryPath" >&2
exit 1
fi
Expand Down

0 comments on commit 44ab995

Please sign in to comment.