go fmt
All checks were successful
Declarative Tests / test (push) Successful in 48s

This commit is contained in:
Matthew Rich 2024-03-25 13:31:06 -07:00
parent e71d177984
commit e695278d0c
18 changed files with 930 additions and 943 deletions

View File

@ -1,29 +1,27 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
// Container resource
package resource
import (
"context"
"fmt"
_ "os"
_ "gopkg.in/yaml.v3"
_ "os/exec"
_ "strings"
"log/slog"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/docker/client"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gopkg.in/yaml.v3"
_ "gopkg.in/yaml.v3"
"log/slog"
"net/url"
_ "os"
_ "os/exec"
"path/filepath"
_ "strings"
)
type ContainerClient interface {
@ -220,7 +218,6 @@ func (c *Container) Read(ctx context.Context) ([]byte, error) {
return yaml.Marshal(c)
}
func (c *Container) Delete(ctx context.Context) error {
err := c.apiClient.ContainerRemove(ctx, c.Id, types.ContainerRemoveOptions{
RemoveVolumes: true,

View File

@ -1,25 +1,24 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
_ "fmt"
"context"
"testing"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "io"
_ "os"
"github.com/stretchr/testify/assert"
_ "encoding/json"
_ "strings"
"decl/tests/mocks"
_ "encoding/json"
_ "fmt"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "os"
_ "strings"
"testing"
)
func TestNewContainerResource(t *testing.T) {

View File

@ -1,13 +1,12 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
"context"
"fmt"
"log/slog"
"gopkg.in/yaml.v3"
"log/slog"
)
type Declaration struct {

View File

@ -2,12 +2,12 @@
package resource
import (
"fmt"
"github.com/stretchr/testify/assert"
_ "log"
_ "os"
"path/filepath"
"fmt"
_ "log"
"testing"
"github.com/stretchr/testify/assert"
)
func TestYamlLoadDecl(t *testing.T) {

View File

@ -1,13 +1,12 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
_ "fmt"
_ "log"
"io"
"gopkg.in/yaml.v3"
"io"
_ "log"
_ "net/url"
)
@ -22,7 +21,7 @@ func NewDocument() *Document {
func (d *Document) Load(r io.Reader) error {
yamlDecoder := yaml.NewDecoder(r)
yamlDecoder.Decode(d)
for i := range(d.ResourceDecls) {
for i := range d.ResourceDecls {
if _, e := d.ResourceDecls[i].LoadResourceFromYaml(); e != nil {
return e
}
@ -35,7 +34,7 @@ func (d *Document) Resources() []Declaration {
}
func (d *Document) Apply() error {
for i := range(d.ResourceDecls) {
for i := range d.ResourceDecls {
if e := d.ResourceDecls[i].Resource().Apply(); e != nil {
return e
}
@ -43,7 +42,7 @@ func (d *Document) Apply() error {
return nil
}
func (d *Document) Generate(w io.Writer) (error) {
func (d *Document) Generate(w io.Writer) error {
yamlEncoder := yaml.NewEncoder(w)
yamlEncoder.Encode(d)
return yamlEncoder.Close()

View File

@ -3,15 +3,15 @@ package resource
import (
"context"
"os"
"fmt"
"log"
"strings"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"time"
"log"
"os"
"path/filepath"
"strings"
"syscall"
"testing"
"time"
)
func TestNewDocumentLoader(t *testing.T) {

View File

@ -1,17 +1,16 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
"context"
"fmt"
_ "os"
"gopkg.in/yaml.v3"
_ "os/exec"
_ "strings"
_ "log"
"net/url"
_ "os"
_ "os/exec"
_ "strings"
)
type Exec struct {
@ -62,4 +61,3 @@ func (x *Exec) Type() string { return "exec" }
func (x *Exec) Read(ctx context.Context) ([]byte, error) {
return yaml.Marshal(x)
}

View File

@ -1,20 +1,19 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
"context"
"errors"
"fmt"
"gopkg.in/yaml.v3"
"io"
"net/url"
"os"
"os/user"
"io"
"syscall"
"gopkg.in/yaml.v3"
"strconv"
"path/filepath"
"net/url"
"strconv"
"syscall"
"time"
)
@ -83,7 +82,8 @@ func (f *File) Apply() error {
if removeErr != nil {
return removeErr
}
case "present": {
case "present":
{
uid, uidErr := LookupUID(f.Owner)
if uidErr != nil {
return uidErr

View File

@ -15,9 +15,9 @@ import (
"os"
"path/filepath"
_ "strings"
"syscall"
"testing"
"time"
"syscall"
)
func TestNewFileResource(t *testing.T) {

View File

@ -1,6 +1,5 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (

View File

@ -2,16 +2,16 @@
package resource
import (
_ "fmt"
_ "context"
"testing"
_ "encoding/json"
_ "fmt"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "io"
"github.com/stretchr/testify/assert"
_ "encoding/json"
_ "strings"
"testing"
)
func TestLookupUID(t *testing.T) {

View File

@ -42,7 +42,6 @@ type ResourceDeleter interface {
}
type ResourceDecoder struct {
}
func NewResource(uri string) Resource {

View File

@ -3,12 +3,12 @@ package resource
import (
"context"
_ "fmt"
"github.com/stretchr/testify/assert"
"log"
"os"
"path/filepath"
_ "fmt"
"log"
"testing"
"github.com/stretchr/testify/assert"
)
var TempDir string

View File

@ -1,6 +1,5 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (

View File

@ -3,10 +3,10 @@ package resource
import (
_ "context"
"testing"
"github.com/stretchr/testify/assert"
"decl/tests/mocks"
"github.com/stretchr/testify/assert"
"net/url"
"testing"
)
func TestNewResourceTypes(t *testing.T) {

View File

@ -1,19 +1,18 @@
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
//
package resource
import (
"context"
"fmt"
_ "os"
"gopkg.in/yaml.v3"
"os/exec"
"strings"
"log"
"net/url"
_ "os"
"os/exec"
"os/user"
"strconv"
"strings"
)
type User struct {
@ -153,4 +152,3 @@ func (u *User) Read(ctx context.Context) ([]byte, error) {
return yaml.Marshal(u)
}

View File

@ -2,17 +2,17 @@
package resource
import (
_ "fmt"
_ "context"
"testing"
_ "encoding/json"
_ "fmt"
"github.com/stretchr/testify/assert"
_ "io"
_ "net/http"
_ "net/http/httptest"
_ "net/url"
_ "io"
_ "os"
"github.com/stretchr/testify/assert"
_ "encoding/json"
_ "strings"
"testing"
)
func TestNewUserResource(t *testing.T) {