Skip to content

Commit

Permalink
Added --security-level (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemarc authored Dec 12, 2022
1 parent 7730fc8 commit 684a148
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Function struct {
Trigger string `json:"trigger"`
TriggerEvent string `json:"trigger_event"`
TriggerResource string `json:"trigger_resource"`
HttpSecure string `json:"security_level"`

AllowUnauthenticated bool `json:"allow_unauthenticated"`
Gen2 bool `json:"gen2"`
Expand Down Expand Up @@ -107,6 +108,13 @@ func isValidTriggerType(t string) bool {
}[t]
}

func isValidSecureType(s string) bool {
return map[string]bool{
"secure-optional": true,
"secure-always": true,
}[s]
}

func isValidIngressSettings(s string) bool {
return map[string]bool{
"all": true,
Expand Down Expand Up @@ -138,8 +146,9 @@ func isValidFunctionForDeploy(f Function) bool {
return false
}

if f.Trigger == "http" {
return true
if f.Trigger == "http" && f.security_level != "" && !isValidSecureType(f.security_level) {
log.Printf("Invalid Secure Level for http trigger for function %s", f.Name)
return false
}

if (f.Trigger == "" && f.TriggerEvent == "" && f.TriggerResource == "") || !isValidTriggerType(f.Trigger) {
Expand Down Expand Up @@ -325,6 +334,9 @@ func CreateExecutionPlan(cfg *Config) (Plan, error) {
if f.Gen2 {
args = append(args, "--gen2")
}
if f.HttpSecure != "" {
args = append(args, "--security-level", f.security_level)
}
if f.Source != "" {
args = append(args, "--source", f.Source)
}
Expand Down

0 comments on commit 684a148

Please sign in to comment.