Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Can't unit test own usage of InClusterFactory

オープン
#103 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
go

調査の方向性

Start with conditions/factory.go at readNamespace, then trace InClusterFactory.GetNamespacedName through internal/utils/utils.go and review the override used in conditions/conditions_test.go. Determine an externally usable way to supply or override the namespace for unit tests, with tests that exercise wrapper code using a fake runtime client without requiring the current environment namespace.

索引モデルが issue の本文から書いたものです。

説明

lifecycle/frozen

Bug Report

What did you do?
Created a wrapper function in our operator code that finds the name of the associated OLM OperatorCondition and then uses the InClusterFactory API to set the upgradeable condition. Then we started writing tests to test this function.

What did you expect to see?
Tests to pass or fail depending on the correct writing of the wrapper function and calling the correct InClusterFactory and Condition code.

What did you see instead? Under which circumstances?
The error: get operator condition namespace: namespace not found for current environment.
Since the unit tests are using a fake runtime client and running locally, this was to be expected since InClusterFactory.GetNamespacedName() calls utils.GetOperatorNamespace(). However, what was unexpected was in our tests there is no way to override this since:

  • utils package is internal so private
  • readNamespace is private
  • the library's own tests can override since they share the same package as readNamespace.

Environment

  • operator-lib version: 0.9.x
  • github.com/operator-framework/operator-lib v0.9.0

Possible Solutions

  • make readNamespace public
  • provide an interface to allow GetNamespacedName to be overridden
  • allow the namespace to be injected into InClusterFactory (since the operator provides the namespace through request.namespace, it might be a nice alternative?)

Additional context
Add any other context about the problem here.

主要言語
Go
スター
40
フォーク
42
平均マージ
4日 46分
マージ済み PR(30日)
7

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

operator-framework/operator-lib のほかの issue

operator-framework/operator-lib の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。