Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
16bf8c40
Commit
16bf8c40
authored
Jul 13, 2016
by
Wojciech Tyczynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify logging in generators and avoid annoying logs.
parent
89be0393
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
main.go
cmd/libs/go2idl/client-gen/main.go
+2
-3
execute.go
cmd/libs/go2idl/generator/execute.go
+5
-4
import_restrict.go
cmd/libs/go2idl/import-boss/generators/import_restrict.go
+6
-4
parse.go
cmd/libs/go2idl/parser/parse.go
+4
-4
No files found.
cmd/libs/go2idl/client-gen/main.go
View file @
16bf8c40
...
...
@@ -20,14 +20,13 @@ package main
import
(
"fmt"
"path/filepath"
"strings"
"k8s.io/kubernetes/cmd/libs/go2idl/args"
clientgenargs
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators"
"k8s.io/kubernetes/pkg/api/unversioned"
"strings"
"github.com/golang/glog"
flag
"github.com/spf13/pflag"
)
...
...
@@ -182,7 +181,7 @@ func main() {
IncludedTypesOverrides
:
includedTypesOverrides
,
}
fmt
.
Print
f
(
"==arguments: %v
\n
"
,
arguments
)
glog
.
Info
f
(
"==arguments: %v
\n
"
,
arguments
)
}
if
err
:=
arguments
.
Execute
(
...
...
cmd/libs/go2idl/generator/execute.go
View file @
16bf8c40
...
...
@@ -22,13 +22,14 @@ import (
"go/format"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
"k8s.io/kubernetes/cmd/libs/go2idl/namer"
"k8s.io/kubernetes/cmd/libs/go2idl/types"
"github.com/golang/glog"
)
func
errs2strings
(
errors
[]
error
)
[]
string
{
...
...
@@ -63,7 +64,7 @@ type DefaultFileType struct {
}
func
(
ft
DefaultFileType
)
AssembleFile
(
f
*
File
,
pathname
string
)
error
{
log
.
Print
f
(
"Assembling file %q"
,
pathname
)
glog
.
V
(
0
)
.
Info
f
(
"Assembling file %q"
,
pathname
)
destFile
,
err
:=
os
.
Create
(
pathname
)
if
err
!=
nil
{
return
err
...
...
@@ -90,7 +91,7 @@ func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
}
func
(
ft
DefaultFileType
)
VerifyFile
(
f
*
File
,
pathname
string
)
error
{
log
.
Print
f
(
"Verifying file %q"
,
pathname
)
glog
.
V
(
0
)
.
Info
f
(
"Verifying file %q"
,
pathname
)
friendlyName
:=
filepath
.
Join
(
f
.
PackageName
,
f
.
Name
)
b
:=
&
bytes
.
Buffer
{}
et
:=
NewErrorTracker
(
b
)
...
...
@@ -210,7 +211,7 @@ func (c *Context) addNameSystems(namers namer.NameSystems) *Context {
// import path already, this will be appended to 'outDir'.
func
(
c
*
Context
)
ExecutePackage
(
outDir
string
,
p
Package
)
error
{
path
:=
filepath
.
Join
(
outDir
,
p
.
Path
())
log
.
Print
f
(
"Processing package %q, disk location %q"
,
p
.
Name
(),
path
)
glog
.
V
(
0
)
.
Info
f
(
"Processing package %q, disk location %q"
,
p
.
Name
(),
path
)
// Filter out any types the *package* doesn't care about.
packageContext
:=
c
.
filteredBy
(
p
.
Filter
)
os
.
MkdirAll
(
path
,
0755
)
...
...
cmd/libs/go2idl/import-boss/generators/import_restrict.go
View file @
16bf8c40
...
...
@@ -32,6 +32,8 @@ import (
"k8s.io/kubernetes/cmd/libs/go2idl/generator"
"k8s.io/kubernetes/cmd/libs/go2idl/namer"
"k8s.io/kubernetes/cmd/libs/go2idl/types"
"github.com/golang/glog"
)
const
(
...
...
@@ -200,19 +202,19 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
return
fmt
.
Errorf
(
"regexp `%s` in file %q doesn't compile: %v"
,
r
.
SelectorRegexp
,
actualPath
,
err
)
}
for
v
:=
range
f
.
Imports
{
// fmt.Print
f("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
glog
.
V
(
4
)
.
Info
f
(
"Checking %v matches %v: %v
\n
"
,
r
.
SelectorRegexp
,
v
,
re
.
MatchString
(
v
))
if
!
re
.
MatchString
(
v
)
{
continue
}
for
_
,
forbidden
:=
range
r
.
ForbiddenPrefixes
{
// fmt.Print
f("Checking %v against %v\n", v, forbidden)
glog
.
V
(
4
)
.
Info
f
(
"Checking %v against %v
\n
"
,
v
,
forbidden
)
if
strings
.
HasPrefix
(
v
,
forbidden
)
{
return
fmt
.
Errorf
(
"import %v has forbidden prefix %v"
,
v
,
forbidden
)
}
}
found
:=
false
for
_
,
allowed
:=
range
r
.
AllowedPrefixes
{
fmt
.
Print
f
(
"Checking %v against %v
\n
"
,
v
,
allowed
)
glog
.
V
(
0
)
.
Info
f
(
"Checking %v against %v
\n
"
,
v
,
allowed
)
if
strings
.
HasPrefix
(
v
,
allowed
)
{
found
=
true
break
...
...
@@ -224,7 +226,7 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
}
}
if
len
(
rules
.
Rules
)
>
0
{
fmt
.
Print
f
(
"%v passes rules found in %v
\n
"
,
path
,
actualPath
)
glog
.
V
(
0
)
.
Info
f
(
"%v passes rules found in %v
\n
"
,
path
,
actualPath
)
}
return
nil
...
...
cmd/libs/go2idl/parser/parse.go
View file @
16bf8c40
...
...
@@ -79,7 +79,7 @@ func New() *Builder {
// The returned string will have some/path/bin/go, so remove the last two elements.
c
.
GOROOT
=
filepath
.
Dir
(
filepath
.
Dir
(
strings
.
Trim
(
string
(
p
),
"
\n
"
)))
}
else
{
fmt
.
Print
f
(
"Warning: $GOROOT not set, and unable to run `which go` to find it: %v
\n
"
,
err
)
glog
.
Warning
f
(
"Warning: $GOROOT not set, and unable to run `which go` to find it: %v
\n
"
,
err
)
}
}
// Force this to off, since we don't properly parse CGo. All symbols must
...
...
@@ -304,7 +304,7 @@ func (b *Builder) importer(imports map[string]*tc.Package, path string) (*tc.Pac
pkg
,
err
:=
b
.
typeCheckPackage
(
path
)
if
err
!=
nil
{
if
ignoreError
&&
pkg
!=
nil
{
fmt
.
Print
f
(
"type checking encountered some errors in %q, but ignoring.
\n
"
,
path
)
glog
.
V
(
2
)
.
Info
f
(
"type checking encountered some errors in %q, but ignoring.
\n
"
,
path
)
}
else
{
return
nil
,
err
}
...
...
@@ -350,7 +350,7 @@ func (b *Builder) typeCheckPackage(id string) (*tc.Package, error) {
// method. So there can't be cycles in the import graph.
Importer
:
importAdapter
{
b
},
Error
:
func
(
err
error
)
{
fmt
.
Print
f
(
"type checker error: %v
\n
"
,
err
)
glog
.
V
(
2
)
.
Info
f
(
"type checker error: %v
\n
"
,
err
)
},
}
pkg
,
err
:=
c
.
Check
(
id
,
b
.
fset
,
files
,
nil
)
...
...
@@ -685,7 +685,7 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
return
out
}
out
.
Kind
=
types
.
Unsupported
fmt
.
Print
f
(
"Making unsupported type entry %q for: %#v
\n
"
,
out
,
t
)
glog
.
Warning
f
(
"Making unsupported type entry %q for: %#v
\n
"
,
out
,
t
)
return
out
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment