github.com/xeptore/docker-cli@v20.10.14+incompatible/cli/command/stack/kubernetes/warnings.go (about) 1 package kubernetes 2 3 import ( 4 "fmt" 5 "io" 6 7 composetypes "github.com/docker/cli/cli/compose/types" 8 ) 9 10 func warnUnsupportedFeatures(stderr io.Writer, cfg *composetypes.Config) { 11 warnForGlobalNetworks(stderr, cfg) 12 for _, s := range cfg.Services { 13 warnForServiceNetworks(stderr, s) 14 warnForUnsupportedDeploymentStrategy(stderr, s) 15 warnForUnsupportedRestartPolicy(stderr, s) 16 warnForDeprecatedProperties(stderr, s) 17 warnForUnsupportedProperties(stderr, s) 18 } 19 } 20 21 func warnForGlobalNetworks(stderr io.Writer, config *composetypes.Config) { 22 for network := range config.Networks { 23 fmt.Fprintf(stderr, "top-level network %q is ignored\n", network) 24 } 25 } 26 27 func warnServicef(stderr io.Writer, service, format string, args ...interface{}) { 28 fmt.Fprintf(stderr, "service \"%s\": %s\n", service, fmt.Sprintf(format, args...)) 29 } 30 31 func warnForServiceNetworks(stderr io.Writer, s composetypes.ServiceConfig) { 32 for network := range s.Networks { 33 warnServicef(stderr, s.Name, "network %q is ignored", network) 34 } 35 } 36 37 func warnForDeprecatedProperties(stderr io.Writer, s composetypes.ServiceConfig) { 38 if s.ContainerName != "" { 39 warnServicef(stderr, s.Name, "container_name is deprecated") 40 } 41 if len(s.Expose) > 0 { 42 warnServicef(stderr, s.Name, "expose is deprecated") 43 } 44 } 45 46 func warnForUnsupportedDeploymentStrategy(stderr io.Writer, s composetypes.ServiceConfig) { 47 config := s.Deploy.UpdateConfig 48 if config == nil { 49 return 50 } 51 if config.Delay != 0 { 52 warnServicef(stderr, s.Name, "update_config.delay is not supported") 53 } 54 if config.FailureAction != "" { 55 warnServicef(stderr, s.Name, "update_config.failure_action is not supported") 56 } 57 if config.Monitor != 0 { 58 warnServicef(stderr, s.Name, "update_config.monitor is not supported") 59 } 60 if config.MaxFailureRatio != 0 { 61 warnServicef(stderr, s.Name, "update_config.max_failure_ratio is not supported") 62 } 63 } 64 65 func warnForUnsupportedRestartPolicy(stderr io.Writer, s composetypes.ServiceConfig) { 66 policy := s.Deploy.RestartPolicy 67 if policy == nil { 68 return 69 } 70 71 if policy.Delay != nil { 72 warnServicef(stderr, s.Name, "restart_policy.delay is ignored") 73 } 74 if policy.MaxAttempts != nil { 75 warnServicef(stderr, s.Name, "restart_policy.max_attempts is ignored") 76 } 77 if policy.Window != nil { 78 warnServicef(stderr, s.Name, "restart_policy.window is ignored") 79 } 80 } 81 82 func warnForUnsupportedProperties(stderr io.Writer, s composetypes.ServiceConfig) { // nolint: gocyclo 83 if build := s.Build; build.Context != "" || build.Dockerfile != "" || len(build.Args) > 0 || len(build.Labels) > 0 || len(build.CacheFrom) > 0 || build.Network != "" || build.Target != "" { 84 warnServicef(stderr, s.Name, "build is ignored") 85 } 86 if s.CgroupParent != "" { 87 warnServicef(stderr, s.Name, "cgroup_parent is ignored") 88 } 89 if len(s.Devices) > 0 { 90 warnServicef(stderr, s.Name, "devices are ignored") 91 } 92 if s.DomainName != "" { 93 warnServicef(stderr, s.Name, "domainname is ignored") 94 } 95 if len(s.ExternalLinks) > 0 { 96 warnServicef(stderr, s.Name, "external_links are ignored") 97 } 98 if len(s.Links) > 0 { 99 warnServicef(stderr, s.Name, "links are ignored") 100 } 101 if s.MacAddress != "" { 102 warnServicef(stderr, s.Name, "mac_address is ignored") 103 } 104 if s.NetworkMode != "" { 105 warnServicef(stderr, s.Name, "network_mode is ignored") 106 } 107 if s.Restart != "" { 108 warnServicef(stderr, s.Name, "restart is ignored") 109 } 110 if len(s.SecurityOpt) > 0 { 111 warnServicef(stderr, s.Name, "security_opt are ignored") 112 } 113 if len(s.Ulimits) > 0 { 114 warnServicef(stderr, s.Name, "ulimits are ignored") 115 } 116 if len(s.DependsOn) > 0 { 117 warnServicef(stderr, s.Name, "depends_on are ignored") 118 } 119 if s.CredentialSpec.File != "" { 120 warnServicef(stderr, s.Name, "credential_spec is ignored") 121 } 122 if len(s.DNS) > 0 { 123 warnServicef(stderr, s.Name, "dns are ignored") 124 } 125 if len(s.DNSSearch) > 0 { 126 warnServicef(stderr, s.Name, "dns_search are ignored") 127 } 128 if len(s.EnvFile) > 0 { 129 warnServicef(stderr, s.Name, "env_file are ignored") 130 } 131 if s.StopSignal != "" { 132 warnServicef(stderr, s.Name, "stop_signal is ignored") 133 } 134 if s.Logging != nil { 135 warnServicef(stderr, s.Name, "logging is ignored") 136 } 137 for _, m := range s.Volumes { 138 if m.Volume != nil && m.Volume.NoCopy { 139 warnServicef(stderr, s.Name, "volume.nocopy is ignored") 140 } 141 if m.Bind != nil && m.Bind.Propagation != "" { 142 warnServicef(stderr, s.Name, "volume.propagation is ignored") 143 } 144 } 145 }