Skip to content

Commit

Permalink
feat: implement git backend environments storage (#3854)
Browse files Browse the repository at this point in the history
* feat: implement git backend environments storage

* feat(config): update to account for credentials

* fix: rename a bunch of imports from config to env
  • Loading branch information
GeorgeMac authored Jan 30, 2025
1 parent f2afdd8 commit dc83cba
Show file tree
Hide file tree
Showing 89 changed files with 4,994 additions and 5,058 deletions.
46 changes: 26 additions & 20 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import "list"
diagnostics?: #diagnostics
environments?: #environments
storage?: #storage
credentials?: #credentials
log?: #log
meta?: #meta
server?: #server
Expand Down Expand Up @@ -194,26 +195,7 @@ import "list"
ca_cert_path?: string
ca_cert_bytes?: string
insecure_skip_tls?: bool | *false
authentication?: ({
basic: {
username: string
password: string
}
} | {
token: access_token: string
} | {
ssh: {
user?: string | *"git"
password: string
private_key_path: string
}
} | {
ssh: {
user?: string | *"git"
password: string
private_key_bytes: string
}
})
credentials?: string
publishers?: {
object?: {
type: "s3" | "azblob" | "googlecloud" | *""
Expand All @@ -238,6 +220,30 @@ import "list"
}
}

#credentials: [string]: {
type: "basic"
basic: {
username: string
password: string
}
} | {
type: "ssh"
ssh: {
user?: string
password: string
private_key_bytes: string
insecure_ignore_host_key?: bool
} | {
user?: string
password: string
private_key_path: string
insecure_ignore_host_key?: bool
}
} | {
type: "access_token"
access_token: string
}

_#lower: ["debug", "error", "fatal", "info", "panic", "warn"]
_#all: list.Concat([_#lower, [for x in _#lower {strings.ToUpper(x)}]])
#log: {
Expand Down
160 changes: 84 additions & 76 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,82 +632,8 @@
"type": "boolean",
"default": false
},
"authentication": {
"oneOf": [
{
"type": "object",
"properties": {
"basic": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": ["username", "password"]
}
}
},
{
"type": "object",
"properties": {
"token": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
}
},
"required": ["access_token"]
}
}
},
{
"type": "object",
"properties": {
"ssh": {
"type": "object",
"properties": {
"user": {
"type": "string",
"default": "git"
},
"password": {
"type": "string"
},
"private_key_path": {
"type": "string"
}
},
"required": ["password", "private_key_path"]
}
}
},
{
"type": "object",
"properties": {
"ssh": {
"type": "object",
"properties": {
"user": {
"type": "string",
"default": "git"
},
"password": {
"type": "string"
},
"private_key_bytes": {
"type": "string"
}
},
"required": ["password", "private_key_bytes"]
}
}
}
]
"credentials": {
"type": "string"
},
"publishers": {
"type": "object",
Expand Down Expand Up @@ -782,6 +708,88 @@
}
}
},
"credentials": {
"type": "object",
"patternProperties": {
"^.*$": {
"oneOf": [
{
"type": "object",
"properties": {
"basic": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": ["username", "password"]
}
}
},
{
"type": "object",
"properties": {
"token": {
"type": "object",
"properties": {
"access_token": {
"type": "string"
}
},
"required": ["access_token"]
}
}
},
{
"type": "object",
"properties": {
"ssh": {
"type": "object",
"properties": {
"user": {
"type": "string",
"default": "git"
},
"password": {
"type": "string"
},
"private_key_path": {
"type": "string"
}
},
"required": ["password", "private_key_path"]
}
}
},
{
"type": "object",
"properties": {
"ssh": {
"type": "object",
"properties": {
"user": {
"type": "string",
"default": "git"
},
"password": {
"type": "string"
},
"private_key_bytes": {
"type": "string"
}
},
"required": ["password", "private_key_bytes"]
}
}
}
]
}
}
},
"log": {
"type": "object",
"title": "Log",
Expand Down
5 changes: 5 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"fmt"
)

// Is delegates to the stdlib errors function
func Is(err, target error) bool {
return errors.Is(err, target)
}

// As is a utility for one-lining errors.As statements.
// e.g. cerr, match := errors.As[MyCustomError](err).
func As[E error](err error) (e E, _ bool) {
Expand Down
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ go 1.23.0
toolchain go1.23.2

require (
cloud.google.com/go/storage v1.50.0
cuelang.org/go v0.11.1
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0
github.com/ClickHouse/clickhouse-go/v2 v2.29.0
github.com/MakeNowJust/heredoc v1.0.0
github.com/Masterminds/semver/v3 v3.3.1
github.com/aws/aws-sdk-go-v2/config v1.28.6
github.com/aws/aws-sdk-go-v2/service/s3 v1.71.0
github.com/blang/semver/v4 v4.0.0
github.com/coreos/go-oidc/v3 v3.12.0
Expand All @@ -36,7 +32,6 @@ require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1
github.com/h2non/gock v1.2.0
github.com/hashicorp/cap v0.7.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/iancoleman/strcase v0.3.0
github.com/magefile/mage v1.15.0
github.com/mitchellh/mapstructure v1.5.0
Expand Down Expand Up @@ -72,6 +67,7 @@ require (
go.opentelemetry.io/otel/trace v1.34.0
go.uber.org/zap v1.27.0
gocloud.dev v0.40.0
golang.org/x/crypto v0.32.0
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
golang.org/x/net v0.34.0
golang.org/x/oauth2 v0.25.0
Expand All @@ -92,11 +88,13 @@ require (
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.3.0 // indirect
cloud.google.com/go/monitoring v1.22.0 // indirect
cloud.google.com/go/storage v1.50.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.5.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
Expand All @@ -114,6 +112,7 @@ require (
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/aws/aws-sdk-go-v2 v1.32.7 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/config v1.28.6 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.47 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.10 // indirect
Expand Down Expand Up @@ -261,7 +260,6 @@ require (
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.32.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,6 @@ github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapp
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4=
github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
Expand Down Expand Up @@ -1118,8 +1116,6 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
Expand Down
4 changes: 4 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.3.1+incompatible h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI=
github.com/gofrs/uuid v4.3.1+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
Expand Down Expand Up @@ -1229,6 +1230,7 @@ github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc=
Expand Down Expand Up @@ -1469,6 +1471,7 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0=
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM=
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
Expand Down Expand Up @@ -1607,6 +1610,7 @@ github.com/rqlite/gorqlite v0.0.0-20230708021416-2acd02b70b79/go.mod h1:xF/KoXmr
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
Expand Down
Loading

0 comments on commit dc83cba

Please sign in to comment.