Skip to content

Add SkaffoldYamlGenerator#16

Merged
TadCordle merged 8 commits intomasterfrom
add-skaffold-yaml-generator
Aug 14, 2018
Merged

Add SkaffoldYamlGenerator#16
TadCordle merged 8 commits intomasterfrom
add-skaffold-yaml-generator

Conversation

@TadCordle
Copy link
Copy Markdown
Contributor

Fixes #10

coollog
coollog previously approved these changes Aug 14, 2018
Copy link
Copy Markdown
Contributor

@coollog coollog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay for initial versions, but later we should probably consider using a YAML library.

ImmutableList<Path> paths =
ImmutableList.of(Paths.get("MANIFEST_PATH_1"), Paths.get("MANIFEST_PATH_2"));
SkaffoldYamlGenerator generator = new SkaffoldYamlGenerator(paths);
Assert.assertEquals(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might be easier-to-manage/read if this was in a resource file

/** Automatically generates contents of a skaffold.yaml. */
public class SkaffoldYamlGenerator {

private ImmutableList<Path> manifestPaths;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final

import com.google.common.collect.ImmutableList;
import java.nio.file.Path;

/** Automatically generates contents of a skaffold.yaml. */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

…from a provided set of Kubernetes manifests. ?

/**
* Creates a new {@link SkaffoldYamlGenerator}.
*
* @param manifestPaths a non-empty list of paths to kubernetes yamls. Supports glob pattern
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the glob matching seems an odd choice. I'd rather provide a helper to expand a glob to a set of files. Besides the code below doesn't seem to support glob patterns!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really it's skaffold that supports glob matching. I guess I should just remove the comment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make more sense to have the manifestPaths be of type String rather than Path.

@loosebazooka
Copy link
Copy Markdown
Member

If we ever plan on using a library to generate this in the future. We should just do that in this library. If that seems overkill for what this code is supposed to do, then this is okay.

*
* @param manifestPaths a non-empty list of paths to kubernetes yamls. Supports glob pattern
* matching.
* @param manifestPaths a non-empty list of paths to kubernetes yamls.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just realized Skaffold supports globbing.

public void testGenerate() throws URISyntaxException, IOException {
String expected =
new String(
Files.readAllBytes(Paths.get(Resources.getResource("yaml/test-skaffold.yaml").toURI())),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you tie the test resource name to the test? SkaffoldYamlGeneratorTest/generated.yaml?

…ls-for-java into add-skaffold-yaml-generator
public void testGenerate() throws URISyntaxException, IOException {
// Read all lines and join with \n to avoid Windows test failing
List<String> lines =
Files.readAllLines(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include charset here.

@TadCordle TadCordle merged commit c48e1e4 into master Aug 14, 2018
@TadCordle TadCordle deleted the add-skaffold-yaml-generator branch August 14, 2018 19:55
@patflynn
Copy link
Copy Markdown

anybody know if Skaffold has skaffold.yaml generating feature on the roadmap?

@coollog
Copy link
Copy Markdown
Contributor

coollog commented Aug 20, 2018

@patflynn Yep - we discussed this during the skaffold weekly @GoogleContainerTools/container-tools I believe @nkubala has some plans about it.

@nkubala
Copy link
Copy Markdown

nkubala commented Aug 20, 2018

@patflynn @coollog yep I'm working on this right now, should have something to show soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants