Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #49 from aledeganopix4d/add_expose
Browse files Browse the repository at this point in the history
Add possiblity to expose pipeline.
  • Loading branch information
vito authored Feb 5, 2019
2 parents cb320b3 + a929649 commit 45fa8ca
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ Must be non-nil and non-empty. The structure of the `pipeline` object is as foll
be unpaused after the creation. If it is set to `true`, the command
`unpause-pipeline` will be executed for the specific pipeline.

- `exposed`: *Optional.* Boolean specifying if the pipeline should
be exposed after the creation. If it is set to `true`, the command
`expose-pipeline` will be executed for the specific pipeline.

### dynamic

Resource configuration as above for Check, with the following job configuration:
Expand Down
1 change: 1 addition & 0 deletions concourse/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Pipeline struct {
Vars map[string]interface{} `json:"vars" yaml:"vars"`
TeamName string `json:"team" yaml:"team"`
Unpaused bool `json:"unpaused" yaml:"unpaused"`
Exposed bool `json:"exposed" yaml:"exposed"`
}

type OutResponse struct {
Expand Down
8 changes: 8 additions & 0 deletions fly/fly.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Command interface {
SetPipeline(pipelineName string, configFilepath string, varsFilepaths []string, vars map[string]interface{}) ([]byte, error)
DestroyPipeline(pipelineName string) ([]byte, error)
UnpausePipeline(pipelineName string) ([]byte, error)
ExposePipeline(pipelineName string) ([]byte, error)
}

type command struct {
Expand Down Expand Up @@ -151,6 +152,13 @@ func (f command) DestroyPipeline(pipelineName string) ([]byte, error) {
)
}

func (f command) ExposePipeline(pipelineName string) ([]byte, error) {
return f.run(
"expose-pipeline",
"-p", pipelineName,
)
}

func (f command) run(args ...string) ([]byte, error) {
if f.target == "" {
return nil, fmt.Errorf("target cannot be empty in command.run")
Expand Down
24 changes: 24 additions & 0 deletions fly/fly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,28 @@ echo '[{"name":"abc"},{"name":"def"}]'
Expect(string(output)).To(Equal(expectedOutput))
})
})

Describe("ExposePipeline", func() {
var (
pipelineName string
)

BeforeEach(func() {
pipelineName = "some-pipeline"
})

It("returns output without error", func() {
output, err := flyCommand.ExposePipeline(pipelineName)
Expect(err).NotTo(HaveOccurred())

expectedOutput := fmt.Sprintf(
"%s %s %s %s %s\n",
"-t", target,
"expose-pipeline",
"-p", pipelineName,
)

Expect(string(output)).To(Equal(expectedOutput))
})
})
})
78 changes: 78 additions & 0 deletions fly/flyfakes/fake_command.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions out/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ func (c *Command) Run(input concourse.OutRequest) (concourse.OutResponse, error)
return concourse.OutResponse{}, err
}

if p.Exposed {
_, err = c.flyCommand.ExposePipeline(p.Name)
if err != nil {
return concourse.OutResponse{}, err
}
}

if p.Unpaused {
_, err = c.flyCommand.UnpausePipeline(p.Name)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion out/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pipeline3: foo
ConfigFile: "pipeline_2.yml",
TeamName: teamName,
Unpaused: true,
Exposed: true,
},
{
Name: apiPipelines[2],
Expand Down Expand Up @@ -193,11 +194,12 @@ pipeline3: foo
Expect(varsFilepaths[1]).To(Equal(filepath.Join(sourcesDir, p.VarsFiles[1])))
}

// the second pipeline has Unpaused set to true
// the second pipeline has Unpaused and Exposed set to true
if i == 1 {
name := fakeFlyCommand.UnpausePipelineArgsForCall(0)
Expect(name).To(Equal(p.Name))
Expect(fakeFlyCommand.UnpausePipelineCallCount()).To(Equal(1))
Expect(fakeFlyCommand.ExposePipelineCallCount()).To(Equal(1))
}

// the third pipeline has vars
Expand Down

0 comments on commit 45fa8ca

Please sign in to comment.