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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
.vscode
x.json
zz.yaml
15 changes: 15 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- LICENSE
env:
IMAGE_NAME: 'router'
ADAPTOR_IMAGE_NAME: 'router-adaptor'

jobs:
build:
Expand Down Expand Up @@ -84,3 +85,17 @@ jobs:
ghcr.io/datasance/${{ env.IMAGE_NAME }}:latest
ghcr.io/datasance/${{ env.IMAGE_NAME }}:main

- name: Build and Push Router Adaptor to ghcr
uses: docker/build-push-action@v5
id: build_push_adaptor_ghcr
with:
context: .
file: Dockerfile.adaptor
platforms: linux/amd64, linux/arm64
push: true
tags: |
ghcr.io/datasance/${{ env.ADAPTOR_IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/datasance/${{ env.ADAPTOR_IMAGE_NAME }}:latest
ghcr.io/datasance/${{ env.ADAPTOR_IMAGE_NAME }}:main


4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea
.vscode
.vscode
x.json
zz.yaml
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.14-alpine AS go-builder
FROM golang:1.21-alpine AS go-builder

ARG TARGETOS
ARG TARGETARCH
Expand All @@ -9,13 +9,12 @@ COPY . /go/src/github.com/datasance/router
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o bin/router

FROM registry.access.redhat.com/ubi9/ubi-minimal:latest AS tz
RUN microdnf reinstall -y tzdata

RUN microdnf install -y tzdata && microdnf reinstall -y tzdata

FROM quay.io/skupper/skupper-router:main
COPY LICENSE /licenses/LICENSE
COPY --from=go-builder /go/src/github.com/datasance/router/bin/router /home/skrouterd/bin/router
COPY scripts/launch.sh /home/skrouterd/bin/launch.sh
# COPY scripts/launch.sh /home/skrouterd/bin/launch.sh
COPY --from=tz /usr/share/zoneinfo /usr/share/zoneinfo

CMD ["/home/skrouterd/bin/router"]
3 changes: 3 additions & 0 deletions Dockerfile.adaptor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM quay.io/skupper/kube-adaptor:2.0.1

COPY LICENSE /licenses/LICENSE
39 changes: 37 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
module github.com/datasance/router

go 1.16
go 1.21

require github.com/datasance/iofog-go-sdk/v3 v3.4.13
require (
github.com/datasance/iofog-go-sdk/v3 v3.4.13
github.com/interconnectedcloud/go-amqp v0.12.6-0.20200506124159-f51e540008b5
gotest.tools/v3 v3.5.2
k8s.io/api v0.26.0
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
)

require (
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.30 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.24 // indirect
github.com/Azure/go-autorest/autorest/to v0.4.1 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.2 // indirect
github.com/eapache/channels v1.1.0 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/stretchr/testify v1.8.2 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apimachinery v0.26.0 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
996 changes: 77 additions & 919 deletions go.sum

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions internal/config/platform.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package config

import (
"os"
"slices"
"strings"

"github.com/datasance/router/internal/resources/types"
"github.com/datasance/router/internal/utils"
"k8s.io/utils/ptr"
)

var (
Platform string
configuredPlatform *types.Platform
)

func ClearPlatform() {
configuredPlatform = nil
}

// GetPlatform returns the runtime platform defined,
// where the lookup goes through the following sequence:
// - Platform variable,
// - SKUPPER_PLATFORM environment variable
// - Static platform defined by skupper switch
// - Default platform "kubernetes" otherwise.
// In case the defined platform is invalid, "kubernetes"
// will be returned.
func GetPlatform() types.Platform {
if configuredPlatform != nil {
return *configuredPlatform
}

var platform types.Platform
for i, arg := range os.Args {
if slices.Contains([]string{"--platform", "-p"}, arg) && i+1 < len(os.Args) {
platformArg := os.Args[i+1]
platform = types.Platform(platformArg)
break
} else if strings.HasPrefix(arg, "--platform=") || strings.HasPrefix(arg, "-p=") {
platformArg := strings.Split(arg, "=")[1]
platform = types.Platform(platformArg)
break
}
}
if platform == "" {
platform = types.Platform(utils.DefaultStr(Platform,
os.Getenv(types.ENV_PLATFORM),
string(types.PlatformKubernetes)))
}
switch platform {
case types.PlatformPodman:
configuredPlatform = &platform
case types.PlatformDocker:
configuredPlatform = &platform
case types.PlatformLinux:
configuredPlatform = &platform
default:
configuredPlatform = ptr.To(types.PlatformKubernetes)
}
return *configuredPlatform
}
2 changes: 1 addition & 1 deletion internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

func Run(ch chan<- error, command string, args []string, env []string) {
log.Printf("Running command: %s with args: %v and env vars: %v", command, args, env)
// log.Printf("Running command: %s with args: %v and env vars: %v", command, args, env)

cmd := exec.Command(command, args...)
cmd.Env = append(os.Environ(), env...)
Expand Down
27 changes: 27 additions & 0 deletions internal/messaging/messaging.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package messaging

import (
amqp "github.com/interconnectedcloud/go-amqp"
)

type ConnectionFactory interface {
Connect() (Connection, error)
Url() string
}

type Connection interface {
Sender(address string) (Sender, error)
Receiver(address string, credit uint32) (Receiver, error)
Close()
}

type Sender interface {
Send(msg *amqp.Message) error
Close() error
}

type Receiver interface {
Receive() (*amqp.Message, error)
Accept(*amqp.Message) error
Close() error
}
Loading
Loading