Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
ack_generate_info:
build_date: "2021-09-08T23:45:08Z"
build_hash: 394e8294aabf0b221c35f7a5c7bc7e4e43bc6f10
go_version: go1.16.4 linux/amd64
build_date: "2021-09-10T21:06:37Z"
build_hash: a988bddaea3800999e8a548e0e7a4fd44cc00b19
go_version: go1.14.14 darwin/amd64
version: v0.13.2
api_directory_checksum: 155104e002d9c69b75fd9e85789bf7ee292b866c
api_directory_checksum: a13caf20935ebb6193efdee1ab377cae33311ad7
api_version: v1alpha1
aws_sdk_go_version: v1.37.10
generator_config_info:
file_checksum: 4bf1e52543400e3d52cc745da4c1e2e518e9e1e1
file_checksum: 968c7d8481a61c0299fc373cc6d1692a52b55868
original_file_name: generator.yaml
last_modification:
reason: API generation
timestamp: 2021-09-08 23:45:13.439536495 +0000 UTC
timestamp: 2021-09-10 21:06:47.280077 +0000 UTC
27 changes: 23 additions & 4 deletions apis/v1alpha1/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ resources:
ScalableTarget:
is_adoptable: false
hooks:
sdk_read_many_post_build_request:
code: rm.customDescribeScalableTarget(ctx, r, input)
delta_pre_compare:
code: customSetDefaults(a, b)
sdk_create_post_set_output:
code: rm.customSetLastModifiedTime(ko)
sdk_read_many_post_build_request:
code: rm.customDescribeScalableTarget(ctx, r, input)
delta_pre_compare:
code: customSetDefaults(a, b)
sdk_update_post_set_output:
code: rm.customSetLastModifiedTime(ko)
fields:
ResourceID:
is_name: true
Expand All @@ -33,8 +37,18 @@ resources:
from:
operation: DescribeScalableTargets
path: ScalableTargets..CreationTime
LastModifiedTime:
is_read_only: true
from:
operation: DescribeScalableTargets
path: ScalableTargets..CreationTime
ScalingPolicy:
is_adoptable: false
hooks:
sdk_create_post_set_output:
code: rm.customSetLastModifiedTime(ko)
sdk_update_post_set_output:
code: rm.customSetLastModifiedTime(ko)
fields:
ResourceID:
is_name: true
Expand All @@ -45,6 +59,11 @@ resources:
from:
operation: DescribeScalingPolicies
path: ScalingPolicies..CreationTime
LastModifiedTime:
is_read_only: true
from:
operation: DescribeScalingPolicies
path: ScalingPolicies..CreationTime
ignore:
resource_names:
- ScheduledAction
Expand Down
3 changes: 3 additions & 0 deletions apis/v1alpha1/scalable_target.go

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

3 changes: 3 additions & 0 deletions apis/v1alpha1/scaling_policy.go

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

8 changes: 8 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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
Expand Up @@ -242,6 +242,10 @@ spec:
description: The Unix timestamp for when the scalable target was created.
format: date-time
type: string
lastModifiedTime:
description: The Unix timestamp for when the scalable target was created.
format: date-time
type: string
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ spec:
description: The Unix timestamp for when the scaling policy was created.
format: date-time
type: string
lastModifiedTime:
description: The Unix timestamp for when the scaling policy was created.
format: date-time
type: string
type: object
type: object
served: true
Expand Down
27 changes: 23 additions & 4 deletions generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ resources:
ScalableTarget:
is_adoptable: false
hooks:
sdk_read_many_post_build_request:
code: rm.customDescribeScalableTarget(ctx, r, input)
delta_pre_compare:
code: customSetDefaults(a, b)
sdk_create_post_set_output:
code: rm.customSetLastModifiedTime(ko)
sdk_read_many_post_build_request:
code: rm.customDescribeScalableTarget(ctx, r, input)
delta_pre_compare:
code: customSetDefaults(a, b)
sdk_update_post_set_output:
code: rm.customSetLastModifiedTime(ko)
fields:
ResourceID:
is_name: true
Expand All @@ -33,8 +37,18 @@ resources:
from:
operation: DescribeScalableTargets
path: ScalableTargets..CreationTime
LastModifiedTime:
is_read_only: true
from:
operation: DescribeScalableTargets
path: ScalableTargets..CreationTime
ScalingPolicy:
is_adoptable: false
hooks:
sdk_create_post_set_output:
code: rm.customSetLastModifiedTime(ko)
sdk_update_post_set_output:
code: rm.customSetLastModifiedTime(ko)
fields:
ResourceID:
is_name: true
Expand All @@ -45,6 +59,11 @@ resources:
from:
operation: DescribeScalingPolicies
path: ScalingPolicies..CreationTime
LastModifiedTime:
is_read_only: true
from:
operation: DescribeScalingPolicies
path: ScalingPolicies..CreationTime
ignore:
resource_names:
- ScheduledAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ spec:
description: The Unix timestamp for when the scalable target was created.
format: date-time
type: string
lastModifiedTime:
description: The Unix timestamp for when the scalable target was created.
format: date-time
type: string
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ spec:
description: The Unix timestamp for when the scaling policy was created.
format: date-time
type: string
lastModifiedTime:
description: The Unix timestamp for when the scaling policy was created.
format: date-time
type: string
type: object
type: object
served: true
Expand Down
9 changes: 9 additions & 0 deletions pkg/resource/scalable_target/custom_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ package scalable_target

import (
"context"
svcapitypes "github.com/aws-controllers-k8s/applicationautoscaling-controller/apis/v1alpha1"
svcsdk "github.com/aws/aws-sdk-go/service/applicationautoscaling"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need reordering

)

func (rm *resourceManager) customDescribeScalableTarget(
Expand All @@ -31,3 +34,9 @@ func (rm *resourceManager) customDescribeScalableTarget(
input.SetResourceIds(resourceIDList)
}
}

// customSetOutputUpdate sets the LastModifiedTime field to the current time post an update
func (rm *resourceManager) customSetLastModifiedTime(ko *svcapitypes.ScalableTarget) {
currentTime := metav1.Time{Time: time.Now().UTC()}
ko.Status.LastModifiedTime = &currentTime
}
2 changes: 2 additions & 0 deletions pkg/resource/scalable_target/sdk.go

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

26 changes: 26 additions & 0 deletions pkg/resource/scaling_policy/custom_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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 scaling_policy

import (
svcapitypes "github.com/aws-controllers-k8s/applicationautoscaling-controller/apis/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"time"
)

// customSetOutputUpdate sets the LastModifiedTime field to the current time post an update
func (rm *resourceManager) customSetLastModifiedTime(ko *svcapitypes.ScalingPolicy) {
currentTime := metav1.Time{Time: time.Now().UTC()}
ko.Status.LastModifiedTime = &currentTime
}
2 changes: 2 additions & 0 deletions pkg/resource/scaling_policy/sdk.go

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