mirror of
https://github.com/portainer/portainer.git
synced 2025-07-20 05:49:40 +02:00
refactor(stack): stack build process backend only [EE-4342] (#7750)
This commit is contained in:
parent
83a1ce9d2a
commit
e9de484c3e
65 changed files with 2270 additions and 942 deletions
68
api/stacks/stackbuilders/stack_url_builder.go
Normal file
68
api/stacks/stackbuilders/stack_url_builder.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
package stackbuilders
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
httperror "github.com/portainer/libhttp/error"
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
)
|
||||
|
||||
type UrlMethodStackBuildProcess interface {
|
||||
// Set general stack information
|
||||
SetGeneralInfo(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess
|
||||
// Set unique stack information, e.g. swarm stack has swarmID, kubernetes stack has namespace
|
||||
SetUniqueInfo(payload *StackPayload) UrlMethodStackBuildProcess
|
||||
// Deploy stack based on the configuration
|
||||
Deploy(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess
|
||||
// Save the stack information to database
|
||||
SaveStack() (*portainer.Stack, *httperror.HandlerError)
|
||||
// Get reponse from http request. Use if it is needed
|
||||
GetResponse() string
|
||||
// Set manifest url
|
||||
SetURL(payload *StackPayload) UrlMethodStackBuildProcess
|
||||
}
|
||||
|
||||
type UrlMethodStackBuilder struct {
|
||||
StackBuilder
|
||||
}
|
||||
|
||||
func (b *UrlMethodStackBuilder) SetGeneralInfo(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess {
|
||||
stackID := b.dataStore.Stack().GetNextIdentifier()
|
||||
b.stack.ID = portainer.StackID(stackID)
|
||||
b.stack.EndpointID = endpoint.ID
|
||||
b.stack.Status = portainer.StackStatusActive
|
||||
b.stack.CreationDate = time.Now().Unix()
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *UrlMethodStackBuilder) SetUniqueInfo(payload *StackPayload) UrlMethodStackBuildProcess {
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *UrlMethodStackBuilder) SetURL(payload *StackPayload) UrlMethodStackBuildProcess {
|
||||
if b.hasError() {
|
||||
return b
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *UrlMethodStackBuilder) Deploy(payload *StackPayload, endpoint *portainer.Endpoint) UrlMethodStackBuildProcess {
|
||||
if b.hasError() {
|
||||
return b
|
||||
}
|
||||
|
||||
// Deploy the stack
|
||||
err := b.deploymentConfiger.Deploy()
|
||||
if err != nil {
|
||||
b.err = httperror.InternalServerError(err.Error(), err)
|
||||
return b
|
||||
}
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *UrlMethodStackBuilder) GetResponse() string {
|
||||
return ""
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue