Skip to content
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.

Commit

Permalink
[UPDATE] migrate all functions to the wrapper
Browse files Browse the repository at this point in the history
- drop unused code
- clean up code
  • Loading branch information
HappyTobi committed Sep 18, 2019
1 parent b9dcbd0 commit ab0b5d9
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 417 deletions.
7 changes: 6 additions & 1 deletion cf/cli/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ func (ec executor) Execute(arguments []string) (err error) {
return err
}

outChannel := os.NewFile(0, os.DevNull)
if ec.traceLogging {
outChannel = os.Stdout
}

cmd := exec.Cmd{
Path: cfCmdToolPath,
Args: append([]string{cfCmdToolPath}, arguments...),
Stdout: os.Stdout,
Stdout: outChannel,
Stderr: os.Stderr,
}

Expand Down
3 changes: 2 additions & 1 deletion cf/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (adp *ApplicationPushData) PushApplication(venAppName, spaceGUID string, pa
var v2Resources v2.Resources = v2.NewV2Resources(adp.Connection, adp.TraceLogging)
var push v3.Push = v3.NewV3Push(adp.Connection, adp.TraceLogging)
if parsedArguments.AddRoutes {
return push.SwitchRoutesOnly(venAppName, parsedArguments.AppName, spaceGUID, parsedArguments.Manifest.ApplicationManifests[0].Routes, v2Resources)
//TODO loop over applications
return push.SwitchRoutesOnly(venAppName, parsedArguments.AppName, parsedArguments.Manifest.ApplicationManifests[0].Routes)
}
return push.PushApplication(venAppName, spaceGUID, parsedArguments, v2Resources)
}
Expand Down
12 changes: 0 additions & 12 deletions cf/utils/env_convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ import (
"strings"
)

/*func Convert(envVars []string) (conVars map[string]string) {
envs := make(map[string]string)
for _, v := range envVars {
envPair := strings.Split(v, SplitChar)
envKey := strings.TrimSpace(envPair[0])
envVal := strings.TrimSpace(envPair[1])
envs[envKey] = envVal
}
return envs
}*/

func Convert(envVars []string) (conVars map[string]string) {
replacer := strings.NewReplacer("'", "\"", "`", "\"")
envs := make(map[string]string)
Expand Down
47 changes: 0 additions & 47 deletions cf/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,6 @@ var (
ErrAppNotFound = errors.New("application not found")
)

//AppRoutesResponse application response struct
type AppRoutesResponse struct {
NextURL string `json:"next_url,omitempty"`
PrevURL string `json:"prev_url,omitempty"`
Resources []struct {
Entity struct {
AppsURL string `json:"apps_url"`
DomainGUID string `json:"domain_guid"`
DomainURL string `json:"domain_url"`
Host string `json:"host"`
Path string `json:"path"`
Port interface{} `json:"port"`
RouteMappingsURL string `json:"route_mappings_url"`
ServiceInstanceGUID interface{} `json:"service_instance_guid"`
SpaceGUID string `json:"space_guid"`
SpaceURL string `json:"space_url"`
} `json:"entity"`
Metadata struct {
CreatedAt time.Time `json:"created_at"`
GUID string `json:"guid"`
UpdatedAt time.Time `json:"updated_at"`
URL string `json:"url"`
} `json:"metadata"`
} `json:"resources"`
TotalPages int `json:"total_pages"`
TotalResults int `json:"total_results"`
}

type AppResourcesEntity struct {
Metadata Metadata `json:"metadata"`
Entity Entity `json:"entity"`
Expand Down Expand Up @@ -104,25 +76,6 @@ type Entity struct {
RouteMappingsURL string `json:"route_mappings_url"`
}

//LoadAppRoutes
func (resource *ResourcesData) LoadAppRoutes(appGUID string) (*AppRoutesResponse, error) {
ui.Say("LoadAppRoutes called")
path := fmt.Sprintf(`/v2/apps/%s/routes`, appGUID)

jsonResult, err := resource.cli.GetJSON(path)
if err != nil {
return nil, err
}

var response AppRoutesResponse
err = json.Unmarshal([]byte(jsonResult), &response)
if err != nil {
return nil, err
}

return &response, nil
}

//GetAppMetadata
func (resource *ResourcesData) GetAppMetadata(appName string) (*AppResourcesEntity, error) {
space, err := resource.connection.GetCurrentSpace()
Expand Down
4 changes: 0 additions & 4 deletions cf/v2/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
)

type Resources interface {
LoadAppRoutes(appGUID string) (*AppRoutesResponse, error)
CreateRoute(spaceGUID string, domainGUID string, host string) (*RouteResponse, error)
LoadSharedDomains(domainGUID string) (*SharedDomainResponse, error)
FindServiceInstances(serviceNames []string, spaceGUID string) ([]string, error)
GetAppMetadata(appName string) (*AppResourcesEntity, error)
}

Expand Down
65 changes: 0 additions & 65 deletions cf/v2/route.go

This file was deleted.

43 changes: 0 additions & 43 deletions cf/v2/shared_domains.go

This file was deleted.

73 changes: 0 additions & 73 deletions cf/v2/spaces.go

This file was deleted.

11 changes: 3 additions & 8 deletions cf/v3/actions.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
package v3

import (
"github.com/happytobi/cf-puppeteer/arguments"
"github.com/happytobi/cf-puppeteer/ui"
)

func (resource *ResourcesData) AssignAppManifest(parsedArguments *arguments.ParserArguments) (err error) {
args := []string{"v3-apply-manifest", "-f", parsedArguments.ManifestPath}
func (resource *ResourcesData) AssignAppManifest(manifestPath string) (err error) {
args := []string{"v3-apply-manifest", "-f", manifestPath}

ui.Say("apply manifest file")
err = resource.Executor.Execute(args)
if err != nil {
ui.Failed("could not read manifest from path %s error: %s", parsedArguments.ManifestPath, err)
ui.Failed("could not read manifest from path %s error: %s", manifestPath, err)
return err
}

ui.Ok()

return nil
}
Loading

0 comments on commit ab0b5d9

Please sign in to comment.