This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git

commit 3d727afc537ddc77cb0d5e6f6f158b967908ebc7
Author: Michele Sciabarra <[email protected]>
AuthorDate: Thu Jul 18 21:26:14 2024 +0200

    patches for submodules
---
 README.md                  |  11 ++++++++++-
 auth/login.go              |   2 +-
 auth/login_test.go         |   2 +-
 go.mod                     |   1 -
 main.go                    |   6 +++---
 patches/.gitignore         |   3 ++-
 patches/builtin_extra.go   |  47 ++++++++++++++++++++++++++-------------------
 patches/gosh               | Bin 3998109 -> 0 bytes
 patches/patch-wsk.sh       |  45 ++++++++++++++++++++++++++++---------------
 patches/patch-wskdeploy.sh |  11 ++++++-----
 patches/runtimes_extra.go  |   2 +-
 tools/sh                   |   2 +-
 tools/wsk                  |   2 +-
 tools/wskdeploy            |   2 +-
 14 files changed, 83 insertions(+), 53 deletions(-)

diff --git a/README.md b/README.md
index a513fcc..ff70bd0 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,7 @@ The following environment variables allows to ovverride 
certain defaults.
 - `NUV_PWD` is the folder where `nuv` is executed (the current working 
directory). It is used to preserve the original working directory when `nuv` is 
used again in tasks (e.g. nuv -realpath to retrieve the correct path). Change 
it only if you know what you are doing!
 - `NUV_ROOT_PLUGIN` is the folder where `nuv` looks for plugins. If not 
defined, it defaults to the same directory where  `nuv` is located.
 - `NUV_OLARIS` holds the head commit hash of the used olaris repo. You can see 
the hash with `nuv -info`.
+
 ## Where `nuv` looks for binaries 
 - `NUV_USE_COREUTILS` enables the use of 
[coreutils](https://github.com/uutils/coreutils) instead of the current unix 
tools implementation. They will eventually replace the current tools.
 
@@ -82,6 +83,15 @@ Nuv is normally distributed with an installer that includes 
all the tools for th
 
 **NOTE**: You can download the relevant tools when you run from source code 
executing `task install`. This task will download the command line tools and 
setup a link in `/usr/local/bin` to invoke `nuv`.
 
+## Internal environment variables
+
+`OPS_RUNTIMES_JSON` is used for the values of the runtimes json if the system 
is unable to read in other ways the current runtimes json. It is normally 
compiled in when you buid from the current version of the runtimes.json. It can 
be overriden
+
+`OPS_COREUTILS` is a string, a space separated list, which lists all the 
commands the coreutils binary provided. It should be kept updated with the 
values of the current version used. It can be overriden
+
+`OPS_TOOLS` is a string, a space separated list, which lists all the commands 
provided as internal tool by the ops binary. It shold be kept updated with the 
current list of tools provided. It can be overriden defining externally
+
+
 ## Where `nuv` looks for tasks
 
 Nuv is an enhanced task runner. Tasks are described by 
[task](https://taskfile.dev) taskfiles.
@@ -192,4 +202,3 @@ Basic unix like tools (`nuv -<tool> -help for details`):
 
 
 
-
diff --git a/auth/login.go b/auth/login.go
index 0090f0b..335ac2f 100644
--- a/auth/login.go
+++ b/auth/login.go
@@ -30,7 +30,7 @@ import (
        "path/filepath"
 
        "github.com/mitchellh/go-homedir"
-       "github.com/nuvolaris/nuv/config"
+       "github.com/apache/openserverless-cli/config"
        "github.com/zalando/go-keyring"
 )
 
diff --git a/auth/login_test.go b/auth/login_test.go
index f9981ee..6f69615 100644
--- a/auth/login_test.go
+++ b/auth/login_test.go
@@ -26,7 +26,7 @@ import (
        "testing"
 
        "github.com/mitchellh/go-homedir"
-       "github.com/nuvolaris/nuv/config"
+       "github.com/apache/openserverless-cli/config"
        "github.com/stretchr/testify/require"
        "github.com/zalando/go-keyring"
 )
diff --git a/go.mod b/go.mod
index d38acf1..8b11bf3 100644
--- a/go.mod
+++ b/go.mod
@@ -44,7 +44,6 @@ require (
        github.com/nuvolaris/goja_nodejs v0.0.0-20231014102937-c453e3fed097 // 
indirect
        github.com/nuvolaris/openwhisk-cli/commands 
v0.0.0-20240322185850-dd1d7107d5b6
        github.com/nuvolaris/openwhisk-cli/wski18n 
v0.0.0-20240322185850-dd1d7107d5b6
-       github.com/nuvolaris/openwhisk-wskdeploy 
v0.0.0-20230916104531-c4bc982185e9 // indirect
        github.com/nuvolaris/sh/v3 v3.7.1-nuv.2309151614 // indirect
        github.com/nwidger/jsoncolor v0.0.0-20170215171346-75a6de4340e5 // 
indirect
        github.com/pkg/errors v0.9.1 // indirect
diff --git a/main.go b/main.go
index cf0a473..a69916e 100644
--- a/main.go
+++ b/main.go
@@ -28,9 +28,9 @@ import (
        "time"
 
        "github.com/mitchellh/go-homedir"
-       "github.com/nuvolaris/nuv/auth"
-       "github.com/nuvolaris/nuv/config"
-       "github.com/nuvolaris/nuv/tools"
+       "github.com/apache/openserverless-cli/auth"
+       "github.com/apache/openserverless-cli/config"
+       "github.com/apache/openserverless-cli/tools"
 
        _ "embed"
 )
diff --git a/patches/.gitignore b/patches/.gitignore
index bfd6871..74f09bd 100644
--- a/patches/.gitignore
+++ b/patches/.gitignore
@@ -1,4 +1,5 @@
 task
 gosh
 wsk
-wskdeploy
+openwhisk-wskdeploy
+openwhisk-cli
diff --git a/patches/builtin_extra.go b/patches/builtin_extra.go
index aefa1e2..ee10fc7 100644
--- a/patches/builtin_extra.go
+++ b/patches/builtin_extra.go
@@ -6,55 +6,62 @@ package interp
 import (
        "context"
        "fmt"
+       "os"
+       "strings"
 
        "github.com/sciabarracom/sh/v3/syntax"
 )
 
 func isCoreutil(name string) bool {
-       switch name {
-       case
-               "arch", "b2sum", "b3sum", "base32", "base64", "basename", 
"basenc", "cat", "chgrp", "chmod", "chown", "chroot",
-               "cksum", "comm", "cp", "csplit", "cut", "date", "dd", "df", 
"dir", "dircolors", "dirname", "du", "echo", "env", "expand",
-               "expr", "factor", "false", "fmt", "fold", "groups", "hashsum", 
"head", "hostid", "hostname", "id", "install", "join",
-               "kill", "link", "ln", "logname", "ls", "md5sum", "mkdir", 
"mkfifo", "mknod", "mktemp", "more", "mv", "nice", "nl",
-               "nohup", "nproc", "numfmt", "od", "paste", "pathchk", "pinky", 
"pr", "printenv", "printf", "ptx", "pwd", "readlink",
-               "realpath", "rm", "rmdir", "seq", "sha1sum", "sha224sum", 
"sha256sum", "sha3-224sum", "sha3-256sum", "sha3-384sum",
-               "sha3-512sum", "sha384sum", "sha3sum", "sha512sum", 
"shake128sum", "shake256sum", "shred", "shuf", "sleep", "sort",
-               "split", "stat", "stdbuf", "sum", "sync", "tac", "tail", "tee", 
"test", "timeout", "touch", "tr", "true", "truncate",
-               "tsort", "tty", "uname", "unexpand", "uniq", "unlink", 
"uptime", "users", "vdir", "wc", "who", "whoami", "yes",
-               "coreutils":
-               return true
+       coreUtils := os.Getenv("OPS_COREUTILS")
+       if coreUtils == "" {
+               return false
        }
-       return false
+       coreUtils = " coreutils " + coreUtils + " "
+       return strings.Contains(coreUtils, " "+name+" ")
+}
 
+func isTools(name string) bool {
+       tools := os.Getenv("OPS_TOOLS")
+       if tools == "" {
+               return false
+       }
+       tools = " " + tools + " "
+       return strings.Contains(tools, " "+name+" ")
 }
 
 func isBuiltin(name string) bool {
-
        if isCoreutil(name) {
                return true
        }
+       if isTools(name) {
+               return true
+       }
        return _isBuiltin(name)
 }
 
 func (r *Runner) builtinCode(ctx context.Context, pos syntax.Pos, name string, 
args []string) int {
 
        if isCoreutil(name) {
-
                cmd := []string{"coreutils"}
                if name != "coreutils" {
                        cmd = append(cmd, name)
                }
                args = append(cmd, args...)
                fmt.Printf("%v\n", args)
-               // TODO: Consider unix.Exec, i.e. actually replacing
-               // the process. It's in theory what a shell should do,
-               // but in practice it would kill the entire Go process
-               // and it's not available on Windows.
                r.exitShell(ctx, 1)
                r.exec(ctx, args)
                return r.exit
        }
 
+       if isTools(name) {
+               args = append([]string{"ops", "-" + name}, args...)
+               fmt.Printf("%v\n", args)
+               r.exitShell(ctx, 1)
+               r.exec(ctx, args)
+               return r.exit
+
+       }
+
        return _builtinCode(ctx, pos, name, args)
 }
diff --git a/patches/gosh b/patches/gosh
deleted file mode 100755
index feea20d..0000000
Binary files a/patches/gosh and /dev/null differ
diff --git a/patches/patch-wsk.sh b/patches/patch-wsk.sh
index efee39a..d71215a 100644
--- a/patches/patch-wsk.sh
+++ b/patches/patch-wsk.sh
@@ -2,31 +2,44 @@
 cd "$(dirname $0)"
 # any suggestion how to avoid this rename and use just replaces in go.mod is 
welcome
 HERE=$PWD
-STAG="v3.38.0"
-DTAG="$STAG-openserverless"
-cd ../tools/task
-git checkout "$TAG" -B openserverless
-mkdir -p cmd/taskmain
-cat cmd/task/task.go \
-| sed -e 's/package main/package taskmain/' \
-| sed -e 's/func main() {/func Task(_args []string) { os.Args = _args/' \
-| tee cmd/taskmain/task.go
-cp $HERE/task.go cmd/taskmain/task.go
-git add cmd/taskmain/task.go
+STAG="1.2.0"
+DTAG="v$STAG-openserverless"
+cd ../tools/wsk
+git reset --hard
+git checkout "$STAG" -B openserverless
+cp $HERE/i18n_resources.go wski18n/i18n_resources.go
+sed -i '/wski18n\/i18n_resources.go/d' .gitignore
+git add wski18n/i18n_resources.go
 find . \( -name \*.go -o -name go.mod \) | while read file 
 do echo $file 
-   sed -i "s!go-task/task!sciabarracom/task!" $file
-   sed -i 's!mvdan.sh/cc!sciabarracom/sh!' $file
-   sed -i 's!"Taskfile.!"opsfile.!' $file
-   sed -i 's!task: !ops: !' $file
+   sed -i 's!apache/openwhisk-cli/!sciabarracom/openwhisk-cli/!' $file
+   sed -i 's!apache/openwhisk-cli"!sciabarracom/openwhisk-cli"!' $file
+   sed -i 's!apache/openwhisk-cli !sciabarracom/openwhisk-cli !' $file
+   sed -i 's!apache/openwhisk-cli$!sciabarracom/openwhisk-cli!' $file
+   sed -i 's!apache/openwhisk-wskdeploy!sciabarracom/openwhisk-wskdeploy!' 
$file
 done
 go clean -modcache -cache -testcache -fuzzcache
+
+sed -i '/openwhisk-wskdeploy/d' go.mod
+sed -i '/openwhisk-client-go/d' go.mod
+
+go get github.com/sciabarracom/openwhisk-wskdeploy@$DTAG
+go get github.com/apache/openwhisk-client-go@$STAG
+
 go mod tidy
 git commit -m "patching sh for ops" -a
 git push origin-auth openserverless -f
+
 git tag -d $DTAG
 git tag $DTAG
 git push origin-auth --delete $DTAG
 git push origin-auth $DTAG
-GOBIN=$HERE go install github.com/sciabarracom/task/v3/cmd/task@$DTAG
+git push origin-auth openserverless
+
+
+# misterious bug here - it is building apache/openwhisk-cli instead
+#echo $CUR
+#go clean -modcache -cache -testcache -fuzzcache
+#CUR=$(git rev-parse $DTAG)
+#GOBIN=$HERE go install github.com/sciabarracom/openwhisk-cli@$DTAG
 
diff --git a/patches/patch-wskdeploy.sh b/patches/patch-wskdeploy.sh
index 92f313f..66bceba 100644
--- a/patches/patch-wskdeploy.sh
+++ b/patches/patch-wskdeploy.sh
@@ -3,15 +3,16 @@ cd "$(dirname $0)"
 # any suggestion how to avoid this rename and use just replaces in go.mod is 
welcome
 HERE=$PWD
 STAG="1.2.0"
-DTAG="$STAG-openserverless"
+DTAG="v$STAG-openserverless"
 cd ../tools/wskdeploy
 git checkout "$STAG" -B openserverless
-
+cp $HERE/runtimes_extra.go runtimes/runtimes_extra.go
+git add runtimes/runtimes_extra.go
+sed -i -e 's/func ParseOpenWhisk/func _ParseOpenWhisk/' runtimes/runtimes.go
 find . \( -name \*.go -o -name go.mod \) | while read file 
 do echo $file 
-   sed -i "s!apache/openwhisk-wskdeploy!sciabarracom/openwhisk-wskdeploy!" 
$file
+   sed -i 's!apache/openwhisk-wskdeploy!sciabarracom/openwhisk-wskdeploy!' 
$file
 done
-
 go clean -modcache -cache -testcache -fuzzcache
 go mod tidy
 git commit -m "patching sh for ops" -a
@@ -20,5 +21,5 @@ git tag -d $DTAG
 git tag $DTAG
 git push origin-auth --delete $DTAG
 git push origin-auth $DTAG
-GOBIN=$HERE go install github.com/sciabarracom/task/v3/cmd/task@$DTAG
+GOBIN=$HERE go install github.com/sciabarracom/openwhisk-wskdeploy@$DTAG
 
diff --git a/patches/runtimes_extra.go b/patches/runtimes_extra.go
index 55e6d9b..3f376fe 100644
--- a/patches/runtimes_extra.go
+++ b/patches/runtimes_extra.go
@@ -97,7 +97,7 @@ func ParseOpenWhisk(apiHost string) (op OpenWhiskInfo, err 
error) {
        if err != nil {
                stdout := wski18n.T(wski18n.ID_MSG_UNMARSHAL_LOCAL)
                wskprint.PrintOpenWhiskVerbose(utils.Flags.Verbose, stdout)
-               runtimes := []byte(os.Getenv("WSK_RUNTIMES_JSON"))
+               runtimes := []byte(os.Getenv("OPS_RUNTIMES_JSON"))
                err = json.Unmarshal(runtimes, &op)
                if err != nil {
                        fmt.Printf("cannot parse this json: ===\n%s\n===\n", 
runtimes)
diff --git a/tools/sh b/tools/sh
index cff5f78..a15cbff 160000
--- a/tools/sh
+++ b/tools/sh
@@ -1 +1 @@
-Subproject commit cff5f78351fc572179e787b98a733aad73453f8d
+Subproject commit a15cbff318785adeb90f0d45c1a2fd4b565acdbf
diff --git a/tools/wsk b/tools/wsk
index b1ca4bc..a732332 160000
--- a/tools/wsk
+++ b/tools/wsk
@@ -1 +1 @@
-Subproject commit b1ca4bccc2c256a073ffc114913c43d78f412830
+Subproject commit a732332d04d3cb75e8749042d4a753c4ceef90a4
diff --git a/tools/wskdeploy b/tools/wskdeploy
index 03df112..41b6c36 160000
--- a/tools/wskdeploy
+++ b/tools/wskdeploy
@@ -1 +1 @@
-Subproject commit 03df1126c3b5205d642738479a08bb7cd66a03b3
+Subproject commit 41b6c36418c2fbb2127371b27a6abbb9ba730ebe

Reply via email to