Skip to content

Commit

Permalink
Add support for jq and yq
Browse files Browse the repository at this point in the history
  • Loading branch information
paololazzari committed Oct 12, 2023
1 parent 4b6326a commit 2d437e3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
FROM alpine:3.18.4 as build
COPY --from=golang:1.21-alpine3.18 /usr/local/go/ /usr/local/go/
RUN GOBIN=/usr/local/bin/ /usr/local/go/bin/go install github.com/paololazzari/play@latest
RUN apk add --no-cache wget && \
wget -q https://github.com/stedolan/jq/releases/download/jq-1.7/jq-linux64 && \
mv jq-linux64 /usr/local/bin/jq && \
wget -q https://github.com/mikefarah/yq/releases/download/v4.35.2/yq_linux_amd64 && \
mv yq_linux_amd64 /usr/local/bin/yq

FROM alpine:3.18.4 as main
RUN apk add --no-cache bash=5.2.15-r5 && rm -rf /var/cache/apk/*
COPY --from=build /usr/local/bin/jq /usr/local/bin/jq
COPY --from=build /usr/local/bin/yq /usr/local/bin/yq
COPY --from=build /usr/local/bin/play /usr/local/bin/play
RUN apk add --no-cache bash=5.2.15-r5 && \
rm -rf /var/cache/apk/* && \
chmod +x /usr/local/bin/jq && \
chmod +x /usr/local/bin/yq

COPY --from=build /usr/local/bin/play /usr/local/bin

ENTRYPOINT ["/usr/local/bin/play"]
18 changes: 18 additions & 0 deletions cmd/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ var (
run(program.NewProgram("awk", true))
},
}

jqCmd = &cobra.Command{
Use: "jq",
Short: `Play with jq`,
Run: func(cmd *cobra.Command, args []string) {
run(program.NewProgram("jq", false))
},
}

yqCmd = &cobra.Command{
Use: "yq",
Short: `Play with yq`,
Run: func(cmd *cobra.Command, args []string) {
run(program.NewProgram("yq", false))
},
}
)

func exitWithError(e interface{}) {
Expand Down Expand Up @@ -121,6 +137,8 @@ func init() {
rootCmd.AddCommand(grepCmd)
rootCmd.AddCommand(sedCmd)
rootCmd.AddCommand(awkCmd)
rootCmd.AddCommand(jqCmd)
rootCmd.AddCommand(yqCmd)
rootCmd.AddCommand(completion) // https://github.com/spf13/cobra/issues/1507
}

Expand Down

0 comments on commit 2d437e3

Please sign in to comment.