Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
expose public pipeline property
Browse files Browse the repository at this point in the history
[#107331592]

Signed-off-by: Maria Shaldibina <mshaldibina@pivotal.io>
  • Loading branch information
Chris Dutra authored and pilot committed Jun 15, 2016
1 parent c95a7a9 commit 54626d8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions api/pipelines_test.go
Expand Up @@ -37,6 +37,7 @@ var _ = Describe("Pipelines API", func() {
{
ID: 1,
Paused: false,
Public: false,
Pipeline: db.Pipeline{
Name: "a-pipeline",
Config: atc.Config{
Expand All @@ -53,6 +54,7 @@ var _ = Describe("Pipelines API", func() {
{
ID: 2,
Paused: true,
Public: true,
Pipeline: db.Pipeline{
Name: "another-pipeline",
Config: atc.Config{
Expand Down Expand Up @@ -118,6 +120,7 @@ var _ = Describe("Pipelines API", func() {
"name": "a-pipeline",
"url": "/teams/main/pipelines/a-pipeline",
"paused": false,
"public": false,
"team_name": "main",
"groups": [
{
Expand All @@ -130,6 +133,7 @@ var _ = Describe("Pipelines API", func() {
"name": "another-pipeline",
"url": "/teams/main/pipelines/another-pipeline",
"paused": true,
"public": true,
"team_name": "main",
"groups": [
{
Expand Down Expand Up @@ -160,6 +164,7 @@ var _ = Describe("Pipelines API", func() {
{
ID: 1,
Paused: false,
Public: false,
Pipeline: db.Pipeline{
Name: "a-pipeline",
Config: atc.Config{
Expand All @@ -176,6 +181,7 @@ var _ = Describe("Pipelines API", func() {
{
ID: 2,
Paused: true,
Public: true,
Pipeline: db.Pipeline{
Name: "another-pipeline",
Config: atc.Config{
Expand Down Expand Up @@ -224,6 +230,7 @@ var _ = Describe("Pipelines API", func() {
"name": "a-pipeline",
"url": "/teams/a-team/pipelines/a-pipeline",
"paused": false,
"public": false,
"team_name": "a-team",
"groups": [
{
Expand All @@ -236,6 +243,7 @@ var _ = Describe("Pipelines API", func() {
"name": "another-pipeline",
"url": "/teams/a-team/pipelines/another-pipeline",
"paused": true,
"public": true,
"team_name": "a-team",
"groups": [
{
Expand Down Expand Up @@ -265,6 +273,7 @@ var _ = Describe("Pipelines API", func() {
teamDB.GetPipelineByNameReturns(db.SavedPipeline{
ID: 1,
Paused: false,
Public: true,
Pipeline: db.Pipeline{
Name: "some-specific-pipeline",
Config: atc.Config{
Expand Down Expand Up @@ -322,6 +331,7 @@ var _ = Describe("Pipelines API", func() {
"name": "some-specific-pipeline",
"url": "/teams/a-team/pipelines/some-specific-pipeline",
"paused": false,
"public": true,
"team_name": "a-team",
"groups": [
{
Expand Down
1 change: 1 addition & 0 deletions api/present/pipeline.go
Expand Up @@ -22,6 +22,7 @@ func Pipeline(teamName string, savedPipeline db.SavedPipeline, config atc.Config
Name: savedPipeline.Name,
URL: pathForRoute,
Paused: savedPipeline.Paused,
Public: savedPipeline.Public,
Groups: config.Groups,
}
}
1 change: 1 addition & 0 deletions db/pipeline.go
Expand Up @@ -11,6 +11,7 @@ type Pipeline struct {
type SavedPipeline struct {
ID int
Paused bool
Public bool
TeamID int

Pipeline
Expand Down
2 changes: 1 addition & 1 deletion db/sqldb_pipelines.go
@@ -1,6 +1,6 @@
package db

const pipelineColumns = "id, name, config, version, paused, team_id"
const pipelineColumns = "id, name, config, version, paused, team_id, public"

func (db *SQLDB) GetAllPipelines() ([]SavedPipeline, error) {
rows, err := db.conn.Query(`
Expand Down
4 changes: 3 additions & 1 deletion db/team_db.go
Expand Up @@ -644,9 +644,10 @@ func scanPipeline(rows scannable) (SavedPipeline, error) {
var configBlob []byte
var version int
var paused bool
var public bool
var teamID int

err := rows.Scan(&id, &name, &configBlob, &version, &paused, &teamID)
err := rows.Scan(&id, &name, &configBlob, &version, &paused, &teamID, &public)
if err != nil {
return SavedPipeline{}, err
}
Expand All @@ -660,6 +661,7 @@ func scanPipeline(rows scannable) (SavedPipeline, error) {
return SavedPipeline{
ID: id,
Paused: paused,
Public: public,
TeamID: teamID,
Pipeline: Pipeline{
Name: name,
Expand Down
3 changes: 3 additions & 0 deletions db/team_db_test.go
Expand Up @@ -134,6 +134,9 @@ var _ = Describe("TeamDB", func() {
savedPipelines, err := teamDB.GetPipelines()
Expect(err).NotTo(HaveOccurred())
Expect(savedPipelines).To(HaveLen(3))

otherPipeline, err = otherTeamDB.GetPipelineByName("other-pipeline-name")
Expect(err).NotTo(HaveOccurred())
Expect(savedPipelines).To(ConsistOf(savedPipeline1, savedPipeline2, otherPipeline))
})

Expand Down
1 change: 1 addition & 0 deletions pipeline.go
Expand Up @@ -4,6 +4,7 @@ type Pipeline struct {
Name string `json:"name"`
URL string `json:"url"`
Paused bool `json:"paused"`
Public bool `json:"public"`
Groups GroupConfigs `json:"groups,omitempty"`
TeamName string `json:"team_name"`
}

0 comments on commit 54626d8

Please sign in to comment.