-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmodels.go
More file actions
85 lines (73 loc) · 2.39 KB
/
models.go
File metadata and controls
85 lines (73 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package cube
import (
"fmt"
"net/http"
"code.cloudfoundry.org/bbs/models"
"code.cloudfoundry.org/runtimeschema/cc_messages"
"github.com/julz/cube/opi"
)
//Environment Variable Names
const (
EnvDownloadUrl = "DOWNLOAD_URL"
EnvUploadUrl = "UPLOAD_URL"
EnvAppId = "APP_ID"
EnvStagingGuid = "STAGING_GUID"
EnvCompletionCallback = "COMPLETION_CALLBACK"
EnvCfUsername = "CF_USERNAME"
EnvCfPassword = "CF_PASSWORD"
EnvApiAddress = "API_ADDRESS"
EnvCubeAddress = "CUBE_ADDRESS"
)
type AppInfo struct {
AppName string `json:"name"`
SpaceName string `json:"space_name"`
AppGuid string `json:"application_id"`
}
//go:generate counterfeiter . CfClient
type CfClient interface {
GetDropletByAppGuid(string) ([]byte, error)
PushDroplet(string, string) error
GetAppBitsByAppGuid(string) (*http.Response, error)
}
type SyncConfig struct {
Properties SyncProperties `yaml:"sync"`
}
type SyncProperties struct {
KubeConfig string `yaml:"kube_config"`
KubeNamespace string `yaml:"kube_namespace"`
KubeEndpoint string `yaml:"kube_endpoint"`
RegistryEndpoint string `yaml:"registry_endpoint"`
CcApi string `yaml:"api_endpoint"`
Backend string `yaml:"backend"`
CfUsername string `yaml:"cf_username"`
CfPassword string `yaml:"cf_password"`
CcUser string `yaml:"cc_internal_user"`
CcPassword string `yaml:"cc_internal_password"`
ExternalAddress string `yaml:"external_cube_address"`
SkipSslValidation bool `yaml:"skip_ssl_validation"`
InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}
//go:generate counterfeiter . St8ger
type St8ger interface {
Run(task opi.Task) error
}
//go:generate counterfeiter . Backend
type Backend interface {
CreateStagingTask(string, cc_messages.StagingRequestFromCC) (opi.Task, error)
BuildStagingResponse(*models.TaskCallbackResponse) (cc_messages.StagingResponseForCC, error)
}
type BackendConfig struct {
CfUsername string
CfPassword string
ApiAddress string
CubeAddress string
SkipSslValidation bool
}
//go:generate counterfeiter . Extractor
type Extractor interface {
Extract(src, targetDir string) error
}
func GetInternalServiceName(appName string) string {
//Prefix service as the appName could start with numerical characters, which is not allowed
return fmt.Sprintf("cf-%s", appName)
}