-
Notifications
You must be signed in to change notification settings - Fork 226
Add service metadata configuration file #126
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
Conversation
go.mod
Outdated
github.com/spf13/cobra v1.1.1 | ||
github.com/stretchr/testify v1.7.0 | ||
golang.org/x/mod v0.4.1 | ||
golang.org/x/tools v0.0.0-20200616195046-dc31b401abb5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where'd this come from? maybe remove it with go mod tidy
?
pkg/metadata/api_info.go
Outdated
APIStatusRemoved = "removed" | ||
APIStatusDeprecated = "deprecated" | ||
APIStatusUnknown APIStatus = "unknown" | ||
APIStatusInDevelopment = "in_development" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this just development
and make it the default instead of unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we really need a development
status for API versions. I think that we should increase the API Version whenever the CRD schema changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO development
should be a status for the service controller and not a specific API version. Unless, if development
means "not released" with the controller helm chart yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fair. The API version in development will always be the latest available option. "In development" vs. "released" is controlled by our controller release already.
pkg/testdata/models/metadata.yaml
Outdated
documentation: https://docs.example.com/ | ||
versions: | ||
- api_version: v1alpha1 | ||
status: development No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to have a helper script in the code-generator that will examine a new controller repository and construct a default metadata file given a service name...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to know what would happen if we don't have an APIStatusDevelopment
pkg/metadata/api_info.go
Outdated
APIStatusRemoved = "removed" | ||
APIStatusDeprecated = "deprecated" | ||
APIStatusUnknown APIStatus = "unknown" | ||
APIStatusInDevelopment = "in_development" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we really need a development
status for API versions. I think that we should increase the API Version whenever the CRD schema changes.
pkg/metadata/api_info.go
Outdated
APIStatusRemoved = "removed" | ||
APIStatusDeprecated = "deprecated" | ||
APIStatusUnknown APIStatus = "unknown" | ||
APIStatusInDevelopment = "in_development" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO development
should be a status for the service controller and not a specific API version. Unless, if development
means "not released" with the controller helm chart yet.
type ServiceVersion struct { | ||
APIVersion string `json:"api_version"` | ||
Status APIStatus `json:"status"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also add a boolean field called IsHub
, to be able to override the hub version. In most of the cases the latest Available
version is the hub (prefered storage version). However, according to k8s deprecation policy sometimes the hub can be different from the latest version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am quite averse to the idea of the hub being anything other than the latest generated version - we rely on it being the latest for the common runtime elements to match.
pkg/model/model.go
Outdated
// Metadata for the service | ||
meta *ackmetadata.ServiceMetadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need *ackmetadata.ServiceMetadata
in ackmode.Model
and multiversion.APIVersionManager
? what are the use cases when generating one single api version (ack-generate apis
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I had this in before your last PR, I'll remove it again.
apiInfos: apisInfo, | ||
models: models, | ||
} | ||
// TODO(hilalymh): Audit deprecated and removed versions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still going to send a PR for API versions examination. Mainly to verify that service controller maintainers didn't violate one of the deprecation/removal policies.
pkg/model/multiversion/manager.go
Outdated
hubVersion, err := metadata.GetLatestAPIVersion() | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hub version is not always the latest version. I would prefer to keep the APIVersionManager
flexible in term of choosing a hub version. However we can still enforce "choosing the latest version as hub" in the build script or cmd
/ pkg/generate/ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Will wait for your changes to cmd
- we can load it in there.
// path to a metadata file | ||
func NewServiceMetadata( | ||
metadataPath string, | ||
) (ServiceMetadata, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you can return a *ServiceMetadata
to avoid allocating a new ServiceMetadata{}
when you return an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! 👍
pkg/testdata/models/metadata.yaml
Outdated
documentation: https://docs.example.com/ | ||
versions: | ||
- api_version: v1alpha1 | ||
status: development No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious to know what would happen if we don't have an APIStatusDevelopment
func (m *ServiceMetadata) GetLatestAPIVersion() (string, error) { | ||
availableVersions := m.GetAvailableAPIVersions() | ||
|
||
if len(availableVersions) == 0 { | ||
return "", ErrNoAvailableVersions | ||
} | ||
|
||
return availableVersions[len(availableVersions)-1], nil | ||
} | ||
|
||
func (m *ServiceMetadata) GetDeprecatedAPIVersions() []string { | ||
return m.getVersionsByStatus(APIStatusDeprecated) | ||
} | ||
|
||
func (m *ServiceMetadata) GetRemovedAPIVersions() []string { | ||
return m.getVersionsByStatus(APIStatusRemoved) | ||
} | ||
|
||
func (m *ServiceMetadata) GetAvailableAPIVersions() []string { | ||
return m.getVersionsByStatus(APIStatusAvailable) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
half nit:please add godoc comment, at least for the exported functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on this @RedbackThomson :)
DEFAULT_METADATA_OUTPUT_PATH="$SERVICE_CONTROLLER_SOURCE_PATH/metadata.yaml" | ||
METADATA_OUTPUT_PATH="${METADATA_OUTPUT_PATH:-$DEFAULT_METADATA_OUTPUT_PATH}" | ||
|
||
echo "🧙 Welcome to the service metadata setup wizard" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweet emojis.
/lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description of changes:
Creates a new specification for a
metadata.yaml
file that resides in the root of the controller repository. The purpose of this file is to provide human-friendly display information about the service (long name, acronym, links) and to provide a source of truth for API versions.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.