Compare commits
2 commits
aa2a4d42d8
...
c019ca2c41
Author | SHA1 | Date | |
---|---|---|---|
c019ca2c41 | |||
cd44b05547 |
7 changed files with 100 additions and 130 deletions
88
.drone.yml
Normal file
88
.drone.yml
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
---
|
||||||
|
# Test building the code and docker image
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: test-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: go-test
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- make -C polyculeconnect test
|
||||||
|
depends_on:
|
||||||
|
|
||||||
|
- name: go-build
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- make -C polyculeconnect build
|
||||||
|
depends_on:
|
||||||
|
|
||||||
|
- name: docker-build-only
|
||||||
|
image: thegeeklab/drone-docker-buildx
|
||||||
|
privileged: true
|
||||||
|
settings:
|
||||||
|
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||||
|
tags: latest
|
||||||
|
dry_run: true
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
# - linux/arm64
|
||||||
|
depends_on:
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
exclude:
|
||||||
|
- main
|
||||||
|
|
||||||
|
- name: docker-build-push
|
||||||
|
image: thegeeklab/drone-docker-buildx
|
||||||
|
privileged: true
|
||||||
|
settings:
|
||||||
|
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||||
|
registry: git.faercol.me
|
||||||
|
tags: latest
|
||||||
|
username:
|
||||||
|
from_secret: GIT_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: GIT_PASSWORD
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
# - linux/arm64
|
||||||
|
depends_on:
|
||||||
|
- go-test
|
||||||
|
- go-build
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
|
---
|
||||||
|
# On a tag, only build the related docker image
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: tag-release
|
||||||
|
depends_on:
|
||||||
|
- test-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker-push-tag
|
||||||
|
image: thegeeklab/drone-docker-buildx
|
||||||
|
privileged: true
|
||||||
|
settings:
|
||||||
|
registry: git.faercol.me
|
||||||
|
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
||||||
|
auto_tag: true
|
||||||
|
platforms:
|
||||||
|
- linux/amd64
|
||||||
|
# - linux/arm64
|
||||||
|
username:
|
||||||
|
from_secret: GIT_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: GIT_PASSWORD
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- tag
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -23,5 +23,3 @@ go.work
|
||||||
|
|
||||||
# Go build file
|
# Go build file
|
||||||
**/build/
|
**/build/
|
||||||
|
|
||||||
.vscode
|
|
|
@ -1,57 +0,0 @@
|
||||||
steps:
|
|
||||||
docker-build-only:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
privileged: true
|
|
||||||
settings:
|
|
||||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
|
||||||
tags: latest
|
|
||||||
dry_run: true
|
|
||||||
platforms:
|
|
||||||
- linux/amd64
|
|
||||||
# - linux/arm64
|
|
||||||
when:
|
|
||||||
- event: pull_request
|
|
||||||
- event: push
|
|
||||||
branch:
|
|
||||||
exclude: [main]
|
|
||||||
|
|
||||||
docker-build-push:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
privileged: true
|
|
||||||
settings:
|
|
||||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
|
||||||
registry: git.faercol.me
|
|
||||||
tags: latest
|
|
||||||
username:
|
|
||||||
from_secret: git_username
|
|
||||||
password:
|
|
||||||
from_secret: git_password
|
|
||||||
platforms:
|
|
||||||
- linux/amd64
|
|
||||||
# - linux/arm64
|
|
||||||
when:
|
|
||||||
- event: push
|
|
||||||
branch: main
|
|
||||||
|
|
||||||
docker-push-tag:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
privileged: true
|
|
||||||
settings:
|
|
||||||
registry: git.faercol.me
|
|
||||||
repo: git.faercol.me/polyculeconnect/polyculeconnect
|
|
||||||
auto_tag: true
|
|
||||||
platforms:
|
|
||||||
- linux/amd64
|
|
||||||
# - linux/arm64
|
|
||||||
username:
|
|
||||||
from_secret: git_username
|
|
||||||
password:
|
|
||||||
from_secret: git_password
|
|
||||||
when:
|
|
||||||
- event: tag
|
|
||||||
|
|
||||||
depends_on:
|
|
||||||
- test
|
|
||||||
|
|
||||||
when:
|
|
||||||
event: [push, tag]
|
|
|
@ -1,13 +0,0 @@
|
||||||
steps:
|
|
||||||
go-test:
|
|
||||||
image: golang
|
|
||||||
commands:
|
|
||||||
- make -C polyculeconnect test
|
|
||||||
|
|
||||||
go-build:
|
|
||||||
image: golang
|
|
||||||
commands:
|
|
||||||
- make -C polyculeconnect build
|
|
||||||
|
|
||||||
when:
|
|
||||||
event: [push, tag]
|
|
|
@ -1,6 +1,6 @@
|
||||||
# PolyculeConnect
|
# PolyculeConnect
|
||||||
|
|
||||||
[![status-badge](https://ci-polycule-connect.chapoline.me/api/badges/1/status.svg)](https://ci-polycule-connect.chapoline.me/repos/1)
|
[![Build Status](https://drone.faercol.me/api/badges/PolyculeConnect/polycule-connect/status.svg)](https://drone.faercol.me/PolyculeConnect/polycule-connect)
|
||||||
|
|
||||||
![Project logo](./polyculeconnect/static/img/logo-text.png)
|
![Project logo](./polyculeconnect/static/img/logo-text.png)
|
||||||
|
|
||||||
|
|
|
@ -40,18 +40,11 @@ const (
|
||||||
ModeNet
|
ModeNet
|
||||||
)
|
)
|
||||||
|
|
||||||
type BackendConfigType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
Memory BackendConfigType = "memory"
|
|
||||||
SQLite BackendConfigType = "sqlite"
|
|
||||||
)
|
|
||||||
|
|
||||||
type BackendConfig struct {
|
type BackendConfig struct {
|
||||||
Config *oidc.Config `json:"config"`
|
Config *oidc.Config `json:"config"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ID string `json:"ID"`
|
ID string `json:"ID"`
|
||||||
Type BackendConfigType `json:"type"`
|
Type string `json:"type"`
|
||||||
Local bool `json:"local"`
|
Local bool `json:"local"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,19 +54,6 @@ type OpenConnectConfig struct {
|
||||||
Issuer string `json:"issuer"`
|
Issuer string `json:"issuer"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StorageConfig struct {
|
|
||||||
File string `json:"file"`
|
|
||||||
Host string `json:"host"`
|
|
||||||
Port int `json:"port"`
|
|
||||||
Database string `json:"database"`
|
|
||||||
User string `json:"user"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
Ssl struct {
|
|
||||||
Mode string `json:"mode"`
|
|
||||||
CaFile string `json:"caFile"`
|
|
||||||
} `json:"ssl"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type jsonConf struct {
|
type jsonConf struct {
|
||||||
Log struct {
|
Log struct {
|
||||||
Level string `json:"level"`
|
Level string `json:"level"`
|
||||||
|
@ -84,10 +64,6 @@ type jsonConf struct {
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
SockPath string `json:"sock"`
|
SockPath string `json:"sock"`
|
||||||
} `json:"server"`
|
} `json:"server"`
|
||||||
Storage struct {
|
|
||||||
StorageType string `json:"type"`
|
|
||||||
Config *StorageConfig `json:"config"`
|
|
||||||
} `json:"storage"`
|
|
||||||
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
OpenConnectConfig *OpenConnectConfig `json:"openconnect"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +73,6 @@ type AppConfig struct {
|
||||||
Host string
|
Host string
|
||||||
Port int
|
Port int
|
||||||
SockPath string
|
SockPath string
|
||||||
StorageType string
|
|
||||||
StorageConfig *StorageConfig
|
|
||||||
OpenConnectConfig *OpenConnectConfig
|
OpenConnectConfig *OpenConnectConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,8 +102,6 @@ func (ac *AppConfig) UnmarshalJSON(data []byte) error {
|
||||||
ac.Host = jsonConf.Server.Host
|
ac.Host = jsonConf.Server.Host
|
||||||
ac.Port = jsonConf.Server.Port
|
ac.Port = jsonConf.Server.Port
|
||||||
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
ac.OpenConnectConfig = jsonConf.OpenConnectConfig
|
||||||
ac.StorageType = jsonConf.Storage.StorageType
|
|
||||||
ac.StorageConfig = jsonConf.Storage.Config
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +110,6 @@ var defaultConfig AppConfig = AppConfig{
|
||||||
ServerMode: ModeNet,
|
ServerMode: ModeNet,
|
||||||
Host: "0.0.0.0",
|
Host: "0.0.0.0",
|
||||||
Port: 5000,
|
Port: 5000,
|
||||||
StorageType: "memory",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(filepath string) (*AppConfig, error) {
|
func New(filepath string) (*AppConfig, error) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
@ -35,17 +34,6 @@ func parseArgs() *cliArgs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStorage(conf *config.AppConfig) (storage.Storage, error) {
|
|
||||||
var storageType storage.Storage
|
|
||||||
switch conf.StorageType {
|
|
||||||
case "memory":
|
|
||||||
storageType = memory.New(logger.L)
|
|
||||||
default:
|
|
||||||
return storageType, fmt.Errorf("unsupported storage backend type: %s", conf.StorageType)
|
|
||||||
}
|
|
||||||
return storageType, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
args := parseArgs()
|
args := parseArgs()
|
||||||
|
|
||||||
|
@ -59,17 +47,12 @@ func main() {
|
||||||
logger.Init(conf.LogLevel)
|
logger.Init(conf.LogLevel)
|
||||||
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
logger.L.Infof("Initialized logger with level %v", conf.LogLevel)
|
||||||
|
|
||||||
storageType, err := initStorage(conf)
|
|
||||||
if err != nil {
|
|
||||||
logger.L.Fatalf("Failed to initialize storage backend: %s", err.Error())
|
|
||||||
}
|
|
||||||
logger.L.Infof("Initialized storage backend %q", conf.StorageType)
|
|
||||||
dexConf := dex_server.Config{
|
dexConf := dex_server.Config{
|
||||||
Web: dex_server.WebConfig{
|
Web: dex_server.WebConfig{
|
||||||
Dir: "./",
|
Dir: "./",
|
||||||
Theme: "default",
|
Theme: "default",
|
||||||
},
|
},
|
||||||
Storage: storageType,
|
Storage: memory.New(logger.L),
|
||||||
Issuer: conf.OpenConnectConfig.Issuer,
|
Issuer: conf.OpenConnectConfig.Issuer,
|
||||||
SupportedResponseTypes: []string{"code"},
|
SupportedResponseTypes: []string{"code"},
|
||||||
SkipApprovalScreen: false,
|
SkipApprovalScreen: false,
|
||||||
|
@ -99,7 +82,7 @@ func main() {
|
||||||
if err := dexConf.Storage.CreateConnector(storage.Connector{
|
if err := dexConf.Storage.CreateConnector(storage.Connector{
|
||||||
ID: backend.ID,
|
ID: backend.ID,
|
||||||
Name: backend.Name,
|
Name: backend.Name,
|
||||||
Type: string(backend.Type),
|
Type: backend.Type,
|
||||||
Config: backendConfJson,
|
Config: backendConfJson,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
logger.L.Errorf("Failed to add connector for backend %q to stage: %s", backend.Name, err.Error())
|
logger.L.Errorf("Failed to add connector for backend %q to stage: %s", backend.Name, err.Error())
|
||||||
|
|
Loading…
Reference in a new issue