Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"app.go",
"build.go",
"client.go",
"common_config.go",
"config.go",
"force.go",
"rpc.go",
"tag.go",
],
importpath = "go-common/app/infra/config/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//library/time:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,30 @@
package model
import "go-common/library/time"
// DBApp mysql app DB.
type DBApp struct {
ID int64 `json:"id" gorm:"primary_key"`
Name string `json:"name"`
Token string `json:"token"`
Env string `json:"env"`
Zone string `json:"zone"`
TreeID int `json:"tree_id"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName app
func (DBApp) TableName() string {
return "app"
}
// App app local cache.
type App struct {
ID int64 `json:"id"`
Name string `json:"name"`
Token string `json:"token"`
Env string `json:"env"`
Zone string `json:"zone"`
TreeID int `json:"tree_id"`
}

View File

@@ -0,0 +1,19 @@
package model
import "go-common/library/time"
// Build build.
type Build struct {
ID int64 `json:"id"`
AppID int64 `json:"app_id"`
Name string `json:"name"`
TagID int64 `json:"tag_id"`
Operator string `json:"operator"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName build.
func (Build) TableName() string {
return "build"
}

View File

@@ -0,0 +1,95 @@
package model
import (
"go-common/library/time"
)
const (
// HostOffline host offline state.
HostOffline = 0
// HostOnline host online state.
HostOnline = 1
// HostStateOK host state ok.
HostStateOK = 2
// UnknownVersion unknown version.
UnknownVersion = -1
)
// Diff return to client.
type Diff struct {
Version int64 `json:"version"`
Diffs []int64 `json:"diffs"`
}
// Version return to client.
type Version struct {
Version int64 `json:"version"`
}
// ReVer reVer
type ReVer struct {
Version int64 `json:"version"`
Remark string `json:"remark"`
}
// Versions versions
type Versions struct {
Version []*ReVer `json:"version"`
DefVer int64 `json:"defver"`
}
// Content return to client.
type Content struct {
Version int64 `json:"version"`
Md5 string `json:"md5"`
Content string `json:"content"`
}
// Namespace the key-value config object.
type Namespace struct {
Name string `json:"name"`
Data map[string]string `json:"data"`
}
// Service service
type Service struct {
Name string
BuildVersion string
Env string
Token string
File string
Version int64
Host string
IP string
Appoint int64
}
// NSValue config value.
type NSValue struct {
ConfigID int64 `json:"cid"`
NamespaceID int64 `json:"nsid"`
Name string `json:"name"`
Config string `json:"config"`
}
// Value config value.
type Value struct {
ConfigID int64 `json:"cid"`
Name string `json:"name"`
Config string `json:"config"`
}
// Host host.
type Host struct {
Name string `json:"hostname"`
Service string `json:"service"`
BuildVersion string `json:"build"`
IP string `json:"ip"`
ConfigVersion int64 `json:"version"`
HeartbeatTime time.Time `json:"heartbeat_time"`
State int `json:"state"`
Appoint int64 `json:"appoint"`
Customize string `json:"customize"`
Force int8 `json:"force"`
ForceVersion int64 `json:"force_version"`
}

View File

@@ -0,0 +1,21 @@
package model
import "go-common/library/time"
// CommonConf common config.
type CommonConf struct {
ID int64 `json:"id" gorm:"primary_key"`
TeamID int64 `json:"team_id"`
Name string `json:"name"`
Comment string `json:"comment"`
State int8 `json:"state"`
Mark string `json:"mark"`
Operator string `json:"operator"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName commonConfig.
func (CommonConf) TableName() string {
return "common_config"
}

View File

@@ -0,0 +1,29 @@
package model
import "go-common/library/time"
var (
//ConfigIng config ing.
ConfigIng = int8(1)
//ConfigEnd config ing.
ConfigEnd = int8(2)
)
// Config config.
type Config struct {
ID int64 `json:"id" gorm:"primary_key"`
AppID int64 `json:"app_id"`
Name string `json:"name"`
Comment string `json:"comment"`
From int64 `json:"from"`
State int8 `json:"state"`
Mark string `json:"mark"`
Operator string `json:"operator"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName config
func (Config) TableName() string {
return "config"
}

View File

@@ -0,0 +1,20 @@
package model
import "go-common/library/time"
// Force ...
type Force struct {
ID int64 `json:"id"`
AppID int64 `json:"app_id"`
HostName string `json:"hostname"`
IP string `json:"ip"`
Version int64 `json:"version"`
Operator string `json:"operator"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName build.
func (Force) TableName() string {
return "force"
}

View File

@@ -0,0 +1,18 @@
package model
// ArgConf config param.
type ArgConf struct {
App string
BuildVer string
Ver int64
Env string
Hosts map[string]string
SType int8
}
// ArgToken token param.
type ArgToken struct {
App string
Token string
Env string
}

View File

@@ -0,0 +1,20 @@
package model
import "go-common/library/time"
// DBTag tag table in mysql.
type DBTag struct {
ID int64 `json:"id" gorm:"primary_key"`
AppID int64 `json:"app_id"`
ConfigIDs string `json:"config_ids"`
Mark string `json:"mark"`
Force int8 `json:"force"`
Operator string `json:"operator"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName tag.
func (DBTag) TableName() string {
return "tag"
}