Giter Club home page Giter Club logo

nifcloud-sdk-go's People

Contributors

aokumasan avatar fujita-hiroki1115 avatar fuku2014 avatar matsuoka-k-git avatar miyuush avatar o108minmin avatar sogokato avatar tily avatar tunakyonn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nifcloud-sdk-go's Issues

Wait 系の機能が欲しい

computing や rdb, nas 等のインスタンス作成・設定変更に際して、作業完了まで待つ機能が欲しい

Signature V3 faild on missing timezone environment

Summary

Expected

  • I think nicloud-sdk-go should executable in environment without timezone database.

Reproduce

reproduce steps on busybox
docker run -it --rm -v /etc/ssl/certs:/etc/ssl/certs busybox:1.35.0 sh
mkdir /work && cd /work
wget https://go.dev/dl/go1.20.2.linux-amd64.tar.gz
mkdir -p /usr/local
tar -C /usr/local -xzf go1.20.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go mod init test
cat << EOF > main.go
package main

import (
        "fmt"
        "context"
        "os"

        "github.com/nifcloud/nifcloud-sdk-go/nifcloud"
        "github.com/nifcloud/nifcloud-sdk-go/service/dns"
)

func main() {
    // Create config with credentials and region.
    cfg := nifcloud.NewConfig(
            os.Getenv("NIFCLOUD_ACCESS_KEY_ID"),
            os.Getenv("NIFCLOUD_SECRET_ACCESS_KEY"),
            "jp-east-1",
    )

    // Create the DNS client with Config value.
    svc := dns.NewFromConfig(cfg)

    // Send the request
    resp, err := svc.ListHostedZones(context.TODO(), nil)
    if err != nil {
            panic(err)
    }

    fmt.Println("Zones:")
    for _, hostedZone := range resp.HostedZones {
        fmt.Println(nifcloud.ToString(hostedZone.Name))
    }
}
EOF
go mod tidy

export NIFCLOUD_ACCESS_KEY_ID=XXXXXXXX
export NIFCLOUD_SECRET_ACCESS_KEY=XXXXXXXX

go build main.go
./main
# Zones:
# myzone.examle.com
# Remove golang timezone database
mv /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/_zoneinfo.zip
./main
# panic: operation error dns: ListHostedZones, failed to sign request: failed to sign http request, unknown time zone GMT
#
# goroutine 1 [running]:
# main.main()
#        /work/main.go:26 +0x3e6

Solutions

I think 2 solution. maybe (a) is better.

(a) Using asctime

nifcloud signature v3 is support asctime. time.LoadLocation("UTC") is available on missing timezone environment.

        if req.Header.Get("Date") == "" {
                location, err := time.LoadLocation("UTC")
                if err != nil {
                        return signedRequest{}, err
                }

                req.Header.Set("Date", time.Now().In(location).Format(time.ANSIC))
        }

(b) Import time/tzdata

time/tzdata provides an embedded copy of the timezone database.

import (
    ...

    _ "time/tzdata"

    ...
)

It is easy, But increases size of program.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.