-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from aws-controllers-k8s/readiness-check
Add readiness check for resources
- Loading branch information
Showing
15 changed files
with
323 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/ack-controller/ec2-controller/ec2-controller-instance.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package resourcegroup | ||
|
||
import ( | ||
"slices" | ||
|
||
"k8s.io/kube-openapi/pkg/validation/spec" | ||
) | ||
|
||
type ReadyOnExpression struct { | ||
Resolved bool | ||
Expression string | ||
} | ||
|
||
// This function goes through the schema of a resource | ||
// and retrieves the field names fo rthe readOnly feature | ||
// | ||
// Currently we support all the top level fields besides | ||
// apiVersion and kind. If we do see a case where they would | ||
// be necessary for readyOns, we can include them here. | ||
func getResourceTopLevelFieldNames(schema *spec.Schema) []string { | ||
|
||
fieldNames := []string{} | ||
|
||
if schema == nil || schema.Properties == nil { | ||
return fieldNames | ||
} | ||
for k, _ := range schema.Properties { | ||
if k != "apiVersion" && k != "kind" { | ||
fieldNames = append(fieldNames, k) | ||
} | ||
} | ||
|
||
slices.Sort(fieldNames) | ||
return fieldNames | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
|
||
package parser | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// This function parses resource condition expressions. | ||
// These expressions need to be standalone expressions | ||
// so, this function also does some validation. | ||
// At the end we return the expressions with '${}' removed | ||
// | ||
// To be honest I wouldn't necessarily call it parse, since | ||
// we are mostly just validating, without caring what's in | ||
// the expression. Maybe we can rename it in the future 🤔 | ||
func ParseConditionExpressions(conditions []string) ([]string, error) { | ||
|
||
expressions := make([]string, 0, len(conditions)) | ||
|
||
for _, e := range conditions { | ||
ok, err := isOneShotExpression(e) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if !ok { | ||
return nil, fmt.Errorf("single expression per line allowed") | ||
} | ||
expressions = append(expressions, strings.Trim(e, "${}")) | ||
} | ||
|
||
return expressions, nil | ||
} |
Oops, something went wrong.