Skip to content

Commit

Permalink
Reorganize all CLIs into a separate dir. Add stubs for executor and a…
Browse files Browse the repository at this point in the history
…piserver
  • Loading branch information
jessesuen committed Oct 19, 2017
1 parent 74baac7 commit 8137021
Show file tree
Hide file tree
Showing 16 changed files with 134 additions and 98 deletions.
5 changes: 5 additions & 0 deletions Dockerfile-executor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:9.1

COPY dist/argo-executor /bin/

ENTRYPOINT [ "/bin/argo-executor" ]
30 changes: 24 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ BUILDER_IMAGE=argo-builder
BUILDER_CMD=docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} ${BUILDER_IMAGE}

# Build the project
all: lint cli-linux cli-darwin workflow workflow-image apiserver
all: lint cli-linux cli-darwin workflow-image apiserver-image executor-image

builder:
cd ${BUILD_DIR}; \
Expand All @@ -26,7 +26,7 @@ builder:

cli:
cd ${BUILD_DIR}; \
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/argo ./cli ; \
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/argo ./cmd/argo ; \
cd - >/dev/null

cli-linux: builder
Expand All @@ -37,12 +37,12 @@ cli-linux: builder

cli-darwin:
cd ${BUILD_DIR}; \
GOOS=darwin GOARCH=${GOARCH} go build -v ${LDFLAGS} -o ${DIST_DIR}/argocli/${GOOS}-${GOARCH}/argo ./cli ; \
GOOS=darwin GOARCH=${GOARCH} go build -v ${LDFLAGS} -o ${DIST_DIR}/argocli/${GOOS}-${GOARCH}/argo ./cmd/argo ; \
cd - >/dev/null

apiserver:
cd ${BUILD_DIR}; \
go build -i ${LDFLAGS} -o ${DIST_DIR}/argo-apiserver ./apiserver ; \
go build -i ${LDFLAGS} -o ${DIST_DIR}/argo-apiserver ./cmd/argo-apiserver ; \
cd - >/dev/null

apiserver-linux: builder
Expand All @@ -55,7 +55,7 @@ apiserver-image: apiserver-linux

workflow:
cd ${BUILD_DIR}; \
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/workflow-controller ./workflow ; \
go build -v -i ${LDFLAGS} -o ${DIST_DIR}/workflow-controller ./cmd/workflow-controller ; \
cd - >/dev/null

workflow-linux: builder
Expand All @@ -66,6 +66,19 @@ workflow-image: workflow-linux
docker build -f Dockerfile-workflow-controller . ; \
cd - >/dev/null

executor:
cd ${BUILD_DIR}; \
go build -i ${LDFLAGS} -o ${DIST_DIR}/argo-executor ./cmd/argo-executor ; \
cd - >/dev/null

executor-linux: builder
${BUILDER_CMD} make executor

executor-image: executor-linux
cd ${BUILD_DIR}; \
docker build -f Dockerfile-executor . ; \
cd - >/dev/null

test:
if ! hash go2xunit 2>/dev/null; then go install github.com/tebeka/go2xunit; fi
cd ${BUILD_DIR}; \
Expand All @@ -85,4 +98,9 @@ fmt:
clean:
-rm -rf ${BUILD_DIR}/dist

.PHONY: builder cli cli-linux cli-darwin workflow workflow-image apiserver lint test fmt clean
.PHONY: builder \
cli cli-linux cli-darwin \
workflow workflow-linux workflow-image \
apiserver apiserver-linux apiserver-image \
executor executor-linux executor-image \
lint test fmt clean
14 changes: 0 additions & 14 deletions apiserver/cmd/root.go

This file was deleted.

25 changes: 0 additions & 25 deletions apiserver/cmd/version.go

This file was deleted.

26 changes: 0 additions & 26 deletions apiserver/main.go

This file was deleted.

1 change: 1 addition & 0 deletions apiserver/router.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package apiserver
2 changes: 2 additions & 0 deletions apiserver/schema/schema.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package schema contains the database schema for Argo backend
package schema
25 changes: 0 additions & 25 deletions cli/cmd/version.go

This file was deleted.

34 changes: 34 additions & 0 deletions cmd/argo-apiserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"fmt"
"os"

"github.com/argoproj/argo/util/cmd"
"github.com/spf13/cobra"
)

const (
// CLIName is the name of the CLI
CLIName = "argo-apiserver"
)

// RootCmd is the root level command
var RootCmd = &cobra.Command{
Use: CLIName,
Short: "Argo API Server",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
}

func init() {
RootCmd.AddCommand(cmd.NewVersionCmd(CLIName))
}

func main() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
34 changes: 34 additions & 0 deletions cmd/argo-executor/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package main

import (
"fmt"
"os"

"github.com/argoproj/argo/util/cmd"
"github.com/spf13/cobra"
)

const (
// CLIName is the name of the CLI
CLIName = "argo-executor"
)

// RootCmd is the root level command
var RootCmd = &cobra.Command{
Use: CLIName,
Short: "Argo Container Executor",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
}

func init() {
RootCmd.AddCommand(cmd.NewVersionCmd(CLIName))
}

func main() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
12 changes: 11 additions & 1 deletion cli/cmd/root.go → cmd/argo/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package cmd

import (
"github.com/argoproj/argo/util/cmd"
"github.com/spf13/cobra"
)

const (
// CLIName is the name of the CLI
CLIName = "argo"
)

func init() {
RootCmd.AddCommand(cmd.NewVersionCmd(CLIName))
}

// RootCmd is the argo root level command
var RootCmd = &cobra.Command{
Use: "argo",
Use: CLIName,
Short: "argo is the command line interface to Argo",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
Expand Down
2 changes: 1 addition & 1 deletion cli/main.go → cmd/argo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"os"

"github.com/argoproj/argo/cli/cmd"
"github.com/argoproj/argo/cmd/argo/cmd"
)

func main() {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions executor/executor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package executor
21 changes: 21 additions & 0 deletions util/cmd/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Package cmd provides functionally common to various argo CLIs

package cmd

import (
"fmt"

"github.com/argoproj/argo"
"github.com/spf13/cobra"
)

// NewVersionCmd returns a new `version` command to be used as a sub-command to root
func NewVersionCmd(cliName string) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: fmt.Sprintf("Print version information"),
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s version %s\n", cliName, argo.FullVersion)
},
}
}
File renamed without changes.

0 comments on commit 8137021

Please sign in to comment.