diff options
-rw-r--r-- | completions/fish/podman-remote.fish | 30 | ||||
-rw-r--r-- | completions/fish/podman.fish | 30 | ||||
-rw-r--r-- | docs/source/markdown/podman-network-create.1.md | 3 | ||||
-rw-r--r-- | libpod/network/create.go | 9 | ||||
-rw-r--r-- | test/e2e/network_create_test.go | 17 |
5 files changed, 42 insertions, 47 deletions
diff --git a/completions/fish/podman-remote.fish b/completions/fish/podman-remote.fish index e0216844d..b3a4a173a 100644 --- a/completions/fish/podman-remote.fish +++ b/completions/fish/podman-remote.fish @@ -10,7 +10,7 @@ end function __podman_remote_perform_completion __podman_remote_debug "Starting __podman_remote_perform_completion" - set args (string split -- " " (commandline -c)) + set args (string split -- " " (string trim -l (commandline -c))) set lastArg "$args[-1]" __podman_remote_debug "args: $args" @@ -23,16 +23,13 @@ function __podman_remote_perform_completion end __podman_remote_debug "emptyArg: $emptyArg" - if not type -q "$args[1]" - # This can happen when "complete --do-complete podman-remote" is called when running this script. - __podman_remote_debug "Cannot find $args[1]. No completions." - return - end - set requestComp "$args[1] __complete $args[2..-1] $emptyArg" __podman_remote_debug "Calling $requestComp" - set results (eval $requestComp 2> /dev/null) + # Call the command as a sub-shell so that we can redirect any errors + # For example, if $requestComp has an unmatched quote + # https://github.com/spf13/cobra/issues/1214 + set results (fish -c "$requestComp" 2> /dev/null) set comps $results[1..-2] set directiveLine $results[-1] @@ -81,8 +78,6 @@ function __podman_remote_prepare_completions set shellCompDirectiveNoFileComp 4 set shellCompDirectiveFilterFileExt 8 set shellCompDirectiveFilterDirs 16 - set shellCompDirectiveLegacyCustomComp 32 - set shellCompDirectiveLegacyCustomArgsComp 64 if test -z "$directive" set directive 0 @@ -95,15 +90,6 @@ function __podman_remote_prepare_completions return 1 end - set legacyCustom (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomComp) % 2) - set legacyCustomArgs (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomArgsComp) % 2) - if test $legacyCustom -eq 1; or test $legacyCustomArgs -eq 1 - __podman_remote_debug "Legacy bash custom completion not applicable to fish" - # Do full file completion instead - set --global __podman_remote_comp_do_file_comp 1 - return 1 - end - set filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2) set dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2) if test $filefilter -eq 1; or test $dirfilter -eq 1 @@ -121,14 +107,14 @@ function __podman_remote_prepare_completions # we need to count the number of valid completions. # To do so, we will filter on prefix as the completions we have received # may not already be filtered so as to allow fish to match on different - # criteria than prefix. + # criteria than the prefix. if test $nospace -ne 0; or test $nofiles -eq 0 set prefix (commandline -t) __podman_remote_debug "prefix: $prefix" set completions for comp in $__podman_remote_comp_results - if test (string match -e -r "^$prefix" "$comp") + if test (string match -e -r -- "^$prefix" "$comp") set -a completions $comp end end @@ -166,7 +152,7 @@ end # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves # so we can properly delete any completions provided by another script. -# The space after the the program name is essential to trigger completion for the program +# The space after the program name is essential to trigger completion for the program # and not completion of the program name itself. complete --do-complete "podman-remote " > /dev/null 2>&1 # Using '> /dev/null 2>&1' since '&>' is not supported in older versions of fish. diff --git a/completions/fish/podman.fish b/completions/fish/podman.fish index 2a89e7118..05dd2d72b 100644 --- a/completions/fish/podman.fish +++ b/completions/fish/podman.fish @@ -10,7 +10,7 @@ end function __podman_perform_completion __podman_debug "Starting __podman_perform_completion" - set args (string split -- " " (commandline -c)) + set args (string split -- " " (string trim -l (commandline -c))) set lastArg "$args[-1]" __podman_debug "args: $args" @@ -23,16 +23,13 @@ function __podman_perform_completion end __podman_debug "emptyArg: $emptyArg" - if not type -q "$args[1]" - # This can happen when "complete --do-complete podman" is called when running this script. - __podman_debug "Cannot find $args[1]. No completions." - return - end - set requestComp "$args[1] __complete $args[2..-1] $emptyArg" __podman_debug "Calling $requestComp" - set results (eval $requestComp 2> /dev/null) + # Call the command as a sub-shell so that we can redirect any errors + # For example, if $requestComp has an unmatched quote + # https://github.com/spf13/cobra/issues/1214 + set results (fish -c "$requestComp" 2> /dev/null) set comps $results[1..-2] set directiveLine $results[-1] @@ -81,8 +78,6 @@ function __podman_prepare_completions set shellCompDirectiveNoFileComp 4 set shellCompDirectiveFilterFileExt 8 set shellCompDirectiveFilterDirs 16 - set shellCompDirectiveLegacyCustomComp 32 - set shellCompDirectiveLegacyCustomArgsComp 64 if test -z "$directive" set directive 0 @@ -95,15 +90,6 @@ function __podman_prepare_completions return 1 end - set legacyCustom (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomComp) % 2) - set legacyCustomArgs (math (math --scale 0 $directive / $shellCompDirectiveLegacyCustomArgsComp) % 2) - if test $legacyCustom -eq 1; or test $legacyCustomArgs -eq 1 - __podman_debug "Legacy bash custom completion not applicable to fish" - # Do full file completion instead - set --global __podman_comp_do_file_comp 1 - return 1 - end - set filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) % 2) set dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) % 2) if test $filefilter -eq 1; or test $dirfilter -eq 1 @@ -121,14 +107,14 @@ function __podman_prepare_completions # we need to count the number of valid completions. # To do so, we will filter on prefix as the completions we have received # may not already be filtered so as to allow fish to match on different - # criteria than prefix. + # criteria than the prefix. if test $nospace -ne 0; or test $nofiles -eq 0 set prefix (commandline -t) __podman_debug "prefix: $prefix" set completions for comp in $__podman_comp_results - if test (string match -e -r "^$prefix" "$comp") + if test (string match -e -r -- "^$prefix" "$comp") set -a completions $comp end end @@ -166,7 +152,7 @@ end # Since Fish completions are only loaded once the user triggers them, we trigger them ourselves # so we can properly delete any completions provided by another script. -# The space after the the program name is essential to trigger completion for the program +# The space after the program name is essential to trigger completion for the program # and not completion of the program name itself. complete --do-complete "podman " > /dev/null 2>&1 # Using '> /dev/null 2>&1' since '&>' is not supported in older versions of fish. diff --git a/docs/source/markdown/podman-network-create.1.md b/docs/source/markdown/podman-network-create.1.md index 16e4e3bdb..2fafd1e31 100644 --- a/docs/source/markdown/podman-network-create.1.md +++ b/docs/source/markdown/podman-network-create.1.md @@ -41,7 +41,8 @@ Define a gateway for the subnet. If you want to provide a gateway address, you m #### **--internal** -Restrict external access of this network +Restrict external access of this network. Note when using this option, the dnsname plugin will be +automatically disabled. #### **--ip-range** diff --git a/libpod/network/create.go b/libpod/network/create.go index e7f65358b..a8f985af9 100644 --- a/libpod/network/create.go +++ b/libpod/network/create.go @@ -14,6 +14,7 @@ import ( "github.com/containers/podman/v2/pkg/rootless" "github.com/containers/podman/v2/pkg/util" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // Create the CNI network @@ -226,8 +227,12 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon // if we find the dnsname plugin or are rootless, we add configuration for it // the rootless-cni-infra container has the dnsname plugin always installed if (HasDNSNamePlugin(runtimeConfig.Network.CNIPluginDirs) || rootless.IsRootless()) && !options.DisableDNS { - // Note: in the future we might like to allow for dynamic domain names - plugins = append(plugins, NewDNSNamePlugin(DefaultPodmanDomainName)) + if options.Internal { + logrus.Warnf("dnsname and --internal networks are incompatible. dnsname plugin not configured for network %s", name) + } else { + // Note: in the future we might like to allow for dynamic domain names + plugins = append(plugins, NewDNSNamePlugin(DefaultPodmanDomainName)) + } } ncList["plugins"] = plugins b, err := json.MarshalIndent(ncList, "", " ") diff --git a/test/e2e/network_create_test.go b/test/e2e/network_create_test.go index 73e18cbce..1bf2a2691 100644 --- a/test/e2e/network_create_test.go +++ b/test/e2e/network_create_test.go @@ -375,4 +375,21 @@ var _ = Describe("Podman network create", func() { Expect(nc).To(ExitWithError()) }) + It("podman network create with internal should not have dnsname", func() { + net := "internal-test" + stringid.GenerateNonCryptoID() + nc := podmanTest.Podman([]string{"network", "create", "--internal", net}) + nc.WaitWithDefaultTimeout() + defer podmanTest.removeCNINetwork(net) + Expect(nc.ExitCode()).To(BeZero()) + // Not performing this check on remote tests because it is a logrus error which does + // not come back via stderr on the remote client. + if !IsRemote() { + Expect(nc.ErrorToString()).To(ContainSubstring("dnsname and --internal networks are incompatible")) + } + nc = podmanTest.Podman([]string{"network", "inspect", net}) + nc.WaitWithDefaultTimeout() + Expect(nc.ExitCode()).To(BeZero()) + Expect(nc.OutputToString()).ToNot(ContainSubstring("dnsname")) + }) + }) |