-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into import-yaml-stream
- Loading branch information
Showing
53 changed files
with
1,438 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,6 @@ jobs: | |
cmd: yq -i '.app.env = "Nightly"' stackhawk.yml | ||
|
||
- name: Run HawkScan | ||
uses: stackhawk/[email protected].1 | ||
uses: stackhawk/[email protected].2 | ||
with: | ||
apiKey: ${{ secrets.HAWK_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Flipt is a modern, self-hosted, feature flag solution | ||
|
||
Usage: | ||
flipt <command> <subcommand> [flags] | ||
flipt [command] | ||
|
||
Examples: | ||
$ flipt | ||
$ flipt config init | ||
$ flipt --config /path/to/config.yml migrate | ||
|
||
|
||
Available Commands: | ||
config Manage Flipt configuration | ||
export Export flags/segments/rules to file/stdout | ||
help Help about any command | ||
import Import flags/segments/rules from file | ||
migrate Run pending database migrations | ||
validate Validate Flipt flag state (.yaml, .yml) files | ||
|
||
Flags: | ||
--config string path to config file | ||
-h, --help help for flipt | ||
-v, --version version for flipt | ||
|
||
Use "flipt [command] --help" for more information about a command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
|
||
"github.com/AlecAivazis/survey/v2" | ||
"github.com/spf13/cobra" | ||
"go.flipt.io/flipt/internal/config" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type initCommand struct { | ||
force bool | ||
} | ||
|
||
func (c *initCommand) run(cmd *cobra.Command, args []string) error { | ||
var ( | ||
file string | ||
defaultFile = providedConfigFile | ||
) | ||
|
||
if defaultFile == "" { | ||
defaultFile = userConfigFile | ||
} | ||
|
||
q := []*survey.Question{ | ||
{ | ||
Name: "file", | ||
Prompt: &survey.Input{ | ||
Message: "Configuration file path:", | ||
Default: defaultFile, | ||
}, | ||
Validate: survey.Required, | ||
}, | ||
} | ||
|
||
if err := survey.Ask(q, &file); err != nil { | ||
return err | ||
} | ||
|
||
overwrite := c.force | ||
if !overwrite { | ||
// check if file exists | ||
if _, err := os.Stat(file); err == nil { | ||
// file exists | ||
prompt := &survey.Confirm{ | ||
Message: "File exists. Overwrite?", | ||
} | ||
if err := survey.AskOne(prompt, &overwrite); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
cfg := config.Default() | ||
cfg.Version = config.Version // write version for backward compatibility | ||
out, err := yaml.Marshal(cfg) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
var b bytes.Buffer | ||
b.WriteString("# yaml-language-server: $schema=https://raw.githubusercontent.com/flipt-io/flipt/main/config/flipt.schema.json\n\n") | ||
b.Write(out) | ||
|
||
return os.WriteFile(file, b.Bytes(), 0600) | ||
} | ||
|
||
func newConfigCommand() *cobra.Command { | ||
var configCmd = &cobra.Command{ | ||
Use: "config", | ||
Short: "Manage Flipt configuration", | ||
} | ||
|
||
initCmd := &initCommand{} | ||
|
||
var init = &cobra.Command{ | ||
Use: "init", | ||
Short: "Initialize Flipt configuration", | ||
RunE: initCmd.run, | ||
} | ||
|
||
init.Flags().BoolVarP(&initCmd.force, "force", "y", false, "Overwrite existing configuration file") | ||
|
||
configCmd.AddCommand(init) | ||
return configCmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
|
||
package main | ||
|
||
var defaultCfgPath string | ||
var defaultConfigFile string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.