[lucicfg] Add meta.version(), bump the version to 1.0.0.

Can be used in end-user scripts to bark if lucicfg is older than required.
This will be useful in early stages of lucicfg deployment when luccifg is
still frequently changing.

R=tandrii@chromium.org, nodir@chromium.org
BUG=833946

Change-Id: Ib1f412a5d48d1e48639a02b9d61f3741feb2fc0d
Reviewed-on: https://chromium-review.googlesource.com/c/1440922
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/lucicfg/doc/README.md b/lucicfg/doc/README.md
index 0dd9790..9c683d3 100644
--- a/lucicfg/doc/README.md
+++ b/lucicfg/doc/README.md
@@ -51,7 +51,7 @@
 ***
 
 
-## Configuring lucicfg itself
+## Configuring and inspecting lucicfg itself
 
 
 
@@ -96,6 +96,20 @@
 
 
 
+### meta.version {#meta.version}
+
+```python
+meta.version()
+```
+
+
+
+Returns a triple with lucicfg version: `(major, minor, revision)`.
+
+
+
+
+
 
 
 ## Working with time
diff --git a/lucicfg/doc/templates/README.mdt b/lucicfg/doc/templates/README.mdt
index 4e98045..4287a4b 100644
--- a/lucicfg/doc/templates/README.mdt
+++ b/lucicfg/doc/templates/README.mdt
@@ -18,11 +18,12 @@
 {{end}}
 
 {{$sym.Doc.Description | LinkifySymbols}}
-
+{{if $sym.Doc.Args}}
 #### Arguments {#{{$sym.Anchor "args"}}}
 {{range $sym.Doc.Args}}
 * **{{.Name | EscapeMD}}**: {{.Desc | LinkifySymbols}}
 {{- end}}
+{{- end}}
 
 {{if $sym.Doc.Returns}}
 #### Returns  {#{{$sym.Anchor "returns"}}}
@@ -72,7 +73,7 @@
 ### Defining cron schedules {#schedules_doc}
 {{template "todo"}}
 
-## Configuring lucicfg itself
+## Configuring and inspecting lucicfg itself
 {{template "gen-funcs-doc" $meta}}
 
 ## Working with time
diff --git a/lucicfg/starlark/assets.gen.go b/lucicfg/starlark/assets.gen.go
index 5b73f36..e7ecfcd 100644
--- a/lucicfg/starlark/assets.gen.go
+++ b/lucicfg/starlark/assets.gen.go
@@ -6258,11 +6258,21 @@
 		101, 116, 95, 109, 101, 116, 97, 40, 39, 102, 97, 105, 108, 95,
 		111, 110, 95, 119, 97, 114, 110, 105, 110, 103, 115, 39, 44, 32,
 		102, 97, 105, 108, 95, 111, 110, 95, 119, 97, 114, 110, 105, 110,
-		103, 115, 41, 10, 10, 10, 35, 32, 80, 117, 98, 108, 105, 99,
-		32, 65, 80, 73, 46, 10, 10, 109, 101, 116, 97, 32, 61, 32,
-		115, 116, 114, 117, 99, 116, 40, 10, 32, 32, 32, 32, 99, 111,
-		110, 102, 105, 103, 32, 61, 32, 95, 99, 111, 110, 102, 105, 103,
-		44, 10, 41, 10}),
+		103, 115, 41, 10, 10, 10, 100, 101, 102, 32, 95, 118, 101, 114,
+		115, 105, 111, 110, 40, 41, 58, 10, 32, 32, 34, 34, 34, 82,
+		101, 116, 117, 114, 110, 115, 32, 97, 32, 116, 114, 105, 112, 108,
+		101, 32, 119, 105, 116, 104, 32, 108, 117, 99, 105, 99, 102, 103,
+		32, 118, 101, 114, 115, 105, 111, 110, 58, 32, 96, 40, 109, 97,
+		106, 111, 114, 44, 32, 109, 105, 110, 111, 114, 44, 32, 114, 101,
+		118, 105, 115, 105, 111, 110, 41, 96, 46, 34, 34, 34, 10, 32,
+		32, 114, 101, 116, 117, 114, 110, 32, 95, 95, 110, 97, 116, 105,
+		118, 101, 95, 95, 46, 118, 101, 114, 115, 105, 111, 110, 40, 41,
+		10, 10, 10, 35, 32, 80, 117, 98, 108, 105, 99, 32, 65, 80,
+		73, 46, 10, 10, 109, 101, 116, 97, 32, 61, 32, 115, 116, 114,
+		117, 99, 116, 40, 10, 32, 32, 32, 32, 99, 111, 110, 102, 105,
+		103, 32, 61, 32, 95, 99, 111, 110, 102, 105, 103, 44, 10, 32,
+		32, 32, 32, 118, 101, 114, 115, 105, 111, 110, 32, 61, 32, 95,
+		118, 101, 114, 115, 105, 111, 110, 44, 10, 41, 10}),
 	"stdlib/internal/re.star": string([]byte{35, 32,
 		67, 111, 112, 121, 114, 105, 103, 104, 116, 32, 50, 48, 49, 56,
 		32, 84, 104, 101, 32, 76, 85, 67, 73, 32, 65, 117, 116, 104,
@@ -7778,10 +7788,10 @@
 		129, 162, 164, 88, 181, 159, 2, 243, 41, 227, 175, 87, 253, 96,
 		199, 191, 255, 222, 64, 33, 182, 96, 9, 205, 217, 35, 172, 133,
 		108, 80},
-	"stdlib/internal/meta.star": {238, 223,
-		186, 196, 154, 19, 246, 139, 241, 123, 71, 53, 167, 147, 33, 69,
-		136, 3, 66, 82, 40, 169, 229, 176, 69, 11, 132, 195, 237, 183,
-		155, 86},
+	"stdlib/internal/meta.star": {242, 6,
+		53, 29, 3, 233, 228, 142, 176, 139, 96, 72, 196, 109, 92, 212,
+		100, 131, 153, 50, 56, 147, 173, 1, 85, 147, 212, 44, 3, 88,
+		179, 29},
 	"stdlib/internal/re.star": {4, 123,
 		46, 145, 7, 187, 116, 232, 151, 158, 165, 168, 200, 155, 80, 142,
 		10, 195, 65, 236, 197, 10, 1, 39, 36, 88, 47, 218, 235, 35,
diff --git a/lucicfg/starlark/stdlib/internal/meta.star b/lucicfg/starlark/stdlib/internal/meta.star
index 078f646..7102791 100644
--- a/lucicfg/starlark/stdlib/internal/meta.star
+++ b/lucicfg/starlark/stdlib/internal/meta.star
@@ -79,8 +79,14 @@
     __native__.set_meta('fail_on_warnings', fail_on_warnings)
 
 
+def _version():
+  """Returns a triple with lucicfg version: `(major, minor, revision)`."""
+  return __native__.version()
+
+
 # Public API.
 
 meta = struct(
     config = _config,
+    version = _version,
 )
diff --git a/lucicfg/testdata/misc/version.star b/lucicfg/testdata/misc/version.star
new file mode 100644
index 0000000..5a0abc3
--- /dev/null
+++ b/lucicfg/testdata/misc/version.star
@@ -0,0 +1,9 @@
+def test_meta_version():
+  ver = meta.version()
+  assert.eq(type(ver), 'tuple')
+  assert.eq(len(ver), 3)
+  for i in ver:
+    assert.eq(type(i), 'int')
+  assert.true(ver >= (1, 0, 0))
+
+test_meta_version()
diff --git a/lucicfg/version.go b/lucicfg/version.go
index 3181132..891334a 100644
--- a/lucicfg/version.go
+++ b/lucicfg/version.go
@@ -14,12 +14,37 @@
 
 package lucicfg
 
+import (
+	"fmt"
+
+	"go.starlark.net/starlark"
+)
+
 const (
 	// Version is the version of lucicfg tool.
 	//
-	// It ends up in CLI output, in generated files and in User-Agent headers.
-	Version = "0.1.0"
+	// It ends up in CLI output and in User-Agent headers.
+	Version = "1.0.0"
 
 	// UserAgent is used for User-Agent header in HTTP requests from lucicfg.
 	UserAgent = "lucicfg v" + Version
 )
+
+func init() {
+	// See //internal/meta.star.
+	declNative("version", func(call nativeCall) (starlark.Value, error) {
+		if err := call.unpack(0); err != nil {
+			return nil, err
+		}
+		var major, minor, rev int
+		_, err := fmt.Sscanf(Version, "%d.%d.%d", &major, &minor, &rev)
+		if err != nil {
+			panic(err)
+		}
+		return starlark.Tuple{
+			starlark.MakeInt(major),
+			starlark.MakeInt(minor),
+			starlark.MakeInt(rev),
+		}, nil
+	})
+}