chore(kompose): remove the code EE-4917 (#12003)

pull/12028/head
andres-portainer 2024-07-08 17:19:07 -03:00 committed by GitHub
parent ac4b129195
commit 6e7a42727a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 61 additions and 168 deletions

View File

@ -643,7 +643,6 @@
"Scopes": "",
"UserIdentifier": ""
},
"ShowKomposeBuildOption": false,
"SnapshotInterval": "5m",
"TemplatesURL": "",
"TrustOnFirstConnect": false,
@ -803,7 +802,6 @@
"FromAppTemplate": false,
"GitConfig": null,
"Id": 2,
"IsComposeFormat": false,
"Name": "alpine",
"Namespace": "",
"Option": null,
@ -826,7 +824,6 @@
"FromAppTemplate": false,
"GitConfig": null,
"Id": 5,
"IsComposeFormat": false,
"Name": "redis",
"Namespace": "",
"Option": null,
@ -849,7 +846,6 @@
"FromAppTemplate": false,
"GitConfig": null,
"Id": 6,
"IsComposeFormat": false,
"Name": "nginx",
"Namespace": "",
"Option": null,

View File

@ -18,7 +18,3 @@ func (deployer *kubernetesMockDeployer) Deploy(userID portainer.UserID, endpoint
func (deployer *kubernetesMockDeployer) Remove(userID portainer.UserID, endpoint *portainer.Endpoint, manifestFiles []string, namespace string) (string, error) {
return "", nil
}
func (deployer *kubernetesMockDeployer) ConvertCompose(data []byte) ([]byte, error) {
return nil, nil
}

View File

@ -137,29 +137,6 @@ func (deployer *KubernetesDeployer) command(operation string, userID portainer.U
return string(output), nil
}
// ConvertCompose leverages the kompose binary to deploy a compose compliant manifest.
func (deployer *KubernetesDeployer) ConvertCompose(data []byte) ([]byte, error) {
command := path.Join(deployer.binaryPath, "kompose")
if runtime.GOOS == "windows" {
command = path.Join(deployer.binaryPath, "kompose.exe")
}
args := make([]string, 0)
args = append(args, "convert", "-f", "-", "--stdout")
var stderr bytes.Buffer
cmd := exec.Command(command, args...)
cmd.Stderr = &stderr
cmd.Stdin = bytes.NewReader(data)
output, err := cmd.Output()
if err != nil {
return nil, errors.New(stderr.String())
}
return output, nil
}
func (deployer *KubernetesDeployer) getAgentURL(endpoint *portainer.Endpoint) (string, *factory.ProxyServer, error) {
proxy, err := deployer.proxyManager.CreateAgentProxyServer(endpoint)
if err != nil {

View File

@ -19,8 +19,6 @@ type publicSettingsResponse struct {
RequiredPasswordLength int `json:"RequiredPasswordLength" example:"1"`
// Deployment options for encouraging deployment as code
GlobalDeploymentOptions portainer.GlobalDeploymentOptions `json:"GlobalDeploymentOptions"`
// Show the Kompose build option (discontinued in 2.18)
ShowKomposeBuildOption bool `json:"ShowKomposeBuildOption" example:"false"`
// Whether edge compute features are enabled
EnableEdgeComputeFeatures bool `json:"EnableEdgeComputeFeatures" example:"true"`
// Supported feature flags
@ -80,7 +78,6 @@ func generatePublicSettings(appSettings *portainer.Settings) *publicSettingsResp
RequiredPasswordLength: appSettings.InternalAuthSettings.RequiredPasswordLength,
EnableEdgeComputeFeatures: appSettings.EnableEdgeComputeFeatures,
GlobalDeploymentOptions: appSettings.GlobalDeploymentOptions,
ShowKomposeBuildOption: appSettings.ShowKomposeBuildOption,
EnableTelemetry: appSettings.EnableTelemetry,
KubeconfigExpiry: appSettings.KubeconfigExpiry,
Features: featureflags.FeatureFlags(),

View File

@ -14,10 +14,10 @@ import (
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
"golang.org/x/oauth2"
"github.com/asaskevich/govalidator"
"github.com/pkg/errors"
"golang.org/x/oauth2"
)
type settingsUpdatePayload struct {
@ -37,8 +37,6 @@ type settingsUpdatePayload struct {
// Deployment options for encouraging deployment as code
GlobalDeploymentOptions *portainer.GlobalDeploymentOptions // The default check in interval for edge agent (in seconds)
EdgeAgentCheckinInterval *int `example:"5"`
// Show the Kompose build option (discontinued in 2.18)
ShowKomposeBuildOption *bool `json:"ShowKomposeBuildOption" example:"false"`
// Whether edge compute features are enabled
EnableEdgeComputeFeatures *bool `example:"true"`
// The duration of a user session
@ -125,11 +123,11 @@ func (handler *Handler) settingsUpdate(w http.ResponseWriter, r *http.Request) *
}
var settings *portainer.Settings
err = handler.DataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
if err = handler.DataStore.UpdateTx(func(tx dataservices.DataStoreTx) error {
settings, err = handler.updateSettings(tx, payload)
return err
})
if err != nil {
}); err != nil {
var httpErr *httperror.HandlerError
if errors.As(err, &httpErr) {
return httpErr
@ -158,25 +156,18 @@ func (handler *Handler) updateSettings(tx dataservices.DataStoreTx, payload sett
// Update the global deployment options, and the environment deployment options if they have changed
settings.GlobalDeploymentOptions = *cmp.Or(payload.GlobalDeploymentOptions, &settings.GlobalDeploymentOptions)
if payload.ShowKomposeBuildOption != nil {
settings.ShowKomposeBuildOption = *payload.ShowKomposeBuildOption
}
if payload.HelmRepositoryURL != nil {
settings.HelmRepositoryURL = ""
if *payload.HelmRepositoryURL != "" {
newHelmRepo := strings.TrimSuffix(strings.ToLower(*payload.HelmRepositoryURL), "/")
if newHelmRepo != settings.HelmRepositoryURL && newHelmRepo != portainer.DefaultHelmRepositoryURL {
err := libhelm.ValidateHelmRepositoryURL(*payload.HelmRepositoryURL, nil)
if err != nil {
if err := libhelm.ValidateHelmRepositoryURL(*payload.HelmRepositoryURL, nil); err != nil {
return nil, httperror.BadRequest("Invalid Helm repository URL. Must correspond to a valid URL format", err)
}
}
settings.HelmRepositoryURL = newHelmRepo
} else {
settings.HelmRepositoryURL = ""
}
}
@ -207,6 +198,7 @@ func (handler *Handler) updateSettings(tx dataservices.DataStoreTx, payload sett
if kubeSecret == nil {
kubeSecret = settings.OAuthSettings.KubeSecretKey
}
settings.OAuthSettings = *payload.OAuthSettings
settings.OAuthSettings.ClientSecret = clientSecret
settings.OAuthSettings.KubeSecretKey = kubeSecret

View File

@ -34,7 +34,6 @@ func createStackPayloadFromK8sFileContentPayload(name, namespace, fileContent st
StackName: name,
Namespace: namespace,
StackFileContent: fileContent,
ComposeFormat: composeFormat,
FromAppTemplate: fromAppTemplate,
}
}
@ -67,7 +66,6 @@ func createStackPayloadFromK8sGitPayload(name, repoUrl, repoReference, repoUsern
TLSSkipVerify: repoSkipSSLVerify,
},
Namespace: namespace,
ComposeFormat: composeFormat,
ManifestFile: manifest,
AdditionalFiles: additionalFiles,
AutoUpdate: autoUpdate,
@ -83,10 +81,9 @@ type kubernetesManifestURLDeploymentPayload struct {
func createStackPayloadFromK8sUrlPayload(name, namespace, manifestUrl string, composeFormat bool) stackbuilders.StackPayload {
return stackbuilders.StackPayload{
StackName: name,
Namespace: namespace,
ManifestURL: manifestUrl,
ComposeFormat: composeFormat,
StackName: name,
Namespace: namespace,
ManifestURL: manifestUrl,
}
}
@ -102,22 +99,23 @@ func (payload *kubernetesGitDeploymentPayload) Validate(r *http.Request) error {
if govalidator.IsNull(payload.RepositoryURL) || !govalidator.IsURL(payload.RepositoryURL) {
return errors.New("Invalid repository URL. Must correspond to a valid URL format")
}
if payload.RepositoryAuthentication && govalidator.IsNull(payload.RepositoryPassword) {
return errors.New("Invalid repository credentials. Password must be specified when authentication is enabled")
}
if govalidator.IsNull(payload.ManifestFile) {
return errors.New("Invalid manifest file in repository")
}
if err := update.ValidateAutoUpdateSettings(payload.AutoUpdate); err != nil {
return err
}
return nil
return update.ValidateAutoUpdateSettings(payload.AutoUpdate)
}
func (payload *kubernetesManifestURLDeploymentPayload) Validate(r *http.Request) error {
if govalidator.IsNull(payload.ManifestURL) || !govalidator.IsURL(payload.ManifestURL) {
return errors.New("Invalid manifest URL")
}
return nil
}
@ -171,9 +169,8 @@ func (handler *Handler) createKubernetesStackFromFileContent(w http.ResponseWrit
}
stackBuilderDirector := stackbuilders.NewStackBuilderDirector(k8sStackBuilder)
_, httpErr := stackBuilderDirector.Build(&stackPayload, endpoint)
if httpErr != nil {
return httpErr
if _, err := stackBuilderDirector.Build(&stackPayload, endpoint); err != nil {
return err
}
resp := &createKubernetesStackResponse{
@ -213,13 +210,11 @@ func (handler *Handler) createKubernetesStackFromGitRepository(w http.ResponseWr
return httperror.InternalServerError("Unable to load user information from the database", err)
}
//make sure the webhook ID is unique
// Make sure the webhook ID is unique
if payload.AutoUpdate != nil && payload.AutoUpdate.Webhook != "" {
isUnique, err := handler.checkUniqueWebhookID(payload.AutoUpdate.Webhook)
if err != nil {
if isUnique, err := handler.checkUniqueWebhookID(payload.AutoUpdate.Webhook); err != nil {
return httperror.InternalServerError("Unable to check for webhook ID collision", err)
}
if !isUnique {
} else if !isUnique {
return httperror.Conflict(fmt.Sprintf("Webhook ID: %s already exists", payload.AutoUpdate.Webhook), stackutils.ErrWebhookIDAlreadyExists)
}
}
@ -247,16 +242,13 @@ func (handler *Handler) createKubernetesStackFromGitRepository(w http.ResponseWr
user)
stackBuilderDirector := stackbuilders.NewStackBuilderDirector(k8sStackBuilder)
_, httpErr := stackBuilderDirector.Build(&stackPayload, endpoint)
if httpErr != nil {
return httpErr
if _, err := stackBuilderDirector.Build(&stackPayload, endpoint); err != nil {
return err
}
resp := &createKubernetesStackResponse{
return response.JSON(w, &createKubernetesStackResponse{
Output: k8sStackBuilder.GetResponse(),
}
return response.JSON(w, resp)
})
}
// @id StackCreateKubernetesUrl
@ -296,16 +288,13 @@ func (handler *Handler) createKubernetesStackFromManifestURL(w http.ResponseWrit
user)
stackBuilderDirector := stackbuilders.NewStackBuilderDirector(k8sStackBuilder)
_, httpErr := stackBuilderDirector.Build(&stackPayload, endpoint)
if httpErr != nil {
return httpErr
if _, err := stackBuilderDirector.Build(&stackPayload, endpoint); err != nil {
return err
}
resp := &createKubernetesStackResponse{
return response.JSON(w, &createKubernetesStackResponse{
Output: k8sStackBuilder.GetResponse(),
}
return response.JSON(w, resp)
})
}
func (handler *Handler) deployKubernetesStack(userID portainer.UserID, endpoint *portainer.Endpoint, stack *portainer.Stack, appLabels k.KubeAppLabels) (string, error) {
@ -320,8 +309,7 @@ func (handler *Handler) deployKubernetesStack(userID portainer.UserID, endpoint
return "", errors.Wrap(err, "failed to create temp kub deployment files")
}
err = k8sDeploymentConfig.Deploy()
if err != nil {
if err := k8sDeploymentConfig.Deploy(); err != nil {
return "", err
}

View File

@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"os"
"strconv"
portainer "github.com/portainer/portainer/api"
@ -202,40 +201,7 @@ func (handler *Handler) deleteStack(userID portainer.UserID, stack *portainer.St
}
if stack.Type == portainer.KubernetesStack {
var manifestFiles []string
//if it is a compose format kub stack, create a temp dir and convert the manifest files into it
//then process the remove operation
if stack.IsComposeFormat {
fileNames := stackutils.GetStackFilePaths(stack, false)
tmpDir, err := os.MkdirTemp("", "kube_delete")
if err != nil {
return errors.Wrap(err, "failed to create temp directory for deleting kub stack")
}
defer os.RemoveAll(tmpDir)
for _, fileName := range fileNames {
manifestFilePath := filesystem.JoinPaths(tmpDir, fileName)
manifestContent, err := handler.FileService.GetFileContent(stack.ProjectPath, fileName)
if err != nil {
return errors.Wrap(err, "failed to read manifest file")
}
manifestContent, err = handler.KubernetesDeployer.ConvertCompose(manifestContent)
if err != nil {
return errors.Wrap(err, "failed to convert docker compose file to a kube manifest")
}
err = filesystem.WriteToFile(manifestFilePath, manifestContent)
if err != nil {
return errors.Wrap(err, "failed to create temp manifest file")
}
manifestFiles = append(manifestFiles, manifestFilePath)
}
} else {
manifestFiles = stackutils.GetStackFilePaths(stack, true)
}
manifestFiles := stackutils.GetStackFilePaths(stack, true)
out, err := handler.KubernetesDeployer.Remove(userID, endpoint, manifestFiles, stack.Namespace)
if err != nil {

View File

@ -1,7 +1,6 @@
package stacks
import (
"fmt"
"net/http"
"os"
"strconv"
@ -41,6 +40,7 @@ func (payload *kubernetesFileStackUpdatePayload) Validate(r *http.Request) error
if govalidator.IsNull(payload.StackFileContent) {
return errors.New("Invalid stack file content")
}
return nil
}
@ -48,13 +48,13 @@ func (payload *kubernetesGitStackUpdatePayload) Validate(r *http.Request) error
if err := update.ValidateAutoUpdateSettings(payload.AutoUpdate); err != nil {
return err
}
return nil
}
func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.Stack, endpoint *portainer.Endpoint) *httperror.HandlerError {
if stack.GitConfig != nil {
//stop the autoupdate job if there is any
// Stop the autoupdate job if there is any
if stack.AutoUpdate != nil {
deployments.StopAutoupdate(stack.ID, stack.AutoUpdate.JobID, handler.Scheduler)
}
@ -67,6 +67,7 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
stack.GitConfig.ReferenceName = payload.RepositoryReferenceName
stack.GitConfig.TLSSkipVerify = payload.TLSSkipVerify
stack.GitConfig.Authentication = nil
stack.AutoUpdate = payload.AutoUpdate
if payload.RepositoryAuthentication {
@ -74,16 +75,15 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
if password == "" && stack.GitConfig != nil && stack.GitConfig.Authentication != nil {
password = stack.GitConfig.Authentication.Password
}
stack.GitConfig.Authentication = &gittypes.GitAuthentication{
Username: payload.RepositoryUsername,
Password: password,
}
_, err := handler.GitService.LatestCommitID(stack.GitConfig.URL, stack.GitConfig.ReferenceName, stack.GitConfig.Authentication.Username, stack.GitConfig.Authentication.Password, stack.GitConfig.TLSSkipVerify)
if err != nil {
if _, err := handler.GitService.LatestCommitID(stack.GitConfig.URL, stack.GitConfig.ReferenceName, stack.GitConfig.Authentication.Username, stack.GitConfig.Authentication.Password, stack.GitConfig.TLSSkipVerify); err != nil {
return httperror.InternalServerError("Unable to fetch git repository", err)
}
} else {
stack.GitConfig.Authentication = nil
}
if payload.AutoUpdate != nil && payload.AutoUpdate.Interval != "" {
@ -99,8 +99,7 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
var payload kubernetesFileStackUpdatePayload
err := request.DecodeAndValidateJSONPayload(r, &payload)
if err != nil {
if err := request.DecodeAndValidateJSONPayload(r, &payload); err != nil {
return httperror.BadRequest("Invalid request payload", err)
}
@ -118,8 +117,7 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
if payload.StackName != stack.Name {
stack.Name = payload.StackName
err := handler.DataStore.Stack().Update(stack.ID, stack)
if err != nil {
if err := handler.DataStore.Stack().Update(stack.ID, stack); err != nil {
return httperror.InternalServerError("Failed to update stack name", err)
}
}
@ -132,18 +130,16 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
registryutils.RefreshEcrSecret(cli, endpoint, handler.DataStore, stack.Namespace)
}
//use temp dir as the stack project path for deployment
//so if the deployment failed, the original file won't be over-written
// Use temp dir as the stack project path for deployment
// so if the deployment failed, the original file won't be over-written
stack.ProjectPath = tempFileDir
_, err = handler.deployKubernetesStack(tokenData.ID, endpoint, stack, k.KubeAppLabels{
if _, err := handler.deployKubernetesStack(tokenData.ID, endpoint, stack, k.KubeAppLabels{
StackID: int(stack.ID),
StackName: stack.Name,
Owner: stack.CreatedBy,
Kind: "content",
})
if err != nil {
}); err != nil {
return httperror.InternalServerError("Unable to deploy Kubernetes stack via file content", err)
}
@ -154,12 +150,7 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
log.Warn().Err(rollbackErr).Msg("rollback stack file error")
}
fileType := "Manifest"
if stack.IsComposeFormat {
fileType = "Compose"
}
errMsg := fmt.Sprintf("Unable to persist Kubernetes %s file on disk", fileType)
return httperror.InternalServerError(errMsg, err)
return httperror.InternalServerError("Unable to persist Kubernetes Manifest file on disk", err)
}
stack.ProjectPath = projectPath

View File

@ -954,8 +954,6 @@ type (
GlobalDeploymentOptions GlobalDeploymentOptions `json:"GlobalDeploymentOptions"`
// The default check in interval for edge agent (in seconds)
EdgeAgentCheckinInterval int `json:"EdgeAgentCheckinInterval" example:"5"`
// Show the Kompose build option (discontinued in 2.18)
ShowKomposeBuildOption bool `json:"ShowKomposeBuildOption" example:"false"`
// Whether edge compute features are enabled
EnableEdgeComputeFeatures bool `json:"EnableEdgeComputeFeatures"`
// The duration of a user session
@ -1052,8 +1050,6 @@ type (
FromAppTemplate bool `example:"false"`
// Kubernetes namespace if stack is a kube application
Namespace string `example:"default"`
// IsComposeFormat indicates if the Kubernetes stack is created from a Docker Compose file
IsComposeFormat bool `example:"false"`
}
// StackOption represents the options for stack deployment
@ -1512,7 +1508,6 @@ type (
KubernetesDeployer interface {
Deploy(userID UserID, endpoint *Endpoint, manifestFiles []string, namespace string) (string, error)
Remove(userID UserID, endpoint *Endpoint, manifestFiles []string, namespace string) (string, error)
ConvertCompose(data []byte) ([]byte, error)
}
// KubernetesSnapshotter represents a service used to create Kubernetes environment(endpoint) snapshots

View File

@ -54,20 +54,12 @@ func (config *KubernetesStackDeploymentConfig) Deploy() error {
return errors.Wrap(err, "failed to read manifest file")
}
if config.stack.IsComposeFormat {
manifestContent, err = config.kubernetesDeployer.ConvertCompose(manifestContent)
if err != nil {
return errors.Wrap(err, "failed to convert docker compose file to a kube manifest")
}
}
manifestContent, err = k.AddAppLabels(manifestContent, config.appLabels.ToMap())
if err != nil {
return errors.Wrap(err, "failed to add application labels")
}
err = filesystem.WriteToFile(manifestFilePath, manifestContent)
if err != nil {
if err := filesystem.WriteToFile(manifestFilePath, manifestContent); err != nil {
return errors.Wrap(err, "failed to create temp manifest file")
}

View File

@ -1,7 +1,6 @@
package stackbuilders
import (
"fmt"
"strconv"
"sync"
@ -40,6 +39,7 @@ func CreateK8sStackFileContentBuilder(dataStore dataservices.DataStore,
func (b *K8sStackFileContentBuilder) SetGeneralInfo(payload *StackPayload, endpoint *portainer.Endpoint) FileContentMethodStackBuildProcess {
b.FileContentMethodStackBuilder.SetGeneralInfo(payload, endpoint)
return b
}
@ -47,13 +47,14 @@ func (b *K8sStackFileContentBuilder) SetUniqueInfo(payload *StackPayload) FileCo
if b.hasError() {
return b
}
b.stack.Name = payload.StackName
b.stack.Type = portainer.KubernetesStack
b.stack.EntryPoint = filesystem.ManifestFileDefaultName
b.stack.Namespace = payload.Namespace
b.stack.CreatedBy = b.User.Username
b.stack.IsComposeFormat = payload.ComposeFormat
b.stack.FromAppTemplate = payload.FromAppTemplate
return b
}
@ -65,14 +66,11 @@ func (b *K8sStackFileContentBuilder) SetFileContent(payload *StackPayload) FileC
stackFolder := strconv.Itoa(int(b.stack.ID))
projectPath, err := b.fileService.StoreStackFileFromBytes(stackFolder, b.stack.EntryPoint, []byte(payload.StackFileContent))
if err != nil {
fileType := "Manifest"
if b.stack.IsComposeFormat {
fileType = "Compose"
}
errMsg := fmt.Sprintf("Unable to persist Kubernetes %s file on disk", fileType)
b.err = httperror.InternalServerError(errMsg, err)
b.err = httperror.InternalServerError("Unable to persist Kubernetes Manifest file on disk", err)
return b
}
b.stack.ProjectPath = projectPath
return b
@ -96,6 +94,7 @@ func (b *K8sStackFileContentBuilder) Deploy(payload *StackPayload, endpoint *por
k8sDeploymentConfig, err := deployments.CreateKubernetesStackDeploymentConfig(b.stack, b.KuberneteDeployer, k8sAppLabel, b.User, endpoint)
if err != nil {
b.err = httperror.InternalServerError("failed to create temp kub deployment files", err)
return b
}

View File

@ -42,6 +42,7 @@ func CreateKubernetesStackGitBuilder(dataStore dataservices.DataStore,
func (b *KubernetesStackGitBuilder) SetGeneralInfo(payload *StackPayload, endpoint *portainer.Endpoint) GitMethodStackBuildProcess {
b.GitMethodStackBuilder.SetGeneralInfo(payload, endpoint)
return b
}
@ -55,12 +56,13 @@ func (b *KubernetesStackGitBuilder) SetUniqueInfo(payload *StackPayload) GitMeth
b.stack.Name = payload.StackName
b.stack.EntryPoint = payload.ManifestFile
b.stack.CreatedBy = b.user.Username
b.stack.IsComposeFormat = payload.ComposeFormat
return b
}
func (b *KubernetesStackGitBuilder) SetGitRepository(payload *StackPayload) GitMethodStackBuildProcess {
b.GitMethodStackBuilder.SetGitRepository(payload)
return b
}
@ -92,6 +94,7 @@ func (b *KubernetesStackGitBuilder) Deploy(payload *StackPayload, endpoint *port
func (b *KubernetesStackGitBuilder) SetAutoUpdate(payload *StackPayload) GitMethodStackBuildProcess {
b.GitMethodStackBuilder.SetAutoUpdate(payload)
return b
}

View File

@ -40,6 +40,7 @@ func CreateKubernetesStackUrlBuilder(dataStore dataservices.DataStore,
func (b *KubernetesStackUrlBuilder) SetGeneralInfo(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess {
b.UrlMethodStackBuilder.SetGeneralInfo(payload, endpoint)
return b
}
@ -53,7 +54,7 @@ func (b *KubernetesStackUrlBuilder) SetUniqueInfo(payload *StackPayload) UrlMeth
b.stack.Name = payload.StackName
b.stack.EntryPoint = filesystem.ManifestFileDefaultName
b.stack.CreatedBy = b.user.Username
b.stack.IsComposeFormat = payload.ComposeFormat
return b
}
@ -62,10 +63,10 @@ func (b *KubernetesStackUrlBuilder) SetURL(payload *StackPayload) UrlMethodStack
return b
}
var manifestContent []byte
manifestContent, err := client.Get(payload.ManifestURL, 30)
if err != nil {
b.err = httperror.InternalServerError("Unable to retrieve manifest from URL", err)
return b
}
@ -73,6 +74,7 @@ func (b *KubernetesStackUrlBuilder) SetURL(payload *StackPayload) UrlMethodStack
projectPath, err := b.fileService.StoreStackFileFromBytes(stackFolder, b.stack.EntryPoint, manifestContent)
if err != nil {
b.err = httperror.InternalServerError("Unable to persist Kubernetes manifest file on disk", err)
return b
}
b.stack.ProjectPath = projectPath
@ -98,6 +100,7 @@ func (b *KubernetesStackUrlBuilder) Deploy(payload *StackPayload, endpoint *port
k8sDeploymentConfig, err := deployments.CreateKubernetesStackDeploymentConfig(b.stack, b.KuberneteDeployer, k8sAppLabel, b.user, endpoint)
if err != nil {
b.err = httperror.InternalServerError("failed to create temp kub deployment files", err)
return b
}

View File

@ -23,8 +23,6 @@ type StackPayload struct {
FromAppTemplate bool `example:"false"`
// Kubernetes stack name
StackName string
// Whether the kubernetes stack config file is compose format
ComposeFormat bool
// Kubernetes stack namespace
Namespace string
// Path to the k8s Stack file. Used by k8s git repository method