From 93c37dee554d5a1ffbf727452c90f8e62fa15537 Mon Sep 17 00:00:00 2001 From: Jacob Pleiness Date: Wed, 10 Apr 2024 19:53:40 -0400 Subject: [PATCH] cmd/appliance: Add appliance service boilerplate / stub the service (#61706) * k8s: update deps and fix breaks * appliance: Add internal spec of config Add an internal spec of Sourcegraph to be used for user config and state in the appliance. * cmd/appliance: Add boilerplate and stub service * Fix the bazel deps * fix missing err returns * Use 'MainWithoutConfig * Add readme with basic info --- cmd/appliance/BUILD.bazel | 19 + cmd/appliance/README.md | 13 + cmd/appliance/main.go | 12 + cmd/appliance/shared/BUILD.bazel | 21 + cmd/appliance/shared/config.go | 21 + cmd/appliance/shared/main.go | 58 +++ cmd/appliance/shared/service.go | 26 + .../internal/worker/command/kubernetes.go | 2 +- deps.bzl | 201 ++++++-- go.mod | 34 +- go.sum | 75 +-- internal/appliance/BUILD.bazel | 12 + internal/appliance/spec.go | 447 ++++++++++++++++++ internal/k8s/resource/pvc/pvc.go | 4 +- internal/k8s/resource/pvc/pvc_test.go | 16 +- .../resource/statefulset/statefulset_test.go | 4 +- 16 files changed, 859 insertions(+), 106 deletions(-) create mode 100644 cmd/appliance/BUILD.bazel create mode 100644 cmd/appliance/README.md create mode 100644 cmd/appliance/main.go create mode 100644 cmd/appliance/shared/BUILD.bazel create mode 100644 cmd/appliance/shared/config.go create mode 100644 cmd/appliance/shared/main.go create mode 100644 cmd/appliance/shared/service.go create mode 100644 internal/appliance/BUILD.bazel create mode 100644 internal/appliance/spec.go diff --git a/cmd/appliance/BUILD.bazel b/cmd/appliance/BUILD.bazel new file mode 100644 index 00000000000..ac262b8c9e6 --- /dev/null +++ b/cmd/appliance/BUILD.bazel @@ -0,0 +1,19 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "appliance_lib", + srcs = ["main.go"], + importpath = "github.com/sourcegraph/sourcegraph/cmd/appliance", + visibility = ["//visibility:private"], + deps = [ + "//cmd/appliance/shared", + "//internal/sanitycheck", + "//internal/service/svcmain", + ], +) + +go_binary( + name = "appliance", + embed = [":appliance_lib"], + visibility = ["//visibility:public"], +) diff --git a/cmd/appliance/README.md b/cmd/appliance/README.md new file mode 100644 index 00000000000..2de19dff338 --- /dev/null +++ b/cmd/appliance/README.md @@ -0,0 +1,13 @@ +# Appliance + +Appliance provides a platform for configuration and automation of Sourcegraph deployments and administration in a Kubernetes environment. This allows users to easily setup and configure Sourcegraph in their environment as well as more easily manage administration tasks such as upgrades. + +--- + +## Architecture + +Appliance runs as a standard Kubernetes Deployment and utilizes Kubernetes [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) in order to manage deployment and administration tasks. + +## Own + +For more information or for help, see the [Release Team](https://handbook.sourcegraph.com/departments/engineering/teams/release/). diff --git a/cmd/appliance/main.go b/cmd/appliance/main.go new file mode 100644 index 00000000000..68133446b71 --- /dev/null +++ b/cmd/appliance/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "github.com/sourcegraph/sourcegraph/cmd/appliance/shared" + "github.com/sourcegraph/sourcegraph/internal/sanitycheck" + "github.com/sourcegraph/sourcegraph/internal/service/svcmain" +) + +func main() { + sanitycheck.Pass() + svcmain.SingleServiceMainWithoutConf(shared.Service, svcmain.OutOfBandConfiguration{}) +} diff --git a/cmd/appliance/shared/BUILD.bazel b/cmd/appliance/shared/BUILD.bazel new file mode 100644 index 00000000000..2da613c4c0b --- /dev/null +++ b/cmd/appliance/shared/BUILD.bazel @@ -0,0 +1,21 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "shared", + srcs = [ + "config.go", + "main.go", + "service.go", + ], + importpath = "github.com/sourcegraph/sourcegraph/cmd/appliance/shared", + visibility = ["//visibility:public"], + deps = [ + "//internal/appliance", + "//internal/debugserver", + "//internal/env", + "//internal/observation", + "//internal/service", + "@com_github_sourcegraph_log//:log", + "@io_k8s_sigs_controller_runtime//:controller-runtime", + ], +) diff --git a/cmd/appliance/shared/config.go b/cmd/appliance/shared/config.go new file mode 100644 index 00000000000..97c8aadbda5 --- /dev/null +++ b/cmd/appliance/shared/config.go @@ -0,0 +1,21 @@ +package shared + +import ( + "github.com/sourcegraph/sourcegraph/internal/appliance" + "github.com/sourcegraph/sourcegraph/internal/env" +) + +type Config struct { + env.BaseConfig + + Spec *appliance.Sourcegraph +} + +func (c *Config) Load() { + c.Spec = &appliance.Sourcegraph{} +} + +func (c *Config) Validate() error { + var errs error + return errs +} diff --git a/cmd/appliance/shared/main.go b/cmd/appliance/shared/main.go new file mode 100644 index 00000000000..d4329e69bf7 --- /dev/null +++ b/cmd/appliance/shared/main.go @@ -0,0 +1,58 @@ +package shared + +import ( + "context" + "os" + "os/signal" + "syscall" + + ctrl "sigs.k8s.io/controller-runtime" + + "github.com/sourcegraph/log" + + "github.com/sourcegraph/sourcegraph/internal/observation" + "github.com/sourcegraph/sourcegraph/internal/service" +) + +var onlyOneSignalHandler = make(chan struct{}) + +func Start(ctx context.Context, observationCtx *observation.Context, ready service.ReadyFunc, config *Config) error { + logger := observationCtx.Logger + + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{}) + if err != nil { + logger.Fatal("unable to start manager", log.Error(err)) + return err + } + + // Mark health server as ready + ready() + + logger.Info("starting manager") + if err := mgr.Start(shutdownOnSignal(ctx)); err != nil { + logger.Fatal("problem running manager", log.Error(err)) + return err + } + + return nil +} + +// shutdownOnSignal registers for SIGTERM and SIGINT. A context is returned +// which is canceled on one of these signals. If a second signal is caught, the program +// is terminated with exit code 1. +func shutdownOnSignal(ctx context.Context) context.Context { + close(onlyOneSignalHandler) + + ctx, cancel := context.WithCancel(ctx) + + c := make(chan os.Signal, 2) + signal.Notify(c, os.Interrupt, syscall.SIGTERM) + go func() { + <-c + cancel() // first signal. Cancel context. + <-c + os.Exit(1) // second signal. Exit now. + }() + + return ctx +} diff --git a/cmd/appliance/shared/service.go b/cmd/appliance/shared/service.go new file mode 100644 index 00000000000..d9ac7fe9741 --- /dev/null +++ b/cmd/appliance/shared/service.go @@ -0,0 +1,26 @@ +package shared + +import ( + "context" + + "github.com/sourcegraph/sourcegraph/internal/debugserver" + "github.com/sourcegraph/sourcegraph/internal/env" + "github.com/sourcegraph/sourcegraph/internal/observation" + "github.com/sourcegraph/sourcegraph/internal/service" +) + +var Service service.Service = svc{} + +type svc struct{} + +func (svc) Name() string { return "appliance" } + +func (svc) Configure() (env.Config, []debugserver.Endpoint) { + var config Config + config.Load() + return &config, nil +} + +func (svc) Start(ctx context.Context, observationCtx *observation.Context, ready service.ReadyFunc, config env.Config) error { + return Start(ctx, observationCtx, ready, config.(*Config)) +} diff --git a/cmd/executor/internal/worker/command/kubernetes.go b/cmd/executor/internal/worker/command/kubernetes.go index 9f303fead20..97a83f590fc 100644 --- a/cmd/executor/internal/worker/command/kubernetes.go +++ b/cmd/executor/internal/worker/command/kubernetes.go @@ -167,7 +167,7 @@ func (c *KubernetesCommand) CreateJobPVC(ctx context.Context, namespace string, }, Spec: corev1.PersistentVolumeClaimSpec{ AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{corev1.ResourceStorage: size}, }, }, diff --git a/deps.bzl b/deps.bzl index 21e2725f5c6..8089554db0c 100644 --- a/deps.bzl +++ b/deps.bzl @@ -695,6 +695,13 @@ def go_dependencies(): sum = "h1:w/jqZtC9YD4DS/Vp9GhWfWcCpuAL58oTnLoI8vE9YHU=", version = "v0.0.4", ) + go_repository( + name = "com_github_blang_semver_v4", + build_file_proto_mode = "disable_global", + importpath = "github.com/blang/semver/v4", + sum = "h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=", + version = "v4.0.0", + ) go_repository( name = "com_github_bmatcuk_doublestar", build_file_proto_mode = "disable_global", @@ -1171,8 +1178,8 @@ def go_dependencies(): name = "com_github_coreos_go_semver", build_file_proto_mode = "disable_global", importpath = "github.com/coreos/go-semver", - sum = "h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=", - version = "v0.3.0", + sum = "h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=", + version = "v0.3.1", ) go_repository( name = "com_github_coreos_go_systemd", @@ -1566,8 +1573,8 @@ def go_dependencies(): name = "com_github_emicklei_go_restful_v3", build_file_proto_mode = "disable_global", importpath = "github.com/emicklei/go-restful/v3", - sum = "h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ=", - version = "v3.10.1", + sum = "h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=", + version = "v3.11.0", ) go_repository( name = "com_github_emicklei_proto", @@ -1604,6 +1611,13 @@ def go_dependencies(): sum = "h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U=", version = "v5.6.0+incompatible", ) + go_repository( + name = "com_github_evanphx_json_patch_v5", + build_file_proto_mode = "disable_global", + importpath = "github.com/evanphx/json-patch/v5", + sum = "h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro=", + version = "v5.8.0", + ) go_repository( name = "com_github_facebookgo_clock", build_file_proto_mode = "disable_global", @@ -1920,6 +1934,13 @@ def go_dependencies(): sum = "h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=", version = "v1.2.2", ) + go_repository( + name = "com_github_go_logr_zapr", + build_file_proto_mode = "disable_global", + importpath = "github.com/go-logr/zapr", + sum = "h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=", + version = "v1.3.0", + ) go_repository( name = "com_github_go_martini_martini", build_file_proto_mode = "disable_global", @@ -1952,15 +1973,15 @@ def go_dependencies(): name = "com_github_go_openapi_jsonpointer", build_file_proto_mode = "disable_global", importpath = "github.com/go-openapi/jsonpointer", - sum = "h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY=", - version = "v0.19.5", + sum = "h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=", + version = "v0.19.6", ) go_repository( name = "com_github_go_openapi_jsonreference", build_file_proto_mode = "disable_global", importpath = "github.com/go-openapi/jsonreference", - sum = "h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA=", - version = "v0.20.0", + sum = "h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=", + version = "v0.20.2", ) go_repository( name = "com_github_go_openapi_loads", @@ -2409,8 +2430,8 @@ def go_dependencies(): name = "com_github_google_cel_go", build_file_proto_mode = "disable_global", importpath = "github.com/google/cel-go", - sum = "h1:s2151PDGy/eqpCI80/8dl4VL3xTkqI/YubXLXCFw0mw=", - version = "v0.17.1", + sum = "h1:6ebJFzu1xO2n7TLtN+UBqShGBhlD85bhvglh5DpcfqQ=", + version = "v0.17.7", ) go_repository( name = "com_github_google_flatbuffers", @@ -2426,6 +2447,13 @@ def go_dependencies(): sum = "h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54=", version = "v0.5.7-v3refs", ) + go_repository( + name = "com_github_google_gnostic_models", + build_file_proto_mode = "disable_global", + importpath = "github.com/google/gnostic-models", + sum = "h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=", + version = "v0.6.8", + ) go_repository( name = "com_github_google_go_cmp", build_file_proto_mode = "disable_global", @@ -4342,15 +4370,15 @@ def go_dependencies(): name = "com_github_onsi_ginkgo_v2", build_file_proto_mode = "disable_global", importpath = "github.com/onsi/ginkgo/v2", - sum = "h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU=", - version = "v2.11.0", + sum = "h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY=", + version = "v2.14.0", ) go_repository( name = "com_github_onsi_gomega", build_file_proto_mode = "disable_global", importpath = "github.com/onsi/gomega", - sum = "h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI=", - version = "v1.27.10", + sum = "h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=", + version = "v1.30.0", ) go_repository( name = "com_github_opencontainers_go_digest", @@ -5129,8 +5157,8 @@ def go_dependencies(): name = "com_github_soheilhy_cmux", build_file_proto_mode = "disable_global", importpath = "github.com/soheilhy/cmux", - sum = "h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=", - version = "v0.1.4", + sum = "h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=", + version = "v0.1.5", ) go_repository( name = "com_github_sourcegraph_conc", @@ -5510,8 +5538,8 @@ def go_dependencies(): name = "com_github_tmc_grpc_websocket_proxy", build_file_proto_mode = "disable_global", importpath = "github.com/tmc/grpc-websocket-proxy", - sum = "h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=", - version = "v0.0.0-20190109142713-0ad062ec5ee5", + sum = "h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE=", + version = "v0.0.0-20220101234140-673ab2c3ae75", ) go_repository( name = "com_github_tomnomnom_linkheader", @@ -6910,36 +6938,57 @@ def go_dependencies(): name = "io_etcd_go_bbolt", build_file_proto_mode = "disable_global", importpath = "go.etcd.io/bbolt", - sum = "h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=", - version = "v1.3.7", + sum = "h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=", + version = "v1.3.8", ) go_repository( name = "io_etcd_go_etcd_api_v3", build_file_proto_mode = "disable_global", importpath = "go.etcd.io/etcd/api/v3", - sum = "h1:OHVyt3TopwtUQ2GKdd5wu3PmmipR4FTwCqoEjSyRdIc=", - version = "v3.5.4", + sum = "h1:szRajuUUbLyppkhs9K6BRtjY37l66XQQmw7oZRANE4k=", + version = "v3.5.10", ) go_repository( name = "io_etcd_go_etcd_client_pkg_v3", build_file_proto_mode = "disable_global", importpath = "go.etcd.io/etcd/client/pkg/v3", - sum = "h1:lrneYvz923dvC14R54XcA7FXoZ3mlGZAgmwhfm7HqOg=", - version = "v3.5.4", + sum = "h1:kfYIdQftBnbAq8pUWFXfpuuxFSKzlmM5cSn76JByiT0=", + version = "v3.5.10", ) go_repository( name = "io_etcd_go_etcd_client_v2", build_file_proto_mode = "disable_global", importpath = "go.etcd.io/etcd/client/v2", - sum = "h1:ftQ0nOOHMcbMS3KIaDQ0g5Qcd6bhaBrQT6b89DfwLTs=", - version = "v2.305.0", + sum = "h1:MrmRktzv/XF8CvtQt+P6wLUlURaNpSDJHFZhe//2QE4=", + version = "v2.305.10", ) go_repository( name = "io_etcd_go_etcd_client_v3", build_file_proto_mode = "disable_global", importpath = "go.etcd.io/etcd/client/v3", - sum = "h1:p83BUL3tAYS0OT/r0qglgc3M1JjhM0diV8DSWAhVXv4=", - version = "v3.5.4", + sum = "h1:W9TXNZ+oB3MCd/8UjxHTWK5J9Nquw9fQBLJd5ne5/Ao=", + version = "v3.5.10", + ) + go_repository( + name = "io_etcd_go_etcd_pkg_v3", + build_file_proto_mode = "disable_global", + importpath = "go.etcd.io/etcd/pkg/v3", + sum = "h1:WPR8K0e9kWl1gAhB5A7gEa5ZBTNkT9NdNWrR8Qpo1CM=", + version = "v3.5.10", + ) + go_repository( + name = "io_etcd_go_etcd_raft_v3", + build_file_proto_mode = "disable_global", + importpath = "go.etcd.io/etcd/raft/v3", + sum = "h1:cgNAYe7xrsrn/5kXMSaH8kM/Ky8mAdMqGOxyYwpP0LA=", + version = "v3.5.10", + ) + go_repository( + name = "io_etcd_go_etcd_server_v3", + build_file_proto_mode = "disable_global", + importpath = "go.etcd.io/etcd/server/v3", + sum = "h1:4NOGyOwD5sUZ22PiWYKmfxqoeh72z6EhYjNosKGLmZg=", + version = "v3.5.10", ) go_repository( name = "io_gorm_driver_postgres", @@ -6959,29 +7008,57 @@ def go_dependencies(): name = "io_k8s_api", build_file_proto_mode = "disable_global", importpath = "k8s.io/api", - sum = "h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ=", - version = "v0.26.2", + sum = "h1:hBC7B9+MU+ptchxEqTNW2DkUosJpp1P+Wn6YncZ474A=", + version = "v0.29.2", + ) + go_repository( + name = "io_k8s_apiextensions_apiserver", + build_file_proto_mode = "disable_global", + importpath = "k8s.io/apiextensions-apiserver", + sum = "h1:UK3xB5lOWSnhaCk0RFZ0LUacPZz9RY4wi/yt2Iu+btg=", + version = "v0.29.2", ) go_repository( name = "io_k8s_apimachinery", build_file_proto_mode = "disable_global", importpath = "k8s.io/apimachinery", - sum = "h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ=", - version = "v0.26.2", + sum = "h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8=", + version = "v0.29.2", + ) + go_repository( + name = "io_k8s_apiserver", + build_file_proto_mode = "disable_global", + importpath = "k8s.io/apiserver", + sum = "h1:+Z9S0dSNr+CjnVXQePG8TcBWHr3Q7BmAr7NraHvsMiQ=", + version = "v0.29.2", ) go_repository( name = "io_k8s_client_go", build_file_proto_mode = "disable_global", importpath = "k8s.io/client-go", - sum = "h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI=", - version = "v0.26.2", + sum = "h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg=", + version = "v0.29.2", + ) + go_repository( + name = "io_k8s_code_generator", + build_file_proto_mode = "disable_global", + importpath = "k8s.io/code-generator", + sum = "h1:c9/iw2KnNpw2IRV+wwuG/Wns2TjPSgjWzbbjTevyiHI=", + version = "v0.29.2", + ) + go_repository( + name = "io_k8s_component_base", + build_file_proto_mode = "disable_global", + importpath = "k8s.io/component-base", + sum = "h1:lpiLyuvPA9yV1aQwGLENYyK7n/8t6l3nn3zAtFTJYe8=", + version = "v0.29.2", ) go_repository( name = "io_k8s_gengo", build_file_proto_mode = "disable_global", importpath = "k8s.io/gengo", - sum = "h1:GohjlNKauSai7gN4wsJkeZ3WAJx4Sh+oT/b5IYn5suA=", - version = "v0.0.0-20210813121822-485abfe95c7c", + sum = "h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks=", + version = "v0.0.0-20230829151522-9cce18d56c01", ) go_repository( name = "io_k8s_klog", @@ -6994,22 +7071,43 @@ def go_dependencies(): name = "io_k8s_klog_v2", build_file_proto_mode = "disable_global", importpath = "k8s.io/klog/v2", - sum = "h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=", - version = "v2.90.1", + sum = "h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0=", + version = "v2.110.1", + ) + go_repository( + name = "io_k8s_kms", + build_file_proto_mode = "disable_global", + importpath = "k8s.io/kms", + sum = "h1:MDsbp98gSlEQs7K7dqLKNNTwKFQRYYvO4UOlBOjNy6Y=", + version = "v0.29.2", ) go_repository( name = "io_k8s_kube_openapi", build_file_proto_mode = "disable_global", importpath = "k8s.io/kube-openapi", - sum = "h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E=", - version = "v0.0.0-20221012153701-172d655c2280", + sum = "h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=", + version = "v0.0.0-20231010175941-2dd684a91f00", + ) + go_repository( + name = "io_k8s_sigs_apiserver_network_proxy_konnectivity_client", + build_file_proto_mode = "disable_global", + importpath = "sigs.k8s.io/apiserver-network-proxy/konnectivity-client", + sum = "h1:TgtAeesdhpm2SGwkQasmbeqDo8th5wOBA5h/AjTKA4I=", + version = "v0.28.0", + ) + go_repository( + name = "io_k8s_sigs_controller_runtime", + build_file_proto_mode = "disable_global", + importpath = "sigs.k8s.io/controller-runtime", + sum = "h1:65QmN7r3FWgTxDMz9fvGnO1kbf2nu+acg9p2R9oYYYk=", + version = "v0.17.3", ) go_repository( name = "io_k8s_sigs_json", build_file_proto_mode = "disable_global", importpath = "sigs.k8s.io/json", - sum = "h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k=", - version = "v0.0.0-20220713155537-f223a00ba0e2", + sum = "h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=", + version = "v0.0.0-20221116044647-bc3834ca7abd", ) go_repository( name = "io_k8s_sigs_kustomize_kyaml", @@ -7022,22 +7120,22 @@ def go_dependencies(): name = "io_k8s_sigs_structured_merge_diff_v4", build_file_proto_mode = "disable_global", importpath = "sigs.k8s.io/structured-merge-diff/v4", - sum = "h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=", - version = "v4.2.3", + sum = "h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=", + version = "v4.4.1", ) go_repository( name = "io_k8s_sigs_yaml", build_file_proto_mode = "disable_global", importpath = "sigs.k8s.io/yaml", - sum = "h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=", - version = "v1.3.0", + sum = "h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=", + version = "v1.4.0", ) go_repository( name = "io_k8s_utils", build_file_proto_mode = "disable_global", importpath = "k8s.io/utils", - sum = "h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk=", - version = "v0.0.0-20230220204549-a5ecb0141aa5", + sum = "h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=", + version = "v0.0.0-20230726121419-3b25d923346b", ) go_repository( name = "io_opencensus_go", @@ -7782,3 +7880,10 @@ def go_dependencies(): sum = "h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=", version = "v3.5.1", ) + go_repository( + name = "xyz_gomodules_jsonpatch_v2", + build_file_proto_mode = "disable_global", + importpath = "gomodules.xyz/jsonpatch/v2", + sum = "h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=", + version = "v2.4.0", + ) diff --git a/go.mod b/go.mod index 5f83779421e..3766d8c3b1d 100644 --- a/go.mod +++ b/go.mod @@ -86,7 +86,7 @@ require ( github.com/buildkite/go-buildkite/v3 v3.0.1 github.com/cespare/xxhash/v2 v2.2.0 github.com/coreos/go-oidc v2.2.1+incompatible - github.com/coreos/go-semver v0.3.0 + github.com/coreos/go-semver v0.3.1 github.com/crewjam/saml v0.4.14 github.com/davecgh/go-spew v1.1.1 github.com/daviddengcn/go-colortext v1.0.0 @@ -234,13 +234,13 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.2.1 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.26.2 - k8s.io/apimachinery v0.26.2 - k8s.io/client-go v0.26.2 - k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 + k8s.io/api v0.29.2 + k8s.io/apimachinery v0.29.2 + k8s.io/client-go v0.29.2 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b layeh.com/gopher-luar v1.0.10 sigs.k8s.io/kustomize/kyaml v0.13.3 - sigs.k8s.io/yaml v1.3.0 + sigs.k8s.io/yaml v1.4.0 ) require ( @@ -295,6 +295,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.46.0 google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe gorm.io/gorm v1.25.5 + sigs.k8s.io/controller-runtime v0.17.3 ) require ( @@ -337,7 +338,8 @@ require ( github.com/distribution/reference v0.5.0 // indirect github.com/docker/cli v25.0.2+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/emicklei/go-restful/v3 v3.10.1 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/evanphx/json-patch/v5 v5.8.0 // indirect github.com/fullstorydev/grpcurl v1.8.6 // indirect github.com/go-chi/chi/v5 v5.0.10 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -346,7 +348,7 @@ require ( github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/s2a-go v0.1.7 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/gosimple/slug v1.12.0 // indirect @@ -376,7 +378,6 @@ require ( github.com/morikuni/aec v1.0.0 // indirect github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc6 // indirect github.com/pierrec/lz4/v4 v4.1.18 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect @@ -409,9 +410,12 @@ require ( go.uber.org/goleak v1.3.0 // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/tools/go/vcs v0.1.0-deprecated // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gotest.tools/v3 v3.5.1 // indirect + k8s.io/apiextensions-apiserver v0.29.2 // indirect + k8s.io/component-base v0.29.2 // indirect ) require ( @@ -489,8 +493,8 @@ require ( github.com/go-logr/stdr v1.2.2 github.com/go-openapi/analysis v0.21.4 // indirect github.com/go-openapi/errors v0.20.3 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect - github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/loads v0.21.2 // indirect github.com/go-openapi/runtime v0.24.2 // indirect github.com/go-openapi/spec v0.20.7 // indirect @@ -620,9 +624,9 @@ require ( gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gorm.io/driver/postgres v1.5.4 - k8s.io/klog/v2 v2.90.1 // indirect - k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect + k8s.io/klog/v2 v2.110.1 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect mvdan.cc/gofumpt v0.5.0 // indirect - sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) diff --git a/go.sum b/go.sum index bbc46da95ea..0be46787edd 100644 --- a/go.sum +++ b/go.sum @@ -407,8 +407,9 @@ github.com/coreos/go-iptables v0.6.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFE github.com/coreos/go-oidc v2.2.1+incompatible h1:mh48q/BqXqgjVHpy2ZY7WnWAbenxRjsz9N1i1YxjHAk= github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= +github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -501,8 +502,8 @@ github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/El github.com/elimity-com/scim v0.0.0-20220121082953-15165b1a61c8 h1:6fUaAaX4Xe07LhVrHNmpfnlU41Nsto4skz4vhVqGwYk= github.com/elimity-com/scim v0.0.0-20220121082953-15165b1a61c8/go.mod h1:JkjcmqbLW+khwt2fmBPJFBhx2zGZ8XobRZ+O0VhlwWo= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.10.1 h1:rc42Y5YTp7Am7CS630D7JmhRjq4UlEUuEKfrDac4bSQ= -github.com/emicklei/go-restful/v3 v3.10.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/proto v1.6.15 h1:XbpwxmuOPrdES97FrSfpyy67SSCV/wBIKXqgJzh6hNw= github.com/emicklei/proto v1.6.15/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -519,6 +520,8 @@ github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBF github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.8.0 h1:lRj6N9Nci7MvzrXuX6HFzU8XjmhPiXPlsKEy1u0KQro= +github.com/evanphx/json-patch/v5 v5.8.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw= github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= @@ -603,13 +606,15 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= +github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= @@ -640,16 +645,18 @@ github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwds github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= -github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= @@ -871,8 +878,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/flatbuffers v2.0.8+incompatible h1:ivUb1cGomAB101ZM1T0nOiWz9pSrTMoa9+EiY7igmkM= github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= -github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.1.1-0.20171103154506-982329095285/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -1438,16 +1445,16 @@ github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k 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 v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/ginkgo/v2 v2.14.0 h1:vSmGj2Z5YPb9JwCWT6z6ihcUvDhuXLc3sJiqd3jMKAY= +github.com/onsi/ginkgo/v2 v2.14.0/go.mod h1:JkUdW7JkN0V6rFvsHcJ478egV3XH9NxpD27Hal/PhZw= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= @@ -2418,6 +2425,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= gonum.org/v1/gonum v0.13.0 h1:a0T3bh+7fhRyqeNbiC3qVHYmkiQgit3wnNan/2c0HMM= gonum.org/v1/gonum v0.13.0/go.mod h1:/WPYRckkfWrhWefxyYTfrTtQR0KH4iyHNuzxqXAKyAU= google.golang.org/api v0.0.0-20160322025152-9bf6e6e569ff/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -2610,21 +2619,25 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.2 h1:dM3cinp3PGB6asOySalOZxEG4CZ0IAdJsrYZXE/ovGQ= -k8s.io/api v0.26.2/go.mod h1:1kjMQsFE+QHPfskEcVNgL3+Hp88B80uj0QtSOlj8itU= -k8s.io/apimachinery v0.26.2 h1:da1u3D5wfR5u2RpLhE/ZtZS2P7QvDgLZTi9wrNZl/tQ= -k8s.io/apimachinery v0.26.2/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= -k8s.io/client-go v0.26.2/go.mod h1:u5EjOuSyBa09yqqyY7m3abZeovO/7D/WehVVlZ2qcqU= +k8s.io/api v0.29.2 h1:hBC7B9+MU+ptchxEqTNW2DkUosJpp1P+Wn6YncZ474A= +k8s.io/api v0.29.2/go.mod h1:sdIaaKuU7P44aoyyLlikSLayT6Vb7bvJNCX105xZXY0= +k8s.io/apiextensions-apiserver v0.29.2 h1:UK3xB5lOWSnhaCk0RFZ0LUacPZz9RY4wi/yt2Iu+btg= +k8s.io/apiextensions-apiserver v0.29.2/go.mod h1:aLfYjpA5p3OwtqNXQFkhJ56TB+spV8Gc4wfMhUA3/b8= +k8s.io/apimachinery v0.29.2 h1:EWGpfJ856oj11C52NRCHuU7rFDwxev48z+6DSlGNsV8= +k8s.io/apimachinery v0.29.2/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= +k8s.io/client-go v0.29.2 h1:FEg85el1TeZp+/vYJM7hkDlSTFZ+c5nnK44DJ4FyoRg= +k8s.io/client-go v0.29.2/go.mod h1:knlvFZE58VpqbQpJNbCbctTVXcd35mMyAAwBdpt4jrA= +k8s.io/component-base v0.29.2 h1:lpiLyuvPA9yV1aQwGLENYyK7n/8t6l3nn3zAtFTJYe8= +k8s.io/component-base v0.29.2/go.mod h1:BfB3SLrefbZXiBfbM+2H1dlat21Uewg/5qtKOl8degM= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= -k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= -k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= layeh.com/gopher-luar v1.0.10 h1:55b0mpBhN9XSshEd2Nz6WsbYXctyBT35azk4POQNSXo= layeh.com/gopher-luar v1.0.10/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk= mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ= @@ -2633,13 +2646,15 @@ mvdan.cc/gofumpt v0.5.0/go.mod h1:HBeVDtMKRZpXyxFciAirzdKklDlGu8aAy1wEbH5Y9js= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= -sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/controller-runtime v0.17.3 h1:65QmN7r3FWgTxDMz9fvGnO1kbf2nu+acg9p2R9oYYYk= +sigs.k8s.io/controller-runtime v0.17.3/go.mod h1:N0jpP5Lo7lMTF9aL56Z/B2oWBJjey6StQM0jRbKQXtY= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/kustomize/kyaml v0.13.3 h1:tNNQIC+8cc+aXFTVg+RtQAOsjwUdYBZRAgYOVI3RBc4= sigs.k8s.io/kustomize/kyaml v0.13.3/go.mod h1:/ya3Gk4diiQzlE4mBh7wykyLRFZNvqlbh+JnwQ9Vhrc= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/appliance/BUILD.bazel b/internal/appliance/BUILD.bazel new file mode 100644 index 00000000000..269209312ad --- /dev/null +++ b/internal/appliance/BUILD.bazel @@ -0,0 +1,12 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "appliance", + srcs = ["spec.go"], + importpath = "github.com/sourcegraph/sourcegraph/internal/appliance", + visibility = ["//:__subpackages__"], + deps = [ + "@io_k8s_api//core/v1:core", + "@io_k8s_apimachinery//pkg/apis/meta/v1:meta", + ], +) diff --git a/internal/appliance/spec.go b/internal/appliance/spec.go new file mode 100644 index 00000000000..c1e9a7422e7 --- /dev/null +++ b/internal/appliance/spec.go @@ -0,0 +1,447 @@ +package appliance + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type ManagementStateType string + +const ( + // ManagementStateManaged denotes that Sourcegraph should be reconciled + // by the operator. + ManagementStateManaged ManagementStateType = "Managed" + + // ManagementStateUnmanaged denotes that Sourcegraph should not be reconciled + // by the operator. + ManagementStateUnmanaged ManagementStateType = "Unmanaged" +) + +type DatabaseSpec struct { + Host string `json:"host,omitempty"` + Port string `json:"port,omitempty"` + User string `json:"user,omitempty"` + Password string `json:"password,omitempty"` + Database string `json:"database,omitempty"` +} + +// BlobstoreSpec defines the desired state of Blobstore. +type BlobstoreSpec struct { + // Disabled defines if Blobstore is enabled or not. + // Default: false + Disabled bool `json:"enabled,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Blobstore. + Env map[string]string `json:"env,omitempty"` +} + +// CodeInsightsDBSpec defines the desired state of Code Insights database. +type CodeInsightsDBSpec struct { + // Disabled defines if Code Insights is enabled or not. + // Default: false + Disabled bool `json:"disabled,omitempty"` + + // ExistingSecret is the name of an existing secret to use for CodeInsights DB credentials. + ExistingSecret string `json:"existingSecret,omitempty"` + + // Database allows for custom database connection details. + Database *DatabaseSpec `json:"database,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Code Insights. + Env map[string]string `json:"env,omitempty"` +} + +// CodeIntelDBSpec defines the desired state of Code Intel database. +type CodeIntelDBSpec struct { + // Disabled defines if Code Intel is enabled or not. + // Default: false + Disabled bool `json:"disabled,omitempty"` + + // ExistingSecret is the name of an existing secret to use for CodeIntel DB credentials. + ExistingSecret string `json:"existingSecret,omitempty"` + + // Database allows for custom database connection details. + Database *DatabaseSpec `json:"database,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Code Intel. + Env map[string]string `json:"env,omitempty"` +} + +type IngressSpec struct { + Disabled bool `json:"enabled,omitempty"` + Annotations map[string]string `json:"annotations,omitempty"` + Host string `json:"host,omitempty"` + IngressClassName string `json:"ingressClassName,omitempty"` + TLSSecret string `json:"tlsSecret,omitempty"` +} + +// FrontendSpec defines the desired state of Frontend. +type FrontendSpec struct { + // Replicas defines the number of Frontend pod replicas. + // Default: 2 + Replicas int32 `json:"replicas,omitempty"` + + // Ingress allows for changes to the custom Sourcegraph ingress. + Ingress *IngressSpec `json:"ingress,omitempty"` + + // ExistingSecret is the name of an existing secret to use for Postgres credentials. + ExistingSecret string `json:"existingSecret,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Frontend. + Env map[string]string `json:"env,omitempty"` +} + +// GitServerSpec defines the desired state of GitServer. +type GitServerSpec struct { + // Replicas defines the number of GitServer pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // SSHSecret is the name of existing secret that contains SSH credentials to clone repositories. + // This secret generally contains keys such as `id_rsa` (private key) and `known_hosts`. + SSHSecret string `json:"sshSecret,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Git Server. + Env map[string]string `json:"env,omitempty"` +} + +// IndexedSearchSpec defines the desired state of Index Search. +type IndexedSearchSpec struct { + // Replicas defines the number of Index Search pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Indexed Search. + Env map[string]string `json:"env,omitempty"` +} + +// IndexedSearchIndexerSpec defines the desired state of the Index Search Indexer. +type IndexedSearchIndexerSpec struct { + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Indexed Search Indexer. + Env map[string]string `json:"env,omitempty"` +} + +// PGSQLSpec defines the desired state of the PostgreSQL server. +type PGSQLSpec struct { + // Disabled defines if pgsql is enabled or not. + // Default: false + Disabled bool `json:"disabled,omitempty"` + + // ExistingSecret is the name of an existing secret to use for Postgres credentials. + ExistingSecret string `json:"existingSecret,omitempty"` + + // Database allows for custom database connection details. + Database *DatabaseSpec `json:"database,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 200Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for PGSQL. + Env map[string]string `json:"env,omitempty"` +} + +type PostgresExporterSpec struct { + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Postgres Exporter. + Env map[string]string `json:"env,omitempty"` +} + +type PreciseCodeIntelSpec struct { + // Replicas defines the number of Precise Code Intel Worker pod replicas. + // Default: 2 + Replicas int32 `json:"replicas,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Code Intel. + Env map[string]string `json:"env,omitempty"` +} + +// RedisCacheSpec defines the desired state of the Redis cache service. +type RedisCacheSpec struct { + // Disabled defines if Redis Cache is enabled or not. + // Default: false + Disabled bool `json:"disabled,omitempty"` + + // ExistingSecret is the name of an existing secret to use. + ExistingSecret string `json:"existingSecret,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 100Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Redis Cache. + Env map[string]string `json:"env,omitempty"` +} + +// RedisExporterSpec defines the desired state of the Redis Exporter service. +type RedisExporterSpec struct { + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Redis Exporter. + Env map[string]string `json:"env,omitempty"` +} + +// RedisStoreSpec defines the desired state of the Redis Store service. +type RedisStoreSpec struct { + // Disabled defines if Redis Store is enabled or not. + // Default: false + Disabled bool `json:"disabled,omitempty"` + + // ExistingSecret is the name of an existing secret to use. + ExistingSecret string `json:"existingSecret,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 100Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Redis Store. + Env map[string]string `json:"env,omitempty"` +} + +// RepoUpdaterSpec defines the desired state of the Repo Updater service. +type RepoUpdaterSpec struct { + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Redis Updater. + Env map[string]string `json:"env,omitempty"` +} + +// SearcherSpec defines the desired state of the Searcher service. +type SearcherSpec struct { + // Enabled defines if Code Intel is enabled or not. + // Default: true + Enabled bool `json:"enabled,omitempty"` + + // Replicas defines the number of Searcher pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 26Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Searcher. + Env map[string]string `json:"env,omitempty"` +} + +// SymbolsSpec defines the desired state of the Symbols service. +type SymbolsSpec struct { + // Replicas defines the number of Symbols pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // StorageSize defines the requested amount of storage for the PVC. + // Default: 12Gi + StorageSize string `json:"storageSize,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Symbols. + Env map[string]string `json:"env,omitempty"` +} + +// SyntectServerSpec defines the desired state of the Syntect server service. +type SyntectServerSpec struct { + // Replicas defines the number of Syntect Server pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Syntect Server. + Env map[string]string `json:"env,omitempty"` +} + +type WorkerSpec struct { + // Replicas defines the number of Worker pod replicas. + // Default: 1 + Replicas int32 `json:"replicas,omitempty"` + + // Resources allows for custom resource limits and requests. + Resources *corev1.ResourceList `json:"resources,omitempty"` + + // Env defines environment variables for Worker. + Env map[string]string `json:"env,omitempty"` +} + +type StorageClassSpec struct { + // Name is the name of the storageClass. + // Default: sourcegraph + Name string `json:"name,omitempty"` + + // Create will enable/disable the creation of storageClass. + // Enable if you have your own existing storage class. + // Default: false + Create bool `json:"create,omitempty"` + + // Provisioner is the storageClass provisioner. + // Default: kubernetes.io/no-provisioner + Provisioner string `json:"provisioner,omitempty"` + + // Type is the `type` key in storageClass `parameters`. + Type string `json:"type,omitempty"` + + // Parameters defines any extra parameters of StorageClass. + Parameters map[string]string `json:"parameters,omitempty"` +} + +// SourcegraphSpec defines the desired state of Sourcegraph +type SourcegraphSpec struct { + // ManagementState defines if Sourcegraph should be managed by the operator or not. + // Default is managed. + ManagementState ManagementStateType `json:"managementState,omitempty"` + + // LocalDevMode will remove all resource requests, allowing the scheduler to best-fit pods. + // Intended for local development with limited resources. + // Default: false + LocalDevMode bool `json:"localDevMode,omitempty"` + + // MaintenancePassword will set the password for the administrator maintenance UI. + // If no password is set, a random password will be generated and storage in a secret. + MaintenancePassword string `json:"maintenancePassword,omitempty"` + + // Blobstore defines the desired state of the Blobstore service. + Blobstore BlobstoreSpec `json:"blobstore,omitempty"` + + // CodeInsights defines the desired state of the Code Insights service. + CodeInsights CodeInsightsDBSpec `json:"codeInsights,omitempty"` + + // CodeIntel defines the desired state of the Code Intel service. + CodeIntel CodeIntelDBSpec `json:"codeIntel,omitempty"` + + // Frontend defines the desired state of the Sourcegraph Frontend. + Frontend FrontendSpec `json:"frontend,omitempty"` + + // GitServer defines the desired state of the GitServer service. + GitServer GitServerSpec `json:"gitServer,omitempty"` + + // IndexedSearch defines the desired state of the Indexed Search service. + IndexedSearch IndexedSearchSpec `json:"indexedSearch,omitempty"` + + // IndexedSearchIndexer defines the desired state of the Indexed Search Indexer service. + IndexedSearchIndexer IndexedSearchIndexerSpec `json:"indexedSearchIndexer,omitempty"` + + // PGSQL defines the desired state of the PostgreSQL database. + PGSQL PGSQLSpec `json:"pgsql,omitempty"` + + // PostgresExporter defines the desired state of the Postgres exporter service. + PostgresExporter PostgresExporterSpec `json:"postgresExporter,omitempty"` + + // PreciseCodeIntel defines the desired state of the Precise Code Intel service. + PreciseCodeIntel PreciseCodeIntelSpec `json:"preciseCodeIntel,omitempty"` + + // RedisCache defines the desired state of the Redis cache service. + RedisCache RedisCacheSpec `json:"redisCache,omitempty"` + + // RedisExporter defines the desired state of the Redis exporter service. + RedisExporter RedisExporterSpec `json:"redisExporter,omitempty"` + + // RedisStore defines the desired state of the Redis store service. + RedisStore RedisStoreSpec `json:"redisStore,omitempty"` + + // RepoUpdater defines the desired state of the Repo updater service. + RepoUpdater RepoUpdaterSpec `json:"repoUpdater,omitempty"` + + // Searcher defines the desired state of the Searcher service. + Searcher SearcherSpec `json:"searcher,omitempty"` + + // Symbols defines the desired state of the Symbols service. + Symbols SymbolsSpec `json:"symbols,omitempty"` + + // SyntectServer defines the desired state of the Syntect Server service. + SyntectServer SyntectServerSpec `json:"syntectServer,omitempty"` + + // Worker defines the desired state of the Worker service. + Worker WorkerSpec `json:"worker,omitempty"` + + // StorageClass defines the desired state a custom storage class. + // If none is specified, default cluster storage class will be used. + StorageClass StorageClassSpec `json:"storageClass,omitempty"` +} + +// SourcegraphStatus defines the observed state of Sourcegraph +type SourcegraphStatus struct { + // CurrentVersion is the version of Sourcegraph currently running. + CurrentVersion string `json:"currentVersion"` + + // Represents the latest available observations of Sourcegraph's current state. + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// Sourcegraph is the Schema for the Sourcegraph API +type Sourcegraph struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec SourcegraphSpec `json:"spec,omitempty"` + Status SourcegraphStatus `json:"status,omitempty"` +} + +// SourcegraphList contains a list of Sourcegraph +type SourcegraphList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Sourcegraph `json:"items"` +} diff --git a/internal/k8s/resource/pvc/pvc.go b/internal/k8s/resource/pvc/pvc.go index 68ff7b9b646..fde918f89c5 100644 --- a/internal/k8s/resource/pvc/pvc.go +++ b/internal/k8s/resource/pvc/pvc.go @@ -30,7 +30,7 @@ func NewPersistentVolumeClaim(name, namespace string, options ...Option) (corev1 AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -76,7 +76,7 @@ func WithAccessMode(accessModes []corev1.PersistentVolumeAccessMode) Option { } // WithResources sets the given Resource Requirements for the PVC. -func WithResources(resources corev1.ResourceRequirements) Option { +func WithResources(resources corev1.VolumeResourceRequirements) Option { return func(pvc *corev1.PersistentVolumeClaim) error { pvc.Spec.Resources = resources return nil diff --git a/internal/k8s/resource/pvc/pvc_test.go b/internal/k8s/resource/pvc/pvc_test.go index e462577d3e1..780dd014a94 100644 --- a/internal/k8s/resource/pvc/pvc_test.go +++ b/internal/k8s/resource/pvc/pvc_test.go @@ -43,7 +43,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -76,7 +76,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -110,7 +110,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -141,7 +141,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteMany, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -155,7 +155,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { name: "foo", namespace: "sourcegraph", options: []Option{ - WithResources(corev1.ResourceRequirements{ + WithResources(corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("100Gi"), }, @@ -174,7 +174,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("100Gi"), }, @@ -203,7 +203,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, @@ -233,7 +233,7 @@ func TestNewPersistentVolumeClaim(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("10Gi"), }, diff --git a/internal/k8s/resource/statefulset/statefulset_test.go b/internal/k8s/resource/statefulset/statefulset_test.go index 6b5e6978b1c..42641773b1c 100644 --- a/internal/k8s/resource/statefulset/statefulset_test.go +++ b/internal/k8s/resource/statefulset/statefulset_test.go @@ -279,7 +279,7 @@ func TestNewStatefulSet(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("200Gi"), }, @@ -319,7 +319,7 @@ func TestNewStatefulSet(t *testing.T) { AccessModes: []corev1.PersistentVolumeAccessMode{ corev1.ReadWriteOnce, }, - Resources: corev1.ResourceRequirements{ + Resources: corev1.VolumeResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceStorage: resource.MustParse("200Gi"), },