mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
contrib: fix name and readability, exclude from test
This commit is contained in:
parent
8655d7cd07
commit
363ce1b39a
@ -47,7 +47,7 @@ const usage = "podex [-format=yaml|json] [-type=pod|container] [-id NAME] IMAGES
|
|||||||
|
|
||||||
var manifestFormat = flag.String("format", "yaml", "manifest format to output, `yaml` or `json`")
|
var manifestFormat = flag.String("format", "yaml", "manifest format to output, `yaml` or `json`")
|
||||||
var manifestType = flag.String("type", "pod", "manifest type to output, `pod` or `container`")
|
var manifestType = flag.String("type", "pod", "manifest type to output, `pod` or `container`")
|
||||||
var manifestId = flag.String("id", "", "manifest id, default to image base name")
|
var manifestName = flag.String("name", "", "manifest name, default to image base name")
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
@ -70,12 +70,12 @@ func main() {
|
|||||||
flag.Usage()
|
flag.Usage()
|
||||||
log.Fatal("pod: missing image argument")
|
log.Fatal("pod: missing image argument")
|
||||||
}
|
}
|
||||||
if *manifestId == "" {
|
if *manifestName == "" {
|
||||||
if flag.NArg() > 1 {
|
if flag.NArg() > 1 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
log.Fatal("podex: -id arg is required when passing more than one image")
|
log.Fatal("podex: -id arg is required when passing more than one image")
|
||||||
}
|
}
|
||||||
_, _, *manifestId, _ = splitDockerImageName(flag.Arg(0))
|
_, _, *manifestName, _ = splitDockerImageName(flag.Arg(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
podContainers := []goyaml.MapSlice{}
|
podContainers := []goyaml.MapSlice{}
|
||||||
@ -100,7 +100,12 @@ func main() {
|
|||||||
log.Fatalf("failed to parse port %q: %v", p.Port(), err)
|
log.Fatalf("failed to parse port %q: %v", p.Port(), err)
|
||||||
}
|
}
|
||||||
portEntry := goyaml.MapSlice{{
|
portEntry := goyaml.MapSlice{{
|
||||||
Key: "name", Value: strings.Join([]string{repo, p.Proto(), p.Port()}, "-")}, {Key: "containerPort", Value: port}}
|
Key: "name",
|
||||||
|
Value: strings.Join([]string{repo, p.Proto(), p.Port()}, "-"),
|
||||||
|
}, {
|
||||||
|
Key: "containerPort",
|
||||||
|
Value: port,
|
||||||
|
}}
|
||||||
portSlice = append(portSlice, portEntry)
|
portSlice = append(portSlice, portEntry)
|
||||||
if p.Proto() != "tcp" {
|
if p.Proto() != "tcp" {
|
||||||
portEntry = append(portEntry, goyaml.MapItem{Key: "protocol", Value: strings.ToUpper(p.Proto())})
|
portEntry = append(portEntry, goyaml.MapItem{Key: "protocol", Value: strings.ToUpper(p.Proto())})
|
||||||
@ -123,12 +128,12 @@ func main() {
|
|||||||
switch *manifestType {
|
switch *manifestType {
|
||||||
case "container":
|
case "container":
|
||||||
containerManifest = append(goyaml.MapSlice{
|
containerManifest = append(goyaml.MapSlice{
|
||||||
{Key: "id", Value: *manifestId},
|
{Key: "id", Value: *manifestName},
|
||||||
}, containerManifest...)
|
}, containerManifest...)
|
||||||
data = containerManifest
|
data = containerManifest
|
||||||
case "pod":
|
case "pod":
|
||||||
data = goyaml.MapSlice{
|
data = goyaml.MapSlice{
|
||||||
{Key: "id", Value: *manifestId},
|
{Key: "id", Value: *manifestName},
|
||||||
{Key: "kind", Value: "Pod"},
|
{Key: "kind", Value: "Pod"},
|
||||||
{Key: "apiVersion", Value: "v1beta1"},
|
{Key: "apiVersion", Value: "v1beta1"},
|
||||||
{Key: "desiredState", Value: goyaml.MapSlice{
|
{Key: "desiredState", Value: goyaml.MapSlice{
|
||||||
|
@ -34,6 +34,7 @@ kube::test::find_dirs() {
|
|||||||
-o -wholename './target' \
|
-o -wholename './target' \
|
||||||
-o -wholename '*/third_party/*' \
|
-o -wholename '*/third_party/*' \
|
||||||
-o -wholename '*/Godeps/*' \
|
-o -wholename '*/Godeps/*' \
|
||||||
|
-o -wholename '*/contrib/podex/*' \
|
||||||
\) -prune \
|
\) -prune \
|
||||||
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
|
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user