forked from concourse/concourse
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds functionality in fly and api for archiving and unarchiving pipelines, in support of concoursegh-2518. replicates: vmware-archive/go-concourse#17 vmware-archive/fly#258 vmware-archive/atc#300
- Loading branch information
Tyler Kellen
committed
Sep 25, 2018
1 parent
4c773bc
commit 0072076
Showing
20 changed files
with
391 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pipelineserver | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/concourse/concourse/atc/db" | ||
) | ||
|
||
func (s *Server) ArchivePipeline(pipelineDB db.Pipeline) http.Handler { | ||
logger := s.logger.Session("archive-pipeline") | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
err := pipelineDB.Archive() | ||
if err != nil { | ||
logger.Error("failed-to-archive-pipeline", err) | ||
w.WriteHeader(http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
w.WriteHeader(http.StatusOK) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pipelineserver | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/concourse/concourse/atc/db" | ||
) | ||
|
||
func (s *Server) UnarchivePipeline(pipelineDB db.Pipeline) http.Handler { | ||
logger := s.logger.Session("unarchive-pipeline") | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
err := pipelineDB.Unarchive() | ||
if err != nil { | ||
logger.Error("failed-to-unarchive-pipeline", err) | ||
w.WriteHeader(http.StatusInternalServerError) | ||
return | ||
} | ||
|
||
w.WriteHeader(http.StatusOK) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
atc/db/migration/migrations/1537818458_add_archived_flag_to_pipelines.down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BEGIN; | ||
ALTER TABLE pipelines | ||
DROP COLUMN archived; | ||
COMMIT; |
4 changes: 4 additions & 0 deletions
4
atc/db/migration/migrations/1537818458_add_archived_flag_to_pipelines.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
BEGIN; | ||
ALTER TABLE pipelines | ||
ADD COLUMN archived boolean NOT NULL DEFAULT false; | ||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/concourse/concourse/fly/commands/internal/displayhelpers" | ||
"github.com/concourse/concourse/fly/commands/internal/flaghelpers" | ||
"github.com/concourse/concourse/fly/rc" | ||
) | ||
|
||
type ArchivePipelineCommand struct { | ||
Pipeline flaghelpers.PipelineFlag `short:"p" long:"pipeline" required:"true" description:"Pipeline to archive"` | ||
} | ||
|
||
func (command *ArchivePipelineCommand) Validate() error { | ||
return command.Pipeline.Validate() | ||
} | ||
|
||
func (command *ArchivePipelineCommand) Execute(args []string) error { | ||
err := command.Validate() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pipelineName := string(command.Pipeline) | ||
|
||
target, err := rc.LoadTarget(Fly.Target, Fly.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = target.Validate() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
found, err := target.Team().ArchivePipeline(pipelineName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if found { | ||
fmt.Printf("archived '%s'\n", pipelineName) | ||
} else { | ||
displayhelpers.Failf("pipeline '%s' not found\n", pipelineName) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/concourse/concourse/fly/commands/internal/displayhelpers" | ||
"github.com/concourse/concourse/fly/commands/internal/flaghelpers" | ||
"github.com/concourse/concourse/fly/rc" | ||
) | ||
|
||
type UnarchivePipelineCommand struct { | ||
Pipeline flaghelpers.PipelineFlag `short:"p" long:"pipeline" required:"true" description:"Pipeline to unarchive"` | ||
} | ||
|
||
func (command *UnarchivePipelineCommand) Validate() error { | ||
return command.Pipeline.Validate() | ||
} | ||
|
||
func (command *UnarchivePipelineCommand) Execute(args []string) error { | ||
err := command.Validate() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pipelineName := string(command.Pipeline) | ||
|
||
target, err := rc.LoadTarget(Fly.Target, Fly.Verbose) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
err = target.Validate() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
found, err := target.Team().UnarchivePipeline(pipelineName) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if found { | ||
fmt.Printf("unarchived '%s'\n", pipelineName) | ||
} else { | ||
displayhelpers.Failf("pipeline '%s' not found\n", pipelineName) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.