Skip to content

Commit

Permalink
Use rendered kots kinds (#4239)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh authored Dec 22, 2023
1 parent 3acd8f9 commit b35c513
Show file tree
Hide file tree
Showing 140 changed files with 4,019 additions and 723 deletions.
14 changes: 7 additions & 7 deletions cmd/imagedeps/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ func TestFunctional(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
rootDir := path.Join("testdata", tc.name)

expectedConstants, err := ioutil.ReadFile(path.Join(rootDir, "constants.go"))
expectedConstants, err := os.ReadFile(path.Join(rootDir, "constants.go"))
require.Nil(t, err)

expectedEnvs, err := ioutil.ReadFile(path.Join(rootDir, ".image.env"))
expectedEnvs, err := os.ReadFile(path.Join(rootDir, ".image.env"))
require.Nil(t, err)

tempDir := t.TempDir()
Expand Down Expand Up @@ -178,10 +178,10 @@ func TestFunctional(t *testing.T) {

require.Nil(t, err)

actualConstants, err := ioutil.ReadFile(constantFile)
actualConstants, err := os.ReadFile(constantFile)
require.Nil(t, err)

actualEnv, err := ioutil.ReadFile(envFile)
actualEnv, err := os.ReadFile(envFile)
require.Nil(t, err)

require.Equal(t, string(expectedConstants), string(actualConstants))
Expand All @@ -195,10 +195,10 @@ func TestFunctional(t *testing.T) {
require.Nil(t, err)

for _, f := range files {
expectedContent, err := ioutil.ReadFile(path.Join(expectedDir, f.Name()))
expectedContent, err := os.ReadFile(path.Join(expectedDir, f.Name()))
require.Nil(t, err)

actualContent, err := ioutil.ReadFile(path.Join(actualDir, f.Name()))
actualContent, err := os.ReadFile(path.Join(actualDir, f.Name()))
require.Nil(t, err)

require.Equal(t, string(expectedContent), string(actualContent))
Expand All @@ -220,7 +220,7 @@ func copyDirFiles(inputDir string, outputDir string) error {
}

for _, f := range files {
content, err := ioutil.ReadFile(path.Join(inputDir, f.Name()))
content, err := os.ReadFile(path.Join(inputDir, f.Name()))
if err != nil {
return errors.Wrapf(err, "failed to read file %s", path.Join(inputDir, f.Name()))
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/kots/cli/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cli
import (
"context"
"fmt"
"io/ioutil"
"os"

"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/identity"
Expand Down Expand Up @@ -65,7 +65,7 @@ func IdentityServiceInstallCmd() *cobra.Command {

identityConfig := kotsv1beta1.IdentityConfig{}
if identityConfigPath := v.GetString("identity-config"); identityConfigPath != "" {
content, err := ioutil.ReadFile(identityConfigPath)
content, err := os.ReadFile(identityConfigPath)
if err != nil {
return errors.Wrap(err, "failed to read identity service config file")
}
Expand Down Expand Up @@ -132,7 +132,7 @@ func IdentityServiceConfigureCmd() *cobra.Command {

identityConfig := kotsv1beta1.IdentityConfig{}
if identityConfigPath := v.GetString("identity-config"); identityConfigPath != "" {
content, err := ioutil.ReadFile(identityConfigPath)
content, err := os.ReadFile(identityConfigPath)
if err != nil {
return errors.Wrap(err, "failed to read identity service config file")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/kots/cli/ingress.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cli

import (
"io/ioutil"
"os"

"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/identity"
Expand Down Expand Up @@ -54,7 +54,7 @@ func IngressInstallCmd() *cobra.Command {

ingressConfig := kotsv1beta1.IngressConfig{}
if ingressConfigPath := v.GetString("ingress-config"); ingressConfigPath != "" {
content, err := ioutil.ReadFile(ingressConfigPath)
content, err := os.ReadFile(ingressConfigPath)
if err != nil {
return errors.Wrap(err, "failed to read ingress service config file")
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/kots/cli/pull.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"io/ioutil"
"os"
"path"
"strings"
Expand Down Expand Up @@ -151,7 +150,7 @@ func getAppSlugForPull(uri string, licenseFile string) (string, error) {
return appSlug, nil
}

licenseData, err := ioutil.ReadFile(licenseFile)
licenseData, err := os.ReadFile(licenseFile)
if err != nil {
return "", errors.Wrap(err, "failed to read license file")
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/kots/cli/set-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -176,7 +175,7 @@ func getConfigValuesFromArgs(v *viper.Viper, args []string) ([]byte, error) {
return nil, errors.New("--config-file cannot be used with other key/value arguments")
}

data, err := ioutil.ReadFile(fileName)
data, err := os.ReadFile(fileName)
if err != nil {
return nil, errors.Wrap(err, "failed to load config from file")
}
Expand Down Expand Up @@ -206,7 +205,7 @@ func getConfigValuesFromArgs(v *viper.Viper, args []string) ([]byte, error) {
Value: value,
}
} else if valueFile != "" {
data, err := ioutil.ReadFile(valueFile)
data, err := os.ReadFile(valueFile)
if err != nil {
return nil, errors.Wrap(err, "failed to load value from file")
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/kots/cli/velero.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -394,7 +393,7 @@ func VeleroConfigureOtherS3Cmd() *cobra.Command {
if err != nil {
return err
}
caCertData, err = ioutil.ReadFile(realPath)
caCertData, err = os.ReadFile(realPath)
if err != nil {
return err
}
Expand Down Expand Up @@ -506,7 +505,7 @@ func VeleroConfigureGCPServiceAccount() *cobra.Command {

jsonFile := ""
if jsonFilePath := v.GetString("json-file"); jsonFilePath != "" {
content, err := ioutil.ReadFile(jsonFilePath)
content, err := os.ReadFile(jsonFilePath)
if err != nil {
return errors.Wrap(err, "failed to read json file")
}
Expand Down
3 changes: 2 additions & 1 deletion integration/database/rqlite_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ory/dockertest/v3/docker"
"github.com/pkg/errors"
"github.com/replicatedhq/kots/pkg/image"
"github.com/replicatedhq/kots/pkg/imageutil"
"github.com/replicatedhq/kots/pkg/persistence"
"github.com/rqlite/gorqlite"
)
Expand Down Expand Up @@ -72,7 +73,7 @@ func TestMigrateFromPostgresToRqlite(t *testing.T) {
if err := os.WriteFile(rqliteAuthConfigPath, []byte(RQLITE_AUTH_CONFIG), 0644); err != nil {
t.Fatalf("Failed to write to file %s", rqliteAuthConfigPath)
}
rqliteTag, _ := image.GetTag(image.Rqlite)
rqliteTag, _ := imageutil.GetTag(image.Rqlite)
rqliteRunOptions := &dockertest.RunOptions{
Name: "rqlite",
Repository: "kotsadm/rqlite",
Expand Down
4 changes: 2 additions & 2 deletions integration/docker/registry/temp_registry_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package replicated

import (
"io/ioutil"
"os"
"path"
"reflect"
"testing"
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestTempRegistry_GetImageLayers(t *testing.T) {

req := require.New(t)

manifestsContent, err := ioutil.ReadFile(path.Join("assets", "manifests.yaml"))
manifestsContent, err := os.ReadFile(path.Join("assets", "manifests.yaml"))
req.NoError(err)

var manifests map[string]string
Expand Down
4 changes: 2 additions & 2 deletions integration/replicated/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func generateReplicatedAppArchive(rawArchivePath string) ([]byte, error) {
if err := tarGz.Archive([]string{rawArchivePath}, archiveFile); err != nil {
return nil, errors.Wrap(err, "failed to create archive")
}
b, err := ioutil.ReadFile(archiveFile)
b, err := os.ReadFile(archiveFile)
if err != nil {
return nil, errors.Wrap(err, "failed to read archive file")
}
Expand Down Expand Up @@ -152,7 +152,7 @@ func generateExpectedFilesystem(namespace, rawArchivePath string) ([]byte, error
if err := tarGz.Archive(paths, archiveFile); err != nil {
return nil, errors.Wrap(err, "failed to create archive")
}
b, err := ioutil.ReadFile(archiveFile)
b, err := os.ReadFile(archiveFile)
if err != nil {
return nil, errors.Wrap(err, "failed to read archive file")
}
Expand Down
9 changes: 5 additions & 4 deletions integration/replicated/pull_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package replicated

import (
"io/ioutil"
"os"
"path"
"testing"

Expand Down Expand Up @@ -42,11 +43,11 @@ func Test_PullReplicated(t *testing.T) {
t.Run(testDir.Name(), func(t *testing.T) {
req := require.New(t)

archiveData, err := ioutil.ReadFile(path.Join(testResourcePath, "archive.tar.gz"))
archiveData, err := os.ReadFile(path.Join(testResourcePath, "archive.tar.gz"))
req.NoError(err)

licenseFilepath := path.Join(testResourcePath, "license.yaml")
licenseFile, err := ioutil.ReadFile(licenseFilepath)
licenseFile, err := os.ReadFile(licenseFilepath)
req.NoError(err)

server, err := StartMockServer(archiveData, licenseFile)
Expand Down Expand Up @@ -84,7 +85,7 @@ func Test_PullReplicated(t *testing.T) {
err = tarGz.Archive(paths, path.Join(actualFilesystemDir, "archive.tar.gz"))
req.NoError(err)

actualFilesystemBytes, err := ioutil.ReadFile(path.Join(actualFilesystemDir, "archive.tar.gz"))
actualFilesystemBytes, err := os.ReadFile(path.Join(actualFilesystemDir, "archive.tar.gz"))
req.NoError(err)

// create an archive of the expected
Expand All @@ -98,7 +99,7 @@ func Test_PullReplicated(t *testing.T) {
err = tarGz.Archive(paths, path.Join(expectedFilesystemDir, "archive.tar.gz"))
req.NoError(err)

expectedFilesystemBytes, err := ioutil.ReadFile(path.Join(expectedFilesystemDir, "archive.tar.gz"))
expectedFilesystemBytes, err := os.ReadFile(path.Join(expectedFilesystemDir, "archive.tar.gz"))
req.NoError(err)

compareOptions := util.CompareOptions{
Expand Down
2 changes: 1 addition & 1 deletion kurl_proxy/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ type kotsadmApp struct {
func kotsadmApplication() (kotsadmApp, error) {
app := kotsadmApp{}

data, err := ioutil.ReadFile("/etc/kotsadm/application.yaml")
data, err := os.ReadFile("/etc/kotsadm/application.yaml")
if err != nil {
return app, errors.Wrap(err, "read file /etc/kotsadm/application.yaml")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/airgap/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func CreateAppFromAirgap(opts CreateAirgapAppOpts) (finalError error) {
return errors.Wrap(err, "failed to create support bundle dependencies")
}

kotsKinds, err := kotsutil.LoadKotsKindsFromPath(filepath.Join(tmpRoot, "upstream"))
kotsKinds, err := kotsutil.LoadKotsKinds(tmpRoot)
if err != nil {
return errors.Wrap(err, "failed to load kotskinds from path")
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/airgap/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
}
defer os.RemoveAll(archiveDir)

beforeKotsKinds, err := kotsutil.LoadKotsKindsFromPath(filepath.Join(archiveDir, "upstream"))
beforeKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return errors.Wrap(err, "failed to load current kotskinds")
}
Expand Down Expand Up @@ -177,6 +177,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
AppSlug: a.Slug,
AppSequence: appSequence,
SkipCompatibilityCheck: skipCompatibilityCheck,
KotsKinds: beforeKotsKinds,
}

if _, err := pull.Pull(fmt.Sprintf("replicated://%s", beforeKotsKinds.License.Spec.AppSlug), pullOptions); err != nil {
Expand All @@ -185,7 +186,7 @@ func UpdateAppFromPath(a *apptypes.App, airgapRoot string, airgapBundlePath stri
}
}

afterKotsKinds, err := kotsutil.LoadKotsKindsFromPath(filepath.Join(archiveDir, "upstream"))
afterKotsKinds, err := kotsutil.LoadKotsKinds(archiveDir)
if err != nil {
return errors.Wrap(err, "failed to read after kotskinds")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apparchive/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func GetRenderedApp(versionArchive string, downstreamName, kustomizeBinPath stri
return nil
}

content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
return errors.Wrapf(err, "failed to read file %s", path)
}
Expand Down Expand Up @@ -216,7 +216,7 @@ func cleanBaseApp(baseDir string, filter func(path string) (bool, error)) error
}
}

content, err := ioutil.ReadFile(path)
content, err := os.ReadFile(path)
if err != nil {
return errors.Wrapf(err, "failed to read file %s", path)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apparchive/helm-v1beta1.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func RenderChartsArchive(baseDir string, overlaysDir string, downstreamName stri
}

for _, filename := range metadataFiles {
content, err := ioutil.ReadFile(filepath.Join(sourceChartsDir, relPath, filename))
content, err := os.ReadFile(filepath.Join(sourceChartsDir, relPath, filename))
if err != nil {
if os.IsNotExist(err) {
continue
Expand Down
4 changes: 2 additions & 2 deletions pkg/apparchive/helm-v1beta1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ kind: Kustomization
req.NoError(err)

for wantPath, wantContent := range tt.wantRenderedFilesMap {
gotContent, err := ioutil.ReadFile(filepath.Join(extracted, "charts", wantPath))
gotContent, err := os.ReadFile(filepath.Join(extracted, "charts", wantPath))
require.Nil(t, err)

if !reflect.DeepEqual(gotContent, wantContent) {
Expand Down Expand Up @@ -517,7 +517,7 @@ kind: Kustomization
req.NoError(err)

for wantPath, wantContent := range tt.wantRenderedFilesMap {
gotContent, err := ioutil.ReadFile(filepath.Join(extracted, "charts", wantPath))
gotContent, err := os.ReadFile(filepath.Join(extracted, "charts", wantPath))
require.Nil(t, err)

if !reflect.DeepEqual(gotContent, wantContent) {
Expand Down
Loading

0 comments on commit b35c513

Please sign in to comment.