From c987dcdc2ffb62c2bf30e262ed3a532227f9e835 Mon Sep 17 00:00:00 2001 From: Amir Nagri Date: Wed, 10 Oct 2018 10:57:06 +0530 Subject: [PATCH] [Amir|Praveen] adding support for newly added meta fields - authors, contributors, organization to proctor server and client --- .travis.yml | 3 +- Makefile | 6 ++++ cmd/procs/description/descriptor.go | 2 ++ cmd/procs/description/descriptor_test.go | 2 ++ glide.lock | 10 +++---- glide.yaml | 2 ++ proc/metadata.go | 9 ++++-- proctord/jobs/metadata/handler_test.go | 11 +++++--- proctord/jobs/metadata/metadata.go | 11 +++++--- proctord/jobs/metadata/store_test.go | 36 ++++++++++++++++-------- 10 files changed, 62 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad6d3813..d8e63e7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,8 +55,7 @@ jobs: - go test -race -cover $(glide novendor) # testing proctor cli - cd ../. - - glide install - - go test -race -cover ./cmd/... ./config/... ./io/... ./proc/... ./daemon/... . -v + - make ci.test after_success: - scripts/release.sh diff --git a/Makefile b/Makefile index a8a7118c..77d5f95c 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,12 @@ compile: mkdir -p out/ go build -race $(GLIDE_NOVENDOR) +ci.test: build-deps + ENVIRONMENT=test go test $(shell glide novendor | grep -v proctord) -v + +test: + ENVIRONMENT=test go test $(shell glide novendor | grep -v proctord) + build: build-deps compile fmt vet lint fmt: diff --git a/cmd/procs/description/descriptor.go b/cmd/procs/description/descriptor.go index 6c2c18b7..94f7b402 100644 --- a/cmd/procs/description/descriptor.go +++ b/cmd/procs/description/descriptor.go @@ -42,6 +42,8 @@ func NewCmd(printer io.Printer, proctorEngineClient daemon.Client) *cobra.Comman printer.Println(fmt.Sprintf("%-40s %-100s", "Proc Name", desiredProc.Name), color.Reset) printer.Println(fmt.Sprintf("%-40s %-100s", "Proc Description", desiredProc.Description), color.Reset) + printer.Println(fmt.Sprintf("%-40s %-100s", "Contributors", desiredProc.Contributors), color.Reset) + printer.Println(fmt.Sprintf("%-40s %-100s", "Organization", desiredProc.Organization), color.Reset) printer.Println("\nVariables", color.FgMagenta) for _, arg := range desiredProc.EnvVars.Args { diff --git a/cmd/procs/description/descriptor_test.go b/cmd/procs/description/descriptor_test.go index 5baff1b3..05fe700e 100644 --- a/cmd/procs/description/descriptor_test.go +++ b/cmd/procs/description/descriptor_test.go @@ -64,6 +64,8 @@ func (s *DescribeCmdTestSuite) TestDescribeCmdRun() { s.mockPrinter.On("Println", fmt.Sprintf("%-40s %-100s", "Proc Name", doSomething.Name), color.Reset).Once() s.mockPrinter.On("Println", fmt.Sprintf("%-40s %-100s", "Proc Description", doSomething.Description), color.Reset).Once() + s.mockPrinter.On("Println", fmt.Sprintf("%-40s %-100s", "Contributors", doSomething.Contributors), color.Reset).Once() + s.mockPrinter.On("Println", fmt.Sprintf("%-40s %-100s", "Organization", doSomething.Organization), color.Reset).Once() s.mockPrinter.On("Println", "\nVariables", color.FgMagenta).Once() s.mockPrinter.On("Println", fmt.Sprintf("%-40s %-100s", arg.Name, arg.Description), color.Reset).Once() s.mockPrinter.On("Println", "\nConstants", color.FgMagenta).Once() diff --git a/glide.lock b/glide.lock index f27b5a6f..34df3158 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: 99d5240e2827968d8fea8861618d19371699d856ce4634572dfab614345e80c7 -updated: 2018-09-28T15:53:00.690113+05:30 +hash: 67ebf11da4bd491f297d869e5d2ac01ee6b3248b355be7312ea6a73df316c3ac +updated: 2018-10-10T10:38:35.770913+05:30 imports: - name: cloud.google.com/go version: 3b1ae45394a234c385be014e9a488f2bb6eef821 @@ -126,8 +126,8 @@ imports: version: 5bd2802263f21d8788851d5305584c82a5c75d7e - name: github.com/satori/go.uuid version: f58768cc1a7a7e77a3bd49e98cdd21419399b6a3 -- name: github.com/sirupsen/logrus - version: 95cd2b9c79aa5e72ab0bc69b7ccc2be15bf850f6 +- name: github.com/Sirupsen/logrus + version: ba1b36c82c5e05c4f912a88eab0dcd91a171688f - name: github.com/spf13/afero version: 8d919cbe7e2627e417f3e45c3c0e489a5b7e2536 subpackages: @@ -139,7 +139,7 @@ imports: - name: github.com/spf13/jwalterweatherman version: 12bd96e66386c1960ab0f74ced1362f66f552f7b - name: github.com/spf13/pflag - version: 9a97c102cda95a86cec2345a6f09f55a939babf5 + version: 298182f68c66c05229eb03ac171abe6e309ee79a - name: github.com/spf13/viper version: a1b837276271029e31f796ae5d03ba9ffb017244 - name: github.com/stretchr/objx diff --git a/glide.yaml b/glide.yaml index b93d0b40..1e52b6e0 100644 --- a/glide.yaml +++ b/glide.yaml @@ -16,3 +16,5 @@ import: version: v0.0.1 - package: github.com/thingful/httpmock version: 0.0.2 +- package: github.com/Sirupsen/logrus + version: ba1b36c82c5e05c4f912a88eab0dcd91a171688f diff --git a/proc/metadata.go b/proc/metadata.go index 155dd073..77727e86 100644 --- a/proc/metadata.go +++ b/proc/metadata.go @@ -3,7 +3,10 @@ package proc import "github.com/gojektech/proctor/proc/env" type Metadata struct { - Name string `json:"name"` - Description string `json:"description"` - EnvVars env.Vars `json:"env_vars"` + Name string `json:"name"` + Description string `json:"description"` + Author string `json:"author"` + Contributors string `json:"contributors"` + Organization string `json:"organization"` + EnvVars env.Vars `json:"env_vars"` } diff --git a/proctord/jobs/metadata/handler_test.go b/proctord/jobs/metadata/handler_test.go index fe872d40..93be1cad 100644 --- a/proctord/jobs/metadata/handler_test.go +++ b/proctord/jobs/metadata/handler_test.go @@ -52,10 +52,13 @@ func (s *MetadataHandlerTestSuite) TestSuccessfulMetadataSubmission() { Args: args, } metadata := Metadata{ - Name: "run-sample", - Description: "This is a hello world script", - ImageName: "proctor-jobs-run-sample", - EnvVars: envVars, + Name: "run-sample", + Description: "This is a hello world script", + ImageName: "proctor-jobs-run-sample", + Author: "Test User", + Contributors: "Test User", + Organization: "Test Org", + EnvVars: envVars, } jobMetadata := []Metadata{metadata} diff --git a/proctord/jobs/metadata/metadata.go b/proctord/jobs/metadata/metadata.go index 5c16fcdc..791133bf 100644 --- a/proctord/jobs/metadata/metadata.go +++ b/proctord/jobs/metadata/metadata.go @@ -3,8 +3,11 @@ package metadata import "github.com/gojektech/proctor/proctord/jobs/metadata/env" type Metadata struct { - Name string `json:"name"` - Description string `json:"description"` - ImageName string `json:"image_name"` - EnvVars env.Vars `json:"env_vars"` + Name string `json:"name"` + Description string `json:"description"` + Author string `json:"author"` + Contributors string `json:"contributors"` + Organization string `json:"organization"` + ImageName string `json:"image_name"` + EnvVars env.Vars `json:"env_vars"` } diff --git a/proctord/jobs/metadata/store_test.go b/proctord/jobs/metadata/store_test.go index bc2282eb..5c6dd3f3 100644 --- a/proctord/jobs/metadata/store_test.go +++ b/proctord/jobs/metadata/store_test.go @@ -27,9 +27,12 @@ func (s *MetadataStoreTestSuite) TestCreateOrUpdateJobMetadata() { t := s.T() metadata := Metadata{ - Name: "any-name", - ImageName: "any-image-name", - Description: "any-description", + Name: "any-name", + ImageName: "any-image-name", + Description: "any-description", + Author: "Test User", + Contributors: "Test User, Test Admin", + Organization: "Test Org", } binaryJobMetadata, err := json.Marshal(metadata) @@ -59,14 +62,20 @@ func (s *MetadataStoreTestSuite) TestGetAllJobsMetadata() { t := s.T() metadata1 := Metadata{ - Name: "job1", - ImageName: "job1-image-name", - Description: "desc1", + Name: "job1", + ImageName: "job1-image-name", + Description: "desc1", + Author: "Test User