github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/actor/pushaction/command_line_settings.go (about) 1 package pushaction 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/types" 7 "code.cloudfoundry.org/cli/util/manifest" 8 ) 9 10 type CommandLineSettings struct { 11 Buildpack types.FilteredString 12 Command types.FilteredString 13 CurrentDirectory string 14 DefaultRouteDomain string 15 DefaultRouteHostname string 16 DiskQuota uint64 17 DockerImage string 18 DockerPassword string 19 DockerUsername string 20 HealthCheckTimeout int 21 HealthCheckType string 22 Instances types.NullInt 23 Memory uint64 24 Name string 25 NoHostname bool 26 NoRoute bool 27 ProvidedAppPath string 28 RandomRoute bool 29 RoutePath string 30 StackName string 31 } 32 33 func (settings CommandLineSettings) OverrideManifestSettings(app manifest.Application) manifest.Application { 34 if settings.Buildpack.IsSet { 35 app.Buildpack = settings.Buildpack 36 } 37 38 if settings.Command.IsSet { 39 app.Command = settings.Command 40 } 41 42 if settings.DefaultRouteDomain != "" { 43 app.Domain = settings.DefaultRouteDomain 44 } 45 46 if settings.DefaultRouteHostname != "" { 47 app.Hostname = settings.DefaultRouteHostname 48 } 49 50 if settings.DiskQuota != 0 { 51 app.DiskQuota.ParseUint64Value(&settings.DiskQuota) 52 } 53 54 if settings.DockerImage != "" { 55 app.DockerImage = settings.DockerImage 56 } 57 58 if settings.DockerUsername != "" { 59 app.DockerUsername = settings.DockerUsername 60 } 61 62 if settings.DockerPassword != "" { 63 app.DockerPassword = settings.DockerPassword 64 } 65 66 if settings.HealthCheckTimeout != 0 { 67 app.HealthCheckTimeout = settings.HealthCheckTimeout 68 } 69 70 if settings.HealthCheckType != "" { 71 app.HealthCheckType = settings.HealthCheckType 72 } 73 74 if settings.Instances.IsSet { 75 app.Instances = settings.Instances 76 } 77 78 if settings.Memory != 0 { 79 app.Memory.ParseUint64Value(&settings.Memory) 80 } 81 82 if settings.Name != "" { 83 app.Name = settings.Name 84 } 85 86 if settings.NoHostname { 87 app.NoHostname = true 88 } 89 90 if settings.NoRoute { 91 app.NoRoute = true 92 } 93 94 if settings.ProvidedAppPath != "" { 95 app.Path = settings.ProvidedAppPath 96 } 97 if app.Path == "" && app.DockerImage == "" { 98 app.Path = settings.CurrentDirectory 99 } 100 101 if settings.RandomRoute { 102 app.RandomRoute = true 103 } 104 105 if settings.RoutePath != "" { 106 app.RoutePath = settings.RoutePath 107 } 108 109 if settings.StackName != "" { 110 app.StackName = settings.StackName 111 } 112 113 return app 114 } 115 116 func (settings CommandLineSettings) String() string { 117 return fmt.Sprintf( 118 "App Name: '%s', Buildpack: (%t, '%s'), Command: (%t, '%s'), CurrentDirectory: '%s', Disk Quota: '%d', Docker Image: '%s', Health Check Timeout: '%d', Health Check Type: '%s', Instances: (%t, '%d'), Memory: '%d', Provided App Path: '%s', Stack: '%s', RoutePath: '%s', Domain: '%s', Hostname: '%s'", 119 settings.Name, 120 settings.Buildpack.IsSet, 121 settings.Buildpack.Value, 122 settings.Command.IsSet, 123 settings.Command.Value, 124 settings.CurrentDirectory, 125 settings.DiskQuota, 126 settings.DockerImage, 127 settings.HealthCheckTimeout, 128 settings.HealthCheckType, 129 settings.Instances.IsSet, 130 settings.Instances.Value, 131 settings.Memory, 132 settings.ProvidedAppPath, 133 settings.StackName, 134 settings.RoutePath, 135 settings.DefaultRouteDomain, 136 settings.DefaultRouteHostname, 137 ) 138 }