You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by "Luke-Roy-IBM (via GitHub)" <gi...@apache.org> on 2023/03/31 13:28:26 UTC

[GitHub] [openwhisk-runtime-go] Luke-Roy-IBM opened a new pull request, #191: Add tar.gz support to the go Proxy

Luke-Roy-IBM opened a new pull request, #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191

   This new feature will allow for more versatile deployment packages and greater flexibility in handling compressed files. Giving an alternative to zip files.
   
   this feature does not impact the current functionality of the go Proxy


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [openwhisk-runtime-go] Luke-Roy-IBM commented on a diff in pull request #191: Add tar.gz support to the go Proxy

Posted by "Luke-Roy-IBM (via GitHub)" <gi...@apache.org>.
Luke-Roy-IBM commented on code in PR #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191#discussion_r1158237758


##########
openwhisk/tar.go:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package openwhisk
+
+import (
+	"archive/tar"
+	"bytes"
+	"compress/gzip"
+	"fmt"
+	"io"
+	"os"
+	"path/filepath"
+)
+
+func openTar(src []byte) (*tar.Reader, error) {
+	// Create a new bytes.Reader from the input byte slice
+	reader := bytes.NewReader(src)
+
+	// Create a new gzip.Reader from the bytes.Reader
+	gzipReader, err := gzip.NewReader(reader)
+	if err != nil {
+		return nil, err
+	}
+	defer gzipReader.Close()
+
+	// Create a new tar.Reader from the gzip.Reader
+	tarReader := tar.NewReader(gzipReader)
+
+	return tarReader, nil
+}
+
+func UnTar(src []byte, dest string) error {
+	r, err := openTar(src)
+	if err != nil {
+		return err
+	}
+	Debug("open Tar")
+	os.MkdirAll(dest, 0755)
+	for {
+		header, err := r.Next()
+		fmt.Println("Err", err)

Review Comment:
   Yes that was left from debugging has been removed now @dgrove-oss 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [openwhisk-runtime-go] dgrove-oss commented on a diff in pull request #191: Add tar.gz support to the go Proxy

Posted by "dgrove-oss (via GitHub)" <gi...@apache.org>.
dgrove-oss commented on code in PR #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191#discussion_r1156338226


##########
openwhisk/filetype.go:
##########
@@ -65,3 +65,13 @@ func IsZip(buf []byte) bool {
 		(buf[2] == 0x3 || buf[2] == 0x5 || buf[2] == 0x7) &&
 		(buf[3] == 0x4 || buf[3] == 0x6 || buf[3] == 0x8)
 }
+
+// IsTarGz checks if the given file is a valid tar.gz file
+func IsTarGz(buf []byte) bool {

Review Comment:
   I think this is only checking for a gzip file.  Is there a check for tar format too?  or should the name of the function be changed to`isGz` 



##########
openwhisk/extractor.go:
##########
@@ -64,6 +64,17 @@ func (ap *ActionProxy) ExtractAction(buf *[]byte, suffix string) (string, error)
 		}
 		Debug("Extract Action, assuming a zip")
 		return file, Unzip(*buf, newDir)
+
+	} else if IsTarGz(*buf) {
+		jar := os.Getenv("OW_SAVE_JAR")
+		if jar != "" {
+			jarFile := newDir + "/" + jar
+			Debug("Extract Action, checking if it is a jar first")
+			return jarFile, UnzipOrSaveJar(*buf, newDir, jarFile)
+		}
+
+		Debug("Extract Action, assuming a zip")

Review Comment:
   ```suggestion
   		Debug("Extract Action, assuming a tar.gz")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [openwhisk-runtime-go] Luke-Roy-IBM commented on a diff in pull request #191: Add tar.gz support to the go Proxy

Posted by "Luke-Roy-IBM (via GitHub)" <gi...@apache.org>.
Luke-Roy-IBM commented on code in PR #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191#discussion_r1156897138


##########
openwhisk/filetype.go:
##########
@@ -65,3 +65,13 @@ func IsZip(buf []byte) bool {
 		(buf[2] == 0x3 || buf[2] == 0x5 || buf[2] == 0x7) &&
 		(buf[3] == 0x4 || buf[3] == 0x6 || buf[3] == 0x8)
 }
+
+// IsTarGz checks if the given file is a valid tar.gz file
+func IsTarGz(buf []byte) bool {

Review Comment:
   Added your suggestions 👍 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [openwhisk-runtime-go] dgrove-oss commented on a diff in pull request #191: Add tar.gz support to the go Proxy

Posted by "dgrove-oss (via GitHub)" <gi...@apache.org>.
dgrove-oss commented on code in PR #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191#discussion_r1157266359


##########
openwhisk/tar.go:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package openwhisk
+
+import (
+	"archive/tar"
+	"bytes"
+	"compress/gzip"
+	"fmt"
+	"io"
+	"os"
+	"path/filepath"
+)
+
+func openTar(src []byte) (*tar.Reader, error) {
+	// Create a new bytes.Reader from the input byte slice
+	reader := bytes.NewReader(src)
+
+	// Create a new gzip.Reader from the bytes.Reader
+	gzipReader, err := gzip.NewReader(reader)
+	if err != nil {
+		return nil, err
+	}
+	defer gzipReader.Close()
+
+	// Create a new tar.Reader from the gzip.Reader
+	tarReader := tar.NewReader(gzipReader)
+
+	return tarReader, nil
+}
+
+func UnTar(src []byte, dest string) error {
+	r, err := openTar(src)
+	if err != nil {
+		return err
+	}
+	Debug("open Tar")
+	os.MkdirAll(dest, 0755)
+	for {
+		header, err := r.Next()
+		fmt.Println("Err", err)

Review Comment:
   Left over debugging code?  Not sure why we want a println here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [openwhisk-runtime-go] Luke-Roy-IBM merged pull request #191: Add tar.gz support to the go Proxy

Posted by "Luke-Roy-IBM (via GitHub)" <gi...@apache.org>.
Luke-Roy-IBM merged PR #191:
URL: https://github.com/apache/openwhisk-runtime-go/pull/191


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@openwhisk.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org