-
Notifications
You must be signed in to change notification settings - Fork 13
chore: iaw uses org setting insted of feature flag #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b338260
5d52b5c
cf5706b
49856e6
b5fd0d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package contract | ||
|
||
// API reference: https://docs.snyk.io/snyk-api/reference/organizations-v1#get-org-orgid-settings | ||
|
||
type OrgIgnoreSettings struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: please link to the API spec this relates to |
||
ReasonRequired bool `json:"reasonRequired,omitempty"` | ||
AutoApproveIgnores bool `json:"autoApproveIgnores,omitempty"` | ||
ApprovalWorkflowEnabled bool `json:"approvalWorkflowEnabled,omitempty"` | ||
} | ||
|
||
type OrgRequestAccessSettings struct { | ||
Enabled bool `json:"enabled,omitempty"` | ||
} | ||
|
||
type OrgSettingsResponse struct { | ||
Ignores *OrgIgnoreSettings `json:"ignores"` | ||
RequestAccess *OrgRequestAccessSettings `json:"requestAccess"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"github.com/google/uuid" | ||
|
||
"github.com/snyk/error-catalog-golang-public/cli" | ||
"github.com/snyk/go-application-framework/internal/api" | ||
policyApi "github.com/snyk/go-application-framework/internal/api/policy/2024-10-15" | ||
"github.com/snyk/go-application-framework/pkg/configuration" | ||
"github.com/snyk/go-application-framework/pkg/local_workflows/local_models" | ||
|
@@ -43,6 +44,32 @@ func addCreateIgnoreDefaultConfigurationValues(invocationCtx workflow.Invocation | |
}) | ||
} | ||
|
||
func getOrgIgnoreApprovalEnabled(engine workflow.Engine) configuration.DefaultValueFunction { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: please add a test |
||
return func(_ configuration.Configuration, existingValue interface{}) (interface{}, error) { | ||
if existingValue != nil { | ||
PeterSchafer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return existingValue, nil | ||
} | ||
|
||
config := engine.GetConfiguration() | ||
org := config.GetString(configuration.ORGANIZATION) | ||
client := engine.GetNetworkAccess().GetHttpClient() | ||
url := config.GetString(configuration.API_URL) | ||
apiClient := api.NewApi(url, client) | ||
|
||
settings, err := apiClient.GetOrgSettings(org) | ||
if err != nil { | ||
engine.GetLogger().Err(err).Msg("Failed to access settings.") | ||
return nil, err | ||
} | ||
|
||
if settings.Ignores != nil && settings.Ignores.ApprovalWorkflowEnabled { | ||
return true, nil | ||
} | ||
|
||
return false, nil | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BugThe
|
||
|
||
func remoteRepoUrlDefaultFunc(existingValue interface{}, config configuration.Configuration) (interface{}, error) { | ||
if existingValue != nil && existingValue != "" { | ||
return existingValue, nil | ||
|
Uh oh!
There was an error while loading. Please reload this page.