Skip to content

Commit

Permalink
Merge branch 'main' into general_refs/planner
Browse files Browse the repository at this point in the history
  • Loading branch information
johanfylling committed Sep 26, 2023
2 parents 0a16968 + 919b290 commit 114a06a
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nightly
on:
workflow_dispatch: {} # Allow for manual triggers
schedule:
- cron: '0 8 * * *' # Daily, at 8:00 UTC
- cron: '0 8 * * 0-4' # Sun-Thu, at 8:00 UTC


jobs:
Expand Down
5 changes: 3 additions & 2 deletions ast/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2385,8 +2385,9 @@ func (c *Compiler) rewriteLocalVarsInRule(rule *Rule, unusedArgs VarSet, argsSta
// Rewrite assignments in body.
used := NewVarSet()

last := rule.Head.Ref()[len(rule.Head.Ref())-1]
used.Update(last.Vars())
for _, t := range rule.Head.Ref()[1:] {
used.Update(t.Vars())
}

if rule.Head.Key != nil {
used.Update(rule.Head.Key.Vars())
Expand Down
25 changes: 25 additions & 0 deletions ast/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6861,6 +6861,8 @@ func TestCompilerMockVirtualDocumentPartially(t *testing.T) {
}

func TestCompilerCheckUnusedAssignedVar(t *testing.T) {
t.Setenv("EXPERIMENTAL_GENERAL_RULE_REFS", "true")

type testCase struct {
note string
module string
Expand Down Expand Up @@ -7278,6 +7280,29 @@ func TestCompilerCheckUnusedAssignedVar(t *testing.T) {
&Error{Message: "assigned var y unused"},
},
},
{
note: "general ref in rule head",
module: `package test
p[q].r[s] := 1 {
q := "foo"
s := "bar"
t := "baz"
}
`,
expectedErrors: Errors{
&Error{Message: "assigned var t unused"},
},
},
{
note: "general ref in rule head (no errors)",
module: `package test
p[q].r[s] := 1 {
q := "foo"
s := "bar"
}
`,
expectedErrors: Errors{},
},
}

makeTestRunner := func(tc testCase, strict bool) func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require (
go.uber.org/automaxprocs v1.5.3
golang.org/x/net v0.15.0
golang.org/x/time v0.3.0
google.golang.org/grpc v1.58.1
google.golang.org/grpc v1.58.2
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/yaml.v2 v2.4.0
oras.land/oras-go/v2 v2.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I=
google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
39 changes: 38 additions & 1 deletion plugins/rest/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,43 @@ func (acs *awsCredentialServiceChain) addService(service awsCredentialService) {
acs.awsCredentialServices = append(acs.awsCredentialServices, service)
}

type awsCredentialCheckErrors []*awsCredentialCheckError

func (e awsCredentialCheckErrors) Error() string {

if len(e) == 0 {
return "no error(s)"
}

if len(e) == 1 {
return fmt.Sprintf("1 error occurred: %v", e[0].Error())
}

s := make([]string, len(e))
for i, err := range e {
s[i] = err.Error()
}

return fmt.Sprintf("%d errors occurred:\n%s", len(e), strings.Join(s, "\n"))
}

type awsCredentialCheckError struct {
message string
}

func newAWSCredentialError(message string) *awsCredentialCheckError {
return &awsCredentialCheckError{
message: message,
}
}

func (e *awsCredentialCheckError) Error() string {
return e.message
}

func (acs *awsCredentialServiceChain) credentials(ctx context.Context) (aws.Credentials, error) {
var errs awsCredentialCheckErrors

for _, service := range acs.awsCredentialServices {
credential, err := service.credentials(ctx)
if err != nil {
Expand All @@ -731,14 +767,15 @@ func (acs *awsCredentialServiceChain) credentials(ctx context.Context) (aws.Cred
return aws.Credentials{}, err
}

errs = append(errs, newAWSCredentialError(err.Error()))
continue
}

acs.logger.Debug("awsSigningAuthPlugin:%T successful", service)
return credential, nil
}

return aws.Credentials{}, errors.New("all AWS credential providers failed")
return aws.Credentials{}, fmt.Errorf("all AWS credential providers failed: %v", errs)
}

func (ap *awsSigningAuthPlugin) awsCredentialService() awsCredentialService {
Expand Down
19 changes: 15 additions & 4 deletions plugins/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ func TestAWSCredentialServiceChain(t *testing.T) {
input string
wantErr bool
env map[string]string
errMsg string
}{
{
name: "Fallback to Environment Credential",
Expand Down Expand Up @@ -1826,6 +1827,7 @@ func TestAWSCredentialServiceChain(t *testing.T) {
}
}`,
wantErr: true,
errMsg: "all AWS credential providers failed: 4 errors occurred",
env: map[string]string{},
},
}
Expand Down Expand Up @@ -1859,10 +1861,19 @@ func TestAWSCredentialServiceChain(t *testing.T) {

awsPlugin.logger = client.logger
err = awsPlugin.Prepare(req)
if err != nil && !tc.wantErr {
t.Fatalf("Unexpected error: %v", err)
} else if err == nil && tc.wantErr {
t.Fatalf("Expected error for input %v", tc.input)

if tc.wantErr {
if err == nil {
t.Fatalf("Expected error for input %v", tc.input)
}

if !strings.Contains(err.Error(), tc.errMsg) {
t.Fatalf("Expected error message %v but got %v", tc.errMsg, err.Error())
}
} else {
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/google.golang.org/grpc/version.go

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

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ google.golang.org/genproto/googleapis/api/httpbody
## explicit; go 1.19
google.golang.org/genproto/googleapis/rpc/errdetails
google.golang.org/genproto/googleapis/rpc/status
# google.golang.org/grpc v1.58.1
# google.golang.org/grpc v1.58.2
## explicit; go 1.19
google.golang.org/grpc
google.golang.org/grpc/attributes
Expand Down

0 comments on commit 114a06a

Please sign in to comment.