Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-2509] Bring back docker plugin support for unix sockets #1242

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions ide/docker.api/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>org.netbeans.modules.docker.api</code-name-base>
<module-dependencies>
<dependency>
<code-name-base>libs.c.kohlschutter.junixsocket</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>2.20</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.api.annotations.common</code-name-base>
<build-prerequisite/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.Charset;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -57,14 +56,17 @@ public MuxedStreamResult(Endpoint s, Charset charset, InputStream is) throws IOE
this.stdErr = new ResultInputStream(true);
}

@Override
public OutputStream getStdIn() {
return outputStream;
}

@Override
public InputStream getStdOut() {
return stdOut;
}

@Override
public InputStream getStdErr() {
return stdErr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.netbeans.modules.docker.DirectStreamResult;
import org.netbeans.modules.docker.Demuxer;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
Expand Down Expand Up @@ -77,6 +78,8 @@
import org.netbeans.modules.docker.DockerUtils;
import org.netbeans.modules.docker.Endpoint;
import org.netbeans.modules.docker.StreamResult;
import org.newsclub.net.unix.AFUNIXSocket;
import org.newsclub.net.unix.AFUNIXSocketAddress;
import org.openide.filesystems.FileObject;
import org.openide.util.Pair;
import org.openide.util.Parameters;
Expand Down Expand Up @@ -1252,6 +1255,11 @@ private Endpoint createEndpoint() throws IOException {
}
s.connect(new InetSocketAddress(realUrl.getHost(), port));
return Endpoint.forSocket(s);
} else if ("file".equals(realUrl.getProtocol())) {
AFUNIXSocket s = AFUNIXSocket.newInstance();
AFUNIXSocketAddress sockAdd = new AFUNIXSocketAddress(new File(realUrl.getFile()));
s.connect(sockAdd);
return Endpoint.forSocket(s);
} else {
throw new IOException("Unknown protocol: " + realUrl.getProtocol());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
package org.netbeans.modules.docker.api;

import java.util.Objects;
import javax.swing.event.ChangeListener;
import org.openide.util.ChangeSupport;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public long getTime() {
return time;
}

@Override
public DockerInstance getSource() {
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/
package org.netbeans.modules.docker.api;

import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.NodeChangeEvent;
import java.util.prefs.NodeChangeListener;
Expand Down Expand Up @@ -129,12 +128,12 @@ public void removeChangeListener(ChangeListener listener) {
}

public boolean isSocketSupported() {
return false;
// if (BaseUtilities.getOperatingSystem() != BaseUtilities.OS_LINUX) {
// return false;
// }
// String arch = System.getProperty("os.arch"); // NOI18N
// return arch != null && (arch.contains("x86") || arch.contains("amd64")); // NOI18N
if (BaseUtilities.getOperatingSystem() != BaseUtilities.OS_LINUX
&& BaseUtilities.getOperatingSystem() != BaseUtilities.OS_MAC) {
return false;
}
String arch = System.getProperty("os.arch"); // NOI18N
return arch != null && (arch.contains("x86") || arch.contains("amd64")); // NOI18N
}

private boolean isInitialized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.PrivateKey;
Expand Down
24 changes: 24 additions & 0 deletions ide/libs.c.kohlschutter.junixsocket/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

-->
<project name="ide/libs.c.kohlschutter.junixsocket" default="build" basedir=".">
<import file="../../nbbuild/templates/projectized.xml"/>
</project>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library seems to be on Maven central. Make sure to create external/binaries-files to download the JARs from Maven central instead of having them in the Git repository.

19 changes: 19 additions & 0 deletions ide/libs.c.kohlschutter.junixsocket/external/binaries-list
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
8EF93DCAACE57F1EC4E165777C32BF5DBE4E7F30 com.kohlschutter.junixsocket:junixsocket-native-common:2.2.0
BC02CB0A193C0B5881833A579C631C6DA8CD40C8 com.kohlschutter.junixsocket:junixsocket-common:2.2.0
F747577CF77B76C88079279A50CC6EAE87E5582D com.kohlschutter.junixsocket:junixsocket-core:2.2.0