diff --git a/adapter/Dockerfile b/adapter/Dockerfile index 7a54e505ad..e6e2af306c 100644 --- a/adapter/Dockerfile +++ b/adapter/Dockerfile @@ -33,11 +33,11 @@ ARG GRPC_HEALTH_PROBE_PATH=/bin/grpc_health_probe ARG TARGETARCH ARG MOTD="\n\ - Welcome to WSO2 Docker Resources \n\ - --------------------------------- \n\ - This Docker container comprises of a WSO2 product, running with its latest GA release \n\ - which is under the Apache License, Version 2.0. \n\ - Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n" + Welcome to WSO2 Docker Resources \n\ + --------------------------------- \n\ + This Docker container comprises of a WSO2 product, running with its latest GA release \n\ + which is under the Apache License, Version 2.0. \n\ + Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n" RUN \ addgroup -S -g ${APK_USER_GROUP_ID} ${APK_USER_GROUP} \ @@ -50,7 +50,7 @@ RUN \ wget -q https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.34/grpc_health_probe-linux-${TARGETARCH} \ && mv grpc_health_probe-linux-${TARGETARCH} ${GRPC_HEALTH_PROBE_PATH} \ && if [ "${TARGETARCH}" = "amd64" ]; then echo "${CHECKSUM_AMD64} ${GRPC_HEALTH_PROBE_PATH}" | sha256sum -c -; fi - + RUN \ chmod +x ${GRPC_HEALTH_PROBE_PATH} \ && chown ${APK_USER}:${APK_USER_GROUP} ${GRPC_HEALTH_PROBE_PATH} \ @@ -61,7 +61,11 @@ WORKDIR ${APK_USER_HOME} USER ${APK_USER_ID} COPY resources/conf/config.toml conf/ + COPY resources/check_health.sh . +# Remove the Windows line endings (carriage returns) +RUN sed -i 's/\r//' check_health.sh + COPY resources/conf/log_config.toml conf/ COPY ./${TARGETARCH}/main adapter diff --git a/adapter/README.md b/adapter/README.md index d859184e2b..b0075b1425 100644 --- a/adapter/README.md +++ b/adapter/README.md @@ -9,7 +9,7 @@ The following should be installed in your dev machine. - [Gradle](https://gradle.org/install/) >= 7.5.1 version - [Docker](https://docs.docker.com/engine/install/ubuntu/) >= 17.03 version - [Golang](https://go.dev/doc/install) >= 1.23 version -- [Revive](https://github.com/mgechev/revive#installation) latest version +- [Revive](https://github.com/mgechev/revive#installation) = 1.3.4 version - [Kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) ## Setting up @@ -39,18 +39,22 @@ Code for the operator lies in `{PROJECT_HOME}/adapter/internal/operator`. This w Following are some tasks with the steps that a developer might do in operator development: -- [Adding a new Kind](#adding-a-new-kind) -- [Adding a new property to an existing Kind](#adding-a-new-property-to-an-existing-kind) -- [Adding validating and defaulting logic](#adding-validating-and-defaulting-logic) +- [WSO2 APK - Adapter](#wso2-apk---adapter) + - [Prerequisites](#prerequisites) + - [Setting up](#setting-up) + - [Operator](#operator) + - [Adding a new Kind](#adding-a-new-kind) + - [Adding a new property to an existing Kind](#adding-a-new-property-to-an-existing-kind) + - [Adding validating and defaulting logic](#adding-validating-and-defaulting-logic) ### Adding a new Kind 1. Decide what the k8s resource group will be depending on whether the CRD is for the control-plane or for the data-plane. - | Plane | k8s group | - | ------------- | ------------- | - | Data Plane | dp | - | Control Plane | cp | + | Plane | k8s group | + | ------------- | --------- | + | Data Plane | dp | + | Control Plane | cp | 2. Decide the version for the CRD. Current version for all the CRDs are used as `v1alpha1`. diff --git a/adapter/build.gradle b/adapter/build.gradle index e3b674c40f..2a15244295 100644 --- a/adapter/build.gradle +++ b/adapter/build.gradle @@ -59,7 +59,13 @@ tasks.register('go_test', Exec) { environment "APK_test_test_uint32array", "100" environment "APK_test_test_uint64array", "42949672959" environment "APK_test_test_uintarray2", "-50" - commandLine 'sh', '-c', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + + def osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) + if (osName.contains("windows")) { + commandLine 'cmd', '/c', 'set', 'CGO_ENABLED=1', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + } else { + commandLine 'sh', '-c', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + } } tasks.named('go_revive_run').configure { diff --git a/adapter/go.mod b/adapter/go.mod index c2a095c622..1c44139756 100644 --- a/adapter/go.mod +++ b/adapter/go.mod @@ -82,6 +82,7 @@ require ( go.uber.org/zap v1.26.0 // indirect golang.org/x/net v0.30.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect @@ -105,7 +106,6 @@ replace github.com/wso2/apk/common-go-libs => ../common-go-libs require ( github.com/ghodss/yaml v1.0.0 github.com/stretchr/testify v1.9.0 - golang.org/x/sys v0.26.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 sigs.k8s.io/gateway-api v1.2.0 ) diff --git a/adapter/internal/operator/gateway-api/envoy/shutdown_manager.go b/adapter/internal/operator/gateway-api/envoy/shutdown_manager.go index 94dc8b8c37..d519a5363c 100644 --- a/adapter/internal/operator/gateway-api/envoy/shutdown_manager.go +++ b/adapter/internal/operator/gateway-api/envoy/shutdown_manager.go @@ -30,11 +30,10 @@ import ( "net/http" "os" "os/signal" + "strconv" "syscall" "time" - "golang.org/x/sys/unix" - "github.com/wso2/apk/adapter/internal/loggers" "github.com/wso2/apk/adapter/internal/operator/gateway-api/bootstrap" ) @@ -76,7 +75,8 @@ func ShutdownManager(readyTimeout time.Duration) error { signal.Notify(s, os.Interrupt, syscall.SIGTERM) r := <-s - loggers.LoggerAPKOperator.Info(fmt.Sprintf("received %s", unix.SignalName(r.(syscall.Signal)))) + // loggers.LoggerAPKOperator.Info(fmt.Sprintf("received %s", unix.SignalName(r.(syscall.Signal)))) + loggers.LoggerAPKOperator.Info(fmt.Sprintf("received %s", strconv.Itoa(int(r.(syscall.Signal))))) // Shutdown HTTP server without interrupting active connections if err := srv.Shutdown(context.Background()); err != nil { diff --git a/common-controller/Dockerfile b/common-controller/Dockerfile index 575d2ce9e6..2e3c882e1f 100644 --- a/common-controller/Dockerfile +++ b/common-controller/Dockerfile @@ -36,11 +36,11 @@ ENV COMMON_CONTROLLER_PRIVATE_KEY_PATH=/home/wso2/security/keystore/mg.key ENV COMMON_CONTROLLER_PUBLIC_CERT_PATH=/home/wso2/security/keystore/mg.pem ARG MOTD="\n\ - Welcome to WSO2 Docker Resources \n\ - --------------------------------- \n\ - This Docker container comprises of a WSO2 product, running with its latest GA release \n\ - which is under the Apache License, Version 2.0. \n\ - Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n" + Welcome to WSO2 Docker Resources \n\ + --------------------------------- \n\ + This Docker container comprises of a WSO2 product, running with its latest GA release \n\ + which is under the Apache License, Version 2.0. \n\ + Read more about Apache License, Version 2.0 here @ http://www.apache.org/licenses/LICENSE-2.0.\n" RUN \ addgroup -S -g ${APK_USER_GROUP_ID} ${APK_USER_GROUP} \ @@ -53,7 +53,7 @@ RUN \ wget -q https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.34/grpc_health_probe-linux-${TARGETARCH} \ && mv grpc_health_probe-linux-${TARGETARCH} ${GRPC_HEALTH_PROBE_PATH} \ && if [ "${TARGETARCH}" = "amd64" ]; then echo "${CHECKSUM_AMD64} ${GRPC_HEALTH_PROBE_PATH}" | sha256sum -c -; fi - + RUN \ chmod +x ${GRPC_HEALTH_PROBE_PATH} \ && chown ${APK_USER}:${APK_USER_GROUP} ${GRPC_HEALTH_PROBE_PATH} @@ -64,7 +64,11 @@ USER ${APK_USER_ID} COPY resources/security security COPY resources/conf/config.toml conf/ + COPY resources/check_health.sh . +# Remove the Windows line endings (carriage returns) +RUN sed -i 's/\r//' check_health.sh + COPY resources/conf/log_config.toml conf/ COPY ./${TARGETARCH}/main common-controller diff --git a/common-controller/build.gradle b/common-controller/build.gradle index 7982534fc1..358c04d939 100644 --- a/common-controller/build.gradle +++ b/common-controller/build.gradle @@ -60,7 +60,13 @@ tasks.register('go_test', Exec) { environment "APK_test_test_uint32array", "100" environment "APK_test_test_uint64array", "42949672959" environment "APK_test_test_uintarray2", "-50" - commandLine 'sh', '-c', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + + def osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) + if (osName.contains("windows")) { + commandLine 'cmd', '/c', 'set', 'CGO_ENABLED=1', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + } else { + commandLine 'sh', '-c', "go test -race -coverprofile=coverage.out -covermode=atomic ./..." + } } tasks.named('go_revive_run').configure { diff --git a/common-gradle-scripts/go.gradle b/common-gradle-scripts/go.gradle index 8d4347f1e9..5155bee835 100644 --- a/common-gradle-scripts/go.gradle +++ b/common-gradle-scripts/go.gradle @@ -45,8 +45,13 @@ tasks.register('go_tidy', Exec) { tasks.register('go_build') { group 'go' description 'Compiles the packages named by the import paths, along with their dependencies. AMD64 Archtecture' - dependsOn go_mac_os_build - dependsOn go_linux_build + + if(osName.contains("windows")) { + dependsOn go_windows_build + } else { + dependsOn go_mac_os_build + dependsOn go_linux_build + } } tasks.register('go_mac_os_build', Exec) { group 'go' @@ -67,3 +72,16 @@ tasks.register('go_linux_build', Exec) { throw new StopExecutionException('Missing "file" property') } } +tasks.register('go_windows_build', Exec) { + group 'go' + description 'Compiles the packages named by the import paths, along with their dependencies. AMD64 Archtecture' + if (project.hasProperty('file')) { + environment 'GOOS', 'linux' + environment 'GOARCH', 'amd64' + environment 'CGO_ENABLED', '0' + + commandLine 'go', 'build', '-o', 'amd64/main', file + } else { + throw new StopExecutionException('Missing "file" property') + } +} \ No newline at end of file diff --git a/gateway/router/envoy-filters/mgw-source/filters/http/mgw-wasm-websocket/.bazelversion b/gateway/router/envoy-filters/mgw-source/filters/http/mgw-wasm-websocket/.bazelversion similarity index 100% rename from gateway/router/envoy-filters/mgw-source/filters/http/mgw-wasm-websocket/.bazelversion rename to gateway/router/envoy-filters/mgw-source/filters/http/mgw-wasm-websocket/.bazelversion