Skip to content

Commit

Permalink
Amp version output (#612)
Browse files Browse the repository at this point in the history
* commit server,agents,clients, AMP Bootstrap and fixes reports (#519)

* add bootstrap feature to AMP cluster CLI (#306)

* update vendors (huge diff)

* serverless prototype (#539)

* Amp cleanup (#603)

* Fix for issues #547,#561,#565

* minor cleanup

* commit server,agents,clients, AMP Bootstrap and fixes reports (#519)

* add bootstrap feature to AMP cluster CLI (#306)

* update vendors (huge diff)

* serverless prototype (#539)

* Amp version more useful info
  • Loading branch information
subfuzion committed Dec 30, 2016
1 parent 8f26ccb commit e8edb1a
Show file tree
Hide file tree
Showing 289 changed files with 16,250 additions and 2,033 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/amplifier-gateway
/amp-agent
/amp-log-worker
/amp-function-listener
/amp-function-worker
/amp-cluster
/dist
/*.exe
coverage.out
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile.shrink
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ COPY ./amplifier /usr/local/bin/amplifier
COPY ./amp-agent /usr/local/bin/amp-agent
COPY ./amp-log-worker /usr/local/bin/amp-log-worker
COPY ./amplifier-gateway /usr/local/bin/amplifier-gateway
COPY ./amp-function-listener /usr/local/bin/amp-function-listener
COPY ./amp-function-worker /usr/local/bin/amp-function-worker
COPY ./adm-server /usr/local/bin/adm-server
COPY ./adm-agent /usr/local/bin/adm-agent
EXPOSE 50101
ENTRYPOINT []
CMD [ "amplifier" ]
80 changes: 64 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DIRS = $(shell find . -type d $(EXCLUDE_DIRS_FILTER))
# generated file dependencies for proto rule
PROTOFILES := $(shell find . \( -path ./vendor -o -path ./.git -o -path ./.glide -o -path ./tests \) -prune -o -type f -name '*.proto' -print)
PROTOTARGETS := $(PROTOFILES:.proto=.pb.go)
PROTOGWTARGETS := api/rpc/logs/logs.pb.gw.go api/rpc/service/service.pb.gw.go api/rpc/stack/stack.pb.gw.go api/rpc/stats/stats.pb.gw.go api/rpc/topic/topic.pb.gw.go
PROTOGWTARGETS := api/rpc/logs/logs.pb.gw.go api/rpc/service/service.pb.gw.go api/rpc/stack/stack.pb.gw.go api/rpc/stats/stats.pb.gw.go api/rpc/topic/topic.pb.gw.go api/rpc/function/function.pb.gw.go api/rpc/version/version.pb.gw.go
PROTOALLTARGETS := $(PROTOTARGETS) $(PROTOGWTARGETS)

# generated files that can be cleaned
Expand All @@ -51,6 +51,11 @@ SERVER := amplifier
AGENT := amp-agent
LOGWORKER := amp-log-worker
GATEWAY := amplifier-gateway
FUNCTION_LISTENER := amp-function-listener
FUNCTION_WORKER := amp-function-worker
CLUSTERSERVER := adm-server
CLUSTERAGENT := adm-agent
AMPADM := ampadm

TAG ?= latest
IMAGE := $(OWNER)/amp:$(TAG)
Expand Down Expand Up @@ -104,6 +109,10 @@ install-host: proto-host
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(AGENT)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(LOGWORKER)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(GATEWAY)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(FUNCTION_LISTENER)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(FUNCTION_WORKER)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(CLUSTERSERVER)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(CLUSTERAGENT)

proto: $(PROTOALLTARGETS)

Expand All @@ -121,11 +130,15 @@ bin-clean:
@rm -f $$(which $(AGENT)) ./$(AGENT)
@rm -f $$(which $(LOGWORKER)) ./$(LOGWORKER)
@rm -f $$(which $(GATEWAY)) ./$(GATEWAY)
@rm -f $$(which $(FUNCTION_LISTENER)) ./$(FUNCTION_LISTENER)
@rm -f $$(which $(FUNCTION_WORKER)) ./$(FUNCTION_WORKER)
@rm -f $$(which $(CLUSTERSERVER)) ./$(CLUSTERSERVER)
@rm -f $$(which $(CLUSTERAGENT)) ./$(CLUSTERAGENT)
@rm -f *.exe

clean: proto-clean bin-clean

install: install-cli install-server install-agent install-log-worker install-gateway
install: install-cli install-server install-agent install-log-worker install-gateway install-fn-listener install-fn-worker install-adm-server install-adm-agent install-ampadm

DATASRC := $(shell find ./data -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
APISRC := $(shell find ./api -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
Expand All @@ -136,6 +149,8 @@ SERVERSRC := $(shell find ./cmd/amplifier -type f -name '*.go' -not -name '*.pb.
AGENTSRC := $(shell find ./cmd/amp-agent -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
LOGWORKERSRC := $(shell find ./cmd/amp-log-worker -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
GATEWAYSRC := $(shell find ./cmd/amplifier-gateway -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
FUNCTIONLISTENERSRC := $(shell find ./cmd/amp-function-listener -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
FUNCTIONWORKERSRC := $(shell find ./cmd/amp-function-worker -type f -name '*.go' -not -name '*.pb.go' -not -name '*.pb.gw.go')
install-cli: $(CLISRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(CLI)
install-server: $(SERVERSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
Expand All @@ -146,8 +161,18 @@ install-log-worker: $(LOGWORKERSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALL
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(LOGWORKER)
install-gateway: $(GATEWAYSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(GATEWAY)

build: build-cli build-server build-agent build-log-worker build-gateway
install-fn-listener: $(FUNCTIONLISTENERSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(FUNCTION_LISTENER)
install-fn-worker: $(FUNCTIONWORKERSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(FUNCTION_WORKER)
install-adm-server: $(GATEWAYSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(CLUSTERSERVER)
install-adm-agent: $(GATEWAYSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(CLUSTERAGENT)
install-ampadm: $(GATEWAYSRC) $(DATASRC) $(APISRC) $(VENDORSRC) $(PROTOALLTARGETS)
@go install $(LDFLAGS) $(REPO)/$(CMDDIR)/$(AMPADM)

build: build-cli build-server build-agent build-log-worker build-gateway build-fn-listener build-fn-worker build-adm-server build-adm-agent build-ampadm

build-cli: proto $(CLISRC) $(APISRC) $(VENDORSRC) Makefile
@hack/build $(CLI)
Expand All @@ -159,48 +184,70 @@ build-log-worker: proto
@hack/build $(LOGWORKER)
build-gateway: proto
@hack/build $(GATEWAY)
build-adm-server: proto
@hack/build $(CLUSTERSERVER)
build-adm-agent: proto
@hack/build $(CLUSTERAGENT)
build-ampadm: proto
@hack/build $(CLUSTERADM)
build-fn-listener: proto
@hack/build $(FUNCTION_LISTENER)
build-fn-worker: proto
@hack/build $(FUNCTION_WORKER)

build-server-image:
@docker build --build-arg BUILD=$(BUILD) -t appcelerator/$(SERVER):$(TAG) .

build-cli-linux:
@rm -f $(CLI)
@env GOOS=linux GOARCH=amd64 VERSION=$(VERSION) hack/build $(CLI)
@env GOOS=linux GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(CLI)

build-cli-darwin:
@rm -f $(CLI)
@env GOOS=darwin GOARCH=amd64 VERSION=$(VERSION) hack/build $(CLI)
@env GOOS=darwin GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(CLI)

build-cli-windows:
@rm -f $(CLI).exe
@env GOOS=windows GOARCH=amd64 VERSION=$(VERSION) hack/build $(CLI)
@env GOOS=windows GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(CLI)

build-server-linux:
@rm -f $(SERVER)
@env GOOS=linux GOARCH=amd64 VERSION=$(VERSION) hack/build $(SERVER)
@env GOOS=linux GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(SERVER)

build-server-darwin:
@rm -f $(SERVER)
@env GOOS=darwin GOARCH=amd64 VERSION=$(VERSION) hack/build $(SERVER)
@env GOOS=darwin GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(SERVER)

build-server-windows:
@rm -f $(SERVER).exe
@env GOOS=windows GOARCH=amd64 VERSION=$(VERSION) hack/build $(SERVER)
@env GOOS=windows GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(SERVER)

build-ampadm-linux:
@rm -f $(AMPADM)
@env GOOS=linux GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(AMPADM)

build-ampadm-darwin:
@rm -f $(AMPADM)
@env GOOS=darwin GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(AMPADM)

build-ampadm-windows:
@rm -f $(AMPADM).exe
@env GOOS=windows GOARCH=amd64 VERSION=$(VERSION) BUILD=$(BUILD) hack/build $(AMPADM)

dist-linux: build-cli-linux build-server-linux
dist-linux: build-cli-linux build-server-linux build-ampadm-linux
@rm -f dist/Linux/x86_64/amp-$(VERSION).tgz
@mkdir -p dist/Linux/x86_64
@tar czf dist/Linux/x86_64/amp-$(VERSION).tgz $(CLI) $(SERVER)
@tar czf dist/Linux/x86_64/amp-$(VERSION).tgz $(CLI) $(SERVER) $(AMPADM)

dist-darwin: build-cli-darwin build-server-darwin
dist-darwin: build-cli-darwin build-server-darwin build-ampadm-darwin
@rm -f dist/Darwin/x86_64/amp-$(VERSION).tgz
@mkdir -p dist/Darwin/x86_64
@tar czf dist/Darwin/x86_64/amp-$(VERSION).tgz $(CLI) $(SERVER)
@tar czf dist/Darwin/x86_64/amp-$(VERSION).tgz $(CLI) $(SERVER) $(AMPADM)

dist-windows: build-cli-windows build-server-windows
dist-windows: build-cli-windows build-server-windows build-ampadm-windows
@rm -f dist/Windows/x86_64/amp-$(VERSION).zip
@mkdir -p dist/Windows/x86_64
@zip -q dist/Windows/x86_64/amp-$(VERSION).zip $(CLI).exe $(SERVER).exe
@zip -q dist/Windows/x86_64/amp-$(VERSION).zip $(CLI).exe $(SERVER).exe $(AMPADM).exe

dist: dist-linux dist-darwin dist-windows

Expand Down Expand Up @@ -231,6 +278,7 @@ test-unit:

test-integration:
@docker service rm amp-integration-test > /dev/null 2>&1 || true
@docker build -t appcelerator/amp-demo-function examples/functions/demo-function
@docker build --build-arg BUILD=$(BUILD) -t appcelerator/amp-integration-test .
@docker service create --network amp-infra --name amp-integration-test --restart-condition none appcelerator/amp-integration-test make BUILD=$(BUILD) test-integration-host
@containerid=""; \
Expand Down
15 changes: 8 additions & 7 deletions api/client/amp.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ func (l logger) Println(args ...interface{}) {

// Configuration is for all configurable client settings
type Configuration struct {
Verbose bool
Github string
Target string
Images []string
Port string
ServerAddress string
CmdTheme string
Verbose bool
Github string
Target string
Images []string
Port string
ServerAddress string
AdminServerAddress string
CmdTheme string
}

// AMP holds the state for the current environment
Expand Down
80 changes: 80 additions & 0 deletions api/rpc/function/function.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package function

import (
"github.com/appcelerator/amp/config"
"github.com/appcelerator/amp/data/storage"
"github.com/appcelerator/amp/pkg/nats-streaming"
"github.com/docker/docker/pkg/stringid"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"log"
"path"
"strings"
)

// Server is used to implement function.FunctionServer
type Server struct {
Store storage.Interface
NatsStreaming ns.NatsStreaming
}

// Create implements function.Server
func (s *Server) Create(ctx context.Context, in *CreateRequest) (*CreateReply, error) {
log.Println("rpc-function: Create", in.String())
// Validate the function
fn := in.Function
fn.Name = strings.TrimSpace(fn.Name)
fn.Image = strings.TrimSpace(fn.Image)
if fn.Name == "" {
return nil, grpc.Errorf(codes.InvalidArgument, "function name is mandatory")
}
if fn.Image == "" {
return nil, grpc.Errorf(codes.InvalidArgument, "docker image is mandatory")
}

// Check if the function already exists
reply, err := s.List(ctx, &ListRequest{})
if err != nil {
return nil, grpc.Errorf(codes.Internal, "error listing functions: %v, err")
}
for _, fn := range reply.Functions {
if strings.EqualFold(fn.Name, in.Function.Name) {
return nil, grpc.Errorf(codes.AlreadyExists, "function already exists: %s", in.Function.Name)
}
}

// Store the function
fn.Id = stringid.GenerateNonCryptoID()
if err := s.Store.Create(ctx, path.Join(amp.EtcdFunctionRootKey, fn.Id), fn, nil, 0); err != nil {
return nil, grpc.Errorf(codes.Internal, "error creating function: %v", err)
}
log.Println("Created function:", fn.String())
return &CreateReply{Function: fn}, nil
}

// List implements function.Server
func (s *Server) List(ctx context.Context, in *ListRequest) (*ListReply, error) {
log.Println("rpc-function: List", in.String())
var functions []proto.Message
if err := s.Store.List(ctx, amp.EtcdFunctionRootKey, storage.Everything, &FunctionEntry{}, &functions); err != nil {
return nil, grpc.Errorf(codes.Internal, "error listing functions: %v", err)
}
reply := &ListReply{}
for _, function := range functions {
reply.Functions = append(reply.Functions, function.(*FunctionEntry))
}
log.Println("Listed functions")
return reply, nil
}

// Delete implements function.Server
func (s *Server) Delete(ctx context.Context, in *DeleteRequest) (*DeleteReply, error) {
log.Println("rpc-function: Delete", in.String())
if err := s.Store.Delete(ctx, path.Join(amp.EtcdFunctionRootKey, in.Id), false, nil); err != nil {
return nil, grpc.Errorf(codes.NotFound, "function not found: %s", in.Id)
}
log.Println("Deleted function id: ", in.Id)
return &DeleteReply{}, nil
}
Loading

0 comments on commit e8edb1a

Please sign in to comment.