Skip to content

Commit

Permalink
feat: Cmd evaluation (#2609)
Browse files Browse the repository at this point in the history
  • Loading branch information
mexes20 authored Nov 22, 2024
1 parent 695df79 commit 1c9292d
Show file tree
Hide file tree
Showing 33 changed files with 1,124 additions and 42 deletions.
21 changes: 20 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
pre-version-check:
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
if: ${{ startsWith(github.event.release.tag_name, 'v') }}
name: pre version check
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -101,6 +101,25 @@ jobs:
repository: gofeatureflag/go-feature-flag-lint
readme: "./cmd/lint/DOCKERHUB.md"

dockerhub-cli:
runs-on: ubuntu-latest
name: Upload dockerhub readme
needs:
- goreleaser
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release readme to DockerHub
uses: ms-jpq/sync-dockerhub-readme@v1
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
username: ${DOCKER_USERNAME}
password: ${DOCKER_PASSWORD}
repository: gofeatureflag/go-feature-flag-cli
readme: "./cmd/lint/DOCKERHUB.md"

dockerhub-relay-proxy:
runs-on: ubuntu-latest
name: Upload dockerhub readme
Expand Down
152 changes: 145 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ builds:
goarch: arm
goarm: 6

- id: go-feature-flag-cli
main: ./cmd/cli
binary: go-feature-flag-cli
env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
goarch:
- 386
- amd64
- arm64
- arm
goarm:
- 6
- 7
ignore:
- goos: darwin
goarch: 386
- goos: linux
goarch: arm
goarm: 6

- id: go-feature-flag-editor
main: ./cmd/editor
binary: go-feature-flag-editor
Expand Down Expand Up @@ -166,6 +190,19 @@ archives:
builds:
- go-feature-flag-lint

- id: go-feature-flag-cli
name_template: "go-feature-flag-cli_\
{{ .Version }}_\
{{- title .Os }}_\
{{- if eq .Arch \"amd64\" }}x86_64\
{{- else if eq .Arch \"386\" }}i386\
{{- else }}{{ .Arch }}{{ end }}\
{{- with .Arm }}v{{ . }}{{ end }}\
{{- with .Mips }}_{{ . }}{{ end }}\
{{- if not (eq .Amd64 \"v1\") }}{{ .Amd64 }}{{ end }}"
builds:
- go-feature-flag-cli

- id: goff-lambda
name_template: "go-feature-flag-aws-lambda_{{ .Version }}"
format: zip
Expand All @@ -187,7 +224,7 @@ changelog:
- 'vendor'

dockers:
# DEPRECATED: check go-feature-flag
# DEPRECATED: check go-feature-flag
- use: buildx
goos: linux
goarch: amd64
Expand Down Expand Up @@ -244,7 +281,7 @@ dockers:
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/relay_proxy"
- "--label=org.opencontainers.image.version={{ .Version }}"

# go-feature-flag
# go-feature-flag
- use: buildx
goos: linux
goarch: amd64
Expand Down Expand Up @@ -301,7 +338,7 @@ dockers:
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/relay_proxy"
- "--label=org.opencontainers.image.version={{ .Version }}"

# go-feature-flag-bookworm
# go-feature-flag-bookworm
- use: buildx
goos: linux
goarch: amd64
Expand Down Expand Up @@ -358,7 +395,7 @@ dockers:
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/relay_proxy"
- "--label=org.opencontainers.image.version={{ .Version }}"

# lint
# lint
- use: buildx
goos: linux
goarch: amd64
Expand Down Expand Up @@ -412,6 +449,61 @@ dockers:
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/tooling/linter"
- "--label=org.opencontainers.image.version={{ .Version }}"

# cli
- use: buildx
goos: linux
goarch: amd64
ids:
- go-feature-flag-cli
dockerfile: ./cmd/cli/Dockerfile
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-amd64
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.description=A command line tool to manage GO Feature Flag from your terminal"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.source=https://github.com/thomaspoignant/go-feature-flag"
- "--label=org.opencontainers.image.title=go-feature-flag-cli"
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/tooling/cli"
- "--label=org.opencontainers.image.version={{ .Version }}"
- use: buildx
goos: linux
goarch: arm64
ids:
- go-feature-flag-cli
dockerfile: ./cmd/cli/Dockerfile
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-arm64v8
build_flag_templates:
- "--platform=linux/arm64/v8"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.description=A command line tool to manage GO Feature Flag from your terminal"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.source=https://github.com/thomaspoignant/go-feature-flag"
- "--label=org.opencontainers.image.title=go-feature-flag-cli"
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/tooling/cli"
- "--label=org.opencontainers.image.version={{ .Version }}"
- use: buildx
goos: linux
goarch: arm
goarm: 7
ids:
- go-feature-flag-cli
dockerfile: ./cmd/cli/Dockerfile
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-armv7
build_flag_templates:
- "--platform=linux/arm/v7"
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.description=A command line tool to manage GO Feature Flag from your terminal"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.source=https://github.com/thomaspoignant/go-feature-flag"
- "--label=org.opencontainers.image.title=go-feature-flag-cli"
- "--label=org.opencontainers.image.url=https://gofeatureflag.org/docs/tooling/cli"
- "--label=org.opencontainers.image.version={{ .Version }}"


docker_manifests:
# DEPRECATED: check go-feature-flag
- name_template: thomaspoignant/go-feature-flag-relay-proxy:latest
Expand Down Expand Up @@ -516,7 +608,7 @@ docker_manifests:
- thomaspoignant/go-feature-flag-bookworm:v{{ .RawVersion }}-arm64v8
- thomaspoignant/go-feature-flag-bookworm:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-bookworm:v{{ .RawVersion }}-amd64
# lint-legacy
# lint-legacy
- name_template: thomaspoignant/go-feature-flag-lint:latest
id: go-feature-flag-lint-latest-legacy
image_templates:
Expand Down Expand Up @@ -567,6 +659,31 @@ docker_manifests:
- thomaspoignant/go-feature-flag-lint:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-lint:v{{ .RawVersion }}-amd64

# cli
- name_template: gofeatureflag/go-feature-flag-cli:latest
id: go-feature-flag-cli-latest
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-arm64v8
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-amd64
- name_template: gofeatureflag/go-feature-flag-cli:v{{ .RawVersion }}
id: go-feature-flag-cli-tag
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-arm64v8
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-amd64
- name_template: gofeatureflag/go-feature-flag-cli:v{{ .Major }}
id: go-feature-flag-cli-major
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-arm64v8
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-amd64
- name_template: gofeatureflag/go-feature-flag-cli:v{{ .Major }}.{{ .Minor }}
id: go-feature-flag-cli-major-minor
image_templates:
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-arm64v8
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-armv7
- thomaspoignant/go-feature-flag-cli:v{{ .RawVersion }}-amd64
brews:
# DEPRECATED: check go-feature-flag
- ids:
Expand Down Expand Up @@ -602,11 +719,22 @@ brews:
homepage: "https://gofeatureflag.org/docs/tooling/linter"
description: "A command line tool to lint your feature flag configuration file"
skip_upload: auto
- ids:
- go-feature-flag-cli
name: go-feature-flag-cli
repository:
owner: thomaspoignant
name: homebrew-tap
branch: master
caveats: "A command line tool to manage GO Feature Flag from your terminal"
homepage: "https://gofeatureflag.org/docs/tooling/cli"
description: "A command line tool to manage GO Feature Flag from your terminal"
skip_upload: auto

scoops:
# DEPRECATED: check go-feature-flag
- url_template: https://github.com/thomaspoignant/go-feature-flag/releases/download/{{ .Tag }}/{{ .ArtifactName }}
ids: [go-feature-flag-relay-proxy ]
ids: [ go-feature-flag-relay-proxy ]
name: go-feature-flag-relay-proxy
repository:
owner: go-feature-flag
Expand All @@ -616,7 +744,7 @@ scoops:
license: MIT

- url_template: https://github.com/thomaspoignant/go-feature-flag/releases/download/{{ .Tag }}/{{ .ArtifactName }}
ids: [go-feature-flag ]
ids: [ go-feature-flag ]
name: go-feature-flag
repository:
owner: go-feature-flag
Expand All @@ -635,5 +763,15 @@ scoops:
homepage: "https://gofeatureflag.org/docs/tooling/linter"
license: MIT

- url_template: https://github.com/thomaspoignant/go-feature-flag/releases/download/{{ .Tag }}/{{ .ArtifactName }}
ids: [ go-feature-flag-cli ]
name: go-feature-flag-cli
repository:
owner: go-feature-flag
name: scoop
commit_msg_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}"
homepage: "https://gofeatureflag.org/docs/tooling/cli"
license: MIT

snapshot:
version_template: "{{ incpatch .Version }}-next"
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RESET := $(shell tput -Txterm sgr0)

all: help
## Build:
build: build-relayproxy build-lint build-editor-api build-jsonschema-generator ## Build all the binaries and put the output in out/bin/
build: build-relayproxy build-lint build-editor-api build-jsonschema-generator build-cli ## Build all the binaries and put the output in out/bin/

create-out-dir:
mkdir -p out/bin
Expand All @@ -25,6 +25,9 @@ build-relayproxy: create-out-dir ## Build the relay proxy in out/bin/
build-lint: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/lint ./cmd/lint/

build-cli: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/cli ./cmd/cli/

build-editor-api: create-out-dir ## Build the linter in out/bin/
CGO_ENABLED=0 GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/editor-api ./cmd/editor/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ The format of the data is [described in the documentation](https://gofeatureflag
Events are collected and sent in bulk to avoid spamming your exporter.

## Linter
A command line tool is available to help you lint your configuration file: [go-feature-flag-lint](cmd/lint/README.md).
A command line tool is available to help you lint your configuration file: [go-feature-flag-lint](cmd/cli/README.md).

# How can I contribute?

Expand Down
43 changes: 43 additions & 0 deletions cmd/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# GO Feature Flag Command Line

# What is GO Feature Flag Command Line?

The GO Feature Flag Command Line is a CLI tool to interact with GO Feature Flag in your terminal.
For now it supports the following commands:
- `evaluate` to evaluate feature flags directly in your terminal
- `lint` to validate a configuration file format.

## How to install the cli

### Install using Homebrew (mac and linux)
```shell
brew tap thomaspoignant/homebrew-tap
brew install go-feature-flag-cli
```

### Install using docker
```shell
docker pull gofeatureflag/go-feature-flag-cli
```
More information about the usage of the container in the [dockerhub page](https://hub.docker.com/r/gofeatureflag/go-feature-flag-cli).

# How to use the command line

**`go-feature-flag-cli`** is a command line tool.

## How to evaluate a flag
```shell
go-feature-flag-cli evaluate --config="<location_of_your_flag_configuration_file>" --flag="<name_of_your_flag_to_evaluate>" --ctx='<evaluation_ctx_as_json_string>'
```

## How to lint a configuration file
```shell
go-feature-flag-cli lint <location_of_your_flag_configuration_file> --format="<yaml or json or toml>"
```

# License

View [license](https://github.com/thomaspoignant/go-feature-flag/blob/main/LICENSE) information for the software contained in this image.

## How can I contribute?
This project is open for contribution, see the [contributor's guide](https://github.com/thomaspoignant/go-feature-flag/blob/main/CONTRIBUTING.md) for some helpful tips.
Loading

0 comments on commit 1c9292d

Please sign in to comment.