Skip to content

Commit ba3ac6d

Browse files
author
Jordan Halterman
committed
Add controller submodule
1 parent 9039329 commit ba3ac6d

16 files changed

Lines changed: 409 additions & 19 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: controller.build
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
9+
jobs:
10+
build:
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
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: controller.release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'controller/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: controller
27+
run: make release

controller/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 \

controller/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/controller.build.yml/badge.svg)](https://github.com/atomix/runtime/actions/workflows/controller.build.yml)
2+
[![Go Report Card](https://goreportcard.com/badge/github.com/atomix/runtime/controller)](https://goreportcard.com/report/github.com/atomix/runtime/controller)
3+
[![GoDoc](https://godoc.org/github.com/atomix/runtime/controller?status.svg)](https://godoc.org/github.com/atomix/runtime/controller)
4+
5+
# controller
6+
Runtime controller for Atomix Cloud

controller/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 }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// SPDX-FileCopyrightText: 2022-present Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: 2022-present Intel Corporation
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
set -o errexit
8+
set -o nounset
9+
set -o pipefail
10+
11+
CODEGEN_ROOT=$1
12+
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
13+
14+
bash "${CODEGEN_ROOT}"/generate-groups.sh "deepcopy" \
15+
./pkg/apis ./pkg/apis \
16+
atomix:v1beta1 \
17+
--go-header-file "${SCRIPT_ROOT}"/build/codegen/boilerplate.go.txt

controller/build/docker.yaml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ builds:
1515

1616
dockers:
1717
- id: atomix-controller
18-
dockerfile: ./build/Dockerfile
18+
dockerfile: ./build/controller/Dockerfile
1919
image_templates:
2020
- "atomix/controller:latest"
2121
- "{{ if (not .IsSnapshot) }}atomix/controller:{{ .Tag }}{{ end }}"
@@ -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
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,62 @@
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/spf13/cobra"
10+
"google.golang.org/grpc"
11+
"net"
12+
"os"
13+
"os/signal"
14+
"syscall"
15+
)
16+
717
func main() {
18+
cmd := &cobra.Command{
19+
Use: "atomix-controller",
20+
Run: func(cmd *cobra.Command, args []string) {
21+
host, err := cmd.Flags().GetString("host")
22+
if err != nil {
23+
fmt.Println(err)
24+
os.Exit(1)
25+
}
26+
port, err := cmd.Flags().GetInt("port")
27+
if err != nil {
28+
fmt.Println(err)
29+
os.Exit(1)
30+
}
31+
32+
server := grpc.NewServer()
33+
34+
// TODO: Register services
35+
36+
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
37+
if err != nil {
38+
fmt.Fprintln(cmd.OutOrStderr(), err.Error())
39+
}
40+
41+
go func() {
42+
if err := server.Serve(lis); err != nil {
43+
fmt.Println(err)
44+
os.Exit(1)
45+
}
46+
}()
47+
48+
// Wait for an interrupt signal
49+
ch := make(chan os.Signal, 2)
50+
signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
51+
<-ch
52+
53+
server.Stop()
54+
},
55+
}
56+
cmd.Flags().StringP("host", "h", "", "the host to which to bind the controller server")
57+
cmd.Flags().IntP("port", "p", 5678, "the port to which to bind the controller server")
858

59+
if err := cmd.Execute(); err != nil {
60+
panic(err)
61+
}
962
}

controller/go.mod

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
11
module github.com/atomix/runtime/controller
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+
k8s.io/apimachinery v0.24.0
13+
)
14+
15+
require (
16+
github.com/fsnotify/fsnotify v1.5.1 // indirect
17+
github.com/gogo/protobuf v1.3.2 // indirect
18+
github.com/golang/protobuf v1.5.2 // indirect
19+
github.com/hashicorp/hcl v1.0.0 // indirect
20+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
21+
github.com/kr/text v0.2.0 // indirect
22+
github.com/magiconair/properties v1.8.6 // indirect
23+
github.com/mitchellh/go-homedir v1.1.0 // indirect
24+
github.com/mitchellh/mapstructure v1.4.3 // indirect
25+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
26+
github.com/pelletier/go-toml v1.9.4 // indirect
27+
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
28+
github.com/spf13/afero v1.8.2 // indirect
29+
github.com/spf13/cast v1.4.1 // indirect
30+
github.com/spf13/jwalterweatherman v1.1.0 // indirect
31+
github.com/spf13/pflag v1.0.5 // indirect
32+
github.com/spf13/viper v1.11.0 // indirect
33+
github.com/subosito/gotenv v1.2.0 // indirect
34+
go.uber.org/atomic v1.7.0 // indirect
35+
go.uber.org/multierr v1.6.0 // indirect
36+
go.uber.org/zap v1.21.0 // indirect
37+
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect
38+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
39+
golang.org/x/text v0.3.7 // indirect
40+
google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect
41+
google.golang.org/protobuf v1.28.0 // indirect
42+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
43+
gopkg.in/ini.v1 v1.66.4 // indirect
44+
gopkg.in/yaml.v2 v2.4.0 // indirect
45+
)

0 commit comments

Comments
 (0)