Skip to content

Commit

Permalink
camelCase deploy status constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgooz committed Sep 24, 2018
1 parent dd0a5d7 commit c372e18
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
28 changes: 14 additions & 14 deletions api/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ type StatusType int
const (
_ StatusType = iota // skip zero value.

// RUNNING indicates that status message belongs to a continuous state.
RUNNING
// Running indicates that status message belongs to a continuous state.
Running

// DONE_POSITIVE indicates that status message belongs to a positive noncontinuous state.
DONE_POSITIVE
// DonePositive indicates that status message belongs to a positive noncontinuous state.
DonePositive

// DONE_NEGATIVE indicates that status message belongs to a negative noncontinuous state.
DONE_NEGATIVE
// DoneNegative indicates that status message belongs to a negative noncontinuous state.
DoneNegative
)

// DeployStatus represents the deployment status.
Expand All @@ -82,7 +82,7 @@ func newServiceDeployer(api *API, options ...DeployServiceOption) *serviceDeploy

// FromGitURL deploys a service hosted at a Git url.
func (d *serviceDeployer) FromGitURL(url string) (*service.Service, *importer.ValidationError, error) {
d.sendStatus("Downloading service...", RUNNING)
d.sendStatus("Downloading service...", Running)
path, err := d.createTempDir()
if err != nil {
return nil, nil, err
Expand All @@ -98,7 +98,7 @@ func (d *serviceDeployer) FromGitURL(url string) (*service.Service, *importer.Va
return nil, nil, err
}

d.sendStatus("Service downloaded with success.", DONE_POSITIVE)
d.sendStatus("Service downloaded with success.", DonePositive)
r, err := xarchive.GzippedTar(path)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -149,12 +149,12 @@ func (d *serviceDeployer) forwardDeployStatuses(statuses chan service.DeployStat
for status := range statuses {
var t StatusType
switch status.Type {
case service.DRUNNING:
t = RUNNING
case service.DDONE_POSITIVE:
t = DONE_POSITIVE
case service.DDONE_NEGATIVE:
t = DONE_NEGATIVE
case service.DRunning:
t = Running
case service.DDonePositive:
t = DonePositive
case service.DDoneNegative:
t = DoneNegative
}
d.sendStatus(status.Message, t)
}
Expand Down
30 changes: 15 additions & 15 deletions api/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ func TestDeployService(t *testing.T) {

require.Equal(t, DeployStatus{
Message: "Receiving service context...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service context received with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "[DEPRECATED] Please use .dockerignore instead of .mesgignore",
Type: DONE_NEGATIVE,
Type: DoneNegative,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Building Docker image...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Image built with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service deployed.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

wg.Wait()
Expand Down Expand Up @@ -92,12 +92,12 @@ func TestDeployInvalidService(t *testing.T) {

require.Equal(t, DeployStatus{
Message: "Receiving service context...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service context received with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

select {
Expand Down Expand Up @@ -129,37 +129,37 @@ func TestDeployServiceFromURL(t *testing.T) {

require.Equal(t, DeployStatus{
Message: "Downloading service...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service downloaded with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Receiving service context...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service context received with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Building Docker image...",
Type: RUNNING,
Type: Running,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Image built with success.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

require.Equal(t, DeployStatus{
Message: "Service deployed.",
Type: DONE_POSITIVE,
Type: DonePositive,
}, <-statuses)

wg.Wait()
Expand Down
18 changes: 9 additions & 9 deletions commands/provider/service_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ type StatusType int
const (
_ StatusType = iota // skip zero value.

// RUNNING indicates that status message belongs to a continuous state.
RUNNING
// Running indicates that status message belongs to a continuous state.
Running

// DONE_POSITIVE indicates that status message belongs to a positive noncontinuous state.
DONE_POSITIVE
// DonePositive indicates that status message belongs to a positive noncontinuous state.
DonePositive

// DONE_NEGATIVE indicates that status message belongs to a negative noncontinuous state.
DONE_NEGATIVE
// DoneNegative indicates that status message belongs to a negative noncontinuous state.
DoneNegative
)

// DeployStatus represents the deployment status.
Expand Down Expand Up @@ -125,11 +125,11 @@ func readDeployReply(stream coreapi.Core_DeployServiceClient, deployment chan de

switch status.Type {
case coreapi.DeployServiceReply_Status_RUNNING:
s.Type = RUNNING
s.Type = Running
case coreapi.DeployServiceReply_Status_DONE_POSITIVE:
s.Type = DONE_POSITIVE
s.Type = DonePositive
case coreapi.DeployServiceReply_Status_DONE_NEGATIVE:
s.Type = DONE_NEGATIVE
s.Type = DoneNegative
}

statuses <- s
Expand Down
4 changes: 2 additions & 2 deletions commands/service_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ func printDeployStatuses(statuses chan provider.DeployStatus) {
default:
var sign string
switch status.Type {
case provider.DONE_POSITIVE:
case provider.DonePositive:
sign = pretty.SuccessSign
case provider.DONE_NEGATIVE:
case provider.DoneNegative:
sign = pretty.FailSign
}
pretty.DestroySpinner()
Expand Down
6 changes: 3 additions & 3 deletions interface/grpc/core/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func sendDeployStatus(statuses chan api.DeployStatus, stream coreapi.Core_Deploy
for status := range statuses {
var typ coreapi.DeployServiceReply_Status_Type
switch status.Type {
case api.RUNNING:
case api.Running:
typ = coreapi.DeployServiceReply_Status_RUNNING
case api.DONE_POSITIVE:
case api.DonePositive:
typ = coreapi.DeployServiceReply_Status_DONE_POSITIVE
case api.DONE_NEGATIVE:
case api.DoneNegative:
typ = coreapi.DeployServiceReply_Status_DONE_NEGATIVE
}

Expand Down
8 changes: 4 additions & 4 deletions interface/grpc/core/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDeployService(t *testing.T) {

require.Contains(t, stream.statuses, api.DeployStatus{
Message: "Service deployed.",
Type: api.DONE_POSITIVE,
Type: api.DonePositive,
})
}

Expand All @@ -48,11 +48,11 @@ func (s *testDeployStream) Send(m *coreapi.DeployServiceReply) error {
var typ api.StatusType
switch status.Type {
case coreapi.DeployServiceReply_Status_RUNNING:
typ = api.RUNNING
typ = api.Running
case coreapi.DeployServiceReply_Status_DONE_POSITIVE:
typ = api.DONE_POSITIVE
typ = api.DonePositive
case coreapi.DeployServiceReply_Status_DONE_NEGATIVE:
typ = api.DONE_NEGATIVE
typ = api.DoneNegative
}
s.statuses = append(s.statuses, api.DeployStatus{
Message: status.Message,
Expand Down
24 changes: 12 additions & 12 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ type DStatusType int
const (
_ DStatusType = iota // skip zero value.

// DRUNNING indicates that status message belongs to a continuous state.
DRUNNING
// DRunning indicates that status message belongs to a continuous state.
DRunning

// DDONE_POSITIVE indicates that status message belongs to a positive noncontinuous state.
DDONE_POSITIVE
// DDonePositive indicates that status message belongs to a positive noncontinuous state.
DDonePositive

// DDONE_NEGATIVE indicates that status message belongs to a negative noncontinuous state.
DDONE_NEGATIVE
// DDoneNegative indicates that status message belongs to a negative noncontinuous state.
DDoneNegative
)

// DeployStatus represents the deployment status.
Expand Down Expand Up @@ -183,8 +183,8 @@ func (s *Service) saveContext(r io.Reader) error {
return err
}

s.sendStatus("Receiving service context...", DRUNNING)
defer s.sendStatus("Service context received with success.", DDONE_POSITIVE)
s.sendStatus("Receiving service context...", DRunning)
defer s.sendStatus("Service context received with success.", DDonePositive)

return archive.Untar(r, s.tempPath, &archive.TarOptions{
Compression: archive.Gzip,
Expand All @@ -205,15 +205,15 @@ func (s *Service) deploy() error {
defer s.removeTempDir()
defer s.closeStatusSend()

s.sendStatus("Building Docker image...", DRUNNING)
s.sendStatus("Building Docker image...", DRunning)

imageHash, err := s.docker.Build(s.tempPath)
if err != nil {
return err
}

s.sendStatus("Image built with success.", DDONE_POSITIVE)
s.sendStatus("Service deployed.", DDONE_POSITIVE)
s.sendStatus("Image built with success.", DDonePositive)
s.sendStatus("Service deployed.", DDonePositive)

s.configuration.Key = "service"
s.configuration.Image = imageHash
Expand All @@ -225,7 +225,7 @@ func (s *Service) deploy() error {
func (s *Service) checkDeprecations() error {
if _, err := os.Stat(filepath.Join(s.tempPath, ".mesgignore")); err == nil {
// TODO: remove for a future release
s.sendStatus("[DEPRECATED] Please use .dockerignore instead of .mesgignore", DDONE_NEGATIVE)
s.sendStatus("[DEPRECATED] Please use .dockerignore instead of .mesgignore", DDoneNegative)
}
return nil
}
Expand Down

0 comments on commit c372e18

Please sign in to comment.