diff --git a/.github/workflows/docker-profaastinate.yaml b/.github/workflows/docker-profaastinate.yaml new file mode 100644 index 0000000000..d46932ba27 --- /dev/null +++ b/.github/workflows/docker-profaastinate.yaml @@ -0,0 +1,33 @@ +name: Build and push dashboard image + +on: + workflow_dispatch: + pull_request: + branches: [ mpga-development ] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: quay.io/nuclio/dashboard + SET_IMAGE_NAME: nuclio-dashboard-profaastintate + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build dashboard image + run: make dashboard + + - name: Tag and push dashboard image + run: | + docker tag ${{ env.IMAGE_NAME }}:latest-amd64 ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.SET_IMAGE_NAME }}:latest-amd64 + docker push ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.SET_IMAGE_NAME }}:latest-amd64 diff --git a/.github/workflows/profaastinate.yaml b/.github/workflows/profaastinate.yaml index 490c645cc4..7e24d5c3e2 100644 --- a/.github/workflows/profaastinate.yaml +++ b/.github/workflows/profaastinate.yaml @@ -15,7 +15,8 @@ jobs: go-version: [ 1.21.x ] # Add other versions if needed steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Set up Go ${{ matrix.go-version }} uses: actions/setup-go@v4 with: @@ -23,11 +24,12 @@ jobs: - name: Install dependencies run: go mod tidy - Lint: + lint: runs-on: ubuntu-latest needs: install-deps steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Set up Go ${{ matrix.go-version }} uses: actions/setup-go@v4 with: @@ -37,14 +39,15 @@ jobs: - name: Run Profaastinate Lint run: golangci-lint run ./pkg/nexus/... - Test: + test: runs-on: ubuntu-latest needs: install-deps steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 - name: Set up Go ${{ matrix.go-version }} uses: actions/setup-go@v4 with: go-version: ${{ matrix.go-version }} - name: Run Profaastinate Tests - run: go test -cover ./pkg/nexus/... \ No newline at end of file + run: go test -cover ./pkg/nexus/... diff --git a/pkg/dashboard/server.go b/pkg/dashboard/server.go index 64ec74c22e..ba02d3ebbc 100644 --- a/pkg/dashboard/server.go +++ b/pkg/dashboard/server.go @@ -124,8 +124,7 @@ func NewServer(parentLogger logger.Logger, // create server newServer.AbstractServer, err = restful.NewAbstractServer(parentLogger, DashboardResourceRegistrySingleton, - newServer, - newDockerClient) + newServer) if err != nil { return nil, errors.Wrap(err, "Failed to create restful server") } diff --git a/pkg/nexus/elastic-deploy/docker/docker-deployer.go b/pkg/nexus/elastic-deploy/docker/docker-deployer.go index 7445e1e1d4..cf2077288b 100644 --- a/pkg/nexus/elastic-deploy/docker/docker-deployer.go +++ b/pkg/nexus/elastic-deploy/docker/docker-deployer.go @@ -8,11 +8,6 @@ import ( "time" ) -const ( - running = "running" - paused = "paused" -) - type DockerDeployer struct { *deployer_models.ProElasticDeployerConfig *docker.Client @@ -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 @@ -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 @@ -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 { diff --git a/pkg/nexus/elastic-deploy/models/pro-elastic-deployer-structs.go b/pkg/nexus/elastic-deploy/models/pro-elastic-deployer-structs.go index a0bd205e0b..4c5b6d68b4 100644 --- a/pkg/nexus/elastic-deploy/models/pro-elastic-deployer-structs.go +++ b/pkg/nexus/elastic-deploy/models/pro-elastic-deployer-structs.go @@ -4,6 +4,11 @@ import ( "time" ) +const ( + Running = "Running" + Paused = "Paused" +) + type ElasticDeployer interface { Unpause(functionName string) error Pause(functionName string) error