forked from elastic/elastic-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to select docker variant. (elastic#5338)
- Loading branch information
1 parent
6bb6b1e
commit fd477ec
Showing
8 changed files
with
149 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package mage | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
const ( | ||
undefined = "undefined" | ||
basic = "basic" | ||
ubi = "ubi" | ||
wolfi = "wolfi" | ||
complete = "complete" | ||
cloud = "cloud" | ||
) | ||
|
||
// DockerVariant defines the docker variant to build. | ||
type DockerVariant int | ||
|
||
// List of possible docker variants. | ||
const ( | ||
Undefined = iota | ||
Basic | ||
UBI | ||
Wolfi | ||
Complete | ||
Cloud | ||
) | ||
|
||
// String returns the name of the docker variant type. | ||
func (typ DockerVariant) String() string { | ||
switch typ { | ||
case Undefined: | ||
return undefined | ||
case Basic: | ||
return basic | ||
case UBI: | ||
return ubi | ||
case Wolfi: | ||
return wolfi | ||
case Complete: | ||
return complete | ||
case Cloud: | ||
return cloud | ||
default: | ||
return invalid | ||
} | ||
} | ||
|
||
// MarshalText returns the text representation of DockerVariant. | ||
func (typ DockerVariant) MarshalText() ([]byte, error) { | ||
return []byte(typ.String()), nil | ||
} | ||
|
||
// UnmarshalText returns a DockerVariant based on the given text. | ||
func (typ *DockerVariant) UnmarshalText(text []byte) error { | ||
switch strings.ToLower(string(text)) { | ||
case "": | ||
*typ = Undefined | ||
case basic: | ||
*typ = Basic | ||
case ubi: | ||
*typ = UBI | ||
case wolfi: | ||
*typ = Wolfi | ||
case complete: | ||
*typ = Complete | ||
case cloud: | ||
*typ = Cloud | ||
default: | ||
return fmt.Errorf("unknown docker variant: %v", string(text)) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters