forked from Ivasoft/drone-docker
(feat) publish docker data to create drone card (#347)
* plugin logic to write card data to publish drone card
This commit is contained in:
58
docker.go
58
docker.go
@@ -64,11 +64,34 @@ type (
|
||||
|
||||
// Plugin defines the Docker plugin parameters.
|
||||
Plugin struct {
|
||||
Login Login // Docker login configuration
|
||||
Build Build // Docker build configuration
|
||||
Daemon Daemon // Docker daemon configuration
|
||||
Dryrun bool // Docker push is skipped
|
||||
Cleanup bool // Docker purge is enabled
|
||||
Login Login // Docker login configuration
|
||||
Build Build // Docker build configuration
|
||||
Daemon Daemon // Docker daemon configuration
|
||||
Dryrun bool // Docker push is skipped
|
||||
Cleanup bool // Docker purge is enabled
|
||||
CardPath string // Card path to write file to
|
||||
}
|
||||
|
||||
Inspect []struct {
|
||||
ID string `json:"Id"`
|
||||
RepoTags []string `json:"RepoTags"`
|
||||
RepoDigests []interface{} `json:"RepoDigests"`
|
||||
Parent string `json:"Parent"`
|
||||
Comment string `json:"Comment"`
|
||||
Created time.Time `json:"Created"`
|
||||
Container string `json:"Container"`
|
||||
DockerVersion string `json:"DockerVersion"`
|
||||
Author string `json:"Author"`
|
||||
Architecture string `json:"Architecture"`
|
||||
Os string `json:"Os"`
|
||||
Size int `json:"Size"`
|
||||
VirtualSize int `json:"VirtualSize"`
|
||||
Metadata struct {
|
||||
LastTagTime time.Time `json:"LastTagTime"`
|
||||
} `json:"Metadata"`
|
||||
SizeString string
|
||||
VirtualSizeString string
|
||||
Time string
|
||||
}
|
||||
)
|
||||
|
||||
@@ -157,11 +180,6 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
}
|
||||
|
||||
if p.Cleanup {
|
||||
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
||||
cmds = append(cmds, commandPrune()) // docker system prune -f
|
||||
}
|
||||
|
||||
// execute all commands in batch mode.
|
||||
for _, cmd := range cmds {
|
||||
cmd.Stdout = os.Stdout
|
||||
@@ -180,6 +198,26 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
}
|
||||
|
||||
// output the adaptive card
|
||||
if err := p.writeCard(); err != nil {
|
||||
fmt.Printf("Could not create adaptive card. %s\n", err)
|
||||
}
|
||||
|
||||
// execute cleanup routines in batch mode
|
||||
if p.Cleanup {
|
||||
// clear the slice
|
||||
cmds = nil
|
||||
|
||||
cmds = append(cmds, commandRmi(p.Build.Name)) // docker rmi
|
||||
cmds = append(cmds, commandPrune()) // docker system prune -f
|
||||
|
||||
for _, cmd := range cmds {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
trace(cmd)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user