This repository has been archived by the owner on Oct 10, 2023. It is now read-only.
/
cliplugin_types.go
90 lines (75 loc) · 2.98 KB
/
cliplugin_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2021 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// Target is the namespace of the CLI to which plugin is applicable
type Target string
const (
// TargetK8s is a kubernetes target of the CLI
TargetK8s Target = "kubernetes"
targetK8s Target = "k8s"
// TargetTMC is a Tanzu Mission Control target of the CLI
TargetTMC Target = "mission-control"
targetTMC Target = "tmc"
// TargetNone is used for plugins that are not associated with any target
TargetNone Target = ""
)
var (
// SupportedTargets is a list of all supported Target
SupportedTargets = []Target{TargetK8s, TargetTMC}
)
// ArtifactList contains an Artifact object for every supported platform of a version.
type ArtifactList []Artifact
// Artifact points to an individual plugin binary specific to a version and platform.
type Artifact struct {
// Image is a fully qualified OCI image for the plugin binary.
Image string `json:"image,omitempty"`
// AssetURI is a URI of the plugin binary. This can be a fully qualified HTTP path or a local path.
URI string `json:"uri,omitempty"`
// SHA256 hash of the plugin binary.
Digest string `json:"digest,omitempty"`
// Type of the binary artifact. Valid values are S3, GCP, OCIImage.
Type string `json:"type"`
// OS of the plugin binary in `GOOS` format.
OS string `json:"os"`
// Arch is CPU architecture of the plugin binary in `GOARCH` format.
Arch string `json:"arch"`
}
// CLIPluginSpec defines the desired state of CLIPlugin.
type CLIPluginSpec struct {
// Description is the plugin's description.
Description string `json:"description"`
// Recommended version that Tanzu CLI should use if available.
// The value should be a valid semantic version as defined in
// https://semver.org/. E.g., 2.0.1
RecommendedVersion string `json:"recommendedVersion"`
// Artifacts contains an artifact list for every supported version.
Artifacts map[string]ArtifactList `json:"artifacts"`
// Optional specifies whether the plugin is mandatory or optional
// If optional, the plugin will not get auto-downloaded as part of
// `tanzu login` or `tanzu plugin sync` command
// To view the list of plugin, user can use `tanzu plugin list` and
// to download a specific plugin run, `tanzu plugin install <plugin-name>`
Optional bool `json:"optional"`
// Target specifies the target of the plugin. Only needed for standalone plugins
Target Target `json:"target,omitempty"`
}
//+kubebuilder:object:root=true
// CLIPlugin denotes a Tanzu cli plugin.
type CLIPlugin struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec CLIPluginSpec `json:"spec"`
}
//+kubebuilder:object:root=true
// CLIPluginList contains a list of CLIPlugin
type CLIPluginList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CLIPlugin `json:"items"`
}
func init() {
SchemeBuilder.Register(&CLIPlugin{}, &CLIPluginList{})
}