Merge pull request #5805 from jroden/master
fly: add --team flag to set-pipelines
This commit is contained in:
commit
3e49ee922f
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/concourse/concourse/fly/commands/internal/setpipelinehelpers"
|
||||
"github.com/concourse/concourse/fly/commands/internal/templatehelpers"
|
||||
"github.com/concourse/concourse/fly/rc"
|
||||
"github.com/concourse/concourse/go-concourse/concourse"
|
||||
"github.com/mgutz/ansi"
|
||||
)
|
||||
|
||||
|
@ -22,6 +23,8 @@ type SetPipelineCommand struct {
|
|||
YAMLVar []flaghelpers.YAMLVariablePairFlag `short:"y" long:"yaml-var" value-name:"[NAME=YAML]" description:"Specify a YAML value to set for a variable in the pipeline"`
|
||||
|
||||
VarsFrom []atc.PathFlag `short:"l" long:"load-vars-from" description:"Variable flag that can be used for filling in template values in configuration from a YAML file"`
|
||||
|
||||
Team string `long:"team" description:"Name of the team to which the pipeline belongs, if different from the target default"`
|
||||
}
|
||||
|
||||
func (command *SetPipelineCommand) Validate() error {
|
||||
|
@ -47,10 +50,21 @@ func (command *SetPipelineCommand) Execute(args []string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var team concourse.Team
|
||||
|
||||
if command.Team != "" {
|
||||
team, err = target.FindTeam(command.Team)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
team = target.Team()
|
||||
}
|
||||
|
||||
ansi.DisableColors(command.DisableAnsiColor)
|
||||
|
||||
atcConfig := setpipelinehelpers.ATCConfig{
|
||||
Team: target.Team(),
|
||||
Team: team,
|
||||
PipelineName: pipelineName,
|
||||
TargetName: Fly.Target,
|
||||
Target: target.Client().URL(),
|
||||
|
|
|
@ -116,6 +116,8 @@ var _ = Describe("Fly CLI", func() {
|
|||
exec.Command(flyPath, "-t", targetName, "unpause-job", "-j", "pipeline/job", "--team", "doesnotexist")),
|
||||
Entry("unpause-pipeline command returns an error",
|
||||
exec.Command(flyPath, "-t", targetName, "unpause-pipeline", "-p", "pipeline", "--team", "doesnotexist")),
|
||||
Entry("set-pipeline command returns an error",
|
||||
exec.Command(flyPath, "-t", targetName, "set-pipeline", "-p", "pipeline", "-c", "fixtures/testConfig.yml", "--team", "doesnotexist")),
|
||||
)
|
||||
|
||||
DescribeTable("and you are NOT authorized to view the team",
|
||||
|
@ -144,6 +146,8 @@ var _ = Describe("Fly CLI", func() {
|
|||
exec.Command(flyPath, "-t", targetName, "unpause-job", "-j", "pipeline/job", "--team", "other-team")),
|
||||
Entry("unpause-pipeline command returns an error",
|
||||
exec.Command(flyPath, "-t", targetName, "unpause-pipeline", "-p", "pipeline", "--team", "other-team")),
|
||||
Entry("set-pipeline command returns an error",
|
||||
exec.Command(flyPath, "-t", targetName, "set-pipeline", "-p", "pipeline", "-c", "fixtures/testConfig.yml", "--team", "other-team")),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -969,6 +969,75 @@ this is super secure
|
|||
})
|
||||
})
|
||||
|
||||
Context("when setting new pipeline with non-default team", func() {
|
||||
BeforeEach(func() {
|
||||
atcServer.AppendHandlers(
|
||||
ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/api/v1/teams/other-team"),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, atc.Team{
|
||||
Name: "other-team",
|
||||
}),
|
||||
),
|
||||
ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("GET", "/api/v1/teams/other-team/pipelines/awesome-pipeline/config"),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, atc.Team{
|
||||
Name: "other-team",
|
||||
}),
|
||||
),
|
||||
ghttp.CombineHandlers(
|
||||
ghttp.VerifyRequest("PUT", "/api/v1/teams/other-team/pipelines/awesome-pipeline/config"),
|
||||
ghttp.RespondWithJSONEncoded(http.StatusOK, atc.Team{
|
||||
Name: "other-team",
|
||||
}),
|
||||
),
|
||||
)
|
||||
})
|
||||
|
||||
It("successfully sets new pipeline to non-default team", func() {
|
||||
Expect(func() {
|
||||
flyCmd := exec.Command(flyPath, "-t", targetName, "set-pipeline", "-p", "awesome-pipeline", "-c", configFile.Name(), "--team", "other-team")
|
||||
|
||||
stdin, err := flyCmd.StdinPipe()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Eventually(sess).Should(gbytes.Say(`apply configuration\? \[yN\]: `))
|
||||
yes(stdin)
|
||||
|
||||
Eventually(sess).Should(gbytes.Say("configuration updated"))
|
||||
|
||||
<-sess.Exited
|
||||
Expect(sess.ExitCode()).To(Equal(0))
|
||||
|
||||
}).To(Change(func() int {
|
||||
return len(atcServer.ReceivedRequests())
|
||||
}).By(4))
|
||||
})
|
||||
|
||||
It("bails if the user rejects the configuration", func() {
|
||||
Expect(func() {
|
||||
flyCmd := exec.Command(flyPath, "-t", targetName, "set-pipeline", "-p", "awesome-pipeline", "-c", configFile.Name(), "--team", "other-team")
|
||||
|
||||
stdin, err := flyCmd.StdinPipe()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
sess, err := gexec.Start(flyCmd, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Eventually(sess).Should(gbytes.Say(`apply configuration\? \[yN\]: `))
|
||||
no(stdin)
|
||||
Eventually(sess).Should(gbytes.Say("bailing out"))
|
||||
|
||||
<-sess.Exited
|
||||
Expect(sess.ExitCode()).To(Equal(0))
|
||||
}).To(Change(func() int {
|
||||
return len(atcServer.ReceivedRequests())
|
||||
}).By(3))
|
||||
})
|
||||
})
|
||||
|
||||
Context("when configuring fails", func() {
|
||||
BeforeEach(func() {
|
||||
path, err := atc.Routes.CreatePathForRoute(atc.SaveConfig, rata.Params{"pipeline_name": "awesome-pipeline", "team_name": "main"})
|
||||
|
|
|
@ -20,3 +20,7 @@
|
|||
#### <sub><sup><a name="5770" href="#5770">:link:</a></sup></sub> fix
|
||||
|
||||
* `fly login` now accepts arbitrarily long tokens when pasting the token manually into the console. Previously, the limit was OS dependent (with OSX having a relatively small maximum length of 1024 characters). This has been a long-standing issue, but it became most noticable after 6.1.0 which significantly increased the size of tokens. Note that pasted token is now hidden in the console output. #5770
|
||||
|
||||
#### <sub><sup><a name="5390" href="#5390">:link:</a></sup></sub> feature
|
||||
|
||||
* Add `--team` flag for `fly set-pipelines` command #5805
|
||||
|
|
Loading…
Reference in New Issue