Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added entities for work with DNS v2 API. #249

Merged
merged 18 commits into from
Feb 26, 2024
Merged

Conversation

dchudik
Copy link
Contributor

@dchudik dchudik commented Jan 23, 2024

Планируется публичный релиз DNS v2 API.
В данный момент API v2 доступно для использования, но докуметации и UI апдейта ещё нет.

Добавил новые ресурсы:

  • selectel_domains_zone_v2
  • selectel_domains_rrset_v2

Добавил новые datasource:

  • selectel_domains_zone_v2
  • selectel_domains_rrset_v2

Обновил версию библиотеки domains-go.

@dchudik
Copy link
Contributor Author

dchudik commented Jan 24, 2024

В данный момент немножко хромает прод, могут быть проблемы при прогоне - уже фиксим.
Как буду уверен, что всё окей - оставлю сообщение ниже.

…dded optional field project_id for entities selectel_domains_v2. Fix work with optional fields.
@dchudik
Copy link
Contributor Author

dchudik commented Jan 26, 2024

Исправили то что хотели.
Готов к проверке.

@Gogen120
Copy link
Contributor

Еще, как я помню, надо бы документацию добавить в website/docs с описанием ресурсов

@dchudik
Copy link
Contributor Author

dchudik commented Feb 1, 2024

Добавил документацию по образцу остальных команд.
Исправил замечания с ревью:

  1. Добавил ForceNew для неизменяемых полей
  2. Перенес общие методы в domains_v2

@dchudik dchudik requested a review from Gogen120 February 1, 2024 13:52
selectel/domains_v2.go Outdated Show resolved Hide resolved
selectel/data_source_selectel_domains_rrset_v2.go Outdated Show resolved Hide resolved
selectel/domains_v2.go Outdated Show resolved Hide resolved
selectel/domains_v2.go Show resolved Hide resolved
selectel/resource_selectel_domains_rrset_v2.go Outdated Show resolved Hide resolved
@dchudik
Copy link
Contributor Author

dchudik commented Feb 6, 2024

Убрал замечание из линтера.
Оставил два варианта наименования RRSet и rrset.
Сделал поле project_id обязательным в сущностях, которые добавил.

Остался вопрос с тестами для импорта.
Мы используем проектный токен Keystone. И поэтому при импорте ресурсов важно чтобы параметр project_id в конфиге был установлен.
Если делать по образцу остальных команд, то тесты проходить не будут. При этом тест для импорта у CRaaS (TestAccCRaaSRegistryV1ImportBasic) тоже не работает. Остальные тесты проверить не удалось.
Проблема кроется в том, что функция testAccCheckSelectelImportEnv устанавливает значение переменной SEL_PROJECT_ID, но дальше при импорте не обновляется config. И когда мы в функции импорта берем config.ProjectID - мы берем старое значение (с прошлого запуска тестов).
Нашел два варианта решения проблемы:

  1. В функции импорта использовать os.Getenv("SEL_PROJECT_ID").
  2. При запуске тестов на импорт установить переменную окружения SEL_PROJECT_ID. В рамках будет создана зона и эта же зона будет импортирована.

Остановился на втором варианте.

@dchudik dchudik requested a review from TruePack February 7, 2024 08:43
@dchudik
Copy link
Contributor Author

dchudik commented Feb 13, 2024

Добавил комментарии в функции импорта в ресурсах domains_v2, для большей ясности кода.
Убрал объявление переменных: zoneID := d.Id() и rrsetID := d.Id(). Использую сразу d.Id().

@dchudik dchudik requested a review from TruePack February 13, 2024 11:55
@@ -8,7 +8,9 @@ description: |-

# selectel\_domains\_domain_v1

Provides an ID of a domain in DNS Hosting. For more information about domains in DNS Hosting, see the [official Selectel documentation](https://docs.selectel.ru/networks-services/dns/domains/).
~> **Note:** This is legacy datasource. Using the `selectel_domains_zone_v2` datasource. They utilize different API and created zones live on different authoritative servers. Zone created in v2 API is entirely new zone, and not available via v1 api and vice versa.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все Note нужно изменить на оформление как warning

~> Note: This data source is applicable to DNS Hosting (legacy). We do not support and develop DNS Hosting (legacy), but domains and records created in DNS Hosting (legacy) continue to work until further notice. We recommend to transfer your data to DNS Hosting (actual). For more infomation about DNS Hosting (actual), see the official Selectel documentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В дескрипшене (стр. 6) надо поправить:

Provides an ID of a domain in Selectel DNS Hosting (legacy)

Copy link
Contributor Author

@dchudik dchudik Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Заменил Note на Warning. Чтобы выглядело как тут

В дальнейшем буду просто писать "Заменил Note на Warning".

website/docs/d/domains_domain_v1.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
Copy link
Contributor Author

@dchudik dchudik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил замечания.

website/docs/d/domains_domain_v1.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
```hcl
resource "selectel_domains_rrset_v2" "a_rrset_1" {
zone_id = "zone_id"
name = "a.example.com."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Скорее всего лучше писать руками.
Поправил. только в MX записи content не менял. И не менял ещё где в record_v1 используются переменные в name

website/docs/d/domains_domain_v1.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Show resolved Hide resolved
Copy link
Contributor Author

@dchudik dchudik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправил замечания

website/docs/r/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_rrset_v2.html.markdown Show resolved Hide resolved
website/docs/d/domains_rrset_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_domain_v1.html.markdown Outdated Show resolved Hide resolved
website/docs/d/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
website/docs/r/domains_zone_v2.html.markdown Outdated Show resolved Hide resolved
@dchudik
Copy link
Contributor Author

dchudik commented Feb 26, 2024

Удалил datasource для domains_v2 так как они противоречат концепции datasources в terraform.
Результаты запуска тестов:

=== RUN   TestAccDomainsRRSetV2Basic
--- PASS: TestAccDomainsRRSetV2Basic (72.31s)

=== RUN   TestAccDomainsZoneV2Basic
--- PASS: TestAccDomainsZoneV2Basic (58.27s)

=== RUN   TestAccDomainsZoneV2ImportBasic
--- PASS: TestAccDomainsZoneV2ImportBasic (6.15s)

=== RUN   TestAccDomainsRRSetV2ImportBasic
--- PASS: TestAccDomainsRRSetV2ImportBasic (12.95s)

@TruePack TruePack merged commit 3ee9b6a into selectel:master Feb 26, 2024
2 checks passed
TruePack pushed a commit that referenced this pull request Feb 26, 2024
Added selectel_domains_zone_v2 resource.
Added selectel_domains_rrset_v2 resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants