Skip to content

Commit

Permalink
Merge branch 'release/1.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
deviantony committed May 29, 2020
2 parents fd1fc0f + ef30e13 commit 7e1d3f9
Show file tree
Hide file tree
Showing 32 changed files with 1,366 additions and 627 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
.tmp
86 changes: 52 additions & 34 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type (
EdgeKeySet bool
}

// EdgeStackConfig represnts an Edge stack config
EdgeStackConfig struct {
Name string
FileContent string
Prune bool
}

// AgentMetadata is the representation of the metadata object used to decorate
// all the objects in the response of a Docker aggregated resource request.
Metadata struct {
Expand Down Expand Up @@ -71,6 +78,18 @@ type (
Credentials string
}

InfoTags struct {
AgentPort string
EdgeKeySet bool
EngineStatus EngineStatus
Leader bool
NodeName string
NodeRole NodeRole
}

EngineStatus int
NodeRole int

// OptionParser is used to parse options.
OptionParser interface {
Options() (*Options, error)
Expand All @@ -81,11 +100,11 @@ type (
Create(advertiseAddr string, joinAddr []string) error
Members() []ClusterMember
Leave()
GetMemberByRole(role string) *ClusterMember
GetMemberByRole(role NodeRole) *ClusterMember
GetMemberByNodeName(nodeName string) *ClusterMember
GetMemberWithEdgeKeySet() *ClusterMember
GetTags() map[string]string
UpdateTags(tags map[string]string) error
GetTags() *InfoTags
UpdateTags(tags *InfoTags) error
}

// DigitalSignatureService is used to validate digital signatures.
Expand All @@ -95,7 +114,7 @@ type (

// InfoService is used to retrieve information from a Docker environment.
InfoService interface {
GetInformationFromDockerEngine() (map[string]string, error)
GetInformationFromDockerEngine() (*InfoTags, error)
GetContainerIpFromDockerEngine(containerName string, ignoreNonSwarmNetworks bool) (string, error)
GetServiceNameFromDockerEngine(containerName string) (string, error)
}
Expand All @@ -119,26 +138,23 @@ type (
IsTunnelOpen() bool
}

// TunnelOperator is a service that is used to communicate with a Portainer instance and to manage
// the reverse tunnel.
TunnelOperator interface {
Start() error
IsKeySet() bool
SetKey(key string) error
GetKey() string
CloseTunnel() error
ResetActivityTimer()
}

// Scheduler is used to manage schedules
Scheduler interface {
Schedule(schedules []Schedule) error
}

// DockerStackService is a service used to deploy and remove Docker stacks
DockerStackService interface {
Login() error
Logout() error
Deploy(name, stackFileContent string, prune bool) error
Remove(name string) error
}
)

const (
// Version represents the version of the agent.
Version = "1.5.1"
Version = "1.6.0"
// APIVersion represents the version of the agent's API.
APIVersion = "2"
// DefaultAgentAddr is the default address used by the Agent API server.
Expand All @@ -157,6 +173,8 @@ const (
DefaultEdgePollInterval = "5s"
// DefaultEdgeSleepInterval is the default interval after which the agent will close the tunnel if no activity.
DefaultEdgeSleepInterval = "5m"
// DefaultConfigCheckInterval is the default interval used to check if node config changed
DefaultConfigCheckInterval = "5s"
// SupportedDockerAPIVersion is the minimum Docker API version supported by the agent.
SupportedDockerAPIVersion = "1.24"
// HTTPTargetHeaderName is the name of the header used to specify a target node.
Expand Down Expand Up @@ -185,24 +203,6 @@ const (
// ResponseMetadataKey is the JSON field used to store any Portainer related information in
// response objects.
ResponseMetadataKey = "Portainer"
// MemberTagKeyAgentPort is the name of the label storing information about the port exposed
// by the agent.
MemberTagKeyAgentPort = "AgentPort"
// MemberTagKeyNodeName is the name of the label storing information about the name of the
// node where the agent is running.
MemberTagKeyNodeName = "NodeName"
// MemberTagKeyNodeRole is the name of the label storing information about the role of the
// node where the agent is running.
MemberTagKeyNodeRole = "NodeRole"
// MemberTagEngineStatus is the name of the label storing information about the status of the Docker engine where
// the agent is running. Possible values are "standalone" or "swarm".
MemberTagEngineStatus = "EngineStatus"
// MemberTagEdgeKeySet is the name of the label storing information regarding the association of an Edge key.
MemberTagEdgeKeySet = "EdgeKeySet"
// NodeRoleManager represents a manager node.
NodeRoleManager = "manager"
// NodeRoleWorker represents a worker node.
NodeRoleWorker = "worker"
// TLSCertPath is the default path to the TLS certificate file.
TLSCertPath = "cert.pem"
// TLSKeyPath is the default path to the TLS key file.
Expand All @@ -213,4 +213,22 @@ const (
DataDirectory = "/data"
// EdgeKeyFile is the name of the file used to persist the Edge key associated to the agent.
EdgeKeyFile = "agent_edge_key"
// DockerBinaryPath is the path of the docker binary
DockerBinaryPath = "/app"
// EdgeStackFilesPath is the path where edge stack files are saved
EdgeStackFilesPath = "/tmp/edge_stacks"
// EdgeStackQueueSleepInterval is the interval used to check if there's an Edge stack to deploy
EdgeStackQueueSleepInterval = "5s"
)

const (
_ NodeRole = iota
NodeRoleManager
NodeRoleWorker
)

const (
_ EngineStatus = iota
EngineStatusStandalone
EngineStatusSwarm
)
2 changes: 1 addition & 1 deletion build/linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM portainer/base

WORKDIR /app

COPY dist/agent /app/
COPY dist /app/
COPY static /app/static

ENTRYPOINT ["./agent"]
8 changes: 8 additions & 0 deletions build/linux/alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:latest

WORKDIR /app

COPY dist /app/
COPY static /app/static

ENTRYPOINT ["./agent"]
2 changes: 1 addition & 1 deletion build/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USER ContainerAdministrator

WORKDIR /app

COPY dist/agent.exe /app/
COPY dist /app/
COPY static /app/static

ENTRYPOINT ["C:/app/agent.exe"]
Loading

0 comments on commit 7e1d3f9

Please sign in to comment.