Skip to content

Commit a16d6a9

Browse files
parfenovmaMikhail Parfenov
authored andcommitted
Yandex Cloud DNS API connect
Co-authored-by: Mikhail Parfenov <parfenov.ma21@physics.msu.ru> Co-authored-by: Roman Dyakov <dyakovri@yandex-team.ru> Co-authored-by: Mikhail Parfenov <mixx3@yandex-team.ru>
1 parent b920955 commit a16d6a9

7 files changed

Lines changed: 465 additions & 51 deletions

File tree

.github/workflows/build_test.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Go
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
go-version: [ '1.21.5' ]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Setup Go ${{ matrix.go-version }}
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: ${{ matrix.go-version }}
18+
- name: Display Go version
19+
run: go version
20+
- name: Install deps
21+
run: go get
22+
- name: Build
23+
run: go build
24+
# - name: Test with the Go CLI
25+
# run: go test

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) <TODO: YEAR AND NAME>
3+
Copyright (c) 2024, Профком студентов физфака МГУ
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
**DEVELOPER INSTRUCTIONS:**
1+
# Yandex Cloud DNS for [`libdns`](https://github.com/libdns/libdns)
22

3-
This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations.
3+
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for [Yandex Cloud API](https://yandex.cloud/en/docs/dns/api-ref/) allowing you to manage DNS records.
44

5-
Be sure to update:
65

7-
- The package name
8-
- The Go module name in go.mod
9-
- The latest `libdns/libdns` version in go.mod
10-
- All comments and documentation, including README below and godocs
11-
- License (must be compatible with Apache/MIT)
12-
- All "TODO:"s is in the code
13-
- All methods that currently do nothing
6+
## Authenticate
147

15-
Remove this section from the readme before publishing.
8+
To authenticate API you need to supply a Yandex Cloud IAM token. It will automatically ensure from Service Account authorization keys.
169

17-
---
10+
More info: <https://yandex.cloud/en/docs/dns/api-ref/authentication>
1811

19-
\<PROVIDER NAME\> for [`libdns`](https://github.com/libdns/libdns)
20-
=======================
2112

22-
[![Go Reference](https://pkg.go.dev/badge/test.svg)](https://pkg.go.dev/github.com/libdns/TODO:PROVIDER_NAME)
13+
## Usage
2314

24-
This package implements the [libdns interfaces](https://github.com/libdns/libdns) for \<PROVIDER\>, allowing you to manage DNS records.
15+
```go
16+
package main
2517

26-
TODO: Show how to configure and use. Explain any caveats.
18+
import (
19+
"context"
20+
"fmt"
21+
"os"
22+
"time"
23+
24+
yandex_cloud "github.com/profcomff/libdns-yandex-cloud"
25+
)
26+
27+
func main() {
28+
p := &yandex_cloud.Provider{ServiceAccountConfigPath: "./authorized_keys.json"}
29+
// File structure
30+
// {
31+
// "id": "...",
32+
// "service_account_id": "...",
33+
// "created_at": "2024-08-04T14:00:38.626813184Z",
34+
// "key_algorithm": "RSA_2048",
35+
// "public_key": "-----BEGIN PUBLIC KEY-----\n ... \n-----END PUBLIC KEY-----\n",
36+
// "private_key": "PLEASE DO NOT REMOVE THIS LINE! Yandex.Cloud SA Key ID <...>\n-----BEGIN PRIVATE KEY-----\n ... \n-----END PRIVATE KEY-----\n",
37+
// "dns_zone_id": "..."
38+
// }
39+
40+
41+
records, err := p.GetRecords(context.WithTimeout(context.Background(), time.Duration(15*time.Second)), "")
42+
if err != nil {
43+
fmt.Printf("Error: %s", err.Error())
44+
return
45+
}
46+
47+
fmt.Println(records)
48+
}
49+
```

0 commit comments

Comments
 (0)