operator-sdk icon indicating copy to clipboard operation
operator-sdk copied to clipboard

API Markers

Open TachibanaGin opened this issue 3 years ago • 3 comments

/*
Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.

// ElasticsearchSpec defines the desired state of Elasticsearch
type ElasticsearchSpec struct {
	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
	// Important: Run "make" to regenerate code after modifying this file

	//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Pod Count",xDescriptors="urn:alm:descriptor:com.tectonic.ui:podCount"
	// +kubebuilder:validation:Required
	Size int32                        `json:"size,omitempty"`
	// +kubebuilder:validation:Required
	Image string 				      `json:"image,omitempty"`
	// +kubebuilder:validation:Required
	Jvm string                        `json:"jvm,omitempty"`
	// +kubebuilder:validation:Required
	Env []corev1.EnvVar                 `json:"env,omitempty"`
	// +kubebuilder:validation:Required
	Resources corev1.ResourceRequirements `json:"resources,omitempty"`
	// +kubebuilder:validation:Required
	Service *OwnService `json:"service,omitempty"`
	Config *OwnConfig `json:"config,omitempty"`
	// +kubebuilder:validation:Required
	StorageClass *string                 `json:"storageclass,omitempty"`
	// +kubebuilder:validation:Required
    StorageResourceRequest string      `json:"storageresourcerequest,omitempty"`

}

type OwnResourcesStatus struct {

	Service  OwnResourcesServiceStatus            `json:"service,omitempty"`
	Endpoint []OwnResourcesEndpointStatus         `json:"endpoint,omitempty"`
	PVC      []corev1.PersistentVolumeClaimStatus `json:"pvc,omitempty"`

}

// ElasticsearchStatus defines the observed state of Elasticsearch
type ElasticsearchStatus struct {
	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
	// Important: Run "make" to regenerate code after modifying this file
	//+operator-sdk:csv:customresourcedefinitions:type=spec
	//+operator-sdk:csv:customresourcedefinitions:type=status
	AvailableReplicas int32               `json:"replicas,omitempty"`
	LastUpdateTime metav1.Time            `json:"lastUpdateTime,omitempty"`
	OwnResourcesStatus OwnResourcesStatus `json:"relationResourceStatus,omitempty"`
}

//+operator-sdk:csv:customresourcedefinitions:displayName="Bobft-ElasticSearch",resources={Statefulset,v1,bobft-elasticsearch-statefulset}
// Elasticsearch represents an Elasticsearch resource in a Kubernetes cluster.
// +kubebuilder:resource:categories=elastic,shortName=es
//+kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:storageversion
// Elasticsearch is the Schema for the elasticsearches API
type Elasticsearch struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   ElasticsearchSpec   `json:"spec,omitempty"`
	Status ElasticsearchStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ElasticsearchList contains a list of Elasticsearch
type ElasticsearchList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Elasticsearch `json:"items"`
}

func init() {
	SchemeBuilder.Register(&Elasticsearch{}, &ElasticsearchList{})
}
make bundle 

output error:
wFATA[0012] Error generating kustomize files: error getting ClusterServiceVersion base: error generating ClusterServiceVersion definitions metadata: no spec found for type ElasticsearchStatus 

Update: I edited the original comment to put it in triple backticks

TachibanaGin avatar Jun 27 '22 03:06 TachibanaGin

@TachibanaGin after modifying the *_types.go file (wherein you are changing ElasticsearchSpec can you run make generate and check that the spec you want is rendered in the CRD? After that, you can run make bundle and verify if the error still persists.

varshaprasad96 avatar Jun 27 '22 17:06 varshaprasad96

i use

make generate&make manifests...
input&output:
hatchin@192 Bobft-ElasticSearch-Operator % make generate 
/Users/hatchin/go/src/Bobft-ElasticSearch-Operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
hatchin@192 Bobft-ElasticSearch-Operator % make manifests
/Users/hatchin/go/src/Bobft-ElasticSearch-Operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
hatchin@192 Bobft-ElasticSearch-Operator % make bundle   
/Users/hatchin/go/src/Bobft-ElasticSearch-Operator/bin/controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate kustomize manifests -q

Display name for the operator (required): 
> es

Description for the operator (required): 
> es

Provider's name for the operator (required): 
> es

Any relevant URL for the provider name (optional): 
> es

Comma-separated list of keywords for your operator (required): 
> es

Comma-separated list of maintainers and their emails (e.g. 'name1:email1, name2:email2') (required): 
> es
esFATA[0003] Error generating kustomize files: error getting ClusterServiceVersion base: error generating ClusterServiceVersion definitions metadata: no spec found for type ElasticsearchStatus 
make: *** [bundle] Error 1

TachibanaGin avatar Jun 28 '22 15:06 TachibanaGin

@TachibanaGin could you share your CRD if possible? Does the particular custom resource contain spec like this? (https://github.com/operator-framework/operator-sdk/blob/e7c9b74e20ab2dd17ab246c8c9e867b8c9b5b079/testdata/go/v3/memcached-operator/bundle/manifests/cache.example.com_memcacheds.yaml#L8)

varshaprasad96 avatar Jul 11 '22 17:07 varshaprasad96

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot avatar Oct 10 '22 01:10 openshift-bot

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot avatar Nov 09 '22 08:11 openshift-bot

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-bot avatar Dec 10 '22 00:12 openshift-bot

@openshift-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

openshift-ci[bot] avatar Dec 10 '22 00:12 openshift-ci[bot]