gitops

package
v0.0.0-...-0c70d8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventSync = "sync"
)

These are all the types of events.

View Source
const SyncIntervalStopChanName = "sync_stop_chan"

Variables

View Source
var SshRewriteUrlMap = make(map[string]string)

这个变量保存需要被替换的ssh地址

View Source
var SyncChan = make(chan SyncInfo, 100)

Functions

func Sync

func Sync(namespace string, m *kubernetes.Manifests, repoResources map[string]resource.Resource, changedResources map[string]resource.Resource, clus *kubernetes.Cluster) error

Sync synchronises the cluster to the files in a directory

Types

type Commit

type Commit struct {
	Revision string `json:"revision"`
	Message  string `json:"message"`
}

Commit represents the commit information in a sync event. We could use git.Commit, but that would lead to an import cycle, and may anyway represent coupling (of an internal API to serialised data) that we don't want.

type Event

type Event struct {
	// ID is a UUID for this event. Will be auto-set when saving if blank.
	ID EventID `json:"id"`

	ResourceIDs []resource.ResourceID `json:"resourceIDs"`

	// Type is the type of event, usually "release" for now, but could be other
	// things later
	Type string `json:"type"`

	// StartedAt is the time the event began.
	StartedAt time.Time `json:"startedAt"`

	// EndedAt is the time the event ended. For instantaneous events, this will
	// be the same as StartedAt.
	EndedAt time.Time `json:"endedAt"`

	// Metadata is Event.Type-specific metadata. If an event has no metadata,
	// this will be nil.
	Metadata EventMetadata `json:"metadata,omitempty"`
}

type EventID

type EventID int64

type EventMetadata

type EventMetadata interface {
	Type() string
}

EventMetadata is a type safety trick used to make sure that Metadata field of Event is always a pointer, so that consumers can cast without being concerned about encountering a value type instead. It works by virtue of the fact that the method is only defined for pointer receivers; the actual method chosen is entirely arbitary.

type FileCommit

type FileCommit struct {
	File   string `json:"file"`
	Commit string `json:"commit"`
}

type GitOps

type GitOps struct {
	GitHost string `json:"gitHost,omitempty"`
	Envs    []model.EnvParas
	Wg      *sync.WaitGroup
	// contains filtered or unexported fields
}

func New

func New(wg *sync.WaitGroup, gitConfig git.Config, gitRepos map[string]*git.Repo, kubeClient kube.Client, cluster *kubernetes.Cluster, chans *channel.CRChan) *GitOps

func (*GitOps) AskForSync

func (g *GitOps) AskForSync(namespace string)

func (*GitOps) LogEvent

func (g *GitOps) LogEvent(ev Event, namespace string) error

func (*GitOps) PrepareSSHKeys

func (g *GitOps) PrepareSSHKeys(envs []model.EnvParas, opts *commandutil.Opts) error

func (*GitOps) Process

func (g *GitOps) Process()

func (*GitOps) SyncInterval

func (g *GitOps) SyncInterval(StopCh <-chan struct{})

func (*GitOps) WithStop

func (g *GitOps) WithStop()

type ResourceCommit

type ResourceCommit struct {
	ResourceId string `json:"resourceId"`
	File       string `json:"file"`
	Commit     string `json:"commit"`
}

type ResourceError

type ResourceError struct {
	ID     resource.ResourceID `json:"id,omitempty"`
	Path   string              `json:"path,omitempty"`
	Error  string              `json:"error,omitempty"`
	Commit string              `json:"commit,omitempty"`
}

type SyncEventMetadata

type SyncEventMetadata struct {
	Commit string `json:"commit,omitempty"`
	// Per-resource errors
	Errors          []ResourceError  `json:"errors,omitempty"`
	FileCommits     []FileCommit     `json:"filesCommit,omitempty"`
	ResourceCommits []ResourceCommit `json:"resourceCommits,omitempty"`
}

SyncEventMetadata is the metadata for when new a commit is synced to the cluster

func (*SyncEventMetadata) Type

func (sem *SyncEventMetadata) Type() string

type SyncInfo

type SyncInfo struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL