Skip to content

Commit

Permalink
Add apiserver skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Oct 18, 2017
1 parent 3ed1dfe commit 37b7de8
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.idea/
.DS_Store
vendor/
dist/
dist/
5 changes: 5 additions & 0 deletions Dockerfile-apiserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM debian:9.1

COPY dist/argo-apiserver /bin/

ENTRYPOINT [ "/bin/argo-apiserver" ]
45 changes: 25 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,66 @@ PACKAGE=github.com/argoproj/argo
BUILD_DIR=${GOPATH}/src/${PACKAGE}
DIST_DIR=${GOPATH}/src/${PACKAGE}/dist
CURRENT_DIR=$(shell pwd)
BUILD_DIR_LINK=$(shell readlink ${BUILD_DIR})

VERSION=$(shell cat ${BUILD_DIR}/VERSION)
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)

LDFLAGS = -ldflags "-X ${PACKAGE}.Version=${VERSION} -X ${PACKAGE}.Revision=${COMMIT} -X ${PACKAGE}.Branch=${BRANCH}"

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
all: lint cli-linux cli-darwin workflow workflow-image apiserver

builder:
cd ${BUILD_DIR}; \
docker build -t argo-builder -f Dockerfile-builder . ; \
docker build -t ${BUILDER_IMAGE} -f Dockerfile-builder . ; \
cd - >/dev/null

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

cli-linux: builder
rm -f ${DIST_DIR}/argocli/linux-amd64/argo
docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} argo-builder make cli
${BUILDER_CMD} make cli
mkdir -p ${DIST_DIR}/argocli/linux-amd64
mv ${DIST_DIR}/argo ${DIST_DIR}/argocli/linux-amd64/argo

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

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

apiserver-linux: builder
${BUILDER_CMD} make apiserver

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

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

workflow-linux: builder
docker run --rm -v ${BUILD_DIR}:/root/go/src/${PACKAGE} -w /root/go/src/${PACKAGE} argo-builder make workflow
${BUILDER_CMD} make workflow

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

link:
BUILD_DIR=${BUILD_DIR}; \
BUILD_DIR_LINK=${BUILD_DIR_LINK}; \
CURRENT_DIR=${CURRENT_DIR}; \
if [ "$${BUILD_DIR_LINK}" != "$${CURRENT_DIR}" ]; then \
echo "Fixing symlinks for build"; \
rm -f $${BUILD_DIR}; \
ln -s $${CURRENT_DIR} $${BUILD_DIR}; \
fi

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

.PHONY: builder cli cli-linux cli-darwin workflow workflow-image lint test fmt clean
.PHONY: builder cli cli-linux cli-darwin workflow workflow-image apiserver lint test fmt clean
14 changes: 14 additions & 0 deletions apiserver/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cmd

import (
"github.com/spf13/cobra"
)

// RootCmd is the argo root level command
var RootCmd = &cobra.Command{
Use: "argo-apiserver",
Short: "Argo API Server",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
}
25 changes: 25 additions & 0 deletions apiserver/cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"fmt"

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

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

func init() {
RootCmd.AddCommand(versionCmd)
}

var versionCmd = &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)
},
}
26 changes: 26 additions & 0 deletions apiserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2015-2017 Applatix, Inc. All rights reserved.
package main

import (
"fmt"
"os"

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

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

func main() {
if err := cmd.RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
1 change: 0 additions & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Copyright 2015-2017 Applatix, Inc. All rights reserved.
package main

import (
Expand Down

0 comments on commit 37b7de8

Please sign in to comment.