-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a util func for fetching operator version
This utility function will be used to determine the installed version of the operator. Signed-off-by: Ronny Baturov <[email protected]>
- Loading branch information
Showing
45 changed files
with
7,236 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package version | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/operator-framework/api/pkg/lib/version" | ||
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
) | ||
|
||
var defaultNamespace = "numaresources-operator" | ||
|
||
func OfOperator(ctx context.Context, cli client.Client) (*version.OperatorVersion, error) { | ||
csvList := &operatorsv1alpha1.ClusterServiceVersionList{} | ||
|
||
err := cli.List(context.TODO(), csvList, &client.ListOptions{ | ||
Namespace: defaultNamespace, | ||
}) | ||
|
||
if err != nil { | ||
return nil, fmt.Errorf("failed to fetch ClusterServiceVersion") | ||
} | ||
if len(csvList.Items) != 1 { | ||
return nil, fmt.Errorf("expect only one CSV object under %s namespace", defaultNamespace) | ||
} | ||
return &csvList.Items[0].Spec.Version, nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
vendor/github.com/operator-framework/api/pkg/lib/version/version.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
vendor/github.com/operator-framework/api/pkg/operators/doc.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.