@Override
    public Configuration toConfiguration(CommandLine commandLine) throws FlinkException {

        final Configuration resultingConfiguration = super.toConfiguration(commandLine);
        if (commandLine.hasOption(addressOption.getOpt())) {
            String addressWithPort = commandLine.getOptionValue(addressOption.getOpt());
            InetSocketAddress jobManagerAddress = NetUtils.parseHostPortAddress(addressWithPort);
            setJobManagerAddressInConfig(resultingConfiguration, jobManagerAddress);

            URL url = NetUtils.getCorrectHostnamePort(addressWithPort);
            resultingConfiguration.set(RestOptions.PATH, url.getPath());
            resultingConfiguration.set(SecurityOptions.SSL_REST_ENABLED, isHttpsProtocol(url));
        }
        resultingConfiguration.set(DeploymentOptions.TARGET, RemoteExecutor.NAME);

        DynamicPropertiesUtil.encodeDynamicProperties(commandLine, resultingConfiguration);

        return resultingConfiguration;
    }
@Test
    void testCommandLineMaterialization() throws Exception {
        final String hostname = "home-sweet-home";
        final String urlPath = "/some/other/path/index.html";
        final int port = 1234;
        final String[] args = {"-m", hostname + ':' + port + urlPath};

        final AbstractCustomCommandLine defaultCLI = new DefaultCLI();
        final CommandLine commandLine = defaultCLI.parseCommandLineOptions(args, false);

        Configuration configuration = defaultCLI.toConfiguration(commandLine);

        assertThat(configuration.get(RestOptions.ADDRESS)).isEqualTo(hostname);
        assertThat(configuration.get(RestOptions.PORT)).isEqualTo(port);

        final String httpProtocol = "http";
        assertThat(configuration.get(SecurityOptions.SSL_REST_ENABLED)).isEqualTo(false);
        assertThat(configuration.get(RestOptions.PATH)).isEqualTo(urlPath);

        final String hostnameWithHttpScheme = httpProtocol + "://" + hostname;
        final String[] httpArgs = {"-m", hostnameWithHttpScheme + ':' + port + urlPath};
        final CommandLine httpCommandLine = defaultCLI.parseCommandLineOptions(httpArgs, false);

        Configuration httpConfiguration = defaultCLI.toConfiguration(httpCommandLine);

        assertThat(httpConfiguration.get(RestOptions.ADDRESS)).isEqualTo(hostname);
        assertThat(httpConfiguration.get(RestOptions.PORT)).isEqualTo(port);
        assertThat(httpConfiguration.get(SecurityOptions.SSL_REST_ENABLED)).isEqualTo(false);
        assertThat(httpConfiguration.get(RestOptions.PATH)).isEqualTo(urlPath);

        final String httpsProtocol = "https";

        final String hostnameWithHttpsScheme = httpsProtocol + "://" + hostname;
        final String[] httpsArgs = {"-m", hostnameWithHttpsScheme + ':' + port + urlPath};
        final CommandLine httpsCommandLine = defaultCLI.parseCommandLineOptions(httpsArgs, false);

        Configuration httpsConfiguration = defaultCLI.toConfiguration(httpsCommandLine);

        assertThat(httpsConfiguration.get(RestOptions.ADDRESS)).isEqualTo(hostname);
        assertThat(httpsConfiguration.get(RestOptions.PORT)).isEqualTo(port);
        assertThat(httpsConfiguration.get(SecurityOptions.SSL_REST_ENABLED)).isEqualTo(true);
        assertThat(httpsConfiguration.get(RestOptions.PATH)).isEqualTo(urlPath);
    }