Skip to content

Commit

Permalink
refactor(pkg-nexus): elastic deployer
Browse files Browse the repository at this point in the history
Move running and paused status to deployer models since it can be reused for kuberclient.
  • Loading branch information
KonsumGandalf committed Jan 25, 2024
1 parent 5fdc7b5 commit 94180ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pkg/nexus/elastic-deploy/docker/docker-deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"time"
)

const (
running = "running"
paused = "paused"
)

type DockerDeployer struct {
*deployer_models.ProElasticDeployerConfig
*docker.Client
Expand Down Expand Up @@ -73,7 +68,7 @@ func (ds *DockerDeployer) Unpause(functionName string) error {
}

fmt.Println("Container state: ", container.State)
if container.State == paused {
if container.State == deployer_models.Paused {
err := ds.UnpauseContainer(container.ID)
if err != nil {
return err
Expand All @@ -90,12 +85,12 @@ func (ds *DockerDeployer) Unpause(functionName string) error {

func (ds *DockerDeployer) Pause(functionName string) error {
container := ds.getFunctionContainer(functionName)
if container.State == paused {
if container.State == deployer_models.Paused {
fmt.Printf("Container %s has been paused already\n", ds.getContainerName(functionName))
return nil
}

if container.State == running {
if container.State == deployer_models.Running {
err := ds.PauseContainer(container.ID)
if err != nil {
return err
Expand All @@ -110,7 +105,7 @@ func (ds *DockerDeployer) Pause(functionName string) error {

func (ds *DockerDeployer) IsRunning(functionName string) bool {
container := ds.getFunctionContainer(functionName)
return container.State == running
return container.State == deployer_models.Running
}

func (ds *DockerDeployer) getFunctionContainer(functionName string) *docker.APIContainers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import (
"time"
)

const (
Running = "Running"
Paused = "Paused"
)

type ElasticDeployer interface {
Unpause(functionName string) error
Pause(functionName string) error
Expand Down

0 comments on commit 94180ed

Please sign in to comment.