Skip to content

Commit 1cd987b

Browse files
author
Jordan Halterman
committed
Add proxy submodule
1 parent ba3ac6d commit 1cd987b

15 files changed

Lines changed: 869 additions & 80 deletions

File tree

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: proxy.build
22

33
on:
44
push:
@@ -7,22 +7,7 @@ on:
77
pull_request:
88

99
jobs:
10-
build-controller:
11-
runs-on: ubuntu-20.04
12-
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v2
15-
with:
16-
fetch-depth: 0
17-
- name: Docker Login
18-
uses: docker/login-action@v1
19-
with:
20-
username: ${{ secrets.DOCKER_USERNAME }}
21-
password: ${{ secrets.DOCKER_PASSWORD }}
22-
- name: Build
23-
working-directory: controller
24-
run: make build
25-
build-proxy:
10+
build:
2611
runs-on: ubuntu-20.04
2712
steps:
2813
- name: Checkout
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: proxy.release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'proxy/v*'
7+
pull_request:
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
- name: Docker Login
18+
uses: docker/login-action@v1
19+
with:
20+
username: ${{ secrets.DOCKER_USERNAME }}
21+
password: ${{ secrets.DOCKER_PASSWORD }}
22+
- name: Setup Release Environment
23+
run: |-
24+
echo 'GITHUB_TOKEN=${{secrets.GH_TOKEN}}' > .release-env
25+
- name: Release
26+
working-directory: proxy
27+
run: make release

.github/workflows/release.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

proxy/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
GOLANG_CROSS_VERSION := v1.18.1
66

7+
RUNTIME_VERSION := $(shell go run github.com/atomix/runtime/cmd/atomix-runtime-version@master)
8+
79
.PHONY: build
810
build: build-bin build-docker
911

@@ -12,6 +14,7 @@ build-bin:
1214
--rm \
1315
--privileged \
1416
-e CGO_ENABLED=1 \
17+
-e RUNTIME_VERSION=$(RUNTIME_VERSION) \
1518
-v /var/run/docker.sock:/var/run/docker.sock \
1619
-v `pwd`:/build \
1720
-w /build \
@@ -23,6 +26,7 @@ build-docker:
2326
--rm \
2427
--privileged \
2528
-e CGO_ENABLED=1 \
29+
-e RUNTIME_VERSION=$(RUNTIME_VERSION) \
2630
-v /var/run/docker.sock:/var/run/docker.sock \
2731
-v `pwd`:/build \
2832
-w /build \
@@ -37,6 +41,7 @@ release-bin:
3741
--rm \
3842
--privileged \
3943
-e CGO_ENABLED=1 \
44+
-e RUNTIME_VERSION=$(RUNTIME_VERSION) \
4045
-v /var/run/docker.sock:/var/run/docker.sock \
4146
-v `pwd`:/build \
4247
-w /build \
@@ -48,6 +53,7 @@ release-docker:
4853
--rm \
4954
--privileged \
5055
-e CGO_ENABLED=1 \
56+
-e RUNTIME_VERSION=$(RUNTIME_VERSION) \
5157
-v /var/run/docker.sock:/var/run/docker.sock \
5258
-v `pwd`:/build \
5359
-w /build \

proxy/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[![Build](https://github.com/atomix/runtime/actions/workflows/proxy.build.yml/badge.svg)](https://github.com/atomix/runtime/actions/workflows/proxy.build.yml)
2+
[![Go Report Card](https://goreportcard.com/badge/github.com/atomix/runtime/proxy)](https://goreportcard.com/report/github.com/atomix/runtime/proxy)
3+
[![GoDoc](https://godoc.org/github.com/atomix/runtime/proxy?status.svg)](https://godoc.org/github.com/atomix/runtime/proxy)
4+
5+
# proxy
6+
Runtime proxy for Atomix Cloud

proxy/build/bin.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,4 @@ builds:
2828
- all=-N -l
2929
ldflags:
3030
- -s -w
31-
- -X github.com/atomix/runtime/pkg/version.shortCommit={{ .ShortCommit }}
32-
- -X github.com/atomix/runtime/pkg/version.commit={{ .FullCommit }}
33-
- -X github.com/atomix/runtime/pkg/version.version=v{{ .Version }}
34-
- -X github.com/atomix/runtime/pkg/version.buildType={{ if .IsSnapshot }}snapshot{{ else }}release{{ end }}
31+
- -X github.com/atomix/runtime/pkg/version.version={{ .Env.RUNTIME_VERSION }}

proxy/build/docker.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,3 @@ checksum:
2828

2929
snapshot:
3030
name_template: "{{ incpatch .Version }}-{{.ShortCommit}}"
31-
32-
changelog:
33-
sort: asc
34-
filters:
35-
exclude:
36-
- '^docs:'
37-
38-
release:
39-
github:
40-
owner: atomix
41-
name: runtime
42-
prerelease: auto
43-
draft: true

proxy/cmd/atomix-proxy/main.go

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,85 @@
1-
// SPDX-FileCopyrightText: 2022-present Open Networking Foundation <info@opennetworking.org>
1+
// SPDX-FileCopyrightText: 2022-present Intel Corporation
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

55
package main
66

7+
import (
8+
"fmt"
9+
"github.com/atomix/runtime/proxy/pkg/runtime"
10+
"github.com/spf13/cobra"
11+
"os"
12+
"os/signal"
13+
"syscall"
14+
)
15+
716
func main() {
17+
cmd := &cobra.Command{
18+
Use: "atomix-proxy",
19+
Run: func(cmd *cobra.Command, args []string) {
20+
proxyHost, err := cmd.Flags().GetString("proxy-host")
21+
if err != nil {
22+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
23+
os.Exit(1)
24+
}
25+
proxyPort, err := cmd.Flags().GetInt("proxy-port")
26+
if err != nil {
27+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
28+
os.Exit(1)
29+
}
30+
runtimeHost, err := cmd.Flags().GetString("runtime-host")
31+
if err != nil {
32+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
33+
os.Exit(1)
34+
}
35+
runtimePort, err := cmd.Flags().GetInt("runtime-port")
36+
if err != nil {
37+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
38+
os.Exit(1)
39+
}
40+
configFile, err := cmd.Flags().GetString("config")
41+
if err != nil {
42+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
43+
os.Exit(1)
44+
}
45+
cacheDir, err := cmd.Flags().GetString("cache")
46+
if err != nil {
47+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
48+
os.Exit(1)
49+
}
50+
51+
rt := runtime.New(
52+
runtime.WithProxyHost(proxyHost),
53+
runtime.WithProxyPort(proxyPort),
54+
runtime.WithRuntimeHost(runtimeHost),
55+
runtime.WithRuntimePort(runtimePort),
56+
runtime.WithConfigFile(configFile),
57+
runtime.WithCacheDir(cacheDir))
58+
if err := rt.Start(); err != nil {
59+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
60+
os.Exit(1)
61+
}
62+
63+
// Wait for an interrupt signal
64+
ch := make(chan os.Signal, 2)
65+
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
66+
<-ch
67+
68+
// Stop the proxy service
69+
if err := rt.Stop(); err != nil {
70+
fmt.Println(err)
71+
os.Exit(1)
72+
}
73+
},
74+
}
75+
cmd.Flags().StringP("proxy-host", "h", "", "the host to which to bind the proxy server")
76+
cmd.Flags().IntP("proxy-port", "p", 5678, "the port to which to bind the proxy server")
77+
cmd.Flags().String("runtime-host", "", "the host to which to bind the runtime server")
78+
cmd.Flags().Int("runtime-port", 5679, "the port to which to bind the runtime server")
79+
cmd.Flags().StringP("config", "c", "~/.atomix/config.yaml", "the path to the Atomix configuration file")
80+
cmd.Flags().String("cache", "~/.atomix/cache", "the path to the Atomix cache")
881

82+
if err := cmd.Execute(); err != nil {
83+
panic(err)
84+
}
985
}

proxy/go.mod

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
11
module github.com/atomix/runtime/proxy
22

33
go 1.18
4+
5+
require (
6+
github.com/atomix/api v0.0.0-20220517064555-1a41fdda0a79
7+
github.com/atomix/sdk v0.0.3-0.20220517083411-a8ffd9bcf738
8+
github.com/gofrs/flock v0.8.1
9+
github.com/spf13/cobra v1.4.0
10+
google.golang.org/grpc v1.46.0
11+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
12+
)
13+
14+
require (
15+
github.com/fsnotify/fsnotify v1.5.1 // indirect
16+
github.com/gogo/protobuf v1.3.2 // indirect
17+
github.com/golang/protobuf v1.5.2 // indirect
18+
github.com/hashicorp/hcl v1.0.0 // indirect
19+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
20+
github.com/kr/text v0.2.0 // indirect
21+
github.com/magiconair/properties v1.8.6 // indirect
22+
github.com/mitchellh/go-homedir v1.1.0 // indirect
23+
github.com/mitchellh/mapstructure v1.4.3 // indirect
24+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
25+
github.com/pelletier/go-toml v1.9.4 // indirect
26+
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
27+
github.com/spf13/afero v1.8.2 // indirect
28+
github.com/spf13/cast v1.4.1 // indirect
29+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
30+
github.com/spf13/pflag v1.0.5 // indirect
31+
github.com/spf13/viper v1.11.0 // indirect
32+
github.com/subosito/gotenv v1.2.0 // indirect
33+
go.uber.org/atomic v1.7.0 // indirect
34+
go.uber.org/multierr v1.6.0 // indirect
35+
go.uber.org/zap v1.21.0 // indirect
36+
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
37+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
38+
golang.org/x/text v0.3.7 // indirect
39+
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
40+
google.golang.org/protobuf v1.28.0 // indirect
41+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
42+
gopkg.in/ini.v1 v1.66.4 // indirect
43+
gopkg.in/yaml.v2 v2.4.0 // indirect
44+
)

proxy/pkg/runtime/config.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-FileCopyrightText: 2022-present Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package runtime
6+
7+
type Config struct {
8+
Clusters map[string]ClusterConfig `yaml:"clusters,omitempty"`
9+
}
10+
11+
type ClusterConfig struct {
12+
Name string `yaml:"name"`
13+
Driver DriverConfig `yaml:"driver,omitempty"`
14+
Config map[string]interface{} `yaml:"config,omitempty"`
15+
}
16+
17+
type DriverConfig struct {
18+
Name string `yaml:"name"`
19+
Version string `yaml:"version"`
20+
}

0 commit comments

Comments
 (0)