1

I am trying to integrate carvel ytt module with my app. So far I am trying some basic stuff I have previously tested in playground. When I try to do the same thing in code, it always returns no match.

filesToProcess := yttfiles.NewSortedFiles([]*yttfiles.File{
        yttfiles.MustNewFileFromSource(yttfiles.NewBytesSource(yttPath, readByteFile(yttPath))),
    })
 
    opts.DataValuesFlags = yttcmd.DataValuesFlags{
        FromFiles: []string{filePath},
        ReadFilesFunc: func(path string) ([]*yttfiles.File, error) {
            return []*yttfiles.File{yttfiles.MustNewFileFromSource(yttfiles.NewBytesSource(path, readByteFile(path)))}, nil
        },
    }
    output := opts.RunWithFiles( yttcmd.Input{Files: filesToProcess}, yttui.NewTTY(false))

yttPath is path to yaml containing overlay. Path is path to file I want to edit. readByteFile is just wrapped ioutil.ReadFile.

I am not sure if using overlays in code like this is possible, because there is no example on overlays on their github.

Is this code completely wrong? Thanks in advance to anyone experienced who looks into this.

pepík
  • 11
  • 3

1 Answers1

0

The way in which you're configuring and invoking ytt seems legit to me.

I hear you when you say this is stuff that's working in the Playground. But, if your program is running and you don't get an error, it makes me suspect that there's some subtle issue with the overlay itself.

If you could post a safe-to-share version of yttPath's contents, I might be able to help.

Another angle is to start with the examples/integrating-with-ytt/internal-templating/ example and stick the contents of your yttPath into the tpl variable in that example's run() function.

JTigger
  • 394
  • 2
  • 10