Skip to content

Commit

Permalink
Yandex Cloud DNS API connect
Browse files Browse the repository at this point in the history
Co-authored-by: Mikhail Parfenov <[email protected]>

Co-authored-by: Roman Dyakov <[email protected]>

Co-authored-by: Mikhail Parfenov <[email protected]>
  • Loading branch information
2 people authored and dyakovri committed Aug 4, 2024
1 parent b920955 commit a16d6a9
Show file tree
Hide file tree
Showing 7 changed files with 465 additions and 51 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.21.5' ]

steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Display Go version
run: go version
- name: Install deps
run: go get
- name: Build
run: go build
# - name: Test with the Go CLI
# run: go test
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
57 changes: 40 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
**DEVELOPER INSTRUCTIONS:**
# Yandex Cloud DNS for [`libdns`](https://github.com/libdns/libdns)

This repo is a template for developers to use when creating new [libdns](https://github.com/libdns/libdns) provider implementations.
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.

Be sure to update:

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

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

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

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

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

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

TODO: Show how to configure and use. Explain any caveats.
import (
"context"
"fmt"
"os"
"time"

yandex_cloud "github.com/profcomff/libdns-yandex-cloud"
)

func main() {
p := &yandex_cloud.Provider{ServiceAccountConfigPath: "./authorized_keys.json"}
// File structure
// {
// "id": "...",
// "service_account_id": "...",
// "created_at": "2024-08-04T14:00:38.626813184Z",
// "key_algorithm": "RSA_2048",
// "public_key": "-----BEGIN PUBLIC KEY-----\n ... \n-----END PUBLIC KEY-----\n",
// "private_key": "PLEASE DO NOT REMOVE THIS LINE! Yandex.Cloud SA Key ID <...>\n-----BEGIN PRIVATE KEY-----\n ... \n-----END PRIVATE KEY-----\n",
// "dns_zone_id": "..."
// }


records, err := p.GetRecords(context.WithTimeout(context.Background(), time.Duration(15*time.Second)), "")
if err != nil {
fmt.Printf("Error: %s", err.Error())
return
}

fmt.Println(records)
}
```
Loading

0 comments on commit a16d6a9

Please sign in to comment.