diff --git a/arguments/arguments.go b/arguments/arguments.go index d7de414..7cb6aa5 100644 --- a/arguments/arguments.go +++ b/arguments/arguments.go @@ -50,13 +50,15 @@ var ( //ErrNoArgument error when zero-downtime-push without a argument called ErrNoArgument = errors.New("no valid argument found, use --help / -h for more information") //ErrNoManifest error when manifes on push application was not found - ErrNoManifest = errors.New("a manifest is required to push this application") + ErrNoManifest = errors.New("a application manifest is required to push an application") //ErrWrongEnvFormat error when env files was not in right format - ErrWrongEnvFormat = errors.New("--var would be in wrong format, use the vars like key=value") + ErrWrongEnvFormat = errors.New("environment variables passed in wrong format, pass the variables like key=value") //ErrWrongCombination error when legacy push is used with health check options ErrWrongCombination = errors.New("--legacy-push and health check options couldn't be combined") //ErrWrongDockerCombination error when private docker image repo will be pushed without a pass ErrWrongPrivateDockerRepoCombination = errors.New("--docker-username have to be used in combination with env CF_DOCKER_PASSWORD and --docker-image") + //Error manifest error when a wildcard was in the path directive + ErrNoWildcardSupport = errors.New("wildcard expressions within the path directive in the application manifest are not supported - delete this path directive and pass the artifact path by using the -p option") ) // ParseArgs parses the command line arguments @@ -76,7 +78,7 @@ func ParseArgs(args []string) (*ParserArguments, error) { flags.StringVar(&pta.Process, "process", "", "use health check type process") flags.BoolVar(&pta.ShowLogs, "show-app-log", false, "tail and show application log during application start") flags.BoolVar(&pta.ShowCrashLogs, "show-crash-log", false, "Show recent logs when applications crashes while the deployment") - flags.StringVar(&pta.VenerableAction, "venerable-action", "delete", "option to delete,stop,none application action on vendor app- default is delete") + flags.StringVar(&pta.VenerableAction, "venerable-action", "delete", "option to delete,stop,none application action on venerable app default is delete") flags.Var(&envs, "env", "Variable key value pair for adding dynamic environment variables; can specify multiple times") flags.BoolVar(&pta.LegacyPush, "legacy-push", false, "use legacy push instead of new v3 api") flags.BoolVar(&pta.NoRoute, "no-route", false, "deploy new application without adding routes") @@ -115,6 +117,11 @@ func ParseArgs(args []string) (*ParserArguments, error) { if err != nil { return pta, err //ErrManifest } + + if strings.ContainsAny(parsedManifest.ApplicationManifests[0].Path, "*") && pta.LegacyPush == false { + return pta, ErrNoWildcardSupport + } + pta.Manifest = parsedManifest //check if a docker image shouldbe pushed and verify passed args combination diff --git a/arguments/arguments_test.go b/arguments/arguments_test.go index 66f3dd4..b01a5ec 100644 --- a/arguments/arguments_test.go +++ b/arguments/arguments_test.go @@ -52,6 +52,33 @@ var _ = Describe("Flag Parsing", func() { Expect(parsedArguments.NoRoute).To(Equal(false)) }) + It("parses a all args without venerable action", func() { + parsedArguments, err := ParseArgs( + []string{ + "zero-downtime-push", + "appname", + "-f", "../fixtures/manifest.yml", + "-p", "app-path", + "-s", "stack-name", + }, + ) + Expect(err).ToNot(HaveOccurred()) + + Expect(parsedArguments.AppName).To(Equal("appname")) + Expect(parsedArguments.ManifestPath).To(Equal("../fixtures/manifest.yml")) + Expect(parsedArguments.AppPath).To(Equal("app-path")) + Expect(parsedArguments.StackName).To(Equal("stack-name")) + Expect(parsedArguments.VenerableAction).Should(Equal("delete")) + Expect(parsedArguments.ShowLogs).To(Equal(false)) + Expect(parsedArguments.ShowCrashLogs).To(Equal(false)) + Expect(parsedArguments.NoRoute).To(Equal(false)) + Expect(parsedArguments.Timeout).To(Equal(2)) + Expect(parsedArguments.InvocationTimeout).To(Equal(-1)) + Expect(parsedArguments.Process).To(Equal("")) + Expect(parsedArguments.HealthCheckType).To(Equal("http")) + Expect(parsedArguments.HealthCheckHTTPEndpoint).To(Equal("/health")) + }) + It("parses a all args without timeout", func() { parsedArguments, err := ParseArgs( []string{ @@ -211,7 +238,6 @@ var _ = Describe("Flag Parsing", func() { Expect(parsedArguments.NoRoute).Should(Equal(true)) Expect(parsedArguments.VenerableAction).Should(Equal("none")) }) - }) var _ = Describe("Deprecated flag parsing", func() { @@ -231,4 +257,27 @@ var _ = Describe("Deprecated flag parsing", func() { Expect(arg.ManifestPath).To(Equal("../fixtures/manifest.yml")) Expect(arg.VenerableAction).Should(Equal("stop")) }) + + It("manifest path with wildcard in path test", func() { + _, err := ParseArgs( + []string{ + "zero-downtime-push", + "appname", + "-f", "../fixtures/manifestWildcard.yml", + }, + ) + Expect(err).To(MatchError(ErrNoWildcardSupport)) + }) + + It("manifest path without wildcard in path test", func() { + arg, err := ParseArgs( + []string{ + "zero-downtime-push", + "appname", + "-f", "../fixtures/manifest.yml", + }, + ) + Expect(err).ToNot(HaveOccurred()) + Expect(arg.Manifest.ApplicationManifests[0].Path).To(Equal("")) + }) }) diff --git a/cf/v2/app.go b/cf/v2/app.go index 967318a..4496fd4 100644 --- a/cf/v2/app.go +++ b/cf/v2/app.go @@ -99,6 +99,7 @@ func (resource *ResourcesData) GetAppMetadata(appName string) (*AppResourcesEnti } if len(metaDataResponseEntity.AppResourcesEntity) == 0 { + ui.Warn("No venerable application found") return nil, ErrAppNotFound } diff --git a/cf/v3/app_test.go b/cf/v3/app_test.go index d7579f0..00b9b52 100644 --- a/cf/v3/app_test.go +++ b/cf/v3/app_test.go @@ -95,13 +95,6 @@ var _ = Describe("cf-app test", func() { err := resourcesData.PushApp(arguments) Expect(fakeExecutor.ExecutorCallCount()).To(Equal(3)) //called for each env - output := fakeExecutor.ExecutorArgumentsOutput() - argumentsOutput := []string{"v3-push", "myTestApp", "--no-start"} - Expect(output[0]).To(Equal(argumentsOutput)) - argumentsOutput = []string{"v3-set-env", "myTestApp", "key", "value"} - Expect(output[1]).To(Equal(argumentsOutput)) - argumentsOutput = []string{"v3-set-env", "myTestApp", "newKey", "newValue"} - Expect(output[2]).To(Equal(argumentsOutput)) Expect(err).ToNot(HaveOccurred()) }) @@ -119,7 +112,7 @@ var _ = Describe("cf-app test", func() { "--docker-image", "myDockerImage", "--docker-username", - "mySecretDockerUser",} + "mySecretDockerUser"} Expect(fakeExecutor.ExecutorCallCount()).To(Equal(1)) Expect(fakeExecutor.ExecutorArgumentsOutput()[0]).To(Equal(argumentsOutput)) Expect(err).ToNot(HaveOccurred()) diff --git a/cf/v3/push_application.go b/cf/v3/push_application.go index 44f9702..5f401f7 100644 --- a/cf/v3/push_application.go +++ b/cf/v3/push_application.go @@ -107,7 +107,7 @@ func (resource *ResourcesData) GenerateNoRouteYml(appName string, originalManife return manifestPathTemp, nil } -//SwitchRoutes add new routes and switch "old" one from vendor app to the one +//SwitchRoutes add new routes and switch "old" one from venerable app to the one func (resource *ResourcesData) SwitchRoutes(venAppName string, appName string, routes []map[string]string) (err error) { domains, err := resource.GetDomain(routes) if err != nil { diff --git a/fixtures/manifestWildcard.yml b/fixtures/manifestWildcard.yml new file mode 100644 index 0000000..ccb84ca --- /dev/null +++ b/fixtures/manifestWildcard.yml @@ -0,0 +1,10 @@ +--- +applications: + - name: myApp + memory: 128M + buildpacks: + - java_buildpack + instances: 1 + routes: + - route: route1.external.test.com + path: myfolder/file-*.zip diff --git a/manifest/manifest.go b/manifest/manifest.go index f4e2e9a..4159848 100644 --- a/manifest/manifest.go +++ b/manifest/manifest.go @@ -21,6 +21,7 @@ type Application struct { Env map[string]string `yaml:"env,omitempty"` Services []string `yaml:"services,omitempty"` Stack string `yaml:"stack,omitempty"` + Path string `yaml:"path,omitempty"` Timeout int `yaml:"timeout,omitempty"` HealthCheckType string `yaml:"health-check-type,omitempty"` HealthCheckHTTPEndpoint string `yaml:"health-check-http-endpoint,omitempty"`