Skip to content

Commit

Permalink
chore: renames base manifest type (opendatahub-io#910)
Browse files Browse the repository at this point in the history
Raw Manifest describes better the purpose of the type, as it is a simple text file without any additional processing behavior.
  • Loading branch information
bartoszmajsak authored Mar 11, 2024
1 parent b990de2 commit 410ea57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (f *Feature) createApplier(m Manifest) applier {
return patchResources(f.Client, objects)
}
}
case *baseManifest:
case *rawManifest:
if manifest.patch {
return func(objects []*unstructured.Unstructured) error {
return patchResources(f.Client, objects)
Expand Down
12 changes: 6 additions & 6 deletions pkg/feature/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ type Manifest interface {
Process(data any) ([]*unstructured.Unstructured, error)
}

type baseManifest struct {
type rawManifest struct {
name,
path string
patch bool
fsys fs.FS
}

var _ Manifest = (*baseManifest)(nil)
var _ Manifest = (*rawManifest)(nil)

func (b *baseManifest) Process(_ any) ([]*unstructured.Unstructured, error) {
func (b *rawManifest) Process(_ any) ([]*unstructured.Unstructured, error) {
manifestFile, err := b.fsys.Open(b.path)
if err != nil {
return nil, err
Expand Down Expand Up @@ -169,7 +169,7 @@ func loadManifestsFrom(fsys fs.FS, path string) ([]Manifest, error) {
if isTemplateManifest(path) {
manifests = append(manifests, CreateTemplateManifestFrom(fsys, path))
} else {
manifests = append(manifests, CreateBaseManifestFrom(fsys, path))
manifests = append(manifests, CreateRawManifestFrom(fsys, path))
}

return nil
Expand All @@ -182,10 +182,10 @@ func loadManifestsFrom(fsys fs.FS, path string) ([]Manifest, error) {
return manifests, nil
}

func CreateBaseManifestFrom(fsys fs.FS, path string) *baseManifest { //nolint:golint,revive //No need to export baseManifest.
func CreateRawManifestFrom(fsys fs.FS, path string) *rawManifest { //nolint:golint,revive //No need to export rawManifest.
basePath := filepath.Base(path)

return &baseManifest{
return &rawManifest{
name: basePath,
path: path,
patch: strings.Contains(basePath, ".patch"),
Expand Down
10 changes: 5 additions & 5 deletions pkg/feature/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var _ = Describe("Manifest Processing", func() {

})

Describe("baseManifest Process", func() {
Describe("Raw Manifest Processing", func() {
BeforeEach(func() {
resourceYaml := `
apiVersion: v1
Expand All @@ -55,9 +55,9 @@ data:
Expect(err).ToNot(HaveOccurred())
})

It("should process the base manifest with no substitutions", func() {
It("should process the raw manifest with no substitutions", func() {
// given
manifest := feature.CreateBaseManifestFrom(inMemFS, path)
manifest := feature.CreateRawManifestFrom(inMemFS, path)

data := feature.Spec{
TargetNamespace: "not-used",
Expand All @@ -74,7 +74,7 @@ data:
})
})

Describe("TemplateManifest Process", func() {
Describe("Templated Manifest Processing", func() {
BeforeEach(func() {
resourceYaml := `
apiVersion: v1
Expand Down Expand Up @@ -111,7 +111,7 @@ data:

})

Describe("KustomizeManifest Process", func() {
Describe("Kustomize Manifest Processing", func() {
BeforeEach(func() {
path = "/path/to/kustomization/" // base path here
kustFsys = filesys.MakeFsInMemory()
Expand Down

0 comments on commit 410ea57

Please sign in to comment.