Skip to content

Commit 84c78da

Browse files
authored
Merge pull request #13 from edenlabllc/release/v0.1.3
Release/v0.1.3
2 parents 4bb8e6e + 385436d commit 84c78da

3 files changed

Lines changed: 70 additions & 96 deletions

File tree

.github/workflows/core-public.yaml

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Core CI/CD workflow
1+
name: Core Gitflow CI Action workflow
22

33
on:
44
push:
@@ -15,65 +15,36 @@ on:
1515
- master
1616

1717
env:
18-
# AWS region of the AWS account storing images in ECR.
18+
# AWS region of the AWS account storing images in AWS ECR.
1919
CORE_AWS_REGION: eu-north-1
20-
# The latest action version.
21-
ECR_BUILD_PUSH_ACTION_VERSION: v2
2220

2321
jobs:
24-
ecr-build-push:
25-
name: Checkout main and ecr-build-push action repositories, run ecr-build-push action
26-
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }}
27-
runs-on: ubuntu-20.04
22+
gitflow-ci:
23+
name: Checkout main repository, run Gitflow CI action
24+
runs-on: ubuntu-22.04
2825
steps:
2926
- name: Checkout main repository
30-
uses: actions/checkout@v2
27+
uses: actions/checkout@v4
3128
with:
3229
ref: ${{ github.ref }}
3330
fetch-depth: 0
3431

35-
- name: Checkout ecr-build-push action repository
36-
uses: actions/checkout@v2
32+
- name: Checkout Gitflow CI action repository
33+
uses: actions/checkout@v4
3734
with:
38-
repository: edenlabllc/fhir.ecr_build_push.action
39-
ref: ${{ env.ECR_BUILD_PUSH_ACTION_VERSION }}
35+
repository: edenlabllc/gitflow.ci.action
36+
ref: v1
4037
token: ${{ secrets.GH_TOKEN_REPO_FULL_ACCESS }}
41-
path: .github/actions/ecr-build-push
38+
path: .github/actions/gitflow.ci.action
4239

43-
- name: Configure AWS credentials
44-
uses: aws-actions/configure-aws-credentials@v1
40+
- name: Run Gitflow CI action
41+
uses: ./.github/actions/gitflow.ci.action
4542
with:
46-
aws-region: ${{ env.CORE_AWS_REGION }}
47-
aws-access-key-id: ${{ secrets.CORE_AWS_ACCESS_KEY_ID }}
48-
aws-secret-access-key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
49-
50-
- name: Login to AWS ECR
51-
uses: aws-actions/amazon-ecr-login@v1
52-
53-
- name: Pull ecr-build-push action image from AWS ECR
54-
run: |
55-
ECR_REGISTRY_URL="${{ secrets.CORE_AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.CORE_AWS_REGION }}.amazonaws.com"
56-
IMAGE_NAME="core.fhir.ecr_build_push.action"
57-
IMAGE_FULL_NAME="${ECR_REGISTRY_URL}/${IMAGE_NAME}:${{ env.ECR_BUILD_PUSH_ACTION_VERSION }}"
58-
docker pull "${IMAGE_FULL_NAME}"
59-
docker tag "${IMAGE_FULL_NAME}" "${IMAGE_NAME}"
60-
61-
- name: Run ecr-build-push action
62-
id: ecr-build-push
63-
uses: ./.github/actions/ecr-build-push
64-
65-
# To produce GitHub release artifacts only and skip image and deploy-related functionality
66-
# a single input is required:
67-
#with:
68-
# build_push_image: false
69-
70-
# Common action inputs
71-
with:
72-
core_aws_account_id: ${{ secrets.CORE_AWS_ACCOUNT_ID }}
7343
core_aws_region: ${{ env.CORE_AWS_REGION }}
7444
core_aws_access_key_id: ${{ secrets.CORE_AWS_ACCESS_KEY_ID }}
75-
core_aws_secret_key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
76-
repository_name_prefix: "core."
77-
public_repository: true
78-
delete_image: false
79-
scan_image: false
45+
core_aws_secret_access_key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
46+
github_token_repo_full_access: ${{ secrets.GH_TOKEN_REPO_FULL_ACCESS }}
47+
ecr_public_repository: true
48+
ecr_repository_name_prefix: core.
49+
image_delete: false
50+
image_scan: false

.github/workflows/core.yaml

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Core CI/CD workflow
1+
name: Core Gitflow CI Action workflow
22

33
on:
44
push:
@@ -16,64 +16,35 @@ on:
1616
- release/*
1717

1818
env:
19-
# AWS region of the AWS account storing images in ECR.
19+
# AWS region of the AWS account storing images in AWS ECR.
2020
CORE_AWS_REGION: eu-north-1
21-
# The latest action version.
22-
ECR_BUILD_PUSH_ACTION_VERSION: v2
2321

2422
jobs:
25-
ecr-build-push:
26-
name: Checkout main and ecr-build-push action repositories, run ecr-build-push action
27-
if: ${{ !contains(github.event.head_commit.message, '[ci skip]') }}
28-
runs-on: ubuntu-20.04
23+
gitflow-ci:
24+
name: Checkout main repository, run Gitflow CI action
25+
runs-on: ubuntu-22.04
2926
steps:
3027
- name: Checkout main repository
31-
uses: actions/checkout@v2
28+
uses: actions/checkout@v4
3229
with:
3330
ref: ${{ github.ref }}
3431
fetch-depth: 0
3532

36-
- name: Checkout ecr-build-push action repository
37-
uses: actions/checkout@v2
33+
- name: Checkout Gitflow CI action repository
34+
uses: actions/checkout@v4
3835
with:
39-
repository: edenlabllc/fhir.ecr_build_push.action
40-
ref: ${{ env.ECR_BUILD_PUSH_ACTION_VERSION }}
36+
repository: edenlabllc/gitflow.ci.action
37+
ref: v1
4138
token: ${{ secrets.GH_TOKEN_REPO_FULL_ACCESS }}
42-
path: .github/actions/ecr-build-push
39+
path: .github/actions/gitflow.ci.action
4340

44-
- name: Configure AWS credentials
45-
uses: aws-actions/configure-aws-credentials@v1
41+
- name: Run Gitflow CI action
42+
uses: ./.github/actions/gitflow.ci.action
4643
with:
47-
aws-region: ${{ env.CORE_AWS_REGION }}
48-
aws-access-key-id: ${{ secrets.CORE_AWS_ACCESS_KEY_ID }}
49-
aws-secret-access-key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
50-
51-
- name: Login to AWS ECR
52-
uses: aws-actions/amazon-ecr-login@v1
53-
54-
- name: Pull ecr-build-push action image from AWS ECR
55-
run: |
56-
ECR_REGISTRY_URL="${{ secrets.CORE_AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.CORE_AWS_REGION }}.amazonaws.com"
57-
IMAGE_NAME="core.fhir.ecr_build_push.action"
58-
IMAGE_FULL_NAME="${ECR_REGISTRY_URL}/${IMAGE_NAME}:${{ env.ECR_BUILD_PUSH_ACTION_VERSION }}"
59-
docker pull "${IMAGE_FULL_NAME}"
60-
docker tag "${IMAGE_FULL_NAME}" "${IMAGE_NAME}"
61-
62-
- name: Run ecr-build-push action
63-
id: ecr-build-push
64-
uses: ./.github/actions/ecr-build-push
65-
66-
# To produce GitHub release artifacts only and skip image and deploy-related functionality
67-
# a single input is required:
68-
#with:
69-
# build_push_image: false
70-
71-
# Common action inputs
72-
with:
73-
core_aws_account_id: ${{ secrets.CORE_AWS_ACCOUNT_ID }}
7444
core_aws_region: ${{ env.CORE_AWS_REGION }}
7545
core_aws_access_key_id: ${{ secrets.CORE_AWS_ACCESS_KEY_ID }}
76-
core_aws_secret_key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
77-
repository_name_prefix: "core."
78-
delete_image: false
79-
scan_image: true
46+
core_aws_secret_access_key: ${{ secrets.CORE_AWS_SECRET_ACCESS_KEY }}
47+
github_token_repo_full_access: ${{ secrets.GH_TOKEN_REPO_FULL_ACCESS }}
48+
ecr_repository_name_prefix: core.
49+
image_delete: false
50+
image_scan: true

internal/snapshot/generator.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
package snapshot
22

33
import (
4-
ebsv1alpha1 "ebs-snapshot-provision.operators.infra/api/v1alpha1"
4+
"fmt"
5+
"regexp"
6+
"time"
7+
58
snapv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
69
core_v1 "k8s.io/api/core/v1"
710
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
811

12+
ebsv1alpha1 "ebs-snapshot-provision.operators.infra/api/v1alpha1"
913
"ebs-snapshot-provision.operators.infra/internal/aws"
1014
)
1115

16+
const (
17+
snapshotTimeLayout = "200601021504"
18+
)
19+
1220
var (
1321
volumeSnapshotMeta = metav1.TypeMeta{
1422
APIVersion: "snapshot.storage.k8s.io/v1",
@@ -21,6 +29,7 @@ var (
2129
}
2230

2331
volumeSnapshotContentSourceVolumeMode = core_v1.PersistentVolumeFilesystem
32+
snapshotTimeRe = regexp.MustCompile(`(\d{12})$`)
2433
)
2534

2635
type InputFromCRD struct {
@@ -71,11 +80,20 @@ func (sg *DefaultSnapshotCreator) CreateVolumeSnapshots(input *InputFromCRD) ([]
7180

7281
}
7382

83+
labels := make(map[string]string)
84+
snapshotTime, err := extractTimeFromName(name)
85+
if err != nil {
86+
return nil, nil, err
87+
}
88+
89+
labels["snapscheduler.backube/when"] = snapshotTime
90+
7491
volumeSnapshots = append(volumeSnapshots, snapv1.VolumeSnapshot{
7592
TypeMeta: volumeSnapshotMeta,
7693
ObjectMeta: metav1.ObjectMeta{
7794
Namespace: namespace,
7895
Name: name,
96+
Labels: labels,
7997
},
8098
Spec: snapv1.VolumeSnapshotSpec{
8199
VolumeSnapshotClassName: &input.CRD.Spec.VolumeSnapshotClassName,
@@ -112,3 +130,17 @@ func (sg *DefaultSnapshotCreator) CreateVolumeSnapshots(input *InputFromCRD) ([]
112130

113131
return volumeSnapshots, volumeSnapshotContents, nil
114132
}
133+
134+
func extractTimeFromName(name string) (string, error) {
135+
match := snapshotTimeRe.FindString(name)
136+
if match == "" {
137+
return "", fmt.Errorf("timestamp not found in snapshot name %q", name)
138+
}
139+
140+
t, err := time.Parse(snapshotTimeLayout, match)
141+
if err != nil {
142+
return "", fmt.Errorf("failed to parse timestamp %q from snapshot name %q: %w", match, name, err)
143+
}
144+
145+
return t.Format(snapshotTimeLayout), nil
146+
}

0 commit comments

Comments
 (0)