Skip to content

Commit

Permalink
chores(sdk): update sdk go (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
philibea authored Mar 30, 2023
1 parent c6c1cbe commit 20dae59
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 154 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
Expand All @@ -11,15 +12,15 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.17
- name: Set up Go 1.20
uses: actions/setup-go@v1
with:
go-version: 1.17
go-version: 1.20
id: go

- uses: actions/checkout@v1

- name: Build
run: |
go get -d -v
go build -v
go get -d -v
go build -v
27 changes: 9 additions & 18 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# only serve a purpose to live test
# only serve a purpose to live test
name: Deploy

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
Expand All @@ -18,9 +19,8 @@ on:

jobs:
deploy-scaleway-container:

runs-on: ubuntu-latest
name: deploy scaleway serverless container
name: deploy scaleway serverless container
steps:
# To use this repository's private action,
# you must check out the repository
Expand All @@ -31,7 +31,6 @@ jobs:
run: |
SAFE_GITHUB_HEAD_REF_SLUG_URL=$(echo $GITHUB_HEAD_REF | rev | cut -c-37 | rev)
([[ $GITHUB_REF == 'refs/heads/main' ]] && echo "BRANCH_SLUG=main" || echo "BRANCH_SLUG=$SAFE_GITHUB_HEAD_REF_SLUG_URL") >> $GITHUB_ENV
- uses: hmarr/debug-action@v2

- name: Start deployment
Expand All @@ -44,7 +43,7 @@ jobs:
ref: ${{ github.head_ref }}
debug: true

- name: Scaleway Container Deploy action
- name: Scaleway Container Deploy action
id: deploy
uses: ./ # Uses an action in the root directory
with:
Expand All @@ -56,7 +55,7 @@ jobs:
scw_dns: containers.philibeaux.fr
root_zone: true

- name: check output
- name: check output
shell: bash
run: |
echo "${{ steps.deploy.outputs.url }}"
Expand All @@ -77,7 +76,7 @@ jobs:
env_url: ${{ steps.deploy.outputs.url }}

teardown-scaleway-container:
name: teardown scaleway serverless container
name: teardown scaleway serverless container
needs: deploy-scaleway-container
runs-on: ubuntu-latest
steps:
Expand All @@ -90,10 +89,9 @@ jobs:
run: |
SAFE_GITHUB_HEAD_REF_SLUG_URL=$(echo $GITHUB_HEAD_REF | rev | cut -c-37 | rev)
([[ $GITHUB_REF == 'refs/heads/main' ]] && echo "BRANCH_SLUG=main" || echo "BRANCH_SLUG=$SAFE_GITHUB_HEAD_REF_SLUG_URL") >> $GITHUB_ENV
- uses: hmarr/debug-action@v2

- name: Scaleway Container Teardown action
- name: Scaleway Container Teardown action
id: deploy
uses: ./ # Uses an action in the root directory
with:
Expand All @@ -105,7 +103,7 @@ jobs:
scw_dns: containers.philibeaux.fr
root_zone: true

- name: check output
- name: check output
shell: bash
run: |
echo "${{ steps.deploy.outputs.url }}"
Expand All @@ -120,11 +118,4 @@ jobs:
debug: true
step: delete-env
token: ${{ secrets.GH_TOKEN }}
env: ${{ env.BRANCH_SLUG }}







env: ${{ env.BRANCH_SLUG }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.20

WORKDIR /app

Expand Down
4 changes: 0 additions & 4 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ inputs:
description: "List of environnment variables in the form of KEY=VALUE, separated by commas"
required: false
default: ""
scw_secrets:
description: "List of environnment variables in the form of KEY=VALUE, separated by commas. The value can't contains commas nor equal signs"
required: false
default: ""
scw_secrets:
description: "List of secrets in the form of KEY=VALUE, separated by commas. The value can't contains commas nor equal signs"
required: false
Expand Down
90 changes: 0 additions & 90 deletions async.go

This file was deleted.

40 changes: 7 additions & 33 deletions dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,21 @@ var (
TTL = uint32(360)
)

func WaitForDNS(
client *scw.Client,
DNSZone string,
) (*domain.DNSZone, error) {
timeout := waitForDNSDefaultTimeout
retryInterval := defaultRetryInterval
func WaitForDNSReady(client *scw.Client, DNSZone string) (*domain.DNSZone, error) {
fmt.Println("waiting for dns zone to be ready")

api := domain.NewAPI(client)

terminalStatus := map[domain.DNSZoneStatus]struct{}{
domain.DNSZoneStatusActive: {},
domain.DNSZoneStatusLocked: {},
domain.DNSZoneStatusError: {},
}

dns, err := WaitSync(&WaitSyncConfig{
Get: func() (interface{}, bool, error) {
// listing dns zones and take the first one
DNSZones, err := api.ListDNSZones(&domain.ListDNSZonesRequest{
DNSZone: DNSZone,
})

if err != nil {
return nil, false, err
}

Dns := DNSZones.DNSZones[0]

_, isTerminal := terminalStatus[Dns.Status]

return Dns, isTerminal, nil
},
Timeout: timeout,
IntervalStrategy: LinearIntervalStrategy(retryInterval),
dns, err := api.WaitForDNSZone(&domain.WaitForDNSZoneRequest{
DNSZone: DNSZone,
})

if err != nil {
return nil, fmt.Errorf("error waiting for DNS zone to be ready: %s", err)
return dns, err
}

return dns.(*domain.DNSZone), nil
return dns, nil

}

func DeleteDNSRecord(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module scaleway-container-deploy-action

go 1.17

require github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9
require github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15

require gopkg.in/yaml.v2 v2.4.0 // indirect
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9 h1:0roa6gXKgyta64uqh52AQG3wzZXH21unn+ltzQSXML0=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.9/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15 h1:Y7xOFbD+3jaPw+VN7lkakNJ/pa+ZSQVFp1ONtJaBxns=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func SetupDomain(Client *scw.Client, Container *container.Container) (*container
fmt.Println("unable to set DNS record: ", err)
}

dns, err := WaitForDNS(Client, DNSName)
dns, err := WaitForDNSReady(Client, DNSName)

if err != nil {
fmt.Println(dns)
Expand Down
Binary file added scaleway-container-deploy-action
Binary file not shown.

0 comments on commit 20dae59

Please sign in to comment.