Skip to content

Commit

Permalink
[RM-5835] Support for always enabled flag (#38)
Browse files Browse the repository at this point in the history
* generated swagger

* always enabled in families

* Fixed list with always enabled

* Added release version
  • Loading branch information
ricleal-fugue authored Aug 19, 2021
1 parent 691e8a9 commit 45eef9f
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 47 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ gen: $(SWAGGER)
sed -i "" "s/float64/int64/g" $(INVITE_SRC)
sed -i "" "s/Recommended bool/Recommended *bool/g" $(UPDATE_FAMILY_SRC)
sed -i "" "s/Recommended bool/Recommended *bool/g" $(CREATE_FAMILY_SRC)
sed -i "" "s/AlwaysEnabled bool/AlwaysEnabled *bool/g" $(UPDATE_FAMILY_SRC)
sed -i "" "s/AlwaysEnabled bool/AlwaysEnabled *bool/g" $(CREATE_FAMILY_SRC)

.PHONY: test
test:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.15.0
0.16.0
20 changes: 12 additions & 8 deletions cmd/createFamily.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
)

type createFamilyOptions struct {
Name string
Description string
Recommended bool
RuleIDs []string
Name string
Description string
Recommended bool
AlwaysEnabled bool
RuleIDs []string
}

// NewCreateFamilyCommand returns a command that creates a family
Expand All @@ -31,10 +32,11 @@ func NewCreateFamilyCommand() *cobra.Command {

params := families.NewCreateFamilyParams()
params.Family = &models.CreateFamilyInput{
Name: opts.Name,
Description: opts.Description,
Recommended: &opts.Recommended,
RuleIds: opts.RuleIDs,
Name: opts.Name,
Description: opts.Description,
Recommended: &opts.Recommended,
AlwaysEnabled: &opts.AlwaysEnabled,
RuleIds: opts.RuleIDs,
}

resp, err := client.Families.CreateFamily(params, auth)
Expand Down Expand Up @@ -68,6 +70,7 @@ func NewCreateFamilyCommand() *cobra.Command {
Item{"DESCRIPTION", family.Description},
itemProviders,
Item{"RECOMMENDED", family.Recommended},
Item{"ALWAYS_ENABLED", family.AlwaysEnabled},
itemRules,
Item{"CREATED_AT", format.Unix(family.CreatedAt)},
Item{"CREATED_BY", family.CreatedBy},
Expand All @@ -94,6 +97,7 @@ func NewCreateFamilyCommand() *cobra.Command {
cmd.Flags().StringVar(&opts.Name, "name", "", "Family name")
cmd.Flags().StringVar(&opts.Description, "description", "", "Description")
cmd.Flags().BoolVar(&opts.Recommended, "recommended", true, "If the family is recommended for all new environments")
cmd.Flags().BoolVar(&opts.AlwaysEnabled, "always-enabled", false, "If the family will automatically be enabled on all environments within the tenant")
cmd.Flags().StringSliceVar(&opts.RuleIDs, "rule-ids", []string{}, "List of rule IDs to associate with the family (e.g. FG_R00217,<UUID Custom Rule ID>)")

cmd.MarkFlagRequired("name")
Expand Down
1 change: 1 addition & 0 deletions cmd/getFamily.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func NewGetFamilyCommand() *cobra.Command {
Item{"SOURCE", family.Source},
itemProviders,
Item{"RECOMMENDED", family.Recommended},
Item{"ALWAYS_ENABLED", family.AlwaysEnabled},
itemRules,
Item{"CREATED_AT", format.Unix(family.CreatedAt)},
Item{"CREATED_BY", family.CreatedBy},
Expand Down
76 changes: 42 additions & 34 deletions cmd/listFamilies.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,34 @@ import (
)

type listFamiliesOptions struct {
Columns []string
IDFilter string
NameFilter string
DescriptionFilter string
SourceFilter string
ProvidersFilter string
RecommendedFilter string
SearchQuery string
Offset int64
MaxItems int64
OrderBy string
OrderDirection string
FetchAll bool
Columns []string
IDFilter string
NameFilter string
DescriptionFilter string
SourceFilter string
ProvidersFilter string
RecommendedFilter string
AlwaysEnabledFilter string
SearchQuery string
Offset int64
MaxItems int64
OrderBy string
OrderDirection string
FetchAll bool
}

type listFamiliesViewItem struct {
ID string
Name string
Source string
Description string
Providers string
Recommended bool
CreatedAt string
CreatedBy string
UpdatedAt string
UpdatedBy string
ID string
Name string
Source string
Description string
Providers string
Recommended bool
AlwaysEnabled bool
CreatedAt string
CreatedBy string
UpdatedAt string
UpdatedBy string
}

// NewListFamiliesCommand returns a command that lists families in Fugue
Expand Down Expand Up @@ -88,6 +90,9 @@ func NewListFamiliesCommand() *cobra.Command {
if opts.RecommendedFilter != "" {
searchParams = append(searchParams, fmt.Sprintf("recommended:%s", opts.RecommendedFilter))
}
if opts.AlwaysEnabledFilter != "" {
searchParams = append(searchParams, fmt.Sprintf("always_enabled:%s", opts.AlwaysEnabledFilter))
}

var familiesList []*models.Family
offset := opts.Offset
Expand Down Expand Up @@ -134,16 +139,17 @@ func NewListFamiliesCommand() *cobra.Command {

rows = append(rows, listFamiliesViewItem{

ID: family.ID,
Name: family.Name,
Source: family.Source,
Description: description,
Providers: providers,
Recommended: family.Recommended,
CreatedAt: format.Unix(family.CreatedAt),
CreatedBy: family.CreatedBy,
UpdatedAt: format.Unix(family.UpdatedAt),
UpdatedBy: family.UpdatedBy,
ID: family.ID,
Name: family.Name,
Source: family.Source,
Description: description,
Providers: providers,
Recommended: family.Recommended,
AlwaysEnabled: family.AlwaysEnabled,
CreatedAt: format.Unix(family.CreatedAt),
CreatedBy: family.CreatedBy,
UpdatedAt: format.Unix(family.UpdatedAt),
UpdatedBy: family.UpdatedBy,
})

}
Expand All @@ -168,15 +174,17 @@ func NewListFamiliesCommand() *cobra.Command {
"Description",
"Providers",
"Recommended",
"AlwaysEnabled",
}

cmd.Flags().StringVar(&opts.SearchQuery, "search", "", "Combined filter for Id, Name, Description, Provider, Source and Recommended")
cmd.Flags().StringVar(&opts.SearchQuery, "search", "", "Combined filter for Id, Name, Description, Provider, Source, Recommended and AlwaysEnabled")
cmd.Flags().StringVar(&opts.IDFilter, "id", "", "ID filter (substring match, case sensitive)")
cmd.Flags().StringVar(&opts.NameFilter, "name", "", "Name filter (substring match, case insensitive)")
cmd.Flags().StringVar(&opts.DescriptionFilter, "description", "", "Description filter (substring match, case insensitive)")
cmd.Flags().StringVar(&opts.SourceFilter, "source", "", "Source filter (substring match, case insensitive)")
cmd.Flags().StringVar(&opts.ProvidersFilter, "providers", "", "Providers filter (substring match, case insensitive)")
cmd.Flags().StringVar(&opts.RecommendedFilter, "recommended", "", "Recommended filter (substring match, case insensitive)")
cmd.Flags().StringVar(&opts.AlwaysEnabledFilter, "always-enabled", "", "AlwaysEnabled filter (substring match, case insensitive)")

cmd.Flags().StringSliceVar(&opts.Columns, "columns", defaultCols, "Columns to show")
cmd.Flags().Int64Var(&opts.Offset, "offset", 0, "Offset into results")
Expand Down
13 changes: 9 additions & 4 deletions cmd/updateFamily.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import (
)

type updateFamilyOptions struct {
Name string
Description string
Recommended bool
RuleIDs []string
Name string
Description string
Recommended bool
AlwaysEnabled bool
RuleIDs []string
}

// NewUpdateFamilyCommand returns a command that updates a custom family
Expand Down Expand Up @@ -49,6 +50,8 @@ func NewUpdateFamilyCommand() *cobra.Command {
params.Family.Description = opts.Description
case "recommended":
params.Family.Recommended = &opts.Recommended
case "always-enabled":
params.Family.AlwaysEnabled = &opts.AlwaysEnabled
case "rule-ids":
params.Family.RuleIds = opts.RuleIDs
}
Expand Down Expand Up @@ -81,6 +84,7 @@ func NewUpdateFamilyCommand() *cobra.Command {
Item{"DESCRIPTION", family.Description},
itemProviders,
Item{"RECOMMENDED", family.Recommended},
Item{"ALWAYS_ENABLED", family.AlwaysEnabled},
itemRules,
Item{"CREATED_AT", format.Unix(family.CreatedAt)},
Item{"CREATED_BY", family.CreatedBy},
Expand All @@ -107,6 +111,7 @@ func NewUpdateFamilyCommand() *cobra.Command {
cmd.Flags().StringVar(&opts.Name, "name", "", "Family name")
cmd.Flags().StringVar(&opts.Description, "description", "", "Description")
cmd.Flags().BoolVar(&opts.Recommended, "recommended", true, "If the family is recommended for all new environments")
cmd.Flags().BoolVar(&opts.AlwaysEnabled, "always-enabled", false, "If the family will automatically be enabled on all environments within the tenant")
cmd.Flags().StringSliceVar(&opts.RuleIDs, "rule-ids", []string{}, "List of rule IDs to associate with the family (e.g. FG_R00217,<UUID Custom Rule ID>)")

return cmd
Expand Down
3 changes: 3 additions & 0 deletions models/create_family_input.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions models/family.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions models/family_with_rules.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions models/update_family_input.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45eef9f

Please sign in to comment.