-
Notifications
You must be signed in to change notification settings - Fork 647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix docs and add a validator tool for our api docs #850
Conversation
b954d80
to
a10d11e
Compare
a10d11e
to
88b5184
Compare
docs/validator.go
Outdated
exec.Command("gofmt", cmdArgs...).Run() | ||
|
||
cmdArgs = []string{"-w", testFilePath} | ||
exec.Command("goimports", cmdArgs...).Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation fails for FGetEncryptedObject
, looks like encrypt
is not getting imported
Failed to validate code at docs/API.md:18247
// Generate a master symmetric key
key := encrypt.NewSymmetricKey([]byte("my-secret-key-00"))
// Build the CBC encryption material
cbcMaterials, err := encrypt.NewCBCSecureMaterials(key)
if err != nil {
fmt.Println(err)
return
}
err = minioClient.FGetEncryptedObject("mybucket", "myobject", "/tmp/myobject", cbcMaterials)
if err != nil {
fmt.Println(err)
return
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It runs fine on CI looks like you have a local issue, goimports
has a bug btw it stops scanning imports if it reaches a directory which it cannot access.
Go to the directory and check manually what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goimports has a bug btw it stops scanning imports if it reaches a directory which it cannot access.
This is what I faced.
Go to the directory and check manually what is going on.
will do
docs/validator.go
Outdated
fmt.Printf("Failed to validate code at %s:%d\n%s", docPath, p.Pos, p.Text) | ||
os.Exit(255) | ||
} | ||
fmt.Printf("Successfully validated %s code at %s:%d\n", p.Lang, docPath, p.Pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.Pos is a little confusing, not clear what position it is referring to
Successfully validated go code at docs/API.md:7695
Successfully validated go code at docs/API.md:8261
Successfully validated go code at docs/API.md:8847
Successfully validated go code at docs/API.md:9279
Successfully validated go code at docs/API.md:10467
Successfully validated go code at docs/API.md:11698
Successfully validated go code at docs/API.md:13270
Successfully validated go code at docs/API.md:14553
Successfully validated go code at docs/API.md:15424
Successfully validated go code at docs/API.md:16389
Successfully validated go code at docs/API.md:17463
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A position is the position in file with number of characters. It doesn't equate to line number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in that case, I dont feel it adds any value, can we remove it?
88b5184
to
fad67d4
Compare
docs/validator.go
Outdated
) | ||
|
||
var templateMain = ` | ||
// +build ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text can be in separate file like checker.go.template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
67d3a06
to
4c98239
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and Tested
@balamurugana can you review this again? |
docs/checker.go.tpl
Outdated
@@ -0,0 +1,23 @@ | |||
// +build ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I think this line can be removed.
-
tpl
extension is too limited. IMO we would have fully expanded.template
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot remove build ignore, it is needed to avoid conflicting with other packages
in current directory .tpl is acceptable name most projects like hugo etc support this. We don't need to call it .template
@@ -0,0 +1,167 @@ | |||
// +build ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should build on make
to ensure its compiling all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no make
in minio-go, We ensure by running on travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a make in minio-go
Name: "skip", | ||
Value: 2, | ||
Usage: "Skip entries before validating the code.", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would need to have a template like mc --help
to show how this can be used with examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add that.
docs/validator.go
Outdated
entryN++ | ||
|
||
cmdArgs := []string{"-s", "-w", "-l", testFilePath} | ||
exec.Command("gofmt", cmdArgs...).Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have a function or closure hide this logic here. This way you could have cmdArgs globally. If available I prefer long option than short option for readability (if available)
function runGofmt(string testFilePath) {
...
}
docs/validator.go
Outdated
exec.Command("gofmt", cmdArgs...).Run() | ||
|
||
cmdArgs = []string{"-w", testFilePath} | ||
exec.Command("goimports", cmdArgs...).Run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
docs/validator.go
Outdated
|
||
// Go build current directory | ||
cmdArgs = []string{"build", "-o", testBinPath, testFilePath} | ||
if cerr := exec.Command("go", cmdArgs...).Run(); cerr != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
I think we don't need have args -o testBinPath
. This intention here is to check whether testFilePath
compiles are not.
Also we would need to show compilation error if any. This way we know what exact problem in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-o builds a binary with right name. Compilation error is displayed with the cerr.
f4ae19d
to
9a79ce3
Compare
Can you review this again Bala? |
a152b6b
to
882ec87
Compare
PR is updated @balamurugana please check. |
882ec87
to
340f70f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,17 @@ | |||
all: checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.