diff --git a/internal/prepare.go b/internal/prepare.go index 3b2621b..a0f8191 100644 --- a/internal/prepare.go +++ b/internal/prepare.go @@ -4,15 +4,15 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "math/rand" "os" "path/filepath" "regexp" - "sigs.k8s.io/yaml" "strings" "time" + "sigs.k8s.io/yaml" + "github.com/crossplane/crossplane-runtime/pkg/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" kyaml "k8s.io/apimachinery/pkg/util/yaml" @@ -23,8 +23,8 @@ import ( var ( charset = []rune("abcdefghijklmnopqrstuvwxyz0123456789") - dataSourceRegex = regexp.MustCompile("\\${data\\.(.*?)}") - randomStrRegex = regexp.MustCompile("\\${Rand\\.(.*?)}") + dataSourceRegex = regexp.MustCompile(`\${data\.(.*?)}`) + randomStrRegex = regexp.MustCompile(`\${Rand\.(.*?)}`) caseDirectory = "case" ) @@ -105,7 +105,7 @@ func (p *Preparer) PrepareManifests() ([]config.Manifest, error) { func (p *Preparer) injectVariables() (map[string]string, error) { dataSourceMap := make(map[string]string) if p.dataSourcePath != "" { - dataSource, err := ioutil.ReadFile(p.dataSourcePath) + dataSource, err := os.ReadFile(p.dataSourcePath) if err != nil { return nil, errors.Wrap(err, "cannot read data source file") } @@ -116,7 +116,7 @@ func (p *Preparer) injectVariables() (map[string]string, error) { inputs := make(map[string]string, len(p.testFilePaths)) for _, f := range p.testFilePaths { - manifestData, err := ioutil.ReadFile(f) + manifestData, err := os.ReadFile(f) if err != nil { return nil, errors.Wrapf(err, "cannot read %s", f) } diff --git a/internal/templates/embed.go b/internal/templates/embed.go index e3fb558..8f7c994 100644 --- a/internal/templates/embed.go +++ b/internal/templates/embed.go @@ -3,17 +3,21 @@ package templates import _ "embed" // nolint:golint // inputFileTemplate is the template for the input file. +// //go:embed 00-apply.yaml.tmpl var inputFileTemplate string // assertFileTemplate is the template for the assert file. +// //go:embed 00-assert.yaml.tmpl var assertFileTemplate string // deleteFileTemplate is the template for the delete file. +// //go:embed 01-delete.yaml.tmpl var deleteFileTemplate string // assertDeletedFileTemplate is the template for delete assert file. +// //go:embed 01-assert.yaml.tmpl var assertDeletedFileTemplate string