Documentation ¶
Overview ¶
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.
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.
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.
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.
Example (CheckUpdated_outdated) ¶
// clone olaris folder into a temp folder tmpDir, err := os.MkdirTemp("", "nuv-test") if err != nil { pr("failed to create temp dir", err) } defer os.RemoveAll(tmpDir) tmpDirBranch := joinpath(tmpDir, getNuvBranch()) olarisTmpPath := joinpath(tmpDirBranch, "olaris") repo, _ := git.PlainClone(olarisTmpPath, false, &git.CloneOptions{ URL: getNuvRepo(), }, ) // run checkUpdated and check if it creates the latest_check file createLatestCheckFile(tmpDirBranch) if exists(tmpDirBranch, ".latestcheck") { pr("latest_check file created") } // change latest_check file mtime to 2 seconds ago changeLatestCheckTime(tmpDirBranch, -2*time.Second) // git reset olaris to a previous commit resetOneCommit(repo) // re-run checkUpdated and check output checkUpdated(tmpDir, 1*time.Second)
Output: latest_check file created Checking for updates... New tasks available! Use 'nuv -update' to update.
Example (CheckUpdated_uptodate) ¶
// clone olaris folder into a temp folder tmpDir, err := os.MkdirTemp("", "nuv-test") if err != nil { pr("failed to create temp dir", err) } defer os.RemoveAll(tmpDir) tmpDirBranch := joinpath(tmpDir, getNuvBranch()) olarisTmpPath := joinpath(tmpDirBranch, "olaris") _, _ = git.PlainClone(olarisTmpPath, false, &git.CloneOptions{ URL: getNuvRepo(), }, ) // run checkUpdated and check if it creates the latest_check file createLatestCheckFile(tmpDirBranch) if exists(tmpDirBranch, ".latestcheck") { pr("latest_check file created") } // change latest_check file mtime to 2 seconds ago changeLatestCheckTime(tmpDirBranch, -2*time.Second) // re-run checkUpdated and check output "Tasks up to date!" checkUpdated(tmpDir, 1*time.Second)
Output: latest_check file created Checking for updates... Tasks up to date!
Example (LoadArgs) ¶
_ = os.Chdir(workDir) fmt.Println(1, loadSavedArgs()) _ = os.Chdir(joinpath("tests", "testdata")) fmt.Println(2, loadSavedArgs())
Output: 1 [] 2 [V1=hello V2=hello V2=world]
Example (Locate) ¶
_ = os.Chdir(workDir) dir, err := locateNuvRoot("tests") pr(1, err, npath(dir)) dir, err = locateNuvRoot(joinpath("tests", "olaris")) pr(2, err, npath(dir)) dir, err = locateNuvRoot(joinpath("tests", joinpath("olaris", "sub"))) pr(3, err, npath(dir))
Output: 1 <nil> /work/tests/olaris 2 <nil> /work/tests/olaris 3 <nil> /work/tests/olaris
Example (Locate_git) ¶
_ = os.Chdir(workDir) NuvBranch = "3.0.0-testing" nuvdir, _ := homedir.Expand("~/.nuv") _ = os.RemoveAll(nuvdir) _ = os.Setenv("NUV_BIN", "") _, err := locateNuvRoot(".") pr(1, err) _ = os.Setenv("NUV_BIN", workDir) dir, err := locateNuvRoot("tests") pr(2, err, npath(dir)) _, _ = downloadTasksFromGitHub(true, true) dir, err = locateNuvRoot(".") pr(3, err, nhpath(dir)) _, _ = downloadTasksFromGitHub(true, true) dir, err = locateNuvRoot(".") pr(4, err, nhpath(dir)) os.RemoveAll(nuvdir)
Output: 1 we cannot find nuvfiles, download them with nuv -update 2 <nil> /work/tests/olaris Cloning tasks... Nuvfiles downloaded successfully 3 <nil> /home/.nuv/3.0.0-testing/olaris Updating tasks... Tasks are already up to date! 4 <nil> /home/.nuv/3.0.0-testing/olaris
Example (NuvArg) ¶
// test _ = os.Chdir(workDir) olaris, _ := filepath.Abs(joinpath("tests", "olaris")) err := Nuv(olaris, split("testcmd")) pr(2, err) err = Nuv(olaris, split("testcmd arg")) pr(3, err) err = Nuv(olaris, split("testcmd arg VAR=1")) pr(4, err) err = Nuv(olaris, split("testcmd VAR=1 arg")) pr(5, err)
Output: (olaris) task [-t nuvfile.yml testcmd --] 2 <nil> (olaris) task [-t nuvfile.yml testcmd -- arg] 3 <nil> (olaris) task [-t nuvfile.yml testcmd VAR=1 -- arg] 4 <nil> (olaris) task [-t nuvfile.yml testcmd VAR=1 -- arg] 5 <nil>
Example (PluginsPrint) ¶
p := plugins{ local: make([]string, 0), nuv: make([]string, 0), } p.print() // Output // No plugins installed. Use 'nuv -plugin' to add new ones.
Output:
Example (SetupTmp) ¶
_ = os.Chdir(workDir) nuvdir, _ := homedir.Expand("~/.nuv") os.RemoveAll(nuvdir) setupTmp() fmt.Println(nhpath(os.Getenv("NUV_TMP"))) os.RemoveAll(nuvdir)
Output: /home/.nuv/tmp
Index ¶
- Constants
- Variables
- func GetNuvRootPlugins() (map[string]string, error)
- func IsWskWrapperCommand(name string) ([]string, bool)
- func Main()
- func Nuv(base string, args []string) error
- func Serve(olarisDir string, args []string) error
- func Task(args ...string) (int, error)
- type NuvRootJSON
- type TaskNotFoundErr
Examples ¶
Constants ¶
const CONFIGFILE = "config.json"
const DefaultNuvPort = 9768
default port for nuv server
const LATESTCHECK = ".latestcheck"
const NUVFILE = "nuvfile.yml"
default files
const NUVOPTS = "nuvopts.txt"
const NUVREPO = "http://github.com/nuvolaris/olaris"
repo where download tasks
const NUVROOT = "nuvroot.json"
Variables ¶
var NuvBranch = "3.0.0"
var NuvVersion = "main"
branch where download tasks defaults to test - will be changed in compilation
var WSK_RUNTIMES_JSON string
Functions ¶
func GetNuvRootPlugins ¶
GetNuvRootPlugins returns the map with all the olaris-*/nuvroot.json files in the local and ~/.nuv folders, pointed by their plugin names. If the same plugin is found in both folders, the one in the local folder is used. Useful to build the config map including the plugin configs
func IsWskWrapperCommand ¶
func Nuv ¶
Nuv parses args moving into the folder corresponding to args then parses them with docopts and invokes the task
Example ¶
// test _ = os.Chdir(workDir) os.Setenv("TEST_VAR", "evar") olaris, _ := filepath.Abs(joinpath("tests", "olaris")) err := Nuv(olaris, split("")) pr(1, err) err = Nuv(olaris, split("sub")) pr(4, err) err = Nuv(olaris, split("sub opts")) pr(5, err) _ = Nuv(olaris, split("sub opts ciao 1")) // pr(6, err)
Output:
Types ¶
type NuvRootJSON ¶
type NuvRootJSON struct { Version string `json:"version"` Config map[string]interface{} `json:"config"` }
Represents nuvroot.json. It is used to parse the file.
type TaskNotFoundErr ¶
type TaskNotFoundErr struct {
// contains filtered or unexported fields
}
func (*TaskNotFoundErr) Error ¶
func (e *TaskNotFoundErr) Error() string