GithubHelp home page GithubHelp logo

jhelmfile's Introduction

jhelmfile

A Java runner for helmfile.

What is it

jhelmfile is a java library which can be used to run the helmfile cli tool. It offers a convenient API to create and execute helmfile commands like build, template, or sync. The commands can be executed using a runtime which can be whether a locally installed helmfile binary or a docker image containing helmfile. The output of helmfile is mapped to java objects which can then be used for further processing. For example, you could run verifications against them, as you can see in the example project which uses jhelmfile to test a helmfile using junit.

Usage

Maven

<dependency>
    <groupId>io.github.paichinger</groupId>
    <artifactId>jhelmfile</artifactId>
    <version>1.12</version>
</dependency>

Gradle

implementation 'io.github.paichinger:jhelmfile:1.12'

Commands

For each supported helmfile command (build, template and sync) you can find a builder. See here:

build

The build command currently supports the following parameters:

  • --environment
  • --state-values-set
  • --state-values-file

Here an example with the corresponding builder methods:

BuildCommand buildCommand = BuildCommand
  .builder()
  .helmfileYaml(new File("./my-project/helmfile.yaml"))  // mandatory
  .environment("acceptance") // optional
  .stateValuesFiles(List.of(new File("common-values.yaml"), new File("common-values.yaml"))) // optional
  .stateValuesSet(Map.of("myService.version", "v1.2", "myService.logLevel", "DEBUG")) // optional
  .build();

template

The template command currently supports the following parameters:

  • --environment
  • --state-values-set
  • --state-values-file
  • --selector
  • --skip-deps
  • --skip-needs
  • --include-transitive-needs

Here an example with the corresponding builder methods:

TemplateCommand templateCommand = TemplateCommand
  .builder()
  .helmfileYaml(new File("./my-project/helmfile.yaml")) // mandatory
  .environment("acceptance") // optional
  .stateValuesFiles(List.of(new File("common-values.yaml"), new File("common-values.yaml"))) // optional
  .stateValuesSet(Map.of("myService.version", "v1.2", "myService.logLevel", "DEBUG")) // optional
  .selectors(List.of(new Selector("group", true, "progressive"))) // optional
  .skipDeps(true) // optional - default=false
  .skipNeeds(true) // optional - default=false
  .includeTransitiveNeeds(true) // optional - default=false
  .build();

sync

The sync command currently supports the following parameters:

  • --environment
  • --state-values-set
  • --state-values-file
  • --selector
  • --skip-deps
  • --skip-needs
  • --include-transitive-needs

Here an example with the corresponding builder methods:

SyncCommand templateCommand = SyncCommand
  .builder()
  .helmfileYaml(new File("./my-project/helmfile.yaml")) // mandatory
  .environment("acceptance") // optional
  .stateValuesFiles(List.of(new File("common-values.yaml"), new File("common-values.yaml"))) // optional
  .stateValuesSet(Map.of("myService.version", "v1.2", "myService.logLevel", "DEBUG")) // optional
  .selectors(List.of(new Selector("group", true, "progressive"))) // optional
  .skipDeps(true) // optional - default=false
  .skipNeeds(true) // optional - default=false
  .includeTransitiveNeeds(true) // optional - default=false
  .build();

Runtimes

The above commands can be executed using one of the available runtimes:

Binary Runtime

This runtime can be used if you have the helmfile binary available on your machine. Usage:

BinaryRuntime runtime = BinaryRuntime
  .builder()
  .helmfileBinaryPath("/bin/helmfile")
  .build();

Docker Runtime

You can use the docker runtime if you have docker installed on your machine.

DockerRuntime runtime = DockerRuntime
  .builder()
  .helmfileBinaryPath("/bin/helmfile") // mandatory - points to to the helmfile binary inside the docker image
  .dockerHost("unix:///var/run/docker.sock") // optional - default on linux: "unix:///var/run/docker.sock" on win and mac: "tcp://localhost:2376"
  .imageRepository("ghcr.io/helmfile/helmfile")  // optional - default "ghcr.io/helmfile/helmfile"
  .imageTag("v0.151.0") // optional - default "v0.151.0"
  .build();

Execution

The runtimes offer methods to execute the supported operations (build,template,sync). Those methods return POJOs representing the corresponding helmfile output (HelmfileBuild and HelmfileTemplate). Usage:

HelmfileTemplate templateOutput = runtime.template(templateCmmand);
// or
String syncOutput = runtime.sync(syncCommand);
// or
HelmfileBuild buildOutput = runtime.build(buildCommand);

Note

jhelfmile doesn't support all the features the helmifle cli offers yet. However, if you're missing a feature or a command don't hesitate to open an issue or create a PR.

Use cases

In the examples folder you can find a project which uses jhelmfile to run tests against a helmfile. There, the output of jhelmfile is used to run verifications using junit.

jhelmfile's People

Contributors

paichinger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.