-1

I would like to use the following function in my controller https://github.com/openshift/machine-api-operator/blob/05041eaab5a6b9e22dd26df421d8d51050c39072/pkg/controller/vsphere/util.go#L221 Thefore in my code I do the following import

package controllers

import (
    "context"

    vsphere "github.com/openshift/machine-api-operator/pkg/controller"
    corev1 "k8s.io/api/core/v1"
    "k8s.io/apimachinery/pkg/types"
    "sigs.k8s.io/controller-runtime/pkg/client"
)

However, when I do go mod tidy, I get the following error:


bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1: module sigs.k8s.io/cluster-api@latest found (v1.3.2), but does not contain package sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1
bitbucket.bit.admin.ch/BOSC/bosc-drs-vm-group-controller/controllers imports
        github.com/openshift/machine-api-operator/pkg/controller imports
        github.com/openshift/machine-api-operator/pkg/controller/machinehealthcheck imports
        github.com/openshift/machine-api-operator/pkg/apis/healthchecking/v1alpha1 imports
        sigs.k8s.io/controller-runtime/pkg/runtime/scheme: module sigs.k8s.io/controller-runtime@latest found (v0.14.1), but does not contain package sigs.k8s.io/controller-runtime/pkg/runtime/scheme

It seems that there are some dependencies issues, however I am not sure how to solve them. I tried in go.mod to set sigs.k8s.io/controller-runtime to reference a branch and not to latest, but it doesn't seem that it has any effect.


require (
    ...
)

require (
    ...
    sigs.k8s.io/cluster-api release-1.3 //indirect
    
)

How am I suppose to solve package dependencies issues?

Babas
  • 377
  • 3
  • 16
  • You've imported `github.com/openshift/machine-api-operator/pkg/controller` and aliased it `vsphere`, when according to your explanation you want to import `github.com/openshift/machine-api-operator/pkg/controller/vsphere`. Other than that, it's possible that the mainline of the module you're using has a broken dependency graph. – Adrian Jan 12 '23 at 15:16
  • So if I import github.com/openshift/machine-api-operator/pkg/controller/vsphere, I get the following message: github.com/openshift/machine-api-operator/pkg/controller/vsphere: module github.com/openshift/machine-api-operator@latest found (v0.2.0), but does not contain package github.com/openshift/machine-api-operator/pkg/controller/vsphere. Maybe that's why then I tried to import only github.com/openshift/machine-api-operator/pkg/controller. Still it is not clear to me how this work... – Babas Jan 12 '23 at 15:22
  • 2
    Then the package does not exist in `v0.2.0`. If you need that exact code, you may need to specify the branch or commit. – JimB Jan 12 '23 at 15:50

1 Answers1

2

This works:

go get github.com/openshift/machine-api-operator/pkg/controller/vsphere@master

That package is not available in @latest release.

calogero
  • 53
  • 5