Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Ijaz Ahmad
ksonnet
Commits
08946ced
Unverified
Commit
08946ced
authored
Apr 26, 2018
by
Bryan Liles
Committed by
GitHub
Apr 26, 2018
Browse files
Merge pull request #490 from bryanl/print-array-comp
update ksonnet lib printer with array comprehensions
parents
7692a499
d2b0df05
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
8 deletions
+31
-8
Gopkg.lock
Gopkg.lock
+3
-3
Gopkg.toml
Gopkg.toml
+1
-1
pkg/pipeline/pipeline.go
pkg/pipeline/pipeline.go
+2
-0
vendor/github.com/ksonnet/ksonnet-lib/ksonnet-gen/printer/printer.go
...ub.com/ksonnet/ksonnet-lib/ksonnet-gen/printer/printer.go
+25
-4
No files found.
Gopkg.lock
View file @
08946ced
...
...
@@ -276,8 +276,8 @@
"ksonnet-gen/nodemaker",
"ksonnet-gen/printer"
]
revision = "
6f85269d8cc77d49df665ea240f57dc0de1e7abc
"
version = "v0.1.
0
"
revision = "
cd6bc29c939b79f8e3acdd289356b8fbebf09c50
"
version = "v0.1.
1
"
[[projects]]
name = "github.com/magiconair/properties"
...
...
@@ -683,6 +683,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "
f761dfa7c14879995a07e46c07d35dd95db79cc363e6b7be4310076b7d6d2077
"
inputs-digest = "
52b150f1b6dc5cb0b070e3161194ab302ed6a524834e6dd5177a4c40b64c63bb
"
solver-name = "gps-cdcl"
solver-version = 1
Gopkg.toml
View file @
08946ced
...
...
@@ -50,7 +50,7 @@
[[constraint]]
name
=
"github.com/ksonnet/ksonnet-lib"
version
=
"v0.1.
0
"
version
=
"v0.1.
1
"
[[constraint]]
name
=
"github.com/mattn/go-isatty"
...
...
pkg/pipeline/pipeline.go
View file @
08946ced
...
...
@@ -18,6 +18,7 @@ package pipeline
import
(
"bytes"
"encoding/json"
"fmt"
"io"
"path/filepath"
"regexp"
...
...
@@ -221,6 +222,7 @@ func (p *Pipeline) moduleObjects(module component.Module, filter []string) ([]*u
uns
,
_
,
err
:=
unstructured
.
UnstructuredJSONScheme
.
Decode
([]
byte
(
patched
),
nil
,
nil
)
if
err
!=
nil
{
fmt
.
Println
(
patched
)
return
nil
,
errors
.
Wrap
(
err
,
"decode unstructured"
)
}
ret
=
append
(
ret
,
uns
)
...
...
vendor/github.com/ksonnet/ksonnet-lib/ksonnet-gen/printer/printer.go
View file @
08946ced
...
...
@@ -146,6 +146,8 @@ func (p *printer) print(n interface{}) {
}
}
p
.
writeString
(
"]"
)
case
*
ast
.
ArrayComp
:
p
.
handleArrayComp
(
t
)
case
*
ast
.
Binary
:
p
.
print
(
t
.
Left
)
p
.
writeByte
(
space
,
1
)
...
...
@@ -157,7 +159,10 @@ func (p *printer) print(n interface{}) {
case
*
ast
.
Conditional
:
p
.
handleConditional
(
t
)
case
*
ast
.
Function
:
p
.
writeString
(
"function"
)
p
.
addMethodSignature
(
t
)
p
.
writeString
(
" "
)
p
.
print
(
t
.
Body
)
case
*
ast
.
Import
:
p
.
writeString
(
"import "
)
p
.
print
(
t
.
File
)
...
...
@@ -336,7 +341,7 @@ func (p *printer) handleLocal(l *ast.Local) {
p
.
print
(
bind
.
Body
)
p
.
writeString
(
";"
)
case
*
ast
.
Function
:
p
.
print
(
bind
.
Body
)
p
.
addMethodSignature
(
bodyType
)
p
.
handleLocalFunction
(
bodyType
)
}
c
:=
1
...
...
@@ -389,6 +394,23 @@ func (p *printer) handleObjectComp(oc *ast.ObjectComp) {
p
.
handleObjectField
(
oc
)
}
func
(
p
*
printer
)
handleArrayComp
(
ac
*
ast
.
ArrayComp
)
{
p
.
writeString
(
"["
)
p
.
indentLevel
++
p
.
writeByte
(
newline
,
1
)
p
.
print
(
ac
.
Body
)
p
.
writeByte
(
newline
,
1
)
p
.
forSpec
(
ac
.
Spec
)
p
.
indentLevel
--
p
.
writeByte
(
newline
,
1
)
p
.
writeString
(
"]"
)
}
func
(
p
*
printer
)
forSpec
(
spec
ast
.
ForSpec
)
{
p
.
writeString
(
fmt
.
Sprintf
(
"for %s in "
,
string
(
spec
.
VarName
)))
p
.
print
(
spec
.
Expr
)
}
func
(
p
*
printer
)
handleObjectField
(
n
interface
{})
{
var
ofHide
ast
.
ObjectFieldHide
var
ofKind
ast
.
ObjectFieldKind
...
...
@@ -451,7 +473,7 @@ func (p *printer) handleObjectField(n interface{}) {
switch
ofKind
{
default
:
p
.
err
=
errors
.
Errorf
(
"unknown Kind type
%#v"
,
ofKind
)
p
.
err
=
errors
.
Errorf
(
"unknown Kind type
(%T) %#v"
,
ofKind
,
ofKind
)
return
case
ast
.
ObjectFieldID
:
p
.
writeString
(
ofID
)
...
...
@@ -499,8 +521,7 @@ func (p *printer) handleObjectField(n interface{}) {
p
.
print
(
ofExpr2
)
p
.
writeByte
(
comma
,
1
)
p
.
writeByte
(
space
,
1
)
p
.
writeString
(
fmt
.
Sprintf
(
"for %s in "
,
string
(
forSpec
.
VarName
)))
p
.
print
(
forSpec
.
Expr
)
p
.
forSpec
(
forSpec
)
p
.
indentLevel
--
p
.
writeByte
(
newline
,
1
)
p
.
writeString
(
"}"
)
...
...
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