diff --git a/API.md b/API.md new file mode 100644 index 0000000000..6f0b0b5925 --- /dev/null +++ b/API.md @@ -0,0 +1,1461 @@ +

Packages:

+ +

cr/v1alpha1

+

+

Package v1alpha1 is the v1alpha1 version of the API.

+

+Resource Types: + +

ActionSet +

+

+

ActionSet describes kanister actions.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +cr/v1alpha1 + +
+kind
+string +
ActionSet
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+spec
+ + +ActionSetSpec + + +
+

Spec defines the specification for the actionset. +The specification includes a list of Actions to be performed. Each Action includes details +about the referenced Blueprint and other objects used to perform the defined action.

+
+
+ +
+
+status
+ + +ActionSetStatus + + +
+

Status refers to the current status of the Kanister actions.

+
+

Blueprint +

+

+

Blueprint describes kanister actions.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +cr/v1alpha1 + +
+kind
+string +
Blueprint
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+actions
+ + +map[string]*./pkg/apis/cr/v1alpha1.BlueprintAction + + +
+

Actions is the list of actions constructing the Blueprint.

+
+

Profile +

+

+

Profile captures information about a storage location for backup artifacts and +corresponding credentials, that will be made available to a Blueprint phase.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+string
+ +cr/v1alpha1 + +
+kind
+string +
Profile
+metadata
+ + +Kubernetes meta/v1.ObjectMeta + + +
+Refer to the Kubernetes API documentation for the fields of the +metadata field. +
+location
+ + +Location + + +
+

Location provides the information about the object storage that is going to be used by Kanister to upload the backup objects.

+
+credential
+ + +Credential + + +
+

Credential represents the credentials associated with the Location.

+
+skipSSLVerify
+ +bool + +
+

SkipSSLVerify is a boolean that specifies whether skipping SSL verification +is allowed when operating with the Location. +If omitted from the CR definition, it defaults to false

+
+

ActionProgress +

+

+(Appears on: +ActionSetStatus) +

+

+

ActionProgress provides information on the progress of an action.

+

+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+runningPhase
+ +string + +
+

RunningPhase represents which phase of the action is being run

+
+percentCompleted
+ +string + +
+

PercentCompleted is computed by assessing the number of completed phases +against the the total number of phases.

+
+lastTransitionTime
+ + +Kubernetes meta/v1.Time + + +
+

LastTransitionTime represents the last date time when the progress status +was received.

+
+

ActionSetSpec +

+

+(Appears on: +ActionSet) +

+

+

ActionSetSpec is the specification for the actionset.

+

+ + + + + + + + + + + + + +
FieldDescription
+actions
+ + +[]ActionSpec + + +
+

Actions represents a list of Actions that need to be performed by the actionset.

+
+

ActionSetStatus +

+

+(Appears on: +ActionSet) +

+

+

ActionSetStatus is the status for the actionset. This should only be updated by the controller.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+state
+ + +State + + +
+

State represents the current state of the actionset. +There are four possible values: “Pending”, “Running”, “Failed”, and “Complete”.

+
+actions
+ + +[]ActionStatus + + +
+

Actions list represents the latest available observations of the current state of all the actions.

+
+error
+ + +Error + + +
+

Error contains the detailed error message of an actionset failure.

+
+progress
+ + +ActionProgress + + +
+

Progress provides information on the progress of a running actionset. +This includes the percentage of completion of an actionset and the phase that is +currently being executed.

+
+

ActionSpec +

+

+(Appears on: +ActionSetSpec) +

+

+

ActionSpec is the specification for a single Action.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name is the action we’ll perform. For example: backup or restore.

+
+object
+ + +ObjectReference + + +
+

Object refers to the thing we’ll perform this action on.

+
+blueprint
+ +string + +
+

Blueprint with instructions on how to execute this action.

+
+artifacts
+ + +map[string]./pkg/apis/cr/v1alpha1.Artifact + + +
+

Artifacts will be passed as inputs into this phase.

+
+configMaps
+ + +map[string]./pkg/apis/cr/v1alpha1.ObjectReference + + +
+

ConfigMaps that we’ll get and pass into the blueprint.

+
+secrets
+ + +map[string]./pkg/apis/cr/v1alpha1.ObjectReference + + +
+

Secrets that we’ll get and pass into the blueprint.

+
+profile
+ + +ObjectReference + + +
+

Profile is use to specify the location where store artifacts and the +credentials authorized to access them.

+
+podOverride
+ + +JSONMap + + +
+

PodOverride is used to specify pod specs that will override the +default pod specs

+
+options
+ +map[string]string + +
+

Options will be used to specify additional values +to be used in the Blueprint.

+
+preferredVersion
+ +string + +
+

PreferredVersion will be used to select the preferred version of Kanister functions +to be executed for this action

+
+

ActionStatus +

+

+(Appears on: +ActionSetStatus) +

+

+

ActionStatus is updated as we execute phases.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name is the action we’ll perform. For example: backup or restore.

+
+object
+ + +ObjectReference + + +
+

Object refers to the thing we’ll perform this action on.

+
+blueprint
+ +string + +
+

Blueprint with instructions on how to execute this action.

+
+phases
+ + +[]Phase + + +
+

Phases are sub-actions an are executed sequentially.

+
+artifacts
+ + +map[string]./pkg/apis/cr/v1alpha1.Artifact + + +
+

Artifacts created by this phase.

+
+deferPhase
+ + +Phase + + +
+

DeferPhase is the phase that is executed at the end of an action +irrespective of the status of other phases in the action

+
+

Artifact +

+

+(Appears on: +ActionSpec, +ActionStatus, +BlueprintAction) +

+

+

Artifact tracks objects produced by an action.

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+keyValue
+ +map[string]string + +
+

KeyValue represents key-value pair artifacts produced by the action.

+
+kopiaSnapshot
+ +string + +
+

KopiaSnapshot captures the kopia snapshot information +produced as a JSON string by kando command in phases of an action.

+
+

BlueprintAction +

+

+

BlueprintAction describes the set of phases that constitute an action.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name contains the name of the action.

+
+kind
+ +string + +
+

Kind contains the resource on which this action has to be performed.

+
+configMapNames
+ +[]string + +
+

ConfigMapNames is used to specify the config map names that can be used later in the action phases.

+
+secretNames
+ +[]string + +
+

List of Kubernetes secret names used in action phases.

+
+inputArtifactNames
+ +[]string + +
+

InputArtifactNames is the list of Artifact names that were set from previous action and can be consumed in the current action.

+
+outputArtifacts
+ + +map[string]./pkg/apis/cr/v1alpha1.Artifact + + +
+

OutputArtifacts is the map of rendered artifacts produced by the BlueprintAction.

+
+phases
+ + +[]BlueprintPhase + + +
+

Phases is the list of BlueprintPhases which are invoked in order when executing this action.

+
+deferPhase
+ + +BlueprintPhase + + +
+

DeferPhase is invoked after the execution of Phases that are defined for an action. +A DeferPhase is executed regardless of the statuses of the other phases of the action. +A DeferPhase can be used for cleanup operations at the end of an action.

+
+

BlueprintPhase +

+

+(Appears on: +BlueprintAction) +

+

+

BlueprintPhase is a an individual unit of execution.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+func
+ +string + +
+

Func is the name of a registered Kanister function.

+
+name
+ +string + +
+

Name contains name of the phase.

+
+objects
+ + +map[string]./pkg/apis/cr/v1alpha1.ObjectReference + + +
+

ObjectRefs represents a map of references to the Kubernetes objects that +can later be used in the Args of the function.

+
+args
+ +map[string]interface{} + +
+

Args represents a map of named arguments that the controller will pass to the Kanister function.

+
+

Credential +

+

+(Appears on: +Profile) +

+

+

Credential

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+type
+ + +CredentialType + + +
+

Type represents the information about how the credentials are provided for the respective object storage.

+
+keyPair
+ + +KeyPair + + +
+

KeyPair represents the key-value map used for the Credential of Type KeyPair.

+
+secret
+ + +ObjectReference + + +
+

Secret represents the Kubernetes Secret Object used for the Credential of Type Secret.

+
+kopiaServerSecret
+ + +KopiaServerSecret + + +
+

KopiaServerSecret represents the secret being used by Credential of Type Kopia.

+
+

CredentialType +(string alias)

+

+(Appears on: +Credential) +

+

+

CredentialType

+

+ + + + + + + + + + + + + + +
ValueDescription

"keyPair"

"kopia"

"secret"

+

Error +

+

+(Appears on: +ActionSetStatus) +

+

+

Error represents an error that occurred when executing an actionset.

+

+ + + + + + + + + + + + + +
FieldDescription
+message
+ +string + +
+

Message is the actual error message that is displayed in case of errors.

+
+

JSONMap +(map[string]interface{} alias)

+

+(Appears on: +ActionSpec) +

+

+

JSONMap contains PodOverride specs.

+

+

KeyPair +

+

+(Appears on: +Credential) +

+

+

KeyPair

+

+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+idField
+ +string + +
+

IDField specifies the corresponding key in the secret where the AWS Key ID value is stored.

+
+secretField
+ +string + +
+

SecretField specifies the corresponding key in the secret where the AWS Secret Key value is stored.

+
+secret
+ + +ObjectReference + + +
+

Secret represents a Kubernetes Secret object storing the KeyPair credentials.

+
+

KopiaServerSecret +

+

+(Appears on: +Credential) +

+

+

KopiaServerSecret contains credentials to connect to Kopia server

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+username
+ +string + +
+

Username represents the username used to connect to the Kopia Server.

+
+hostname
+ +string + +
+

Hostname represents the hostname used to connect to the Kopia Server.

+
+userPassphrase
+ + +KopiaServerSecretRef + + +
+

UserPassphrase is the user password used to connect to the Kopia Server.

+
+tlsCert
+ + +KopiaServerSecretRef + + +
+

TLSCert is the certificate used to connect to the Kopia Server.

+
+connectOptions
+ +map[string]int + +
+

ConnectOptions represents a map of options which can be used to connect to the Kopia Server.

+
+

KopiaServerSecretRef +

+

+(Appears on: +KopiaServerSecret) +

+

+

KopiaServerSecretRef refers to K8s secrets containing Kopia creds

+

+ + + + + + + + + + + + + + + + + +
FieldDescription
+key
+ +string + +
+

Key represents the corresponding key in the secret where the required +credential or certificate value is stored.

+
+secret
+ + +ObjectReference + + +
+

Secret is the K8s secret object where the creds related to the Kopia Server are stored.

+
+

Location +

+

+(Appears on: +Profile) +

+

+

Location

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+type
+ + +LocationType + + +
+

Type specifies the kind of object storage that would be used to upload the +backup objects. Currently supported values are: “GCS”, “S3Compliant”, +and “Azure”.

+
+bucket
+ +string + +
+

Bucket represents the bucket on the object storage where the backup is uploaded.

+
+endpoint
+ +string + +
+

Endpoint specifies the endpoint where the object storage is accessible at.

+
+prefix
+ +string + +
+

Prefix is the string that would be prepended to the object path in the +bucket where the backup objects are uploaded.

+
+region
+ +string + +
+

Region represents the region of the bucket specified above.

+
+

LocationType +(string alias)

+

+(Appears on: +Location) +

+

+

LocationType

+

+ + + + + + + + + + + + + + + + +
ValueDescription

"azure"

"gcs"

"kopia"

"s3Compliant"

+

ObjectReference +

+

+(Appears on: +ActionSpec, +ActionStatus, +BlueprintPhase, +Credential, +KeyPair, +KopiaServerSecretRef) +

+

+

ObjectReference refers to a kubernetes object.

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+apiVersion
+ +string + +
+

API version of the referent.

+
+group
+ +string + +
+

API Group of the referent.

+
+resource
+ +string + +
+

Resource name of the referent.

+
+kind
+ +string + +
+

Kind of the referent. +More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

+
+name
+ +string + +
+

Name of the referent. +More info: http://kubernetes.io/docs/user-guide/identifiers#names

+
+namespace
+ +string + +
+

Namespace of the referent. +More info: http://kubernetes.io/docs/user-guide/namespaces

+
+

Phase +

+

+(Appears on: +ActionStatus) +

+

+

Phase is subcomponent of an action.

+

+ + + + + + + + + + + + + + + + + + + + + +
FieldDescription
+name
+ +string + +
+

Name represents the name of the Blueprint phase.

+
+state
+ + +State + + +
+

State represents the current state of execution of the Blueprint phase.

+
+output
+ +map[string]interface{} + +
+

Output is the map of output artifacts produced by the Blueprint phase.

+
+

State +(string alias)

+

+(Appears on: +ActionSetStatus, +Phase) +

+

+

State is the current state of a phase of execution.

+

+ + + + + + + + + + + + + + + + +
ValueDescription

"complete"

StateComplete means this action or phase finished successfully.

+

"failed"

StateFailed means this action or phase was unsuccessful.

+

"pending"

StatePending mean this action or phase has yet to be executed.

+

"running"

StateRunning means this action or phase is currently executing.

+
+
+

+Generated with gen-crd-api-reference-docs +. +

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba28e1819d..a74ef9af91 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,10 @@ styling and safety rules. See the [BUILD.md](BUILD.md) document for instructions on how to build, test and run Kanister locally. +### Updating the API types + +If your changes involve the Kanister API types, generate the API documentation using the `make crd_docs` command and push the updated `API.md` file along with any other changes. + ### Commit messages The basic idea is that we ask all contributors to practice diff --git a/Makefile b/Makefile index 135a9e84f2..838c6570e0 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,27 @@ else @/bin/bash -c $(DOCS_CMD) endif +API_DOCS_CMD = "gen-crd-api-reference-docs \ + -config docs/api_docs/config.json \ + -api-dir ./pkg/apis/cr/v1alpha1 \ + -template-dir docs/api_docs/template \ + -out-file API.md \ +" + +crd_docs: +ifeq ($(DOCKER_BUILD),"true") + @echo "running API_DOCS_CMD in the containerized build environment" + @docker run \ + --entrypoint '' \ + --rm \ + -v "$(PWD):/repo" \ + -w /repo \ + $(BUILD_IMAGE) \ + /bin/bash -c $(API_DOCS_CMD) +else + @/bin/bash -c $(API_DOCS_CMD) +endif + build-dirs: @mkdir -p bin/$(ARCH) @mkdir -p .go/src/$(PKG) .go/pkg .go/bin .go/std/$(ARCH) diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile index cb72edc4e4..014e3d8b2c 100644 --- a/docker/build/Dockerfile +++ b/docker/build/Dockerfile @@ -22,6 +22,9 @@ COPY --from=golangci/golangci-lint:v1.50 /usr/bin/golangci-lint /usr/local/bin/ RUN wget -O /usr/local/bin/kind https://github.com/kubernetes-sigs/kind/releases/download/v0.11.1/kind-linux-amd64 \ && chmod +x /usr/local/bin/kind +# Adding CRD documentation generation tool. +RUN GOBIN=/usr/local/bin go install github.com/ahmetb/gen-crd-api-reference-docs@v0.3.0 + ENV CGO_ENABLED=0 \ GO111MODULE="on" \ GOROOT="/usr/local/go" \ diff --git a/docs/api_docs/config.json b/docs/api_docs/config.json new file mode 100644 index 0000000000..298f00b64c --- /dev/null +++ b/docs/api_docs/config.json @@ -0,0 +1,28 @@ +{ + "hideMemberFields": [ + "TypeMeta" + ], + "hideTypePatterns": [ + "ParseError$", + "List$" + ], + "externalPackages": [ + { + "typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Duration$", + "docsURLTemplate": "https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration" + }, + { + "typeMatchPrefix": "^k8s\\.io/(api|apimachinery/pkg/apis)/", + "docsURLTemplate": "https://v1-18.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}" + }, + { + "typeMatchPrefix": "^github\\.com/knative/pkg/apis/duck/", + "docsURLTemplate": "https://pkg.go.dev/github.com/knative/pkg/apis/duck/{{arrIndex .PackageSegments -1}}#{{.TypeIdentifier}}" + } + ], + "typeDisplayNamePrefixOverrides": { + "k8s.io/api/": "Kubernetes ", + "k8s.io/apimachinery/pkg/apis/": "Kubernetes " + }, + "markdownDisabled": false +} diff --git a/docs/api_docs/template/members.tpl b/docs/api_docs/template/members.tpl new file mode 100644 index 0000000000..07cfa0cff1 --- /dev/null +++ b/docs/api_docs/template/members.tpl @@ -0,0 +1,50 @@ +{*Refering this file from https://github.com/ahmetb/gen-crd-api-reference-docs/ which is used in auto-generation of API CRD documentation.*} + +{{ define "members" }} + +{{ range .Members }} +{{ if not (hiddenMember .)}} + + + {{ fieldName . }}
+ + {{ if linkForType .Type }} + + {{ typeDisplayName .Type }} + + {{ else }} + {{ typeDisplayName .Type }} + {{ end }} + + + + {{ if fieldEmbedded . }} +

+ (Members of {{ fieldName . }} are embedded into this type.) +

+ {{ end}} + + {{ if isOptionalMember .}} + (Optional) + {{ end }} + + {{ safe (renderComments .CommentLines) }} + + {{ if and (eq (.Type.Name.Name) "ObjectMeta") }} + Refer to the Kubernetes API documentation for the fields of the + metadata field. + {{ end }} + + {{ if or (eq (fieldName .) "spec") }} +
+
+ + {{ template "members" .Type }} +
+ {{ end }} + + +{{ end }} +{{ end }} + +{{ end }} diff --git a/docs/api_docs/template/pkg.tpl b/docs/api_docs/template/pkg.tpl new file mode 100644 index 0000000000..e898ca5a89 --- /dev/null +++ b/docs/api_docs/template/pkg.tpl @@ -0,0 +1,51 @@ +{*Refering this file from https://github.com/ahmetb/gen-crd-api-reference-docs/ which is used in auto-generation of API CRD documentation.*} + +{{ define "packages" }} + +{{ with .packages}} +

Packages:

+ +{{ end}} + +{{ range .packages }} +

+ {{- packageDisplayName . -}} +

+ + {{ with (index .GoPackages 0 )}} + {{ with .DocComments }} +

+ {{ safe (renderComments .) }} +

+ {{ end }} + {{ end }} + + Resource Types: + + + {{ range (visibleTypes (sortedTypes .Types))}} + {{ template "type" . }} + {{ end }} +
+{{ end }} + +

+ Generated with gen-crd-api-reference-docs + {{ with .gitCommit }} on git commit {{ . }}{{end}}. +

+ +{{ end }} diff --git a/docs/api_docs/template/type.tpl b/docs/api_docs/template/type.tpl new file mode 100644 index 0000000000..65e0c4946f --- /dev/null +++ b/docs/api_docs/template/type.tpl @@ -0,0 +1,83 @@ +{*Refering this file from https://github.com/ahmetb/gen-crd-api-reference-docs/ which is used in auto-generation of API CRD documentation.*} + +{{ define "type" }} + +

+ {{- .Name.Name }} + {{ if eq .Kind "Alias" }}({{.Underlying}} alias)

{{ end -}} +

+{{ with (typeReferences .) }} +

+ (Appears on: + {{- $prev := "" -}} + {{- range . -}} + {{- if $prev -}}, {{ end -}} + {{ $prev = . }} + {{ typeDisplayName . }} + {{- end -}} + ) +

+{{ end }} + +

+ {{ safe (renderComments .CommentLines) }} +

+ +{{ with (constantsOfType .) }} + + + + + + + + + {{- range . -}} + + {{- /* + renderComments implicitly creates a

element, so we + add one to the display name as well to make the contents + of the two cells align evenly. + */ -}} +

+ + + {{- end -}} + +
ValueDescription

{{ typeDisplayName . }}

{{ safe (renderComments .CommentLines) }}
+{{ end }} + +{{ if .Members }} + + + + + + + + + {{ if isExportedType . }} + + + + + + + + + {{ end }} + {{ template "members" .}} + +
FieldDescription
+ apiVersion
+ string
+ + {{apiGroup .}} + +
+ kind
+ string +
{{.Name.Name}}
+{{ end }} + +{{ end }}