Documentation ¶
Index ¶
- Constants
- Variables
- func Base64EncodedPublicKey(pubKey ssh2.PublicKey) string
- func ContainsDomain(source, target string) bool
- func DBName(applicationID string) string
- func DeleteArtifact(s Storage, artifactID string) error
- func DeleteBuildLog(s Storage, buildID string) error
- func EncodePrivateKeyPem(privKey ed25519.PrivateKey) (string, error)
- func GetArtifact(s Storage, artifactID string) (filename string, r io.ReadCloser, err error)
- func GetBuildLog(s Storage, buildID string) ([]byte, error)
- func GetSuccessBuilds(ctx context.Context, buildRepo BuildRepository, apps []*Application) (map[string]*Build, error)
- func GitAuthMethod(repo *Repository, sshFallback *ssh.PublicKeys) (transport.AuthMethod, error)
- func NewID() string
- func NewPublicKey(pemBytes []byte) (*ssh.PublicKeys, error)
- func SaveArtifact(s Storage, artifactID string, src io.Reader) error
- func SaveBuildLog(s Storage, buildID string, src io.Reader) error
- func ValidateDomain(domain string) error
- func ValidatePossibleWildcardDomain(domain string) error
- func ValidateWildcardDomain(domain string) error
- type Application
- func (a *Application) Apply(args *UpdateApplicationArgs)
- func (a *Application) IsOwner(user *User) bool
- func (a *Application) SelfValidate() error
- func (a *Application) Validate(actor *User, existingApps []*Application, domains AvailableDomainSlice, ...) (validateErr error, err error)
- func (a *Application) WebsiteConflicts(existing []*Application, actor *User) bool
- type ApplicationConfig
- type ApplicationRepository
- type Artifact
- type ArtifactRepository
- type AuthenticationType
- type AvailableDomain
- type AvailableDomainSlice
- type AvailablePort
- type AvailablePortSlice
- type AvatarBaseURL
- type Backend
- type Build
- type BuildConfig
- type BuildConfigRuntimeBuildpack
- type BuildConfigRuntimeCmd
- type BuildConfigRuntimeDockerfile
- type BuildConfigStaticCmd
- type BuildConfigStaticDockerfile
- type BuildRepository
- type BuildStatus
- type BuildType
- type Container
- type ContainerEvent
- type ContainerLog
- type ContainerLogger
- type ContainerState
- type ControllerBuilderService
- type ControllerBuilderServiceClient
- type ControllerSSGenService
- type ControllerSSGenServiceClient
- type ControllerServiceClient
- type CreateArgs
- type CreateUserArgs
- type DeleteArgs
- type DeployType
- type DesiredState
- type Environment
- type EnvironmentRepository
- type GetApplicationCondition
- type GetArtifactCondition
- type GetBuildCondition
- type GetEnvCondition
- type GetRepositoryCondition
- type GetUserCondition
- type GetUserKeyCondition
- type GitRepositoryRepository
- type MariaDBManager
- type MongoDBManager
- type PortPublication
- type PortPublicationProtocol
- type PubSub
- type Repository
- type RepositoryAuth
- type RepositoryAuthMethod
- type RuntimeConfig
- type RuntimeDesiredState
- type SSHConfig
- type StaticConfig
- type StaticServer
- type StaticServerDocumentRootPath
- type StaticSite
- type Storage
- type StorageConfig
- type UpdateApplicationArgs
- type UpdateArtifactArgs
- type UpdateBuildArgs
- type UpdateRepositoryArgs
- type User
- type UserKey
- type UserRepository
- type Website
- type WildcardDomains
Constants ¶
View Source
const ( EnvPrefix = "NS_" EnvMariaDBHostnameKey = EnvPrefix + "MARIADB_HOSTNAME" EnvMariaDBPortKey = EnvPrefix + "MARIADB_PORT" EnvMariaDBUserKey = EnvPrefix + "MARIADB_USER" EnvMariaDBPasswordKey = EnvPrefix + "MARIADB_PASSWORD" EnvMariaDBDatabaseKey = EnvPrefix + "MARIADB_DATABASE" EnvMongoDBHostnameKey = EnvPrefix + "MONGODB_HOSTNAME" EnvMongoDBPortKey = EnvPrefix + "MONGODB_PORT" EnvMongoDBUserKey = EnvPrefix + "MONGODB_USER" EnvMongoDBPasswordKey = EnvPrefix + "MONGODB_PASSWORD" EnvMongoDBDatabaseKey = EnvPrefix + "MONGODB_DATABASE" )
All environment variables injected by neoshowcase must have NS_ prefix
View Source
const IDLength = 22
Variables ¶
View Source
var EmptyCommit = strings.Repeat("0", 40)
View Source
var ( // ErrFileNotFound ファイルが存在しない ErrFileNotFound = errors.New("not found") )
Functions ¶
func Base64EncodedPublicKey ¶
func ContainsDomain ¶ added in v0.4.0
func DeleteArtifact ¶
func DeleteBuildLog ¶
func EncodePrivateKeyPem ¶ added in v0.6.0
func EncodePrivateKeyPem(privKey ed25519.PrivateKey) (string, error)
func GetArtifact ¶
func GetSuccessBuilds ¶ added in v0.7.0
func GetSuccessBuilds(ctx context.Context, buildRepo BuildRepository, apps []*Application) (map[string]*Build, error)
GetSuccessBuilds returns a map of (app id + build id) -> build.
func GitAuthMethod ¶
func GitAuthMethod(repo *Repository, sshFallback *ssh.PublicKeys) (transport.AuthMethod, error)
func NewPublicKey ¶ added in v0.4.5
func NewPublicKey(pemBytes []byte) (*ssh.PublicKeys, error)
func SaveArtifact ¶
SaveArtifact Artifactをtar形式で保存する
func ValidateDomain ¶
func ValidatePossibleWildcardDomain ¶ added in v0.4.0
func ValidateWildcardDomain ¶
Types ¶
type Application ¶
type Application struct { ID string Name string RepositoryID string RefName string DeployType DeployType Running bool Container ContainerState CurrentCommit string WantCommit string CreatedAt time.Time UpdatedAt time.Time Config ApplicationConfig Websites []*Website PortPublications []*PortPublication OwnerIDs []string }
func (*Application) Apply ¶
func (a *Application) Apply(args *UpdateApplicationArgs)
func (*Application) IsOwner ¶
func (a *Application) IsOwner(user *User) bool
func (*Application) SelfValidate ¶
func (a *Application) SelfValidate() error
func (*Application) Validate ¶
func (a *Application) Validate( actor *User, existingApps []*Application, domains AvailableDomainSlice, ports AvailablePortSlice, ) (validateErr error, err error)
func (*Application) WebsiteConflicts ¶
func (a *Application) WebsiteConflicts(existing []*Application, actor *User) bool
type ApplicationConfig ¶
type ApplicationConfig struct {
BuildConfig BuildConfig
}
func (*ApplicationConfig) Validate ¶
func (c *ApplicationConfig) Validate(deployType DeployType) error
type ApplicationRepository ¶
type ApplicationRepository interface { GetApplications(ctx context.Context, cond GetApplicationCondition) ([]*Application, error) GetApplication(ctx context.Context, id string) (*Application, error) CreateApplication(ctx context.Context, app *Application) error UpdateApplication(ctx context.Context, id string, args *UpdateApplicationArgs) error BulkUpdateState(ctx context.Context, m map[string]ContainerState) error DeleteApplication(ctx context.Context, id string) error }
type Artifact ¶
type Artifact struct { ID string BuildID string Size int64 CreatedAt time.Time DeletedAt optional.Of[time.Time] }
func NewArtifact ¶
type ArtifactRepository ¶
type ArtifactRepository interface { GetArtifacts(ctx context.Context, cond GetArtifactCondition) ([]*Artifact, error) CreateArtifact(ctx context.Context, artifact *Artifact) error UpdateArtifact(ctx context.Context, id string, args UpdateArtifactArgs) error HardDeleteArtifacts(ctx context.Context, cond GetArtifactCondition) error }
type AuthenticationType ¶
type AuthenticationType int
const ( AuthenticationTypeOff AuthenticationType = iota AuthenticationTypeSoft AuthenticationTypeHard )
type AvailableDomain ¶
func (*AvailableDomain) Match ¶ added in v0.4.0
func (a *AvailableDomain) Match(fqdn string) bool
func (*AvailableDomain) Validate ¶
func (a *AvailableDomain) Validate() error
type AvailableDomainSlice ¶
type AvailableDomainSlice []*AvailableDomain
func (AvailableDomainSlice) IsAuthAvailable ¶ added in v0.4.0
func (s AvailableDomainSlice) IsAuthAvailable(fqdn string) bool
func (AvailableDomainSlice) IsAvailable ¶
func (s AvailableDomainSlice) IsAvailable(fqdn string) bool
type AvailablePort ¶ added in v0.3.0
type AvailablePort struct { StartPort int EndPort int Protocol PortPublicationProtocol }
func (*AvailablePort) Validate ¶ added in v0.3.0
func (ap *AvailablePort) Validate() error
type AvailablePortSlice ¶ added in v0.3.0
type AvailablePortSlice []*AvailablePort
func (AvailablePortSlice) IsAvailable ¶ added in v0.3.0
func (s AvailablePortSlice) IsAvailable(port int, protocol PortPublicationProtocol) bool
type AvatarBaseURL ¶ added in v0.4.6
type AvatarBaseURL string
type Backend ¶
type Backend interface { Start(ctx context.Context) error Dispose(ctx context.Context) error AvailableDomains() AvailableDomainSlice AvailablePorts() AvailablePortSlice ListenContainerEvents() (sub <-chan *ContainerEvent, unsub func()) Synchronize(ctx context.Context, s *DesiredState) error GetContainer(ctx context.Context, appID string) (*Container, error) ListContainers(ctx context.Context) ([]*Container, error) ExecContainer(ctx context.Context, appID string, cmd []string, stdin io.Reader, stdout, stderr io.Writer) error }
type Build ¶
type BuildConfig ¶
type BuildConfigRuntimeBuildpack ¶
type BuildConfigRuntimeBuildpack struct { RuntimeConfig Context string // contains filtered or unexported fields }
func (*BuildConfigRuntimeBuildpack) BuildType ¶
func (bc *BuildConfigRuntimeBuildpack) BuildType() BuildType
func (*BuildConfigRuntimeBuildpack) Validate ¶
func (bc *BuildConfigRuntimeBuildpack) Validate() error
type BuildConfigRuntimeCmd ¶
type BuildConfigRuntimeCmd struct { RuntimeConfig BaseImage string BuildCmd string BuildCmdShell bool // contains filtered or unexported fields }
func (*BuildConfigRuntimeCmd) BuildType ¶
func (bc *BuildConfigRuntimeCmd) BuildType() BuildType
func (*BuildConfigRuntimeCmd) Validate ¶
func (bc *BuildConfigRuntimeCmd) Validate() error
type BuildConfigRuntimeDockerfile ¶
type BuildConfigRuntimeDockerfile struct { RuntimeConfig DockerfileName string Context string // contains filtered or unexported fields }
func (*BuildConfigRuntimeDockerfile) BuildType ¶
func (bc *BuildConfigRuntimeDockerfile) BuildType() BuildType
func (*BuildConfigRuntimeDockerfile) Validate ¶
func (bc *BuildConfigRuntimeDockerfile) Validate() error
type BuildConfigStaticCmd ¶
type BuildConfigStaticCmd struct { StaticConfig BaseImage string BuildCmd string BuildCmdShell bool ArtifactPath string // contains filtered or unexported fields }
func (*BuildConfigStaticCmd) BuildType ¶
func (bc *BuildConfigStaticCmd) BuildType() BuildType
func (*BuildConfigStaticCmd) Validate ¶
func (bc *BuildConfigStaticCmd) Validate() error
type BuildConfigStaticDockerfile ¶
type BuildConfigStaticDockerfile struct { StaticConfig DockerfileName string Context string ArtifactPath string // contains filtered or unexported fields }
func (*BuildConfigStaticDockerfile) BuildType ¶
func (bc *BuildConfigStaticDockerfile) BuildType() BuildType
func (*BuildConfigStaticDockerfile) Validate ¶
func (bc *BuildConfigStaticDockerfile) Validate() error
type BuildRepository ¶
type BuildRepository interface { GetBuilds(ctx context.Context, cond GetBuildCondition) ([]*Build, error) GetBuild(ctx context.Context, buildID string) (*Build, error) CreateBuild(ctx context.Context, build *Build) error UpdateBuild(ctx context.Context, id string, args UpdateBuildArgs) error MarkCommitAsRetriable(ctx context.Context, applicationID string, commit string) error DeleteBuilds(ctx context.Context, cond GetBuildCondition) error }
type BuildStatus ¶
type BuildStatus int
const ( BuildStatusQueued BuildStatus = iota BuildStatusBuilding BuildStatusSucceeded BuildStatusFailed BuildStatusCanceled BuildStatusSkipped )
func (BuildStatus) IsFinished ¶
func (t BuildStatus) IsFinished() bool
type BuildType ¶
type BuildType int
func (BuildType) DeployType ¶
func (b BuildType) DeployType() DeployType
type Container ¶
type Container struct { ApplicationID string State ContainerState }
type ContainerEvent ¶
type ContainerEvent struct {
ApplicationID string
}
type ContainerLog ¶
type ContainerLogger ¶
type ContainerState ¶
type ContainerState int
const ( ContainerStateMissing ContainerState = iota ContainerStateStarting ContainerStateRunning ContainerStateExited ContainerStateErrored ContainerStateUnknown )
type ControllerBuilderService ¶
type ControllerBuilderService interface { pbconnect.ControllerBuilderServiceHandler ListenBuilderIdle() (sub <-chan struct{}, unsub func()) ListenBuildSettled() (sub <-chan struct{}, unsub func()) StartBuilds(buildIDs []string) BroadcastBuilder(req *pb.BuilderRequest) }
type ControllerBuilderServiceClient ¶
type ControllerBuilderServiceClient interface {
ConnectBuilder(ctx context.Context, onRequest func(req *pb.BuilderRequest), response <-chan *pb.BuilderResponse) error
}
type ControllerSSGenService ¶
type ControllerSSGenService interface { pbconnect.ControllerSSGenServiceHandler BroadcastSSGen(req *pb.SSGenRequest) }
type ControllerSSGenServiceClient ¶
type ControllerSSGenServiceClient interface {
ConnectSSGen(ctx context.Context, onRequest func(req *pb.SSGenRequest)) error
}
type ControllerServiceClient ¶
type ControllerServiceClient interface { GetSSHInfo(ctx context.Context) (host string, port int, err error) GetAvailableDomains(ctx context.Context) (AvailableDomainSlice, error) GetAvailablePorts(ctx context.Context) (AvailablePortSlice, error) FetchRepository(ctx context.Context, repositoryID string) error RegisterBuilds(ctx context.Context) error SyncDeployments(ctx context.Context) error StreamBuildLog(ctx context.Context, buildID string) (<-chan *pb.BuildLog, error) CancelBuild(ctx context.Context, buildID string) error }
type CreateArgs ¶
type CreateArgs struct { // Database データベース/ユーザー名 Database string // Password アクセスパスワード Password string }
CreateArgs データベース作成引数
type CreateUserArgs ¶
type CreateUserArgs struct {
Name string
}
type DeleteArgs ¶
type DeleteArgs struct { // Database データベース/ユーザー名 Database string }
DeleteArgs データベース削除引数
type DeployType ¶
type DeployType int
const ( DeployTypeRuntime DeployType = iota DeployTypeStatic )
type DesiredState ¶
type DesiredState struct { Runtime []*RuntimeDesiredState StaticSites []*StaticSite }
type Environment ¶
type EnvironmentRepository ¶
type EnvironmentRepository interface { GetEnv(ctx context.Context, cond GetEnvCondition) ([]*Environment, error) SetEnv(ctx context.Context, env *Environment) error DeleteEnv(ctx context.Context, cond GetEnvCondition) error }
type GetApplicationCondition ¶
type GetArtifactCondition ¶
type GetBuildCondition ¶
type GetEnvCondition ¶
type GetRepositoryCondition ¶
type GetUserCondition ¶
type GetUserKeyCondition ¶
type GitRepositoryRepository ¶
type GitRepositoryRepository interface { GetRepositories(ctx context.Context, condition GetRepositoryCondition) ([]*Repository, error) GetRepository(ctx context.Context, id string) (*Repository, error) CreateRepository(ctx context.Context, repo *Repository) error UpdateRepository(ctx context.Context, id string, args *UpdateRepositoryArgs) error DeleteRepository(ctx context.Context, id string) error }
type MariaDBManager ¶
type MariaDBManager interface { GetHost() (host string, port int) // Create データベースが存在しない場合、作成します Create(ctx context.Context, args CreateArgs) error // Delete データベースが存在する場合、削除します Delete(ctx context.Context, args DeleteArgs) error // IsExist データベースが存在するか確認します IsExist(ctx context.Context, dbname string) (bool, error) Close(ctx context.Context) error }
MariaDBManager MariaDBマネージャー
type MongoDBManager ¶
type MongoDBManager interface { GetHost() (host string, port int) // Create データベースが存在しない場合、作成します Create(ctx context.Context, args CreateArgs) error // Delete データベースが存在する場合、削除します Delete(ctx context.Context, args DeleteArgs) error // IsExist データベースが存在するか確認します IsExist(ctx context.Context, dbname string) (bool, error) Close(ctx context.Context) error }
MongoDBManager Mongoマネージャー
type PortPublication ¶ added in v0.3.0
type PortPublication struct { InternetPort int ApplicationPort int Protocol PortPublicationProtocol }
func (*PortPublication) Compare ¶ added in v0.4.1
func (p *PortPublication) Compare(other *PortPublication) bool
func (*PortPublication) ConflictsWith ¶ added in v0.3.0
func (p *PortPublication) ConflictsWith(existing []*Application) bool
func (*PortPublication) Validate ¶ added in v0.3.0
func (p *PortPublication) Validate() error
type PortPublicationProtocol ¶ added in v0.3.0
type PortPublicationProtocol string
const ( PortPublicationProtocolTCP PortPublicationProtocol = "tcp" PortPublicationProtocolUDP PortPublicationProtocol = "udp" )
type PubSub ¶
type PubSub[E any] struct { // contains filtered or unexported fields }
PubSub is a simple pub-sub for single event type. A zero-value PubSub is ready for use.
type Repository ¶
type Repository struct { ID string Name string URL string Auth optional.Of[RepositoryAuth] OwnerIDs []string }
func NewRepository ¶ added in v0.5.0
func NewRepository(name, url string, auth optional.Of[RepositoryAuth], ownerIDs []string) *Repository
func (*Repository) Apply ¶
func (r *Repository) Apply(args *UpdateRepositoryArgs)
func (*Repository) IsOwner ¶
func (r *Repository) IsOwner(user *User) bool
func (*Repository) Validate ¶
func (r *Repository) Validate() error
type RepositoryAuth ¶
type RepositoryAuth struct { Method RepositoryAuthMethod Username string Password string SSHKey string }
func (*RepositoryAuth) Validate ¶
func (r *RepositoryAuth) Validate() error
type RepositoryAuthMethod ¶
type RepositoryAuthMethod int
const ( RepositoryAuthMethodBasic RepositoryAuthMethod = iota RepositoryAuthMethodSSH )
type RuntimeConfig ¶ added in v0.3.5
func (*RuntimeConfig) CommandArgs ¶ added in v0.3.5
func (rc *RuntimeConfig) CommandArgs() []string
func (*RuntimeConfig) EntrypointArgs ¶ added in v0.3.5
func (rc *RuntimeConfig) EntrypointArgs() []string
func (*RuntimeConfig) MariaDB ¶ added in v0.3.5
func (rc *RuntimeConfig) MariaDB() bool
func (*RuntimeConfig) MongoDB ¶ added in v0.3.5
func (rc *RuntimeConfig) MongoDB() bool
func (*RuntimeConfig) Validate ¶ added in v0.3.5
func (rc *RuntimeConfig) Validate() error
type RuntimeDesiredState ¶
type RuntimeDesiredState struct { App *Application ImageName string ImageTag string Envs map[string]string }
type StaticConfig ¶ added in v0.3.5
type StaticConfig struct{}
func (*StaticConfig) CommandArgs ¶ added in v0.3.5
func (sc *StaticConfig) CommandArgs() []string
func (*StaticConfig) EntrypointArgs ¶ added in v0.3.5
func (sc *StaticConfig) EntrypointArgs() []string
func (*StaticConfig) MariaDB ¶ added in v0.3.5
func (sc *StaticConfig) MariaDB() bool
func (*StaticConfig) MongoDB ¶ added in v0.3.5
func (sc *StaticConfig) MongoDB() bool
type StaticServer ¶ added in v0.7.0
type StaticServerDocumentRootPath ¶
type StaticServerDocumentRootPath string
type StaticSite ¶
type StaticSite struct { Application *Application Website *Website ArtifactID string }
func GetActiveStaticSites ¶
func GetActiveStaticSites(ctx context.Context, appRepo ApplicationRepository, buildRepo BuildRepository) ([]*StaticSite, error)
type Storage ¶
type Storage interface { Save(filename string, src io.Reader) error Open(filename string) (io.ReadCloser, error) Delete(filename string) error }
Storage ストレージインターフェース
type StorageConfig ¶
type StorageConfig struct { Type string `mapstructure:"type" yaml:"type"` Local struct { // Dir 保存ディレクトリ Dir string `mapstructure:"dir" yaml:"dir"` } `mapstructure:"local" yaml:"local"` S3 struct { // Bucket バケット名 Bucket string `mapstructure:"bucket" yaml:"bucket"` Endpoint string `mapstructure:"endpoint" yaml:"endpoint"` Region string `mapstructure:"region" yaml:"region"` AccessKey string `mapstructure:"accessKey" yaml:"accessKey"` AccessSecret string `mapstructure:"accessSecret" yaml:"accessSecret"` } `mapstructure:"s3" yaml:"s3"` Swift struct { // UserName ユーザー名 UserName string `mapstructure:"username" yaml:"username"` // APIKey APIキー(パスワード) APIKey string `mapstructure:"apiKey" yaml:"apiKey"` // TenantName テナント名 TenantName string `mapstructure:"tenantName" yaml:"tenantName"` // TenantID テナントID TenantID string `mapstructure:"tenantId" yaml:"tenantId"` // Container コンテナ名 Container string `mapstructure:"container" yaml:"container"` // AuthURL 認証エンドポイント AuthURL string `mapstructure:"authUrl" yaml:"authUrl"` } `mapstructure:"swift" yaml:"swift"` }
type UpdateApplicationArgs ¶
type UpdateApplicationArgs struct { Name optional.Of[string] RefName optional.Of[string] Running optional.Of[bool] Container optional.Of[ContainerState] CurrentCommit optional.Of[string] WantCommit optional.Of[string] UpdatedAt optional.Of[time.Time] Config optional.Of[ApplicationConfig] Websites optional.Of[[]*Website] PortPublications optional.Of[[]*PortPublication] OwnerIDs optional.Of[[]string] }
type UpdateBuildArgs ¶
type UpdateRepositoryArgs ¶
type User ¶
func (*User) AvatarURL ¶ added in v0.4.6
func (u *User) AvatarURL(baseURL AvatarBaseURL) string
type UserKey ¶
func (*UserKey) MarshalKey ¶
type UserRepository ¶
type UserRepository interface { EnsureUser(ctx context.Context, name string) (*User, error) EnsureUsers(ctx context.Context, names []string) ([]*User, error) GetUsers(ctx context.Context, cond GetUserCondition) ([]*User, error) GetUserKeys(ctx context.Context, cond GetUserKeyCondition) ([]*UserKey, error) CreateUserKey(ctx context.Context, key *UserKey) error DeleteUserKey(ctx context.Context, keyID string, userID string) error }
type Website ¶
type WildcardDomains ¶
type WildcardDomains []string
func (WildcardDomains) TLSTargetDomain ¶
func (wd WildcardDomains) TLSTargetDomain(website *Website) string
func (WildcardDomains) Validate ¶
func (wd WildcardDomains) Validate() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.