-
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.
introducing models for model transformations
Signed-off-by: Markus Blaschke <[email protected]>
- Loading branch information
Showing
5 changed files
with
136 additions
and
62 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
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,64 @@ | ||
package models | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore" | ||
"github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig" | ||
"github.com/webdevops/go-common/utils/to" | ||
) | ||
|
||
type ( | ||
AzAppconfigSetting struct { | ||
// The primary identifier of the configuration setting. | ||
// A Key is used together with a Label to uniquely identify a configuration setting. | ||
Key *string `json:"key"` | ||
|
||
// The configuration setting's value. | ||
Value *string `json:"value"` | ||
|
||
// A value used to group configuration settings. | ||
// A Label is used together with a Key to uniquely identify a configuration setting. | ||
Label *string `json:"label"` | ||
|
||
// The content type of the configuration setting's value. | ||
// Providing a proper content-type can enable transformations of values when they are retrieved by applications. | ||
ContentType *string `json:"contentType"` | ||
|
||
// An ETag indicating the state of a configuration setting within a configuration store. | ||
ETag *azcore.ETag `json:"eTag"` | ||
|
||
// A dictionary of tags used to assign additional properties to a configuration setting. | ||
// These can be used to indicate how a configuration setting may be applied. | ||
Tags map[string]string `json:"tags"` | ||
|
||
// The last time a modifying operation was performed on the given configuration setting. | ||
LastModified *time.Time `json:"lastModified"` | ||
|
||
// A value indicating whether the configuration setting is read only. | ||
// A read only configuration setting may not be modified until it is made writable. | ||
IsReadOnly bool `json:"isReadOnly"` | ||
|
||
// Sync token for the Azure App Configuration client, corresponding to the current state of the client. | ||
SyncToken *string `json:"syncToken"` | ||
} | ||
) | ||
|
||
func NewAzAppconfigSetting(setting azappconfig.Setting) *AzAppconfigSetting { | ||
return &AzAppconfigSetting{ | ||
Key: setting.Key, | ||
Value: setting.Value, | ||
Label: setting.Label, | ||
ContentType: setting.ContentType, | ||
ETag: setting.ETag, | ||
Tags: setting.Tags, | ||
LastModified: setting.LastModified, | ||
IsReadOnly: to.Bool(setting.IsReadOnly), | ||
} | ||
} | ||
|
||
func NewAzAppconfigSettingFromReponse(setting azappconfig.GetSettingResponse) *AzAppconfigSetting { | ||
ret := NewAzAppconfigSetting(setting.Setting) | ||
ret.SyncToken = setting.SyncToken | ||
return ret | ||
} |
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,56 @@ | ||
package models | ||
|
||
import ( | ||
"github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets" | ||
"github.com/webdevops/go-common/utils/to" | ||
) | ||
|
||
type ( | ||
AzSecret struct { | ||
// The secret management attributes. | ||
Attributes *azsecrets.SecretAttributes `json:"attributes"` | ||
|
||
// The content type of the secret. | ||
ContentType *string `json:"contentType"` | ||
|
||
// The secret id. | ||
ID string `json:"id"` | ||
|
||
// Application specific metadata in the form of key-value pairs. | ||
Tags map[string]*string `json:"tags"` | ||
|
||
// The secret value. | ||
Value *string `json:"value"` | ||
|
||
Managed bool `json:"managed"` | ||
|
||
Version string `json:"version" yaml:"version"` | ||
Name string `json:"name" yaml:"name"` | ||
} | ||
) | ||
|
||
func NewAzSecretItem(secret azsecrets.Secret) *AzSecret { | ||
return &AzSecret{ | ||
Attributes: secret.Attributes, | ||
ContentType: secret.ContentType, | ||
ID: string(*secret.ID), | ||
Tags: secret.Tags, | ||
Value: secret.Value, | ||
Managed: to.Bool(secret.Managed), | ||
Version: secret.ID.Version(), | ||
Name: secret.ID.Name(), | ||
} | ||
} | ||
|
||
func NewAzSecretItemFromSecretproperties(secret azsecrets.SecretProperties) *AzSecret { | ||
return &AzSecret{ | ||
Attributes: secret.Attributes, | ||
ContentType: secret.ContentType, | ||
ID: string(*secret.ID), | ||
Tags: secret.Tags, | ||
Value: nil, | ||
Managed: to.Bool(secret.Managed), | ||
Version: secret.ID.Version(), | ||
Name: secret.ID.Name(), | ||
} | ||
} |