diff --git a/cmd/agent/workspace/up.go b/cmd/agent/workspace/up.go index e1044ff67..864fb5fcb 100644 --- a/cmd/agent/workspace/up.go +++ b/cmd/agent/workspace/up.go @@ -286,7 +286,7 @@ func prepareWorkspace(ctx context.Context, workspaceInfo *provider2.AgentWorkspa return nil } - if workspaceInfo.CLIOptions.DevContainerSource != "" && crane.IsAvailable() { + if crane.ShouldUse(&workspaceInfo.CLIOptions) { log.Infof("Pulling devcontainer spec from %v", workspaceInfo.CLIOptions.DevContainerSource) return nil } diff --git a/cmd/up.go b/cmd/up.go index 9efbc99af..2f9d4cac5 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -153,6 +153,8 @@ func NewUpCmd(flags *flags.GlobalFlags) *cobra.Command { upCmd.Flags().StringVar(&cmd.DevContainerImage, "devcontainer-image", "", "The container image to use, this will override the devcontainer.json value in the project") upCmd.Flags().StringVar(&cmd.DevContainerPath, "devcontainer-path", "", "The path to the devcontainer.json relative to the project") upCmd.Flags().StringVar(&cmd.DevContainerSource, "devcontainer-source", "", "External devcontainer.json source") + upCmd.Flags().StringVar(&cmd.EnvironmentTemplate, "environment-template", "", "Environment template to use") + _ = upCmd.Flags().MarkHidden("environment-template") upCmd.Flags().StringArrayVar(&cmd.ProviderOptions, "provider-option", []string{}, "Provider option in the form KEY=VALUE") upCmd.Flags().BoolVar(&cmd.Recreate, "recreate", false, "If true will remove any existing containers and recreate them") upCmd.Flags().BoolVar(&cmd.Reset, "reset", false, "If true will remove any existing containers including sources, and recreate them") diff --git a/go.mod b/go.mod index 6ce385c72..6dcdcd102 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.1 github.com/joho/godotenv v1.5.1 - github.com/loft-sh/agentapi/v4 v4.1.0-alpha.1 - github.com/loft-sh/api/v4 v4.1.0-alpha.1 + github.com/loft-sh/agentapi/v4 v4.1.0-alpha.10 + github.com/loft-sh/api/v4 v4.1.0-alpha.10 github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac github.com/loft-sh/programming-language-detection v0.0.5 github.com/loft-sh/ssh v0.0.4 @@ -50,14 +50,14 @@ require ( gopkg.in/square/go-jose.v2 v2.6.0 gopkg.in/yaml.v2 v2.4.0 gotest.tools v2.2.0+incompatible - k8s.io/api v0.30.1 - k8s.io/apimachinery v0.30.1 - k8s.io/client-go v0.30.1 + k8s.io/api v0.30.4 + k8s.io/apimachinery v0.30.4 + k8s.io/client-go v0.30.4 k8s.io/klog/v2 v2.120.1 k8s.io/kube-aggregator v0.30.1 k8s.io/kubectl v0.29.1 mvdan.cc/sh/v3 v3.6.0 - sigs.k8s.io/controller-runtime v0.18.4 + sigs.k8s.io/controller-runtime v0.18.5 ) require ( @@ -131,7 +131,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/loft-sh/admin-apis v0.0.0-20240203010124-3600c1c582a8 // indirect + github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354 // indirect github.com/loft-sh/apiserver v0.0.0-20240607231110-634aeeab2b36 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect @@ -176,10 +176,10 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect - k8s.io/apiextensions-apiserver v0.30.1 // indirect - k8s.io/apiserver v0.30.1 // indirect + k8s.io/apiextensions-apiserver v0.30.4 // indirect + k8s.io/apiserver v0.30.4 // indirect k8s.io/cli-runtime v0.29.1 // indirect - k8s.io/component-base v0.30.1 // indirect + k8s.io/component-base v0.30.4 // indirect k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 // indirect diff --git a/go.sum b/go.sum index 89b6dadfd..baedff7b9 100644 --- a/go.sum +++ b/go.sum @@ -676,10 +676,16 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9 github.com/linuxkit/virtsock v0.0.0-20201010232012-f8cee7dfc7a3/go.mod h1:3r6x7q95whyfWQpmGZTu3gk3v2YkMi05HEzl7Tf7YEo= github.com/loft-sh/admin-apis v0.0.0-20240203010124-3600c1c582a8 h1:nuY9Vgvabh2FlaTYp9yhzh3cBzY6jjFEFSsOvw9ZAJw= github.com/loft-sh/admin-apis v0.0.0-20240203010124-3600c1c582a8/go.mod h1:MWczNwKvWssHo1KaeZKaWDdRLYSNbWqQBGsTLoCNd7U= +github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354 h1:aqT1UeosCYB+3DEzfxW0evhcYHxhoBVAEWtkXLXFimI= +github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354/go.mod h1:MWczNwKvWssHo1KaeZKaWDdRLYSNbWqQBGsTLoCNd7U= github.com/loft-sh/agentapi/v4 v4.1.0-alpha.1 h1:exsfePvLXhVnuQHhFqXK5FxbPzBZpQiLhj8jQQ1zq8c= github.com/loft-sh/agentapi/v4 v4.1.0-alpha.1/go.mod h1:5U2JmT3BpfROQg1rX+DIpJ3/JuF62OYBveZ7GzOQA9o= +github.com/loft-sh/agentapi/v4 v4.1.0-alpha.10 h1:XUtSAPorloQbXelYKX98L9TtxLbHTQVFjBhJVxpkYVA= +github.com/loft-sh/agentapi/v4 v4.1.0-alpha.10/go.mod h1:fj/fZ17NpJo63Bpx75eSx+ZmonfTWr52WgIZVwevc48= github.com/loft-sh/api/v4 v4.1.0-alpha.1 h1:SLOhaRlJE3fkZfllaTeOiNnuOQMe/7u14wJXfqgkMio= github.com/loft-sh/api/v4 v4.1.0-alpha.1/go.mod h1:1p5qVavAJC/gVZZpJ/x1YQQt91fux7wZaqSixCX5QlI= +github.com/loft-sh/api/v4 v4.1.0-alpha.10 h1:vUIQ7PgaLOA0wTOu1uPkHjgXvcO6myh2ersBsdxZo1c= +github.com/loft-sh/api/v4 v4.1.0-alpha.10/go.mod h1:GTwXhRrjQGSaEhk9d/PkcEuoXl/jQwOZS6Tfjfa3ixQ= github.com/loft-sh/apiserver v0.0.0-20240607231110-634aeeab2b36 h1:1euJ7mNHMI2MMA+g+jEYYKtoMrHZTkUMapHnmjHb9lM= github.com/loft-sh/apiserver v0.0.0-20240607231110-634aeeab2b36/go.mod h1:XxI95azXiqXHiIDRiyDTpZcxdtXQlUqeU5VMMDz8INA= github.com/loft-sh/log v0.0.0-20240219160058-26d83ffb46ac h1:Gz/7Lb7WgdgIv+KJz87ORA1zvQW52tUqKPGyunlp4dQ= @@ -1517,18 +1523,26 @@ k8s.io/api v0.20.4/go.mod h1:++lNL1AJMkDymriNniQsWRkMDzRaX2Y/POTUi8yvqYQ= k8s.io/api v0.20.6/go.mod h1:X9e8Qag6JV/bL5G6bU8sdVRltWKmdHsFUGS3eVndqE8= k8s.io/api v0.30.1 h1:kCm/6mADMdbAxmIh0LBjS54nQBE+U4KmbCfIkF5CpJY= k8s.io/api v0.30.1/go.mod h1:ddbN2C0+0DIiPntan/bye3SW3PdwLa11/0yqwvuRrJM= +k8s.io/api v0.30.4 h1:XASIELmW8w8q0i1Y4124LqPoWMycLjyQti/fdYHYjCs= +k8s.io/api v0.30.4/go.mod h1:ZqniWRKu7WIeLijbbzetF4U9qZ03cg5IRwl8YVs8mX0= k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws= k8s.io/apiextensions-apiserver v0.30.1/go.mod h1:R4GuSrlhgq43oRY9sF2IToFh7PVlF1JjfWdoG3pixk4= +k8s.io/apiextensions-apiserver v0.30.4 h1:FwOMIk/rzZvM/Gx0IOz0+biZ+dlnlCeyfXW17uzV1qE= +k8s.io/apiextensions-apiserver v0.30.4/go.mod h1:m8cAkJ9PVU8Olb4cPW4hrUDBZGvoSJ0kY0G0CfdGQac= k8s.io/apimachinery v0.20.1/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= k8s.io/apimachinery v0.20.4/go.mod h1:WlLqWAHZGg07AeltaI0MV5uk1Omp8xaN0JGLY6gkRpU= k8s.io/apimachinery v0.20.6/go.mod h1:ejZXtW1Ra6V1O5H8xPBGz+T3+4gfkTCeExAHKU57MAc= k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U= k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/apimachinery v0.30.4 h1:5QHQI2tInzr8LsT4kU/2+fSeibH1eIHswNx480cqIoY= +k8s.io/apimachinery v0.30.4/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= k8s.io/apiserver v0.20.1/go.mod h1:ro5QHeQkgMS7ZGpvf4tSMx6bBOgPfE+f52KwvXfScaU= k8s.io/apiserver v0.20.4/go.mod h1:Mc80thBKOyy7tbvFtB4kJv1kbdD0eIH8k8vianJcbFM= k8s.io/apiserver v0.20.6/go.mod h1:QIJXNt6i6JB+0YQRNcS0hdRHJlMhflFmsBDeSgT1r8Q= k8s.io/apiserver v0.30.1 h1:BEWEe8bzS12nMtDKXzCF5Q5ovp6LjjYkSp8qOPk8LZ8= k8s.io/apiserver v0.30.1/go.mod h1:i87ZnQ+/PGAmSbD/iEKM68bm1D5reX8fO4Ito4B01mo= +k8s.io/apiserver v0.30.4 h1:rHkGJhxd+m4jILrgkenwSmG4X0QXk6ecGuybzS/PQak= +k8s.io/apiserver v0.30.4/go.mod h1:oyGAj9B9/0+I9huJyf4/8SMBF2mNh2bTMlu7703dkH8= k8s.io/cli-runtime v0.29.1 h1:By3WVOlEWYfyxhGko0f/IuAOLQcbBSMzwSaDren2JUs= k8s.io/cli-runtime v0.29.1/go.mod h1:vjEY9slFp8j8UoMhV5AlO8uulX9xk6ogfIesHobyBDU= k8s.io/client-go v0.20.1/go.mod h1:/zcHdt1TeWSd5HoUe6elJmHSQ6uLLgp4bIJHVEuy+/Y= @@ -1536,12 +1550,16 @@ k8s.io/client-go v0.20.4/go.mod h1:LiMv25ND1gLUdBeYxBIwKpkSC5IsozMMmOOeSJboP+k= k8s.io/client-go v0.20.6/go.mod h1:nNQMnOvEUEsOzRRFIIkdmYOjAZrC8bgq0ExboWSU1I0= k8s.io/client-go v0.30.1 h1:uC/Ir6A3R46wdkgCV3vbLyNOYyCJ8oZnjtJGKfytl/Q= k8s.io/client-go v0.30.1/go.mod h1:wrAqLNs2trwiCH/wxxmT/x3hKVH9PuV0GGW0oDoHVqc= +k8s.io/client-go v0.30.4 h1:eculUe+HPQoPbixfwmaSZGsKcOf7D288tH6hDAdd+wY= +k8s.io/client-go v0.30.4/go.mod h1:IBS0R/Mt0LHkNHF4E6n+SUDPG7+m2po6RZU7YHeOpzc= k8s.io/code-generator v0.19.7/go.mod h1:lwEq3YnLYb/7uVXLorOJfxg+cUu2oihFhHZ0n9NIla0= k8s.io/component-base v0.20.1/go.mod h1:guxkoJnNoh8LNrbtiQOlyp2Y2XFCZQmrcg2n/DeYNLk= k8s.io/component-base v0.20.4/go.mod h1:t4p9EdiagbVCJKrQ1RsA5/V4rFQNDfRlevJajlGwgjI= k8s.io/component-base v0.20.6/go.mod h1:6f1MPBAeI+mvuts3sIdtpjljHWBQ2cIy38oBIWMYnrM= k8s.io/component-base v0.30.1 h1:bvAtlPh1UrdaZL20D9+sWxsJljMi0QZ3Lmw+kmZAaxQ= k8s.io/component-base v0.30.1/go.mod h1:e/X9kDiOebwlI41AvBHuWdqFriSRrX50CdwA9TFaHLI= +k8s.io/component-base v0.30.4 h1:FlgKqazIkIIxpLA4wFXsiPiDllJn9fhsN3G4TeX7T7U= +k8s.io/component-base v0.30.4/go.mod h1:Qd3h+OJxV/LrnriXG/E15ZK83dzd306qJHW9+87S5ls= k8s.io/cri-api v0.17.3/go.mod h1:X1sbHmuXhwaHs9xxYffLqJogVsnI+f6cPRcgPel7ywM= k8s.io/cri-api v0.20.1/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= k8s.io/cri-api v0.20.4/go.mod h1:2JRbKt+BFLTjtrILYVqQK5jqhI+XNdF6UiGMgczeBCI= @@ -1577,6 +1595,8 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 h1:/U5vjBbQn3RCh sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0/go.mod h1:z7+wmGM2dfIiLRfrC6jb5kV2Mq/sK1ZP303cxzkV5Y4= sigs.k8s.io/controller-runtime v0.18.4 h1:87+guW1zhvuPLh1PHybKdYFLU0YJp4FhJRmiHvm5BZw= sigs.k8s.io/controller-runtime v0.18.4/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= +sigs.k8s.io/controller-runtime v0.18.5 h1:nTHio/W+Q4aBlQMgbnC5hZb4IjIidyrizMai9P6n4Rk= +sigs.k8s.io/controller-runtime v0.18.5/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= 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/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= diff --git a/pkg/devcontainer/config.go b/pkg/devcontainer/config.go index 3a10e10ca..d4a172111 100644 --- a/pkg/devcontainer/config.go +++ b/pkg/devcontainer/config.go @@ -33,8 +33,8 @@ func (r *runner) getRawConfig(options provider2.CLIOptions) (*config.DevContaine }, Origin: "", }, nil - } else if options.DevContainerSource != "" && crane.IsAvailable() { - localWorkspaceFolder, err := crane.PullConfigFromSource(r.WorkspaceConfig, r.Log) + } else if crane.ShouldUse(&options) { + localWorkspaceFolder, err := crane.PullConfigFromSource(r.WorkspaceConfig, &options, r.Log) if err != nil { return nil, err } diff --git a/pkg/devcontainer/crane/run.go b/pkg/devcontainer/crane/run.go index fced650f0..5cf15b80f 100644 --- a/pkg/devcontainer/crane/run.go +++ b/pkg/devcontainer/crane/run.go @@ -20,25 +20,39 @@ const ( PullCommand = "pull" DecryptCommand = "decrypt" - GitCrane = "git" + GitCrane = "git" + EnvironmentCrane = "environment" - BinPath = "devpod-crane" // FIXME - - tmpDirTemplate = "devpod-crane-*" + defaultBinName = "devpod-crane" + envDevPodCraneName = "DEVPOD_CRANE_NAME" + tmpDirTemplate = "devpod-crane-*" ) type Content struct { Files map[string]string `json:"files"` } -// IsAvailable checks if devpod crane is installed in host system -func IsAvailable() bool { - _, err := exec.LookPath(BinPath) - return err == nil +type command struct { + cmd string + args []string } -func runCommand(command string, args ...string) (string, error) { - cmd := exec.Command(BinPath, append([]string{command}, args...)...) +func New(cmd string) *command { + return &command{cmd: cmd} +} + +func (c *command) WithFlag(flag, val string) *command { + c.args = append(c.args, flag, val) + return c +} + +func (c *command) WithArg(arg string) *command { + c.args = append(c.args, arg) + return c +} + +func (c *command) Run() (string, error) { + cmd := exec.Command(c.cmd, c.args...) var outBuf, errBuf bytes.Buffer cmd.Stdout = &outBuf @@ -51,15 +65,37 @@ func runCommand(command string, args ...string) (string, error) { return outBuf.String(), nil } +// ShouldUse takes CLIOptions and returns true if crane should be used +func ShouldUse(cliOptions *provider2.CLIOptions) bool { + return IsAvailable() && (cliOptions.DevContainerSource != "" || + cliOptions.EnvironmentTemplate != "") +} + +// IsAvailable checks if devpod crane is installed in host system +func IsAvailable() bool { + _, err := exec.LookPath(getBinName()) + return err == nil +} + // PullConfigFromSource pulls devcontainer config from configSource using git crane and returns config path -func PullConfigFromSource(workspaceInfo *provider2.AgentWorkspaceInfo, log log.Logger) (string, error) { - data, err := runCommand(PullCommand, GitCrane, workspaceInfo.CLIOptions.DevContainerSource) +func PullConfigFromSource(workspaceInfo *provider2.AgentWorkspaceInfo, options *provider2.CLIOptions, log log.Logger) (string, error) { + var data string + var err error + + switch { + case options.EnvironmentTemplate != "": + data, err = New(PullCommand).WithArg(EnvironmentCrane).WithArg(options.EnvironmentTemplate).Run() + case options.DevContainerSource != "": + data, err = New(PullCommand).WithArg(GitCrane).WithArg(options.DevContainerSource).Run() + default: + err = fmt.Errorf("failed to pull config from source based on options") + } if err != nil { return "", err } if craneSigningKey != "" { - data, err = runCommand(DecryptCommand, data, "--key", craneSigningKey) + data, err = New(DecryptCommand).WithArg(data).WithFlag("--key", craneSigningKey).Run() if err != nil { return "", err } @@ -111,3 +147,10 @@ func storeFilesInDirectory(content *Content, path string) (string, error) { return path, nil } + +func getBinName() string { + if name := os.Getenv(envDevPodCraneName); name != "" { + return name + } + return defaultBinName +} diff --git a/pkg/devcontainer/setup.go b/pkg/devcontainer/setup.go index 383aed00e..ee6b40d9c 100644 --- a/pkg/devcontainer/setup.go +++ b/pkg/devcontainer/setup.go @@ -79,7 +79,7 @@ func (r *runner) setupContainer( Agent: r.WorkspaceConfig.Agent, ContentFolder: r.WorkspaceConfig.ContentFolder, } - if r.WorkspaceConfig.CLIOptions.DevContainerSource != "" && crane.IsAvailable() { + if crane.ShouldUse(&r.WorkspaceConfig.CLIOptions) { workspaceConfig.PullFromInsideContainer = "true" } // compress container workspace info diff --git a/pkg/provider/workspace.go b/pkg/provider/workspace.go index 730eaa515..9eb012125 100644 --- a/pkg/provider/workspace.go +++ b/pkg/provider/workspace.go @@ -191,6 +191,7 @@ type CLIOptions struct { DevContainerImage string `json:"devContainerImage,omitempty"` DevContainerPath string `json:"devContainerPath,omitempty"` DevContainerSource string `json:"devContainerSource,omitempty"` + EnvironmentTemplate string `json:"environmentTemplate,omitempty"` WorkspaceEnv []string `json:"workspaceEnv,omitempty"` WorkspaceEnvFile []string `json:"workspaceEnvFile,omitempty"` InitEnv []string `json:"initEnv,omitempty"` diff --git a/vendor/github.com/dimchansky/utfbom/.travis.yml b/vendor/github.com/dimchansky/utfbom/.travis.yml index 77be8b345..19312ee35 100644 --- a/vendor/github.com/dimchansky/utfbom/.travis.yml +++ b/vendor/github.com/dimchansky/utfbom/.travis.yml @@ -1,29 +1,29 @@ -language: go -sudo: false - -go: - - 1.10.x - - 1.11.x - - 1.12.x - - 1.13.x - - 1.14.x - - 1.15.x - -cache: - directories: - - $HOME/.cache/go-build - - $HOME/gopath/pkg/mod - -env: - global: - - GO111MODULE=on - -before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover - - go get golang.org/x/tools/cmd/goimports - - go get golang.org/x/lint/golint -script: - - gofiles=$(find ./ -name '*.go') && [ -z "$gofiles" ] || unformatted=$(goimports -l $gofiles) && [ -z "$unformatted" ] || (echo >&2 "Go files must be formatted with gofmt. Following files has problem:\n $unformatted" && false) - - golint ./... # This won't break the build, just show warnings - - $HOME/gopath/bin/goveralls -service=travis-ci +language: go +sudo: false + +go: + - 1.10.x + - 1.11.x + - 1.12.x + - 1.13.x + - 1.14.x + - 1.15.x + +cache: + directories: + - $HOME/.cache/go-build + - $HOME/gopath/pkg/mod + +env: + global: + - GO111MODULE=on + +before_install: + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover + - go get golang.org/x/tools/cmd/goimports + - go get golang.org/x/lint/golint +script: + - gofiles=$(find ./ -name '*.go') && [ -z "$gofiles" ] || unformatted=$(goimports -l $gofiles) && [ -z "$unformatted" ] || (echo >&2 "Go files must be formatted with gofmt. Following files has problem:\n $unformatted" && false) + - golint ./... # This won't break the build, just show warnings + - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/features.go b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/features.go index 49e55b1ff..71ec683db 100644 --- a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/features.go +++ b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/features.go @@ -16,7 +16,10 @@ const ( VirtualClusterProDistroIsolatedControlPlane FeatureName = "vcp-distro-isolated-cp" VirtualClusterProDistroSyncPatches FeatureName = "vcp-distro-sync-patches" VirtualClusterProDistroCentralizedAdmissionControl FeatureName = "vcp-distro-centralized-admission-control" - VirtualClusterProEmbeddedEtcd FeatureName = "vcp-distro-embedded-etcd" + VirtualClusterProDistroEmbeddedEtcd FeatureName = "vcp-distro-embedded-etcd" + VirtualClusterProDistroGenericSync FeatureName = "vcp-distro-generic-sync" + VirtualClusterProDistroTranslatePatches FeatureName = "vcp-distro-translate-patches" + VirtualClusterEnterprisePlugins FeatureName = "vcluster-enterprise-plugins" // Spaces & Clusters ConnectedClusters FeatureName = "connected-clusters" @@ -72,6 +75,9 @@ func GetVClusterFeatures() []FeatureName { VirtualClusterProDistroIsolatedControlPlane, VirtualClusterProDistroSyncPatches, VirtualClusterProDistroCentralizedAdmissionControl, - VirtualClusterProEmbeddedEtcd, + VirtualClusterProDistroEmbeddedEtcd, + VirtualClusterProDistroGenericSync, + VirtualClusterProDistroTranslatePatches, + VirtualClusterEnterprisePlugins, } } diff --git a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license.go b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license.go index c2d92cc30..c49824c2a 100644 --- a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license.go +++ b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license.go @@ -7,6 +7,8 @@ package licenseapi type License struct { // InstanceID contains the instance id of the Loft instance InstanceID string `json:"instance,omitempty"` + // Entity holds a name for an organization, person or entity this product is licensed for. This will be displayed to the user. + Entity string `json:"entity,omitempty"` // Analytics indicates the analytics endpoints and which requests should be sent to the // analytics server. diff --git a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license_new.go b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license_new.go index cc514b9fc..8eb32b062 100644 --- a/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license_new.go +++ b/vendor/github.com/loft-sh/admin-apis/pkg/licenseapi/license_new.go @@ -70,6 +70,11 @@ func New(product ProductName) *License { Name: string(VirtualClusterCentralHostPathMapper), Status: virtualClusterStatus, }, + { + DisplayName: "Enterprise Plugins", + Name: string(VirtualClusterEnterprisePlugins), + Status: virtualClusterStatus, + }, }, }, { @@ -96,6 +101,11 @@ func New(product ProductName) *License { Name: string(VirtualClusterProDistroSyncPatches), Status: virtualClusterStatus, }, + { + DisplayName: "Embedded etcd", + Name: string(VirtualClusterProDistroEmbeddedEtcd), + Status: virtualClusterStatus, + }, { DisplayName: "Isolated Control Plane", Name: string(VirtualClusterProDistroIsolatedControlPlane), @@ -106,6 +116,16 @@ func New(product ProductName) *License { Name: string(VirtualClusterProDistroCentralizedAdmissionControl), Status: virtualClusterStatus, }, + { + DisplayName: "Generic Sync", + Name: string(VirtualClusterProDistroGenericSync), + Status: virtualClusterStatus, + }, + { + DisplayName: "Translate Patches", + Name: string(VirtualClusterProDistroTranslatePatches), + Status: virtualClusterStatus, + }, }, }, { diff --git a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/helmrelease_types.go b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/helmrelease_types.go index 51a764739..6a8133014 100644 --- a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/helmrelease_types.go +++ b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/helmrelease_types.go @@ -1,6 +1,7 @@ package v1 import ( + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -139,6 +140,14 @@ type Bash struct { // ClusterRole is the cluster role to use for this job // +optional ClusterRole string `json:"clusterRole,omitempty"` + + // PodSecurityContext for the bash pod. + // +optional + PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` + + // SecurityContext for the bash container. + // +optional + SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` } // Info describes release information. diff --git a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.conversion.go b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.conversion.go index 5232456c4..9fd59e825 100644 --- a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.conversion.go +++ b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.conversion.go @@ -9,6 +9,7 @@ import ( unsafe "unsafe" cluster "github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster" + corev1 "k8s.io/api/core/v1" conversion "k8s.io/apimachinery/pkg/conversion" runtime "k8s.io/apimachinery/pkg/runtime" ) @@ -227,6 +228,8 @@ func autoConvert_v1_Bash_To_cluster_Bash(in *Bash, out *cluster.Bash, s conversi out.Script = in.Script out.Image = in.Image out.ClusterRole = in.ClusterRole + out.PodSecurityContext = (*corev1.PodSecurityContext)(unsafe.Pointer(in.PodSecurityContext)) + out.SecurityContext = (*corev1.SecurityContext)(unsafe.Pointer(in.SecurityContext)) return nil } @@ -239,6 +242,8 @@ func autoConvert_cluster_Bash_To_v1_Bash(in *cluster.Bash, out *Bash, s conversi out.Script = in.Script out.Image = in.Image out.ClusterRole = in.ClusterRole + out.PodSecurityContext = (*corev1.PodSecurityContext)(unsafe.Pointer(in.PodSecurityContext)) + out.SecurityContext = (*corev1.SecurityContext)(unsafe.Pointer(in.SecurityContext)) return nil } diff --git a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.deepcopy.go b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.deepcopy.go index b5eaa6975..0a34e1f3f 100644 --- a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1/zz_generated.deepcopy.go @@ -6,12 +6,23 @@ package v1 import ( + corev1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Bash) DeepCopyInto(out *Bash) { *out = *in + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(corev1.SecurityContext) + (*in).DeepCopyInto(*out) + } return } @@ -332,7 +343,7 @@ func (in *HelmReleaseConfig) DeepCopyInto(out *HelmReleaseConfig) { if in.Bash != nil { in, out := &in.Bash, &out.Bash *out = new(Bash) - **out = **in + (*in).DeepCopyInto(*out) } if in.Annotations != nil { in, out := &in.Annotations, &out.Annotations diff --git a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.api.register.go b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.api.register.go index 84774cd7e..b98de8d6c 100644 --- a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.api.register.go +++ b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.api.register.go @@ -8,6 +8,7 @@ import ( pkglicenseapi "github.com/loft-sh/admin-apis/pkg/licenseapi" "github.com/loft-sh/apiserver/pkg/builders" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/internalversion" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -122,9 +123,11 @@ func Resource(resource string) schema.GroupResource { type Status string type Bash struct { - Script string `json:"script,omitempty"` - Image string `json:"image,omitempty"` - ClusterRole string `json:"clusterRole,omitempty"` + Script string `json:"script,omitempty"` + Image string `json:"image,omitempty"` + ClusterRole string `json:"clusterRole,omitempty"` + PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` + SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` } type Chart struct { diff --git a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.deepcopy.go b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.deepcopy.go index 6efcd70c0..51b0c3efd 100644 --- a/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.deepcopy.go +++ b/vendor/github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/zz_generated.deepcopy.go @@ -6,12 +6,23 @@ package cluster import ( + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Bash) DeepCopyInto(out *Bash) { *out = *in + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(v1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(v1.SecurityContext) + (*in).DeepCopyInto(*out) + } return } @@ -300,7 +311,7 @@ func (in *HelmReleaseConfig) DeepCopyInto(out *HelmReleaseConfig) { if in.Bash != nil { in, out := &in.Bash, &out.Bash *out = new(Bash) - **out = **in + (*in).DeepCopyInto(*out) } if in.Annotations != nil { in, out := &in.Annotations, &out.Annotations diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/config_types.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/config_types.go index 4c05e54a2..e90bed3b3 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/config_types.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/config_types.go @@ -67,6 +67,9 @@ type ConfigStatus struct { // VaultIntegration holds the vault integration configuration // +optional VaultIntegration *storagev1.VaultIntegrationSpec `json:"vault,omitempty"` + + // DisableLoftConfigEndpoint will disable setting config via the UI and config.management.loft.sh endpoint + DisableConfigEndpoint bool `json:"disableConfigEndpoint,omitempty"` } // Audit holds the audit configuration options for loft. Changing any options will require a loft restart diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/devpodenvironmenttemplate_types.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/devpodenvironmenttemplate_types.go new file mode 100644 index 000000000..a6abe94cf --- /dev/null +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/devpodenvironmenttemplate_types.go @@ -0,0 +1,60 @@ +package v1 + +import ( + storagev1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DevPodEnvironmentTemplate holds the DevPodEnvironmentTemplate information +// +k8s:openapi-gen=true +// +resource:path=devpodenvironmenttemplate,rest=DevPodEnvironmentTemplateREST +type DevPodEnvironmentTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec DevPodEnvironmentTemplateSpec `json:"spec,omitempty"` + Status DevPodEnvironmentTemplateStatus `json:"status,omitempty"` +} + +// DevPodEnvironmentTemplateSpec holds the specification +type DevPodEnvironmentTemplateSpec struct { + storagev1.DevPodEnvironmentTemplateSpec `json:",inline"` +} + +// GitEnvironmentTemplate stores configuration of Git environment template source +type GitEnvironmentTemplate struct { + // Repository stores repository URL for Git environment spec source + Repository string `json:"repository"` + + // Revision stores revision to checkout in repository + // +optional + Revision string `json:"revision,omitempty"` + + // SubPath stores subpath within Repositor where environment spec is + // +optional + SubPath string `json:"subpath,omitempty"` +} + +func (a *DevPodEnvironmentTemplate) GetOwner() *storagev1.UserOrTeam { + return a.Spec.Owner +} + +func (a *DevPodEnvironmentTemplate) SetOwner(userOrTeam *storagev1.UserOrTeam) { + a.Spec.Owner = userOrTeam +} + +func (a *DevPodEnvironmentTemplate) GetAccess() []storagev1.Access { + return a.Spec.Access +} + +func (a *DevPodEnvironmentTemplate) SetAccess(access []storagev1.Access) { + a.Spec.Access = access +} + +// DevPodEnvironmentTemplateStatus holds the status +type DevPodEnvironmentTemplateStatus struct{} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.api.register.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.api.register.go index c1ea9b171..631c4d13a 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.api.register.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.api.register.go @@ -41,6 +41,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ConfigList{}, &ConvertVirtualClusterConfig{}, &ConvertVirtualClusterConfigList{}, + &DevPodEnvironmentTemplate{}, + &DevPodEnvironmentTemplateList{}, &DevPodWorkspaceInstance{}, &DevPodWorkspaceInstanceList{}, &DevPodDeleteOptions{}, @@ -194,6 +196,7 @@ var ( management.ManagementClusterRoleTemplateStorage, management.ManagementConfigStorage, management.ManagementConvertVirtualClusterConfigStorage, + management.ManagementDevPodEnvironmentTemplateStorage, management.ManagementDevPodWorkspaceInstanceStorage, builders.NewApiResourceWithStorage( management.InternalDevPodDeleteOptionsREST, @@ -564,6 +567,14 @@ type ConvertVirtualClusterConfigList struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type DevPodEnvironmentTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DevPodEnvironmentTemplate `json:"items"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + type DevPodWorkspaceInstanceList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.conversion.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.conversion.go index 5dc46c88a..2d5622c2a 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.conversion.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.conversion.go @@ -829,6 +829,46 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*DevPodEnvironmentTemplate)(nil), (*management.DevPodEnvironmentTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_DevPodEnvironmentTemplate_To_management_DevPodEnvironmentTemplate(a.(*DevPodEnvironmentTemplate), b.(*management.DevPodEnvironmentTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*management.DevPodEnvironmentTemplate)(nil), (*DevPodEnvironmentTemplate)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_management_DevPodEnvironmentTemplate_To_v1_DevPodEnvironmentTemplate(a.(*management.DevPodEnvironmentTemplate), b.(*DevPodEnvironmentTemplate), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*DevPodEnvironmentTemplateList)(nil), (*management.DevPodEnvironmentTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_DevPodEnvironmentTemplateList_To_management_DevPodEnvironmentTemplateList(a.(*DevPodEnvironmentTemplateList), b.(*management.DevPodEnvironmentTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*management.DevPodEnvironmentTemplateList)(nil), (*DevPodEnvironmentTemplateList)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_management_DevPodEnvironmentTemplateList_To_v1_DevPodEnvironmentTemplateList(a.(*management.DevPodEnvironmentTemplateList), b.(*DevPodEnvironmentTemplateList), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*DevPodEnvironmentTemplateSpec)(nil), (*management.DevPodEnvironmentTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec(a.(*DevPodEnvironmentTemplateSpec), b.(*management.DevPodEnvironmentTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*management.DevPodEnvironmentTemplateSpec)(nil), (*DevPodEnvironmentTemplateSpec)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec(a.(*management.DevPodEnvironmentTemplateSpec), b.(*DevPodEnvironmentTemplateSpec), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*DevPodEnvironmentTemplateStatus)(nil), (*management.DevPodEnvironmentTemplateStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus(a.(*DevPodEnvironmentTemplateStatus), b.(*management.DevPodEnvironmentTemplateStatus), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*management.DevPodEnvironmentTemplateStatus)(nil), (*DevPodEnvironmentTemplateStatus)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus(a.(*management.DevPodEnvironmentTemplateStatus), b.(*DevPodEnvironmentTemplateStatus), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*DevPodSshOptions)(nil), (*management.DevPodSshOptions)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1_DevPodSshOptions_To_management_DevPodSshOptions(a.(*DevPodSshOptions), b.(*management.DevPodSshOptions), scope) }); err != nil { @@ -4674,6 +4714,7 @@ func autoConvert_v1_ConfigStatus_To_management_ConfigStatus(in *ConfigStatus, ou out.DevPodSubDomain = in.DevPodSubDomain out.UISettings = (*uiv1.UISettingsConfig)(unsafe.Pointer(in.UISettings)) out.VaultIntegration = (*storagev1.VaultIntegrationSpec)(unsafe.Pointer(in.VaultIntegration)) + out.DisableConfigEndpoint = in.DisableConfigEndpoint return nil } @@ -4694,6 +4735,7 @@ func autoConvert_management_ConfigStatus_To_v1_ConfigStatus(in *management.Confi out.DevPodSubDomain = in.DevPodSubDomain out.UISettings = (*uiv1.UISettingsConfig)(unsafe.Pointer(in.UISettings)) out.VaultIntegration = (*storagev1.VaultIntegrationSpec)(unsafe.Pointer(in.VaultIntegration)) + out.DisableConfigEndpoint = in.DisableConfigEndpoint return nil } @@ -4920,6 +4962,98 @@ func Convert_management_DevPodDeleteOptionsList_To_v1_DevPodDeleteOptionsList(in return autoConvert_management_DevPodDeleteOptionsList_To_v1_DevPodDeleteOptionsList(in, out, s) } +func autoConvert_v1_DevPodEnvironmentTemplate_To_management_DevPodEnvironmentTemplate(in *DevPodEnvironmentTemplate, out *management.DevPodEnvironmentTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_v1_DevPodEnvironmentTemplate_To_management_DevPodEnvironmentTemplate is an autogenerated conversion function. +func Convert_v1_DevPodEnvironmentTemplate_To_management_DevPodEnvironmentTemplate(in *DevPodEnvironmentTemplate, out *management.DevPodEnvironmentTemplate, s conversion.Scope) error { + return autoConvert_v1_DevPodEnvironmentTemplate_To_management_DevPodEnvironmentTemplate(in, out, s) +} + +func autoConvert_management_DevPodEnvironmentTemplate_To_v1_DevPodEnvironmentTemplate(in *management.DevPodEnvironmentTemplate, out *DevPodEnvironmentTemplate, s conversion.Scope) error { + out.ObjectMeta = in.ObjectMeta + if err := Convert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec(&in.Spec, &out.Spec, s); err != nil { + return err + } + if err := Convert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus(&in.Status, &out.Status, s); err != nil { + return err + } + return nil +} + +// Convert_management_DevPodEnvironmentTemplate_To_v1_DevPodEnvironmentTemplate is an autogenerated conversion function. +func Convert_management_DevPodEnvironmentTemplate_To_v1_DevPodEnvironmentTemplate(in *management.DevPodEnvironmentTemplate, out *DevPodEnvironmentTemplate, s conversion.Scope) error { + return autoConvert_management_DevPodEnvironmentTemplate_To_v1_DevPodEnvironmentTemplate(in, out, s) +} + +func autoConvert_v1_DevPodEnvironmentTemplateList_To_management_DevPodEnvironmentTemplateList(in *DevPodEnvironmentTemplateList, out *management.DevPodEnvironmentTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]management.DevPodEnvironmentTemplate)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_v1_DevPodEnvironmentTemplateList_To_management_DevPodEnvironmentTemplateList is an autogenerated conversion function. +func Convert_v1_DevPodEnvironmentTemplateList_To_management_DevPodEnvironmentTemplateList(in *DevPodEnvironmentTemplateList, out *management.DevPodEnvironmentTemplateList, s conversion.Scope) error { + return autoConvert_v1_DevPodEnvironmentTemplateList_To_management_DevPodEnvironmentTemplateList(in, out, s) +} + +func autoConvert_management_DevPodEnvironmentTemplateList_To_v1_DevPodEnvironmentTemplateList(in *management.DevPodEnvironmentTemplateList, out *DevPodEnvironmentTemplateList, s conversion.Scope) error { + out.ListMeta = in.ListMeta + out.Items = *(*[]DevPodEnvironmentTemplate)(unsafe.Pointer(&in.Items)) + return nil +} + +// Convert_management_DevPodEnvironmentTemplateList_To_v1_DevPodEnvironmentTemplateList is an autogenerated conversion function. +func Convert_management_DevPodEnvironmentTemplateList_To_v1_DevPodEnvironmentTemplateList(in *management.DevPodEnvironmentTemplateList, out *DevPodEnvironmentTemplateList, s conversion.Scope) error { + return autoConvert_management_DevPodEnvironmentTemplateList_To_v1_DevPodEnvironmentTemplateList(in, out, s) +} + +func autoConvert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec(in *DevPodEnvironmentTemplateSpec, out *management.DevPodEnvironmentTemplateSpec, s conversion.Scope) error { + out.DevPodEnvironmentTemplateSpec = in.DevPodEnvironmentTemplateSpec + return nil +} + +// Convert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec is an autogenerated conversion function. +func Convert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec(in *DevPodEnvironmentTemplateSpec, out *management.DevPodEnvironmentTemplateSpec, s conversion.Scope) error { + return autoConvert_v1_DevPodEnvironmentTemplateSpec_To_management_DevPodEnvironmentTemplateSpec(in, out, s) +} + +func autoConvert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec(in *management.DevPodEnvironmentTemplateSpec, out *DevPodEnvironmentTemplateSpec, s conversion.Scope) error { + out.DevPodEnvironmentTemplateSpec = in.DevPodEnvironmentTemplateSpec + return nil +} + +// Convert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec is an autogenerated conversion function. +func Convert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec(in *management.DevPodEnvironmentTemplateSpec, out *DevPodEnvironmentTemplateSpec, s conversion.Scope) error { + return autoConvert_management_DevPodEnvironmentTemplateSpec_To_v1_DevPodEnvironmentTemplateSpec(in, out, s) +} + +func autoConvert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus(in *DevPodEnvironmentTemplateStatus, out *management.DevPodEnvironmentTemplateStatus, s conversion.Scope) error { + return nil +} + +// Convert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus is an autogenerated conversion function. +func Convert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus(in *DevPodEnvironmentTemplateStatus, out *management.DevPodEnvironmentTemplateStatus, s conversion.Scope) error { + return autoConvert_v1_DevPodEnvironmentTemplateStatus_To_management_DevPodEnvironmentTemplateStatus(in, out, s) +} + +func autoConvert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus(in *management.DevPodEnvironmentTemplateStatus, out *DevPodEnvironmentTemplateStatus, s conversion.Scope) error { + return nil +} + +// Convert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus is an autogenerated conversion function. +func Convert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus(in *management.DevPodEnvironmentTemplateStatus, out *DevPodEnvironmentTemplateStatus, s conversion.Scope) error { + return autoConvert_management_DevPodEnvironmentTemplateStatus_To_v1_DevPodEnvironmentTemplateStatus(in, out, s) +} + func autoConvert_v1_DevPodSshOptions_To_management_DevPodSshOptions(in *DevPodSshOptions, out *management.DevPodSshOptions, s conversion.Scope) error { out.Options = in.Options return nil diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.deepcopy.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.deepcopy.go index 49ddda7c4..4d6bcabfe 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/v1/zz_generated.deepcopy.go @@ -2238,6 +2238,100 @@ func (in *DevPodDeleteOptionsList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplate) DeepCopyInto(out *DevPodEnvironmentTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplate. +func (in *DevPodEnvironmentTemplate) DeepCopy() *DevPodEnvironmentTemplate { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateList) DeepCopyInto(out *DevPodEnvironmentTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DevPodEnvironmentTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateList. +func (in *DevPodEnvironmentTemplateList) DeepCopy() *DevPodEnvironmentTemplateList { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateSpec) DeepCopyInto(out *DevPodEnvironmentTemplateSpec) { + *out = *in + in.DevPodEnvironmentTemplateSpec.DeepCopyInto(&out.DevPodEnvironmentTemplateSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateSpec. +func (in *DevPodEnvironmentTemplateSpec) DeepCopy() *DevPodEnvironmentTemplateSpec { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateStatus) DeepCopyInto(out *DevPodEnvironmentTemplateStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateStatus. +func (in *DevPodEnvironmentTemplateStatus) DeepCopy() *DevPodEnvironmentTemplateStatus { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DevPodSshOptions) DeepCopyInto(out *DevPodSshOptions) { *out = *in @@ -3002,6 +3096,22 @@ func (in *FeatureStatus) DeepCopy() *FeatureStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GitEnvironmentTemplate) DeepCopyInto(out *GitEnvironmentTemplate) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitEnvironmentTemplate. +func (in *GitEnvironmentTemplate) DeepCopy() *GitEnvironmentTemplate { + if in == nil { + return nil + } + out := new(GitEnvironmentTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GroupResources) DeepCopyInto(out *GroupResources) { *out = *in diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.api.register.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.api.register.go index 2bf4c8d12..0676ee378 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.api.register.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.api.register.go @@ -116,7 +116,17 @@ var ( NewConvertVirtualClusterConfigREST = func(getter generic.RESTOptionsGetter) rest.Storage { return NewConvertVirtualClusterConfigRESTFunc(Factory) } - NewConvertVirtualClusterConfigRESTFunc NewRESTFunc + NewConvertVirtualClusterConfigRESTFunc NewRESTFunc + ManagementDevPodEnvironmentTemplateStorage = builders.NewApiResourceWithStorage( // Resource status endpoint + InternalDevPodEnvironmentTemplate, + func() runtime.Object { return &DevPodEnvironmentTemplate{} }, // Register versioned resource + func() runtime.Object { return &DevPodEnvironmentTemplateList{} }, // Register versioned resource list + NewDevPodEnvironmentTemplateREST, + ) + NewDevPodEnvironmentTemplateREST = func(getter generic.RESTOptionsGetter) rest.Storage { + return NewDevPodEnvironmentTemplateRESTFunc(Factory) + } + NewDevPodEnvironmentTemplateRESTFunc NewRESTFunc ManagementDevPodWorkspaceInstanceStorage = builders.NewApiResourceWithStorage( // Resource status endpoint InternalDevPodWorkspaceInstance, func() runtime.Object { return &DevPodWorkspaceInstance{} }, // Register versioned resource @@ -617,6 +627,18 @@ var ( func() runtime.Object { return &ConvertVirtualClusterConfig{} }, func() runtime.Object { return &ConvertVirtualClusterConfigList{} }, ) + InternalDevPodEnvironmentTemplate = builders.NewInternalResource( + "devpodenvironmenttemplate", + "DevPodEnvironmentTemplate", + func() runtime.Object { return &DevPodEnvironmentTemplate{} }, + func() runtime.Object { return &DevPodEnvironmentTemplateList{} }, + ) + InternalDevPodEnvironmentTemplateStatus = builders.NewInternalResourceStatus( + "devpodenvironmenttemplate", + "DevPodEnvironmentTemplateStatus", + func() runtime.Object { return &DevPodEnvironmentTemplate{} }, + func() runtime.Object { return &DevPodEnvironmentTemplateList{} }, + ) InternalDevPodWorkspaceInstance = builders.NewInternalResource( "devpodworkspaceinstances", "DevPodWorkspaceInstance", @@ -1231,6 +1253,8 @@ var ( InternalConfigStatus, InternalConvertVirtualClusterConfig, InternalConvertVirtualClusterConfigStatus, + InternalDevPodEnvironmentTemplate, + InternalDevPodEnvironmentTemplateStatus, InternalDevPodWorkspaceInstance, InternalDevPodWorkspaceInstanceStatus, InternalDevPodDeleteOptionsREST, @@ -1599,7 +1623,7 @@ type BackupStatus struct { } // +genclient -// +genclient +// +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type Cluster struct { @@ -1780,6 +1804,7 @@ type ConfigStatus struct { DevPodSubDomain string `json:"devPodSubDomain,omitempty"` UISettings *uiv1.UISettingsConfig `json:"uiSettings,omitempty"` VaultIntegration *storagev1.VaultIntegrationSpec `json:"vault,omitempty"` + DisableConfigEndpoint bool `json:"disableConfigEndpoint,omitempty"` } type Connector struct { @@ -1826,6 +1851,24 @@ type DevPodDeleteOptions struct { Options string `json:"options,omitempty"` } +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type DevPodEnvironmentTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec DevPodEnvironmentTemplateSpec `json:"spec,omitempty"` + Status DevPodEnvironmentTemplateStatus `json:"status,omitempty"` +} + +type DevPodEnvironmentTemplateSpec struct { + storagev1.DevPodEnvironmentTemplateSpec `json:",inline"` +} + +type DevPodEnvironmentTemplateStatus struct { +} + // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type DevPodSshOptions struct { @@ -2012,7 +2055,7 @@ type KioskStatus struct { } // +genclient -// +genclient +// +genclient:nonNamespaced // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object type License struct { @@ -3901,6 +3944,125 @@ func (s *storageConvertVirtualClusterConfig) DeleteConvertVirtualClusterConfig(c return sync, err } +// DevPodEnvironmentTemplate Functions and Structs +// +// +k8s:deepcopy-gen=false +type DevPodEnvironmentTemplateStrategy struct { + builders.DefaultStorageStrategy +} + +// +k8s:deepcopy-gen=false +type DevPodEnvironmentTemplateStatusStrategy struct { + builders.DefaultStatusStorageStrategy +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type DevPodEnvironmentTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DevPodEnvironmentTemplate `json:"items"` +} + +func (DevPodEnvironmentTemplate) NewStatus() interface{} { + return DevPodEnvironmentTemplateStatus{} +} + +func (pc *DevPodEnvironmentTemplate) GetStatus() interface{} { + return pc.Status +} + +func (pc *DevPodEnvironmentTemplate) SetStatus(s interface{}) { + pc.Status = s.(DevPodEnvironmentTemplateStatus) +} + +func (pc *DevPodEnvironmentTemplate) GetSpec() interface{} { + return pc.Spec +} + +func (pc *DevPodEnvironmentTemplate) SetSpec(s interface{}) { + pc.Spec = s.(DevPodEnvironmentTemplateSpec) +} + +func (pc *DevPodEnvironmentTemplate) GetObjectMeta() *metav1.ObjectMeta { + return &pc.ObjectMeta +} + +func (pc *DevPodEnvironmentTemplate) SetGeneration(generation int64) { + pc.ObjectMeta.Generation = generation +} + +func (pc DevPodEnvironmentTemplate) GetGeneration() int64 { + return pc.ObjectMeta.Generation +} + +// Registry is an interface for things that know how to store DevPodEnvironmentTemplate. +// +k8s:deepcopy-gen=false +type DevPodEnvironmentTemplateRegistry interface { + ListDevPodEnvironmentTemplates(ctx context.Context, options *internalversion.ListOptions) (*DevPodEnvironmentTemplateList, error) + GetDevPodEnvironmentTemplate(ctx context.Context, id string, options *metav1.GetOptions) (*DevPodEnvironmentTemplate, error) + CreateDevPodEnvironmentTemplate(ctx context.Context, id *DevPodEnvironmentTemplate) (*DevPodEnvironmentTemplate, error) + UpdateDevPodEnvironmentTemplate(ctx context.Context, id *DevPodEnvironmentTemplate) (*DevPodEnvironmentTemplate, error) + DeleteDevPodEnvironmentTemplate(ctx context.Context, id string) (bool, error) +} + +// NewRegistry returns a new Registry interface for the given Storage. Any mismatched types will panic. +func NewDevPodEnvironmentTemplateRegistry(sp builders.StandardStorageProvider) DevPodEnvironmentTemplateRegistry { + return &storageDevPodEnvironmentTemplate{sp} +} + +// Implement Registry +// storage puts strong typing around storage calls +// +k8s:deepcopy-gen=false +type storageDevPodEnvironmentTemplate struct { + builders.StandardStorageProvider +} + +func (s *storageDevPodEnvironmentTemplate) ListDevPodEnvironmentTemplates(ctx context.Context, options *internalversion.ListOptions) (*DevPodEnvironmentTemplateList, error) { + if options != nil && options.FieldSelector != nil && !options.FieldSelector.Empty() { + return nil, fmt.Errorf("field selector not supported yet") + } + st := s.GetStandardStorage() + obj, err := st.List(ctx, options) + if err != nil { + return nil, err + } + return obj.(*DevPodEnvironmentTemplateList), err +} + +func (s *storageDevPodEnvironmentTemplate) GetDevPodEnvironmentTemplate(ctx context.Context, id string, options *metav1.GetOptions) (*DevPodEnvironmentTemplate, error) { + st := s.GetStandardStorage() + obj, err := st.Get(ctx, id, options) + if err != nil { + return nil, err + } + return obj.(*DevPodEnvironmentTemplate), nil +} + +func (s *storageDevPodEnvironmentTemplate) CreateDevPodEnvironmentTemplate(ctx context.Context, object *DevPodEnvironmentTemplate) (*DevPodEnvironmentTemplate, error) { + st := s.GetStandardStorage() + obj, err := st.Create(ctx, object, nil, &metav1.CreateOptions{}) + if err != nil { + return nil, err + } + return obj.(*DevPodEnvironmentTemplate), nil +} + +func (s *storageDevPodEnvironmentTemplate) UpdateDevPodEnvironmentTemplate(ctx context.Context, object *DevPodEnvironmentTemplate) (*DevPodEnvironmentTemplate, error) { + st := s.GetStandardStorage() + obj, _, err := st.Update(ctx, object.Name, rest.DefaultUpdatedObjectInfo(object), nil, nil, false, &metav1.UpdateOptions{}) + if err != nil { + return nil, err + } + return obj.(*DevPodEnvironmentTemplate), nil +} + +func (s *storageDevPodEnvironmentTemplate) DeleteDevPodEnvironmentTemplate(ctx context.Context, id string) (bool, error) { + st := s.GetStandardStorage() + _, sync, err := st.Delete(ctx, id, nil, &metav1.DeleteOptions{}) + return sync, err +} + // DevPodWorkspaceInstance Functions and Structs // // +k8s:deepcopy-gen=false diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.deepcopy.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.deepcopy.go index 72261b13f..038e2ecc9 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.deepcopy.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.deepcopy.go @@ -2213,6 +2213,100 @@ func (in *DevPodDeleteOptionsList) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplate) DeepCopyInto(out *DevPodEnvironmentTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplate. +func (in *DevPodEnvironmentTemplate) DeepCopy() *DevPodEnvironmentTemplate { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateList) DeepCopyInto(out *DevPodEnvironmentTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DevPodEnvironmentTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateList. +func (in *DevPodEnvironmentTemplateList) DeepCopy() *DevPodEnvironmentTemplateList { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateSpec) DeepCopyInto(out *DevPodEnvironmentTemplateSpec) { + *out = *in + in.DevPodEnvironmentTemplateSpec.DeepCopyInto(&out.DevPodEnvironmentTemplateSpec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateSpec. +func (in *DevPodEnvironmentTemplateSpec) DeepCopy() *DevPodEnvironmentTemplateSpec { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateStatus) DeepCopyInto(out *DevPodEnvironmentTemplateStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateStatus. +func (in *DevPodEnvironmentTemplateStatus) DeepCopy() *DevPodEnvironmentTemplateStatus { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DevPodSshOptions) DeepCopyInto(out *DevPodSshOptions) { *out = *in diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodenvironmenttemplate_types.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodenvironmenttemplate_types.go new file mode 100644 index 000000000..dc084fd77 --- /dev/null +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodenvironmenttemplate_types.go @@ -0,0 +1,80 @@ +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DevPodWorkspaceEnvironmentSource +// +k8s:openapi-gen=true +type DevPodEnvironmentTemplate struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec DevPodEnvironmentTemplateSpec `json:"spec,omitempty"` +} + +func (a *DevPodEnvironmentTemplate) GetOwner() *UserOrTeam { + return a.Spec.Owner +} + +func (a *DevPodEnvironmentTemplate) SetOwner(userOrTeam *UserOrTeam) { + a.Spec.Owner = userOrTeam +} + +func (a *DevPodEnvironmentTemplate) GetAccess() []Access { + return a.Spec.Access +} + +func (a *DevPodEnvironmentTemplate) SetAccess(access []Access) { + a.Spec.Access = access +} + +type DevPodEnvironmentTemplateSpec struct { + // DisplayName is the name that should be displayed in the UI + // +optional + DisplayName string `json:"displayName,omitempty"` + + // Git holds configuration for git environment spec source + // +optional + Git GitEnvironmentTemplate `json:"git,omitempty"` + + // Owner holds the owner of this object + // +optional + Owner *UserOrTeam `json:"owner,omitempty"` + + // Access to the DevPod machine instance object itself + // +optional + Access []Access `json:"access,omitempty"` +} + +// GitEnvironmentTemplate stores configuration of Git environment template source +type GitEnvironmentTemplate struct { + // Repository stores repository URL for Git environment spec source + Repository string `json:"repository"` + + // Revision stores revision to checkout in repository + // +optional + Revision string `json:"revision,omitempty"` + + // SubPath stores subpath within Repositor where environment spec is + // +optional + SubPath string `json:"subpath,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// DevPodEnvironmentTemplateList contains a list of DevPodEnvironmentTemplate objects +type DevPodEnvironmentTemplateList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []DevPodEnvironmentTemplate `json:"items"` +} + +func init() { + SchemeBuilder.Register(&DevPodEnvironmentTemplate{}, &DevPodEnvironmentTemplateList{}) +} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspaceinstance_types.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspaceinstance_types.go index 1f183a1ca..d7e4d0585 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspaceinstance_types.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspaceinstance_types.go @@ -146,6 +146,10 @@ type DevPodWorkspaceInstanceStatus struct { // IgnoreReconciliation ignores reconciliation for this object // +optional IgnoreReconciliation bool `json:"ignoreReconciliation,omitempty"` + + // ClusterRef holds the runners cluster if the workspace is scheduled + // on kubernetes based runner + ClusterRef *ClusterRef `json:"clusterRef,omitempty"` } type WorkspaceStatusResult struct { diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspacetemplate_types.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspacetemplate_types.go index 9525f0889..9e2b84083 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspacetemplate_types.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodworkspacetemplate_types.go @@ -93,6 +93,16 @@ type DevPodWorkspaceTemplateDefinition struct { // +optional SpaceTemplate *SpaceTemplateDefinition `json:"spaceTemplate,omitempty"` + // VirtualClusterTemplateRef is a reference to the virtual cluster that should get created for this DevPod. + // If this is specified, the kubernetes provider will be selected automatically. + // +optional + VirtualClusterTemplateRef *TemplateRef `json:"virtualClusterTemplateRef,omitempty"` + + // VirtualClusterTemplate is the inline template for a virtual cluster that should get created for this DevPod. + // If this is specified, the kubernetes provider will be selected automatically. + // +optional + VirtualClusterTemplate *VirtualClusterTemplateDefinition `json:"virtualClusterTemplate,omitempty"` + // WorkspaceEnv are environment variables that should be available within the created workspace. // +optional WorkspaceEnv map[string]DevPodProviderOption `json:"workspaceEnv,omitempty"` diff --git a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/zz_generated.deepcopy.go b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/zz_generated.deepcopy.go index 28d482a09..76342ab3a 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/zz_generated.deepcopy.go @@ -1415,6 +1415,95 @@ func (in *DevPodCommandUpOptions) DeepCopy() *DevPodCommandUpOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplate) DeepCopyInto(out *DevPodEnvironmentTemplate) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplate. +func (in *DevPodEnvironmentTemplate) DeepCopy() *DevPodEnvironmentTemplate { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplate) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplate) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateList) DeepCopyInto(out *DevPodEnvironmentTemplateList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]DevPodEnvironmentTemplate, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateList. +func (in *DevPodEnvironmentTemplateList) DeepCopy() *DevPodEnvironmentTemplateList { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *DevPodEnvironmentTemplateList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevPodEnvironmentTemplateSpec) DeepCopyInto(out *DevPodEnvironmentTemplateSpec) { + *out = *in + out.Git = in.Git + if in.Owner != nil { + in, out := &in.Owner, &out.Owner + *out = new(UserOrTeam) + **out = **in + } + if in.Access != nil { + in, out := &in.Access, &out.Access + *out = make([]Access, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevPodEnvironmentTemplateSpec. +func (in *DevPodEnvironmentTemplateSpec) DeepCopy() *DevPodEnvironmentTemplateSpec { + if in == nil { + return nil + } + out := new(DevPodEnvironmentTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DevPodProjectSpec) DeepCopyInto(out *DevPodProjectSpec) { *out = *in @@ -1619,6 +1708,11 @@ func (in *DevPodWorkspaceInstanceStatus) DeepCopyInto(out *DevPodWorkspaceInstan *out = new(DevPodWorkspaceTemplateDefinition) (*in).DeepCopyInto(*out) } + if in.ClusterRef != nil { + in, out := &in.ClusterRef, &out.ClusterRef + *out = new(ClusterRef) + **out = **in + } return } @@ -1721,6 +1815,16 @@ func (in *DevPodWorkspaceTemplateDefinition) DeepCopyInto(out *DevPodWorkspaceTe *out = new(SpaceTemplateDefinition) (*in).DeepCopyInto(*out) } + if in.VirtualClusterTemplateRef != nil { + in, out := &in.VirtualClusterTemplateRef, &out.VirtualClusterTemplateRef + *out = new(TemplateRef) + **out = **in + } + if in.VirtualClusterTemplate != nil { + in, out := &in.VirtualClusterTemplate, &out.VirtualClusterTemplate + *out = new(VirtualClusterTemplateDefinition) + (*in).DeepCopyInto(*out) + } if in.WorkspaceEnv != nil { in, out := &in.WorkspaceEnv, &out.WorkspaceEnv *out = make(map[string]DevPodProviderOption, len(*in)) @@ -1881,6 +1985,22 @@ func (in *EntityInfo) DeepCopy() *EntityInfo { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GitEnvironmentTemplate) DeepCopyInto(out *GitEnvironmentTemplate) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitEnvironmentTemplate. +func (in *GitEnvironmentTemplate) DeepCopy() *GitEnvironmentTemplate { + if in == nil { + return nil + } + out := new(GitEnvironmentTemplate) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GitProjectSpec) DeepCopyInto(out *GitProjectSpec) { *out = *in diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/devpodenvironmenttemplate.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/devpodenvironmenttemplate.go new file mode 100644 index 000000000..c46bb9712 --- /dev/null +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/devpodenvironmenttemplate.go @@ -0,0 +1,152 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/loft-sh/api/v4/pkg/apis/management/v1" + scheme "github.com/loft-sh/api/v4/pkg/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// DevPodEnvironmentTemplatesGetter has a method to return a DevPodEnvironmentTemplateInterface. +// A group's client should implement this interface. +type DevPodEnvironmentTemplatesGetter interface { + DevPodEnvironmentTemplates() DevPodEnvironmentTemplateInterface +} + +// DevPodEnvironmentTemplateInterface has methods to work with DevPodEnvironmentTemplate resources. +type DevPodEnvironmentTemplateInterface interface { + Create(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.CreateOptions) (*v1.DevPodEnvironmentTemplate, error) + Update(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.UpdateOptions) (*v1.DevPodEnvironmentTemplate, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.DevPodEnvironmentTemplate, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.DevPodEnvironmentTemplateList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.DevPodEnvironmentTemplate, err error) + DevPodEnvironmentTemplateExpansion +} + +// devPodEnvironmentTemplates implements DevPodEnvironmentTemplateInterface +type devPodEnvironmentTemplates struct { + client rest.Interface +} + +// newDevPodEnvironmentTemplates returns a DevPodEnvironmentTemplates +func newDevPodEnvironmentTemplates(c *ManagementV1Client) *devPodEnvironmentTemplates { + return &devPodEnvironmentTemplates{ + client: c.RESTClient(), + } +} + +// Get takes name of the devPodEnvironmentTemplate, and returns the corresponding devPodEnvironmentTemplate object, and an error if there is any. +func (c *devPodEnvironmentTemplates) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Get(). + Resource("devpodenvironmenttemplates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of DevPodEnvironmentTemplates that match those selectors. +func (c *devPodEnvironmentTemplates) List(ctx context.Context, opts metav1.ListOptions) (result *v1.DevPodEnvironmentTemplateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.DevPodEnvironmentTemplateList{} + err = c.client.Get(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested devPodEnvironmentTemplates. +func (c *devPodEnvironmentTemplates) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a devPodEnvironmentTemplate and creates it. Returns the server's representation of the devPodEnvironmentTemplate, and an error, if there is any. +func (c *devPodEnvironmentTemplates) Create(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.CreateOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Post(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(devPodEnvironmentTemplate). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a devPodEnvironmentTemplate and updates it. Returns the server's representation of the devPodEnvironmentTemplate, and an error, if there is any. +func (c *devPodEnvironmentTemplates) Update(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.UpdateOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Put(). + Resource("devpodenvironmenttemplates"). + Name(devPodEnvironmentTemplate.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(devPodEnvironmentTemplate). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the devPodEnvironmentTemplate and deletes it. Returns an error if one occurs. +func (c *devPodEnvironmentTemplates) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("devpodenvironmenttemplates"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *devPodEnvironmentTemplates) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched devPodEnvironmentTemplate. +func (c *devPodEnvironmentTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Patch(pt). + Resource("devpodenvironmenttemplates"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/generated_expansion.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/generated_expansion.go index 673657fbc..f8255641c 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/generated_expansion.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/generated_expansion.go @@ -20,6 +20,8 @@ type ConfigExpansion interface{} type ConvertVirtualClusterConfigExpansion interface{} +type DevPodEnvironmentTemplateExpansion interface{} + type DevPodWorkspaceInstanceExpansion interface{} type DevPodWorkspaceTemplateExpansion interface{} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/management_client.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/management_client.go index 7218e5f80..be891c7af 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/management_client.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/management/v1/management_client.go @@ -21,6 +21,7 @@ type ManagementV1Interface interface { ClusterRoleTemplatesGetter ConfigsGetter ConvertVirtualClusterConfigsGetter + DevPodEnvironmentTemplatesGetter DevPodWorkspaceInstancesGetter DevPodWorkspaceTemplatesGetter DirectClusterEndpointTokensGetter @@ -93,6 +94,10 @@ func (c *ManagementV1Client) ConvertVirtualClusterConfigs() ConvertVirtualCluste return newConvertVirtualClusterConfigs(c) } +func (c *ManagementV1Client) DevPodEnvironmentTemplates() DevPodEnvironmentTemplateInterface { + return newDevPodEnvironmentTemplates(c) +} + func (c *ManagementV1Client) DevPodWorkspaceInstances(namespace string) DevPodWorkspaceInstanceInterface { return newDevPodWorkspaceInstances(c, namespace) } diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/devpodenvironmenttemplate.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/devpodenvironmenttemplate.go new file mode 100644 index 000000000..776f2b431 --- /dev/null +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/devpodenvironmenttemplate.go @@ -0,0 +1,152 @@ +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + "context" + "time" + + v1 "github.com/loft-sh/api/v4/pkg/apis/storage/v1" + scheme "github.com/loft-sh/api/v4/pkg/clientset/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" +) + +// DevPodEnvironmentTemplatesGetter has a method to return a DevPodEnvironmentTemplateInterface. +// A group's client should implement this interface. +type DevPodEnvironmentTemplatesGetter interface { + DevPodEnvironmentTemplates() DevPodEnvironmentTemplateInterface +} + +// DevPodEnvironmentTemplateInterface has methods to work with DevPodEnvironmentTemplate resources. +type DevPodEnvironmentTemplateInterface interface { + Create(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.CreateOptions) (*v1.DevPodEnvironmentTemplate, error) + Update(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.UpdateOptions) (*v1.DevPodEnvironmentTemplate, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*v1.DevPodEnvironmentTemplate, error) + List(ctx context.Context, opts metav1.ListOptions) (*v1.DevPodEnvironmentTemplateList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.DevPodEnvironmentTemplate, err error) + DevPodEnvironmentTemplateExpansion +} + +// devPodEnvironmentTemplates implements DevPodEnvironmentTemplateInterface +type devPodEnvironmentTemplates struct { + client rest.Interface +} + +// newDevPodEnvironmentTemplates returns a DevPodEnvironmentTemplates +func newDevPodEnvironmentTemplates(c *StorageV1Client) *devPodEnvironmentTemplates { + return &devPodEnvironmentTemplates{ + client: c.RESTClient(), + } +} + +// Get takes name of the devPodEnvironmentTemplate, and returns the corresponding devPodEnvironmentTemplate object, and an error if there is any. +func (c *devPodEnvironmentTemplates) Get(ctx context.Context, name string, options metav1.GetOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Get(). + Resource("devpodenvironmenttemplates"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(ctx). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of DevPodEnvironmentTemplates that match those selectors. +func (c *devPodEnvironmentTemplates) List(ctx context.Context, opts metav1.ListOptions) (result *v1.DevPodEnvironmentTemplateList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1.DevPodEnvironmentTemplateList{} + err = c.client.Get(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(ctx). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested devPodEnvironmentTemplates. +func (c *devPodEnvironmentTemplates) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch(ctx) +} + +// Create takes the representation of a devPodEnvironmentTemplate and creates it. Returns the server's representation of the devPodEnvironmentTemplate, and an error, if there is any. +func (c *devPodEnvironmentTemplates) Create(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.CreateOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Post(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&opts, scheme.ParameterCodec). + Body(devPodEnvironmentTemplate). + Do(ctx). + Into(result) + return +} + +// Update takes the representation of a devPodEnvironmentTemplate and updates it. Returns the server's representation of the devPodEnvironmentTemplate, and an error, if there is any. +func (c *devPodEnvironmentTemplates) Update(ctx context.Context, devPodEnvironmentTemplate *v1.DevPodEnvironmentTemplate, opts metav1.UpdateOptions) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Put(). + Resource("devpodenvironmenttemplates"). + Name(devPodEnvironmentTemplate.Name). + VersionedParams(&opts, scheme.ParameterCodec). + Body(devPodEnvironmentTemplate). + Do(ctx). + Into(result) + return +} + +// Delete takes name of the devPodEnvironmentTemplate and deletes it. Returns an error if one occurs. +func (c *devPodEnvironmentTemplates) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error { + return c.client.Delete(). + Resource("devpodenvironmenttemplates"). + Name(name). + Body(&opts). + Do(ctx). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *devPodEnvironmentTemplates) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error { + var timeout time.Duration + if listOpts.TimeoutSeconds != nil { + timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Resource("devpodenvironmenttemplates"). + VersionedParams(&listOpts, scheme.ParameterCodec). + Timeout(timeout). + Body(&opts). + Do(ctx). + Error() +} + +// Patch applies the patch and returns the patched devPodEnvironmentTemplate. +func (c *devPodEnvironmentTemplates) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *v1.DevPodEnvironmentTemplate, err error) { + result = &v1.DevPodEnvironmentTemplate{} + err = c.client.Patch(pt). + Resource("devpodenvironmenttemplates"). + Name(name). + SubResource(subresources...). + VersionedParams(&opts, scheme.ParameterCodec). + Body(data). + Do(ctx). + Into(result) + return +} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/generated_expansion.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/generated_expansion.go index 316120753..6faed075c 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/generated_expansion.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/generated_expansion.go @@ -12,6 +12,8 @@ type ClusterAccessExpansion interface{} type ClusterRoleTemplateExpansion interface{} +type DevPodEnvironmentTemplateExpansion interface{} + type DevPodWorkspaceInstanceExpansion interface{} type DevPodWorkspaceTemplateExpansion interface{} diff --git a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/storage_client.go b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/storage_client.go index fa7c6c352..c360fa264 100644 --- a/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/storage_client.go +++ b/vendor/github.com/loft-sh/api/v4/pkg/clientset/versioned/typed/storage/v1/storage_client.go @@ -17,6 +17,7 @@ type StorageV1Interface interface { ClustersGetter ClusterAccessesGetter ClusterRoleTemplatesGetter + DevPodEnvironmentTemplatesGetter DevPodWorkspaceInstancesGetter DevPodWorkspaceTemplatesGetter NetworkPeersGetter @@ -57,6 +58,10 @@ func (c *StorageV1Client) ClusterRoleTemplates() ClusterRoleTemplateInterface { return newClusterRoleTemplates(c) } +func (c *StorageV1Client) DevPodEnvironmentTemplates() DevPodEnvironmentTemplateInterface { + return newDevPodEnvironmentTemplates(c) +} + func (c *StorageV1Client) DevPodWorkspaceInstances(namespace string) DevPodWorkspaceInstanceInterface { return newDevPodWorkspaceInstances(c, namespace) } diff --git a/vendor/k8s.io/api/admissionregistration/v1/types.go b/vendor/k8s.io/api/admissionregistration/v1/types.go index 0510712b2..b9ce1f033 100644 --- a/vendor/k8s.io/api/admissionregistration/v1/types.go +++ b/vendor/k8s.io/api/admissionregistration/v1/types.go @@ -203,7 +203,7 @@ type ValidatingAdmissionPolicyList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of ValidatingAdmissionPolicy. - Items []ValidatingAdmissionPolicy `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicy `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy. @@ -464,7 +464,7 @@ type ValidatingAdmissionPolicyBindingList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of PolicyBinding. - Items []ValidatingAdmissionPolicyBinding `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicyBinding `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding. diff --git a/vendor/k8s.io/api/admissionregistration/v1alpha1/types.go b/vendor/k8s.io/api/admissionregistration/v1alpha1/types.go index bd6b17e15..78d918bc7 100644 --- a/vendor/k8s.io/api/admissionregistration/v1alpha1/types.go +++ b/vendor/k8s.io/api/admissionregistration/v1alpha1/types.go @@ -142,7 +142,7 @@ type ValidatingAdmissionPolicyList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of ValidatingAdmissionPolicy. - Items []ValidatingAdmissionPolicy `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicy `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy. @@ -404,7 +404,7 @@ type ValidatingAdmissionPolicyBindingList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of PolicyBinding. - Items []ValidatingAdmissionPolicyBinding `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicyBinding `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding. diff --git a/vendor/k8s.io/api/admissionregistration/v1beta1/types.go b/vendor/k8s.io/api/admissionregistration/v1beta1/types.go index cf1e29a6c..0f5903123 100644 --- a/vendor/k8s.io/api/admissionregistration/v1beta1/types.go +++ b/vendor/k8s.io/api/admissionregistration/v1beta1/types.go @@ -158,7 +158,7 @@ type ValidatingAdmissionPolicyList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of ValidatingAdmissionPolicy. - Items []ValidatingAdmissionPolicy `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicy `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicySpec is the specification of the desired behavior of the AdmissionPolicy. @@ -419,7 +419,7 @@ type ValidatingAdmissionPolicyBindingList struct { // +optional metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // List of PolicyBinding. - Items []ValidatingAdmissionPolicyBinding `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"` + Items []ValidatingAdmissionPolicyBinding `json:"items" protobuf:"bytes,2,rep,name=items"` } // ValidatingAdmissionPolicyBindingSpec is the specification of the ValidatingAdmissionPolicyBinding. diff --git a/vendor/k8s.io/api/batch/v1/types.go b/vendor/k8s.io/api/batch/v1/types.go index 49b0ec644..adaefbab5 100644 --- a/vendor/k8s.io/api/batch/v1/types.go +++ b/vendor/k8s.io/api/batch/v1/types.go @@ -174,7 +174,7 @@ type PodFailurePolicyOnExitCodesRequirement struct { // When specified, it should match one the container or initContainer // names in the pod template. // +optional - ContainerName *string `json:"containerName" protobuf:"bytes,1,opt,name=containerName"` + ContainerName *string `json:"containerName,omitempty" protobuf:"bytes,1,opt,name=containerName"` // Represents the relationship between the container exit code(s) and the // specified values. Containers completed with success (exit code 0) are @@ -234,14 +234,14 @@ type PodFailurePolicyRule struct { // Represents the requirement on the container exit codes. // +optional - OnExitCodes *PodFailurePolicyOnExitCodesRequirement `json:"onExitCodes" protobuf:"bytes,2,opt,name=onExitCodes"` + OnExitCodes *PodFailurePolicyOnExitCodesRequirement `json:"onExitCodes,omitempty" protobuf:"bytes,2,opt,name=onExitCodes"` // Represents the requirement on the pod conditions. The requirement is represented // as a list of pod condition patterns. The requirement is satisfied if at // least one pattern matches an actual pod condition. At most 20 elements are allowed. // +listType=atomic // +optional - OnPodConditions []PodFailurePolicyOnPodConditionsPattern `json:"onPodConditions" protobuf:"bytes,3,opt,name=onPodConditions"` + OnPodConditions []PodFailurePolicyOnPodConditionsPattern `json:"onPodConditions,omitempty" protobuf:"bytes,3,opt,name=onPodConditions"` } // PodFailurePolicy describes how failed pods influence the backoffLimit. diff --git a/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go b/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go index a32fce5a0..8054b9867 100644 --- a/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go +++ b/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go @@ -116,6 +116,15 @@ func IsUpgradeFailure(err error) bool { return errors.As(err, &upgradeErr) } +// isHTTPSProxyError returns true if error is Gorilla/Websockets HTTPS Proxy dial error; +// false otherwise (see https://github.com/kubernetes/kubernetes/issues/126134). +func IsHTTPSProxyError(err error) bool { + if err == nil { + return false + } + return strings.Contains(err.Error(), "proxy: unknown scheme: https") +} + // IsUpgradeRequest returns true if the given request is a connection upgrade request func IsUpgradeRequest(req *http.Request) bool { for _, h := range req.Header[http.CanonicalHeaderKey(HeaderConnection)] { diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/compile.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/compile.go index b7b589d27..bb5e233d4 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/compile.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/compile.go @@ -222,40 +222,48 @@ func (c compiler) CompileCELExpression(expressionAccessor ExpressionAccessor, op func mustBuildEnvs(baseEnv *environment.EnvSet) variableDeclEnvs { requestType := BuildRequestType() namespaceType := BuildNamespaceType() - envs := make(variableDeclEnvs, 4) // since the number of variable combinations is small, pre-build a environment for each + envs := make(variableDeclEnvs, 8) // since the number of variable combinations is small, pre-build a environment for each for _, hasParams := range []bool{false, true} { for _, hasAuthorizer := range []bool{false, true} { - var envOpts []cel.EnvOption - if hasParams { - envOpts = append(envOpts, cel.Variable(ParamsVarName, cel.DynType)) - } - if hasAuthorizer { + for _, strictCost := range []bool{false, true} { + var envOpts []cel.EnvOption + if hasParams { + envOpts = append(envOpts, cel.Variable(ParamsVarName, cel.DynType)) + } + if hasAuthorizer { + envOpts = append(envOpts, + cel.Variable(AuthorizerVarName, library.AuthorizerType), + cel.Variable(RequestResourceAuthorizerVarName, library.ResourceCheckType)) + } envOpts = append(envOpts, - cel.Variable(AuthorizerVarName, library.AuthorizerType), - cel.Variable(RequestResourceAuthorizerVarName, library.ResourceCheckType)) - } - envOpts = append(envOpts, - cel.Variable(ObjectVarName, cel.DynType), - cel.Variable(OldObjectVarName, cel.DynType), - cel.Variable(NamespaceVarName, namespaceType.CelType()), - cel.Variable(RequestVarName, requestType.CelType())) + cel.Variable(ObjectVarName, cel.DynType), + cel.Variable(OldObjectVarName, cel.DynType), + cel.Variable(NamespaceVarName, namespaceType.CelType()), + cel.Variable(RequestVarName, requestType.CelType())) - extended, err := baseEnv.Extend( - environment.VersionedOptions{ - // Feature epoch was actually 1.26, but we artificially set it to 1.0 because these - // options should always be present. - IntroducedVersion: version.MajorMinor(1, 0), - EnvOptions: envOpts, - DeclTypes: []*apiservercel.DeclType{ - namespaceType, - requestType, + extended, err := baseEnv.Extend( + environment.VersionedOptions{ + // Feature epoch was actually 1.26, but we artificially set it to 1.0 because these + // options should always be present. + IntroducedVersion: version.MajorMinor(1, 0), + EnvOptions: envOpts, + DeclTypes: []*apiservercel.DeclType{ + namespaceType, + requestType, + }, }, - }, - ) - if err != nil { - panic(fmt.Sprintf("environment misconfigured: %v", err)) + ) + if err != nil { + panic(fmt.Sprintf("environment misconfigured: %v", err)) + } + if strictCost { + extended, err = extended.Extend(environment.StrictCostOpt) + if err != nil { + panic(fmt.Sprintf("environment misconfigured: %v", err)) + } + } + envs[OptionalVariableDeclarations{HasParams: hasParams, HasAuthorizer: hasAuthorizer, StrictCost: strictCost}] = extended } - envs[OptionalVariableDeclarations{HasParams: hasParams, HasAuthorizer: hasAuthorizer}] = extended } } return envs diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go index c9f4e6336..ae61dc826 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go @@ -57,10 +57,12 @@ type OptionalVariableDeclarations struct { // HasParams specifies if the "params" variable is declared. // The "params" variable may still be bound to "null" when declared. HasParams bool - // HasAuthorizer specifies if the"authorizer" and "authorizer.requestResource" + // HasAuthorizer specifies if the "authorizer" and "authorizer.requestResource" // variables are declared. When declared, the authorizer variables are // expected to be non-null. HasAuthorizer bool + // StrictCost specifies if the CEL cost limitation is strict for extended libraries as well as native libraries. + StrictCost bool } // FilterCompiler contains a function to assist with converting types and values to/from CEL-typed values. diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/plugin.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/plugin.go index c286cffbd..fb097737a 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/plugin.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/plugin.go @@ -31,6 +31,7 @@ import ( "k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/cel/environment" "k8s.io/apiserver/pkg/features" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/dynamic" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" @@ -43,13 +44,21 @@ const ( ) var ( - compositionEnvTemplate *cel.CompositionEnv = func() *cel.CompositionEnv { - compositionEnvTemplate, err := cel.NewCompositionEnv(cel.VariablesTypeName, environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion())) + compositionEnvTemplateWithStrictCost *cel.CompositionEnv = func() *cel.CompositionEnv { + compositionEnvTemplateWithStrictCost, err := cel.NewCompositionEnv(cel.VariablesTypeName, environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), true)) if err != nil { panic(err) } - return compositionEnvTemplate + return compositionEnvTemplateWithStrictCost + }() + compositionEnvTemplateWithoutStrictCost *cel.CompositionEnv = func() *cel.CompositionEnv { + compositionEnvTemplateWithoutStrictCost, err := cel.NewCompositionEnv(cel.VariablesTypeName, environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), false)) + if err != nil { + panic(err) + } + + return compositionEnvTemplateWithoutStrictCost }() ) @@ -114,12 +123,18 @@ func compilePolicy(policy *Policy) Validator { if policy.Spec.ParamKind != nil { hasParam = true } - optionalVars := cel.OptionalVariableDeclarations{HasParams: hasParam, HasAuthorizer: true} - expressionOptionalVars := cel.OptionalVariableDeclarations{HasParams: hasParam, HasAuthorizer: false} + strictCost := utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForVAP) + optionalVars := cel.OptionalVariableDeclarations{HasParams: hasParam, HasAuthorizer: true, StrictCost: strictCost} + expressionOptionalVars := cel.OptionalVariableDeclarations{HasParams: hasParam, HasAuthorizer: false, StrictCost: strictCost} failurePolicy := policy.Spec.FailurePolicy var matcher matchconditions.Matcher = nil matchConditions := policy.Spec.MatchConditions - + var compositionEnvTemplate *cel.CompositionEnv + if strictCost { + compositionEnvTemplate = compositionEnvTemplateWithStrictCost + } else { + compositionEnvTemplate = compositionEnvTemplateWithoutStrictCost + } filterCompiler := cel.NewCompositedCompilerFromTemplate(compositionEnvTemplate) filterCompiler.CompileAndStoreVariables(convertv1beta1Variables(policy.Spec.Variables), optionalVars, environment.StoredExpressions) diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/typechecking.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/typechecking.go index 16184b4ba..192be9621 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/typechecking.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/policy/validating/typechecking.go @@ -39,6 +39,8 @@ import ( "k8s.io/apiserver/pkg/cel/library" "k8s.io/apiserver/pkg/cel/openapi" "k8s.io/apiserver/pkg/cel/openapi/resolver" + "k8s.io/apiserver/pkg/features" + utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/klog/v2" ) @@ -210,6 +212,7 @@ func (c *TypeChecker) CheckExpression(ctx *TypeCheckingContext, expression strin options := plugincel.OptionalVariableDeclarations{ HasParams: ctx.paramDeclType != nil, HasAuthorizer: true, + StrictCost: utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForVAP), } compiler.CompileAndStoreVariables(convertv1beta1Variables(ctx.variables), options, environment.StoredExpressions) result := compiler.CompileCELExpression(celExpression(expression), options, environment.StoredExpressions) @@ -391,7 +394,7 @@ func (c *TypeChecker) tryRefreshRESTMapper() { } func buildEnvSet(hasParams bool, hasAuthorizer bool, types typeOverwrite) (*environment.EnvSet, error) { - baseEnv := environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion()) + baseEnv := environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForVAP)) requestType := plugincel.BuildRequestType() namespaceType := plugincel.BuildNamespaceType() diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors.go index e60d245a6..f23580cc0 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/accessors.go @@ -27,6 +27,8 @@ import ( "k8s.io/apiserver/pkg/admission/plugin/webhook/predicates/namespace" "k8s.io/apiserver/pkg/admission/plugin/webhook/predicates/object" "k8s.io/apiserver/pkg/cel/environment" + "k8s.io/apiserver/pkg/features" + utilfeature "k8s.io/apiserver/pkg/util/feature" webhookutil "k8s.io/apiserver/pkg/util/webhook" "k8s.io/client-go/rest" ) @@ -139,11 +141,16 @@ func (m *mutatingWebhookAccessor) GetCompiledMatcher(compiler cel.FilterCompiler Expression: matchCondition.Expression, } } + strictCost := false + if utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks) { + strictCost = true + } m.compiledMatcher = matchconditions.NewMatcher(compiler.Compile( expressions, cel.OptionalVariableDeclarations{ HasParams: false, HasAuthorizer: true, + StrictCost: strictCost, }, environment.StoredExpressions, ), m.FailurePolicy, "webhook", "admit", m.Name) @@ -267,11 +274,16 @@ func (v *validatingWebhookAccessor) GetCompiledMatcher(compiler cel.FilterCompil Expression: matchCondition.Expression, } } + strictCost := false + if utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks) { + strictCost = true + } v.compiledMatcher = matchconditions.NewMatcher(compiler.Compile( expressions, cel.OptionalVariableDeclarations{ HasParams: false, HasAuthorizer: true, + StrictCost: strictCost, }, environment.StoredExpressions, ), v.FailurePolicy, "webhook", "validating", v.Name) diff --git a/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/webhook.go b/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/webhook.go index 6a513f1c1..f067b3f72 100644 --- a/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/webhook.go +++ b/vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/generic/webhook.go @@ -21,7 +21,6 @@ import ( "fmt" "io" - admissionmetrics "k8s.io/apiserver/pkg/admission/metrics" "k8s.io/klog/v2" admissionv1 "k8s.io/api/admission/v1" @@ -31,6 +30,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apiserver/pkg/admission" genericadmissioninit "k8s.io/apiserver/pkg/admission/initializer" + admissionmetrics "k8s.io/apiserver/pkg/admission/metrics" "k8s.io/apiserver/pkg/admission/plugin/cel" "k8s.io/apiserver/pkg/admission/plugin/webhook" "k8s.io/apiserver/pkg/admission/plugin/webhook/config" @@ -39,6 +39,8 @@ import ( "k8s.io/apiserver/pkg/admission/plugin/webhook/predicates/rules" "k8s.io/apiserver/pkg/authorization/authorizer" "k8s.io/apiserver/pkg/cel/environment" + "k8s.io/apiserver/pkg/features" + utilfeature "k8s.io/apiserver/pkg/util/feature" webhookutil "k8s.io/apiserver/pkg/util/webhook" "k8s.io/client-go/informers" clientset "k8s.io/client-go/kubernetes" @@ -100,7 +102,7 @@ func NewWebhook(handler *admission.Handler, configFile io.Reader, sourceFactory namespaceMatcher: &namespace.Matcher{}, objectMatcher: &object.Matcher{}, dispatcher: dispatcherFactory(&cm), - filterCompiler: cel.NewFilterCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion())), + filterCompiler: cel.NewFilterCompiler(environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), utilfeature.DefaultFeatureGate.Enabled(features.StrictCostEnforcementForWebhooks))), }, nil } diff --git a/vendor/k8s.io/apiserver/pkg/cel/environment/base.go b/vendor/k8s.io/apiserver/pkg/cel/environment/base.go index c108bdd64..2cea83c2e 100644 --- a/vendor/k8s.io/apiserver/pkg/cel/environment/base.go +++ b/vendor/k8s.io/apiserver/pkg/cel/environment/base.go @@ -46,7 +46,9 @@ func DefaultCompatibilityVersion() *version.Version { return version.MajorMinor(1, 29) } -var baseOpts = []VersionedOptions{ +var baseOpts = append(baseOptsWithoutStrictCost, StrictCostOpt) + +var baseOptsWithoutStrictCost = []VersionedOptions{ { // CEL epoch was actually 1.23, but we artificially set it to 1.0 because these // options should always be present. @@ -132,6 +134,14 @@ var baseOpts = []VersionedOptions{ }, } +var StrictCostOpt = VersionedOptions{ + // This is to configure the cost calculation for extended libraries + IntroducedVersion: version.MajorMinor(1, 0), + ProgramOptions: []cel.ProgramOption{ + cel.CostTracking(&library.CostEstimator{}), + }, +} + // MustBaseEnvSet returns the common CEL base environments for Kubernetes for Version, or panics // if the version is nil, or does not have major and minor components. // @@ -141,7 +151,8 @@ var baseOpts = []VersionedOptions{ // The returned environment contains no CEL variable definitions or custom type declarations and // should be extended to construct environments with the appropriate variable definitions, // type declarations and any other needed configuration. -func MustBaseEnvSet(ver *version.Version) *EnvSet { +// strictCost is used to determine whether to enforce strict cost calculation for CEL expressions. +func MustBaseEnvSet(ver *version.Version, strictCost bool) *EnvSet { if ver == nil { panic("version must be non-nil") } @@ -149,19 +160,33 @@ func MustBaseEnvSet(ver *version.Version) *EnvSet { panic(fmt.Sprintf("version must contain an major and minor component, but got: %s", ver.String())) } key := strconv.FormatUint(uint64(ver.Major()), 10) + "." + strconv.FormatUint(uint64(ver.Minor()), 10) - if entry, ok := baseEnvs.Load(key); ok { - return entry.(*EnvSet) + var entry interface{} + if strictCost { + if entry, ok := baseEnvs.Load(key); ok { + return entry.(*EnvSet) + } + entry, _, _ = baseEnvsSingleflight.Do(key, func() (interface{}, error) { + entry := mustNewEnvSet(ver, baseOpts) + baseEnvs.Store(key, entry) + return entry, nil + }) + } else { + if entry, ok := baseEnvsWithOption.Load(key); ok { + return entry.(*EnvSet) + } + entry, _, _ = baseEnvsWithOptionSingleflight.Do(key, func() (interface{}, error) { + entry := mustNewEnvSet(ver, baseOptsWithoutStrictCost) + baseEnvsWithOption.Store(key, entry) + return entry, nil + }) } - entry, _, _ := baseEnvsSingleflight.Do(key, func() (interface{}, error) { - entry := mustNewEnvSet(ver, baseOpts) - baseEnvs.Store(key, entry) - return entry, nil - }) return entry.(*EnvSet) } var ( - baseEnvs = sync.Map{} - baseEnvsSingleflight = &singleflight.Group{} + baseEnvs = sync.Map{} + baseEnvsWithOption = sync.Map{} + baseEnvsSingleflight = &singleflight.Group{} + baseEnvsWithOptionSingleflight = &singleflight.Group{} ) diff --git a/vendor/k8s.io/apiserver/pkg/features/kube_features.go b/vendor/k8s.io/apiserver/pkg/features/kube_features.go index dbd41b8c5..31c4d9021 100644 --- a/vendor/k8s.io/apiserver/pkg/features/kube_features.go +++ b/vendor/k8s.io/apiserver/pkg/features/kube_features.go @@ -220,6 +220,24 @@ const ( // if the generated name conflicts with an existing resource name, up to a maximum number of 7 retries. RetryGenerateName featuregate.Feature = "RetryGenerateName" + // owner: @cici37 + // alpha: v1.30 + // + // StrictCostEnforcementForVAP is used to apply strict CEL cost validation for ValidatingAdmissionPolicy. + // It will be set to off by default for certain time of period to prevent the impact on the existing users. + // It is strongly recommended to enable this feature gate as early as possible. + // The strict cost is specific for the extended libraries whose cost defined under k8s/apiserver/pkg/cel/library. + StrictCostEnforcementForVAP featuregate.Feature = "StrictCostEnforcementForVAP" + + // owner: @cici37 + // alpha: v1.30 + // + // StrictCostEnforcementForWebhooks is used to apply strict CEL cost validation for matchConditions in Webhooks. + // It will be set to off by default for certain time of period to prevent the impact on the existing users. + // It is strongly recommended to enable this feature gate as early as possible. + // The strict cost is specific for the extended libraries whose cost defined under k8s/apiserver/pkg/cel/library. + StrictCostEnforcementForWebhooks featuregate.Feature = "StrictCostEnforcementForWebhooks" + // owner: @caesarxuchao @roycaihw // alpha: v1.20 // @@ -317,7 +335,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS APIServerTracing: {Default: true, PreRelease: featuregate.Beta}, - APIServingWithRoutine: {Default: true, PreRelease: featuregate.Beta}, + APIServingWithRoutine: {Default: false, PreRelease: featuregate.Alpha}, ValidatingAdmissionPolicy: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.32 @@ -347,6 +365,10 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS StorageVersionHash: {Default: true, PreRelease: featuregate.Beta}, + StrictCostEnforcementForVAP: {Default: false, PreRelease: featuregate.Beta}, + + StrictCostEnforcementForWebhooks: {Default: false, PreRelease: featuregate.Beta}, + StructuredAuthenticationConfiguration: {Default: true, PreRelease: featuregate.Beta}, StructuredAuthorizationConfiguration: {Default: true, PreRelease: featuregate.Beta}, diff --git a/vendor/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/vendor/k8s.io/apiserver/pkg/storage/cacher/cacher.go index 1e6cc4d02..7579ac37e 100644 --- a/vendor/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/vendor/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -51,7 +51,8 @@ import ( ) var ( - emptyFunc = func(bool) {} + emptyFunc = func(bool) {} + coreNamespaceResource = schema.GroupResource{Group: "", Resource: "namespaces"} ) const ( @@ -549,6 +550,12 @@ func (c *Cacher) Watch(ctx context.Context, key string, opts storage.ListOptions scope.name = selectorName } + // for request like '/api/v1/watch/namespaces/*', set scope.namespace to empty. + // namespaces don't populate metadata.namespace in ObjFields. + if c.groupResource == coreNamespaceResource && len(scope.namespace) > 0 && scope.namespace == scope.name { + scope.namespace = "" + } + triggerValue, triggerSupported := "", false if c.indexedTrigger != nil { for _, field := range pred.IndexFields { diff --git a/vendor/modules.txt b/vendor/modules.txt index b5fee0156..1154b8639 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -526,15 +526,15 @@ github.com/kr/fs # github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de ## explicit github.com/liggitt/tabwriter -# github.com/loft-sh/admin-apis v0.0.0-20240203010124-3600c1c582a8 +# github.com/loft-sh/admin-apis v0.0.0-20240814093917-dc663916b354 ## explicit; go 1.21.1 github.com/loft-sh/admin-apis/pkg/licenseapi -# github.com/loft-sh/agentapi/v4 v4.1.0-alpha.1 +# github.com/loft-sh/agentapi/v4 v4.1.0-alpha.10 ## explicit; go 1.22.5 github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1 github.com/loft-sh/agentapi/v4/pkg/apis/loft/storage/v1 -# github.com/loft-sh/api/v4 v4.1.0-alpha.1 +# github.com/loft-sh/api/v4 v4.1.0-alpha.10 ## explicit; go 1.22.5 github.com/loft-sh/api/v4/pkg/apis/audit/v1 github.com/loft-sh/api/v4/pkg/apis/management @@ -1182,7 +1182,7 @@ gotest.tools/assert/cmp gotest.tools/internal/difflib gotest.tools/internal/format gotest.tools/internal/source -# k8s.io/api v0.30.1 +# k8s.io/api v0.30.4 ## explicit; go 1.22.0 k8s.io/api/admission/v1 k8s.io/api/admission/v1beta1 @@ -1240,11 +1240,11 @@ k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 k8s.io/api/storagemigration/v1alpha1 -# k8s.io/apiextensions-apiserver v0.30.1 +# k8s.io/apiextensions-apiserver v0.30.4 ## explicit; go 1.22.0 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 -# k8s.io/apimachinery v0.30.1 +# k8s.io/apimachinery v0.30.4 ## explicit; go 1.22.0 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors @@ -1309,7 +1309,7 @@ k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json k8s.io/apimachinery/third_party/forked/golang/netutil k8s.io/apimachinery/third_party/forked/golang/reflect -# k8s.io/apiserver v0.30.1 +# k8s.io/apiserver v0.30.4 ## explicit; go 1.22.0 k8s.io/apiserver/pkg/admission k8s.io/apiserver/pkg/admission/configuration @@ -1434,7 +1434,7 @@ k8s.io/apiserver/plugin/pkg/authenticator/token/webhook # k8s.io/cli-runtime v0.29.1 ## explicit; go 1.21 k8s.io/cli-runtime/pkg/printers -# k8s.io/client-go v0.30.1 +# k8s.io/client-go v0.30.4 ## explicit; go 1.22.0 k8s.io/client-go/applyconfigurations/admissionregistration/v1 k8s.io/client-go/applyconfigurations/admissionregistration/v1alpha1 @@ -1758,7 +1758,7 @@ k8s.io/client-go/util/jsonpath k8s.io/client-go/util/keyutil k8s.io/client-go/util/retry k8s.io/client-go/util/workqueue -# k8s.io/component-base v0.30.1 +# k8s.io/component-base v0.30.4 ## explicit; go 1.22.0 k8s.io/component-base/cli/flag k8s.io/component-base/featuregate @@ -1849,7 +1849,7 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/client/metrics sigs.k8s.io/apiserver-network-proxy/konnectivity-client/pkg/common/metrics sigs.k8s.io/apiserver-network-proxy/konnectivity-client/proto/client -# sigs.k8s.io/controller-runtime v0.18.4 +# sigs.k8s.io/controller-runtime v0.18.5 ## explicit; go 1.22.0 sigs.k8s.io/controller-runtime sigs.k8s.io/controller-runtime/pkg/builder diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/certwatcher/certwatcher.go b/vendor/sigs.k8s.io/controller-runtime/pkg/certwatcher/certwatcher.go index 2b9b60d8d..fe15fc0dd 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/certwatcher/certwatcher.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/certwatcher/certwatcher.go @@ -173,14 +173,14 @@ func (cw *CertWatcher) ReadCertificate() error { func (cw *CertWatcher) handleEvent(event fsnotify.Event) { // Only care about events which may modify the contents of the file. - if !(isWrite(event) || isRemove(event) || isCreate(event)) { + if !(isWrite(event) || isRemove(event) || isCreate(event) || isChmod(event)) { return } log.V(1).Info("certificate event", "event", event) - // If the file was removed, re-add the watch. - if isRemove(event) { + // If the file was removed or renamed, re-add the watch to the previous name + if isRemove(event) || isChmod(event) { if err := cw.watcher.Add(event.Name); err != nil { log.Error(err, "error re-watching file") } @@ -202,3 +202,7 @@ func isCreate(event fsnotify.Event) bool { func isRemove(event fsnotify.Event) bool { return event.Op.Has(fsnotify.Remove) } + +func isChmod(event fsnotify.Event) bool { + return event.Op.Has(fsnotify.Chmod) +} diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/client/client.go b/vendor/sigs.k8s.io/controller-runtime/pkg/client/client.go index e6c075eb0..451f7b2a1 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/client/client.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/client/client.go @@ -124,19 +124,15 @@ func newClient(config *rest.Config, options Options) (*client, error) { config.UserAgent = rest.DefaultKubernetesUserAgent() } - if !options.WarningHandler.SuppressWarnings { - // surface warnings - logger := log.Log.WithName("KubeAPIWarningLogger") - // Set a WarningHandler, the default WarningHandler - // is log.KubeAPIWarningLogger with deduplication enabled. - // See log.KubeAPIWarningLoggerOptions for considerations - // regarding deduplication. - config.WarningHandler = log.NewKubeAPIWarningLogger( - logger, - log.KubeAPIWarningLoggerOptions{ - Deduplicate: !options.WarningHandler.AllowDuplicateLogs, - }, - ) + // By default, we de-duplicate and surface warnings. + config.WarningHandler = log.NewKubeAPIWarningLogger( + log.Log.WithName("KubeAPIWarningLogger"), + log.KubeAPIWarningLoggerOptions{ + Deduplicate: !options.WarningHandler.AllowDuplicateLogs, + }, + ) + if options.WarningHandler.SuppressWarnings { + config.WarningHandler = rest.NoWarnings{} } // Use the rest HTTP client for the provided config if unset diff --git a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go index 2ce02b105..66a2d277f 100644 --- a/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go +++ b/vendor/sigs.k8s.io/controller-runtime/pkg/manager/internal.go @@ -187,7 +187,7 @@ func (cm *controllerManager) AddMetricsServerExtraHandler(path string, handler h return fmt.Errorf("unable to add new metrics handler because metrics endpoint has already been created") } if cm.metricsServer == nil { - cm.GetLogger().Info("warn: metrics server is currently disabled, registering extra handler %q will be ignored", path) + cm.GetLogger().Info("warn: metrics server is currently disabled, registering extra handler will be ignored", "path", path) return nil } if err := cm.metricsServer.AddExtraHandler(path, handler); err != nil {