Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into evya/approved_intents…
Browse files Browse the repository at this point in the history
…_crd
  • Loading branch information
omris94 committed Feb 26, 2025
2 parents 66e4adc + 780caa2 commit 26e0d5c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 29 deletions.
14 changes: 7 additions & 7 deletions src/operator/api/v1alpha3/clientintents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Intent

status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName)
isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation]
if !ok {
return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name)
}

isShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
isShared := false
if ok {
parsedIsShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
}
isShared = parsedIsShared
}
status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared)

Expand Down
14 changes: 7 additions & 7 deletions src/operator/api/v1beta1/clientintents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,13 +574,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Intent

status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName)
isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation]
if !ok {
return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name)
}

isShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
isShared := false
if ok {
parsedIsShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
}
isShared = parsedIsShared
}
status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared)

Expand Down
14 changes: 7 additions & 7 deletions src/operator/api/v2alpha1/clientintents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Target

status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName)
isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation]
if !ok {
return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name)
}

isShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
isShared := false
if ok {
parsedIsShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
}
isShared = parsedIsShared
}
status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared)

Expand Down
14 changes: 7 additions & 7 deletions src/operator/api/v2beta1/clientintents_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,13 +743,13 @@ func clientIntentsStatusToCloudFormat(clientIntents ClientIntents, intent Target

status.IstioStatus.ServiceAccountName = toPtrOrNil(serviceAccountName)
isSharedValue, ok := clientIntents.Annotations[OtterizeSharedServiceAccountAnnotation]
if !ok {
return nil, false, errors.Errorf("missing annotation shared service account for client intents %s", clientIntents.Name)
}

isShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
isShared := false
if ok {
parsedIsShared, err := strconv.ParseBool(isSharedValue)
if err != nil {
return nil, false, errors.Errorf("failed to parse shared service account annotation for client intents %s", clientIntents.Name)
}
isShared = parsedIsShared
}
status.IstioStatus.IsServiceAccountShared = lo.ToPtr(isShared)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,29 @@ func (s *CloudReconcilerTestSuite) TestIntentStatusFormattingError_MissingShared
},
}

s.expectReconcilerError(clientIntents)
expectedIntent := graphqlclient.IntentInput{
ClientName: lo.ToPtr(clientName),
ServerName: lo.ToPtr(server),
Namespace: lo.ToPtr(testNamespace),
ServerNamespace: lo.ToPtr(testNamespace),
Type: lo.ToPtr(graphqlclient.IntentTypeHttp),
Resources: []*graphqlclient.HTTPConfigInput{
{
Path: lo.ToPtr("/login"),
Methods: []*graphqlclient.HTTPMethod{lo.ToPtr(graphqlclient.HTTPMethodGet), lo.ToPtr(graphqlclient.HTTPMethodPost)},
},
},
Status: &graphqlclient.IntentStatusInput{
IstioStatus: &graphqlclient.IstioStatusInput{
ServiceAccountName: lo.ToPtr(serviceAccountName),
IsServiceAccountShared: lo.ToPtr(false),
IsClientMissingSidecar: lo.ToPtr(false),
IsServerMissingSidecar: lo.ToPtr(false),
},
},
}

s.assertReportedIntents(clientIntents, []graphqlclient.IntentInput{expectedIntent})
}

func (s *CloudReconcilerTestSuite) TestIntentStatusFormattingError_MissingSidecar() {
Expand Down

0 comments on commit 26e0d5c

Please sign in to comment.