grim/convey

remove the old workspace stuff

2019-03-30, Gary Kramlich
268356681abb
Parents 7620d17a033e
Children 1e90226dcdbd
remove the old workspace stuff
--- a/docker/workspace.go Sat Mar 30 00:39:54 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-// Convey
-// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package docker
-
-import (
- "fmt"
- "strings"
- "time"
-
- "github.com/aphistic/gomol"
-
- "bitbucket.org/rw_grim/convey/logging"
- "bitbucket.org/rw_grim/convey/runtime"
- "bitbucket.org/rw_grim/convey/util"
-)
-
-// Workspace represents a docker workspace.
-type Workspace struct {
- name string
- volumeName string
- mountPoint string
-
- logger *gomol.LogAdapter
- rt *runtime.Runtime
-}
-
-func (ws *Workspace) findMountPoint(rt *runtime.Runtime) error {
- cmdv := []string{
- "inspect",
- "--format",
- "{{range .Mounts}}{{if eq .Destination \"/workspace\" }}{{.Source}}{{end}}{{end}}",
- ws.volumeName,
- }
-
- stdout, stderr, err := DockerOutput("findMountPoint", cmdv, rt)
- if err != nil {
- if lErr := ws.logger.Errorf("%s", stderr); lErr != nil {
- fmt.Printf("error reporting error: %s\n", lErr)
- }
-
- return err
- }
-
- ws.mountPoint = strings.TrimSpace(stdout)
-
- return nil
-}
-
-// NewWorkspace creates a new docker workspace.
-func NewWorkspace(rt *runtime.Runtime) (*Workspace, error) {
- ws := &Workspace{
- name: util.ID(),
- logger: logging.NewAdapter("workspace"),
- rt: rt,
- }
-
- cmdv := []string{
- "create",
- "--name=" + ws.name,
- "convey/workspace",
- }
-
- out, _, err := DockerOutput("create workspace", cmdv, rt)
- if err != nil {
- return nil, err
- }
-
- ws.volumeName = strings.TrimSpace(out)
-
- err = ws.findMountPoint(rt)
- if err != nil {
- return nil, err
- }
-
- if lErr := ws.logger.Debugf("created workspace: %#v", ws); lErr != nil {
- fmt.Printf("error reporting debug: %s\n", lErr)
- }
-
- return ws, nil
-}
-
-// Name returns the name of the docker workspace.
-func (ws *Workspace) Name() string {
- return ws.name
-}
-
-// Destroy removes the docker workspace.
-func (ws *Workspace) Destroy() error {
- // monkey with the timeout so our cleanup always runs
- oldTimeout := ws.rt.State.PlanTimeout
- defer func() {
- ws.rt.State.PlanTimeout = oldTimeout
- }()
- ws.rt.State.PlanTimeout = 15 * time.Minute
-
- cmdv := []string{"rm", "-v", ws.name}
-
- return Docker("remove workspace", cmdv, ws.rt)
-}
--- a/docker/workspace_test.go Sat Mar 30 00:39:54 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-// Convey
-// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package docker
-
-import "bitbucket.org/rw_grim/convey/workspace"
-
-var _ workspace.Workspace = &Workspace{}
--- a/workspace/workspace.go Sat Mar 30 00:39:54 2019 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-// Convey
-// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-// Package workspace contains the workspace definition.
-package workspace
-
-// Workspace is a simple interface for creating a Convey workspace.
-type Workspace interface {
- Name() string
- Destroy() error
-}