Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
828769b8
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
828769b8
编写于
2月 24, 2021
作者:
M
Medya Ghazizadeh
提交者:
GitHub
2月 24, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10606 from spowelljr/fixOutOfRange
Check for args length to prevent out of bounds panic
上级
a4d35d56
c50bdaab
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
2 deletion
+21
-2
cmd/minikube/main.go
cmd/minikube/main.go
+1
-1
pkg/minikube/audit/audit.go
pkg/minikube/audit/audit.go
+1
-1
pkg/minikube/audit/audit_test.go
pkg/minikube/audit/audit_test.go
+10
-0
test/integration/main_test.go
test/integration/main_test.go
+9
-0
未找到文件。
cmd/minikube/main.go
浏览文件 @
828769b8
...
...
@@ -158,7 +158,7 @@ func setFlags() {
// setLastStartFlags sets the log_file flag to lastStart.txt if start command and user doesn't specify log_file or log_dir flags.
func
setLastStartFlags
()
{
if
os
.
Args
[
1
]
!=
"start"
{
if
len
(
os
.
Args
)
<
2
||
os
.
Args
[
1
]
!=
"start"
{
return
}
if
pflag
.
CommandLine
.
Changed
(
"log_file"
)
||
pflag
.
CommandLine
.
Changed
(
"log_dir"
)
{
...
...
pkg/minikube/audit/audit.go
浏览文件 @
828769b8
...
...
@@ -52,7 +52,7 @@ func args() string {
// Log details about the executed command.
func
Log
(
startTime
time
.
Time
)
{
if
!
shouldLog
()
{
if
len
(
os
.
Args
)
<
2
||
!
shouldLog
()
{
return
}
r
:=
newRow
(
os
.
Args
[
1
],
args
(),
userName
(),
version
.
GetVersion
(),
startTime
,
time
.
Now
())
...
...
pkg/minikube/audit/audit_test.go
浏览文件 @
828769b8
...
...
@@ -20,6 +20,7 @@ import (
"os"
"os/user"
"testing"
"time"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/config"
...
...
@@ -167,4 +168,13 @@ func TestAudit(t *testing.T) {
}
}
})
// Check if logging with limited args causes a panic
t
.
Run
(
"Log"
,
func
(
t
*
testing
.
T
)
{
oldArgs
:=
os
.
Args
defer
func
()
{
os
.
Args
=
oldArgs
}()
os
.
Args
=
[]
string
{
"minikube"
}
Log
(
time
.
Now
())
})
}
test/integration/main_test.go
浏览文件 @
828769b8
...
...
@@ -17,10 +17,12 @@ limitations under the License.
package
integration
import
(
"context"
"flag"
"fmt"
"math"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
...
...
@@ -62,6 +64,13 @@ func TestMain(m *testing.M) {
os
.
Exit
(
code
)
}
func
TestMainNoArgs
(
t
*
testing
.
T
)
{
rr
,
err
:=
Run
(
t
,
exec
.
CommandContext
(
context
.
Background
(),
Target
()))
if
err
!=
nil
{
t
.
Fatalf
(
"failed running minikube with no args %q: %v"
,
rr
.
Command
(),
err
)
}
}
// setMaxParallelism caps the max parallelism. Go assumes 1 core per test, whereas minikube needs 2 cores per test.
func
setMaxParallelism
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录